NS services: Difference between revisions

No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 349: Line 349:


== ListApplicationRecord ==
== ListApplicationRecord ==
Takes a type-0x6 output buffer containing an array of the below record and an s32 entry_offset, returns an output s32 out_entrycount.
Takes a type-0x6 output buffer containing an array of [[#ApplicationRecord]] and an s32 entry_offset, returns an output s32 out_entrycount.


Returns an array of entries with the below format using the specified offset and count.
Returns an array of entries with the below format using the specified offset and count.
=== Application Record Format ===
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x8
| [[NCM_services#ApplicationId|ApplicationId]]
|-
| 0x8
| 0x1
| Type? (Known values: 0x2=Installing?, 0x3=Installed / Gamecard inserted, 0x5=Gamecard not inserted, 0xB=Archived)
|-
| 0x9
| 0x1
| Unknown, usually 0x02
|-
| 0xA
| 0x6
| Unknown, usually zeros?
|-
| 0x10
| 0x1
| Unknown, seems to change between reboots and removing/reinserting gamecards
|-
| 0x11
| 0x7
| Unknown, usually zeros?
|}


== LaunchApplication ==
== LaunchApplication ==
Line 429: Line 397:


Loads cached [[control.nacp]] to buf+0 and the cached icon to buf+0x4000. Returns an error if the buffer is too small.
Loads cached [[control.nacp]] to buf+0 and the cached icon to buf+0x4000. Returns an error if the buffer is too small.
=== ApplicationControlSource ===
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0x0
| CacheOnly (Returns data from cache)
|-
| 0x1
| Storage (Returns data from storage if not present in cache)
|-
| 0x2
| StorageOnly (Returns data from storage without using cache)
|}


== ListApplicationContentMetaStatus ==
== ListApplicationContentMetaStatus ==
Takes a type-0x6 output buffer containing an array of the below entries, an input s32 index and [[NCM_services#ApplicationId|ApplicationId]], returns an output s32 out_entrycount.
Takes a type-0x6 output buffer containing an array of [[#ApplicationContentMetaStatus]], an input s32 index and [[NCM_services#ApplicationId|ApplicationId]], returns an output s32 out_entrycount.


Returns 0x10-byte entries using the specified [[NCM_services#ApplicationId|ApplicationId]] starting at the specified index. Can only return game titles. The second entry if any is the update-title usually. When the input entryindex is >= totalentries, this will return 0 with out_entrycount=0.
Returns 0x10-byte entries using the specified [[NCM_services#ApplicationId|ApplicationId]] starting at the specified index. Can only return game titles. The second entry if any is the update-title usually. When the input entryindex is >= totalentries, this will return 0 with out_entrycount=0.


Entry structure:
= ns:am2, ns:ec, ns:rid, ns:rt, ns:web, ns:ro, ns:sweb =
{| class="wikitable" border="1"
These are "nn::ns::detail::IServiceGetterInterface".
|-
 
! Offset
These commands check a state field for a command-specific bit and returns an error if not set, this is likely a permissions check for service+command.
! Size
! Description
|-
| 0x0
| 0x1
| [[NCM_services#ContentMetaType|ContentMetaType]] ("type")
|-
| 0x1
| 0x1
| [[NCM_services#StorageId|StorageId]] ("installedStorage")
|-
| 0x2
| 0x1
| Unknown. Non-zero with output from cmd 605, differs for app/update titles.
|-
| 0x3
| 0x1
| Padding
|-
| 0x4
| 0x4
| Version
|-
| 0x8
| 0x8
| [[NCM_services#ApplicationId|ApplicationId]]
|}
 
= ns:am2, ns:ec, ns:rid, ns:rt, ns:web, ns:ro, ns:sweb =
These are "nn::ns::detail::IServiceGetterInterface".
 
These commands check a state field for a command-specific bit and returns an error if not set, this is likely a permissions check for service+command.


[11.0.0+] ns:ro was added.
[11.0.0+] ns:ro was added.
Line 905: Line 825:
|-
|-
| 931 || [20.0.0+]
| 931 || [20.0.0+]
|-
| 933 || [20.1.0+]
|-
|-
| 1000 || [[#RequestVerifyApplicationDeprecated]]
| 1000 || [[#RequestVerifyApplicationDeprecated]]
Line 1,079: Line 1,001:
|-
|-
| 2182 || [6.0.0+] SetActiveRightsContextUsingStateToRightsEnvironment
| 2182 || [6.0.0+] SetActiveRightsContextUsingStateToRightsEnvironment
|-
| 2183 || [20.1.0+]
|-
|-
| 2190 || [6.0.0+] [[#GetRightsEnvironmentHandleForApplication]]
| 2190 || [6.0.0+] [[#GetRightsEnvironmentHandleForApplication]]
Line 1,558: Line 1,482:
No input, returns an output u64.
No input, returns an output u64.


A state flag must be non-zero, otherwise an error is thrown. When a state field is value 1, a hard-coded ProgramId for MaintenanceMenu is used. Otherwise, the ProgramId is loaded from [[System_Settings|system-setting]] <code>ns.applet!system_applet_id</code>.
A state flag must be non-zero, otherwise an error is thrown. When a state field is value 1, a hard-coded ProgramId for MaintenanceMenu is used. Otherwise, the ProgramId is loaded from [[System_Settings|system-setting]] <code>ns.applet!system_applet_id</code> ([20.0.0+] <code>ns.applet!system_applet_id_gen2</code>).


The SystemApplet is launched with StorageId=BuiltInSystem via [[Process_Manager_services|pmshell]] LaunchProgram ([10.0.0+] [[PGL_services#LaunchProgram|pgl]] with pgl_launch_flags=0). [[Process_Manager_services#LaunchFlags|LaunchFlags]] value 0x9 is used here. The output u64 from here is written to the output for this cmd, on success.
The SystemApplet is launched with StorageId=BuiltInSystem via [[Process_Manager_services|pmshell]] LaunchProgram ([10.0.0+] [[PGL_services#LaunchProgram|pgl]] with pgl_launch_flags=0). [[Process_Manager_services#LaunchFlags|LaunchFlags]] value 0x9 is used here. The output u64 from here is written to the output for this cmd, on success.
Line 1,890: Line 1,814:


==== ListPromotionInfo ====
==== ListPromotionInfo ====
[20.0.0+] The input struct size is now 0x28-bytes instead of 0x20-bytes.  
[20.0.0+] The struct size for the output buffer array is now 0x28-bytes instead of 0x20-bytes.


==== ImportPromotionJsonForDebug ====
==== ImportPromotionJsonForDebug ====
Line 2,086: Line 2,010:
|-
|-
| 48 || [[#GetFreeSpaceSize]]
| 48 || [[#GetFreeSpaceSize]]
|-
| 58 || [20.1.0+]
|-
| 71 || [20.1.0+]
|-
|-
| 600 || [[#CountApplicationContentMeta]]
| 600 || [[#CountApplicationContentMeta]]
Line 2,241: Line 2,169:
|-
|-
| 16 || [20.0.0+] ||
| 16 || [20.0.0+] ||
|-
| 17 || [20.1.0+] ||
|}
|}


Line 3,960: Line 3,890:
|}
|}


= VersionListData =
= ApplicationRecord =
This is "nn::ns::VersionListData".
This is "nn::ns::ApplicationRecord".
 
= ApplicationUpdateInfo =
This is "nn::ns::ApplicationUpdateInfo". This is an u8.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Value
! Offset
! Size
! Description
! Description
|-
|-
| 0 || UpToDate
| 0x0
| 0x8
| [[NCM_services#ApplicationId|Id]]
|-
| 0x8
| 0x1
| [[#ApplicationEvent|LastEvent]]
|-
|-
| 1 || Updatable
| 0x9
|}
| 0x1
 
| Attributes
[[qlaunch]] just checks whether this is 0.
 
= ApplicationOccupiedSize =
This is "nn::ns::ApplicationOccupiedSize". This is a 0x80-byte struct.
 
{| class="wikitable" border="1"
|-
|-
! Offset
| 0xA
! Size
| 0x6
! Description
| Reserved
|-
|-
| 0x0 || 0x20 * 4 || Array of [[#ApplicationOccupiedSizeEntity]]
| 0x10
| 0x8
| LastUpdated
|}
|}


= ApplicationOccupiedSizeEntity =
= ApplicationEvent =
This is "nn::ns::ApplicationOccupiedSizeEntity". This is a 0x20-byte struct.
This is "nn::ns::ApplicationEvent".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Offset
! Value
! Size
! Description
! Description
|-
|-
| 0x0 || 0x1 || [[NCM_services#StorageId|StorageId]]
| 0 || Launched
|-
| 1 || LocalInstalled
|-
|-
| 0x1 || 0x7 || Reserved
| 2 || DownloadStarted
|-
|-
| 0x8 || 0x8 || AppSize
| 3 || GameCardInserted
|-
|-
| 0x10 || 0x8 || PatchSize
| 4 || Touched
|-
|-
| 0x18 || 0x8 || AocSize
| 5 ||  
|}
 
= ProgressForDeleteUserSaveDataAll =
This is "nn::ns::detail::ProgressForDeleteUserSaveDataAll". This is a 0x28-byte struct.
 
{| class="wikitable" border="1"
|-
|-
! Offset
| 6 ||
! Size
|-
! Description
| 7 ||
|-
|-
| 0x0 || 0x8 || StartedAt
| 8 ||
|-
|-
| 0x8 || 0x4 || Count
| 9 ||
|-
|-
| 0xC || 0x4 || Reserved
| 10 ||
|-
|-
| 0x10 || 0x8 || SizeInBytes
| 11 ||
|-
|-
| 0x18 || 0x1 || IsSystem
| 12 ||
|-
|-
| 0x19 || 0x7 || Reserved
| 13 ||
|-
|-
| 0x20 || 0x8 || ApplicationId
| 14 ||
|}
|-
 
| 15 ||
= ApplicationViewDeprecated =
|-
This is "nn::ns::ApplicationViewDeprecated". This is a 0x40-byte struct.
| 16 ||
 
|}
{| class="wikitable" border="1"
 
|-
= ApplicationControlSource =
! Offset
This is "nn::ns::ApplicationControlSource".
! Size
 
! Description
{| class="wikitable" border="1"
|-
|-
| 0x0 || 0x8 || [[NCM_services#ApplicationId|ApplicationId]]
! Value
|-
! Description
| 0x8 || 0x4 || Version
|-
|-
| 0
| 0xC || 0x4 || [[#ApplicationViewFlag|Flag]]
| CacheOnly
|-
|-
| 0x10 || 0x18 || [[#ApplicationDownloadProgress|Progress]]
| 1
|-
| Storage
| 0x28 || 0x18 || [[#ApplicationApplyDeltaProgress|ApplyProgress]]
|-
|}
| 2
 
| StorageOnly
This is converted from [[#ApplicationView]] by [[#GetApplicationViewDeprecated]] on newer system-versions as follows:
|}
 
 
{| class="wikitable" border="1"
= ApplicationContentMetaStatus =
|-
This is "nn::ns::ApplicationContentMetaStatus".
! Offset
 
! Size
{| class="wikitable" border="1"
! Description
|-
|-
! Offset
| 0x0 || 0x20 || Same as [[#ApplicationView]] +0x0.
! Size
! Description
|-
| 0x0
| 0x1
| [[NCM_services#ContentMetaType|Type]]
|-
| 0x1
| 0x1
| [[NCM_services#StorageId|InstalledStorage]]
|-
| 0x2
| 0x1
| [[#ContentMetaRightsCheck|RightsCheck]]
|-
| 0x3
| 0x1
| Reserved
|-
| 0x4
| 0x4
| Version
|-
| 0x8
| 0x8
| [[NCM_services#ApplicationId|Id]]
|}
 
= ContentMetaRightsCheck =
This is "nn::ns::ContentMetaRightsCheck".
 
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0
| NotChecked
|-
| 1
| NotNeeded
|-
| 2
| CommonRights
|-
| 3
| PersonalizedRights
|-
| 4
| NoRights
|}
 
= VersionListData =
This is "nn::ns::VersionListData".
 
= ApplicationUpdateInfo =
This is "nn::ns::ApplicationUpdateInfo".
 
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0 || UpToDate
|-
| 1 || Updatable
|}
 
= ApplicationOccupiedSize =
This is "nn::ns::ApplicationOccupiedSize". This is a 0x80-byte struct.
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x20 * 4 || Array of [[#ApplicationOccupiedSizeEntity]]
|}
 
= ApplicationOccupiedSizeEntity =
This is "nn::ns::ApplicationOccupiedSizeEntity". This is a 0x20-byte struct.
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x1 || [[NCM_services#StorageId|StorageId]]
|-
| 0x1 || 0x7 || Reserved
|-
| 0x8 || 0x8 || AppSize
|-
| 0x10 || 0x8 || PatchSize
|-
| 0x18 || 0x8 || AocSize
|}
 
= ProgressForDeleteUserSaveDataAll =
This is "nn::ns::detail::ProgressForDeleteUserSaveDataAll". This is a 0x28-byte struct.
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x8 || StartedAt
|-
| 0x8 || 0x4 || Count
|-
| 0xC || 0x4 || Reserved
|-
| 0x10 || 0x8 || SizeInBytes
|-
| 0x18 || 0x1 || IsSystem
|-
| 0x19 || 0x7 || Reserved
|-
| 0x20 || 0x8 || ApplicationId
|}
 
= ApplicationViewDeprecated =
This is "nn::ns::ApplicationViewDeprecated". This is a 0x40-byte struct.
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x8 || [[NCM_services#ApplicationId|ApplicationId]]
|-
| 0x8 || 0x4 || Version
|-
| 0xC || 0x4 || [[#ApplicationViewFlag|Flag]]
|-
| 0x10 || 0x18 || [[#ApplicationDownloadProgress|Progress]]
|-
| 0x28 || 0x18 || [[#ApplicationApplyDeltaProgress|ApplyProgress]]
|}
 
This is converted from [[#ApplicationView]] by [[#GetApplicationViewDeprecated]] on newer system-versions as follows:
 
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0 || 0x20 || Same as [[#ApplicationView]] +0x0.
|-
|-
| 0x20 || 0x4 || Same as [[#ApplicationView]] +0x20.
| 0x20 || 0x4 || Same as [[#ApplicationView]] +0x20.
Line 4,343: Line 4,420:
= SystemDeliveryInfo =
= SystemDeliveryInfo =
This is "nn::ns::SystemDeliveryInfo". This is a 0x100-byte struct.
This is "nn::ns::SystemDeliveryInfo". This is a 0x100-byte struct.
[20.0.0+] The used (New)SystemUpdateMetaId as selected by NewSystemUpdateMetaIdFlag must now match one of the Ids in [[System_Settings|system-setting]] <code>contents_delivery!acceptable_system_update_ids_string</code>.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 4,360: Line 4,439:
| 0xC || 0x4 || SystemUpdateMetaVersion.
| 0xC || 0x4 || SystemUpdateMetaVersion.
|-
|-
| 0x10 || 0x8 || SystemUpdateMetaId.
| 0x10 || 0x8 || SystemUpdateMetaId. Always the NX Id.
|-
|-
| 0x18 || 0x1 || FirmwareVariationId. Used by [[#RequestSendSystemUpdate]].
| 0x18 || 0x1 || FirmwareVariationId. Used by [[#RequestSendSystemUpdate]]. This is set to 0xC on S2.
|-
|-
| 0x19 || 0x1 || UpdatableFirmwareGroupId. Unused by [[#RequestSendSystemUpdate]]/[[#RequestReceiveSystemUpdate]], besides HMAC validation.
| 0x19 || 0x1 || UpdatableFirmwareGroupId. Unused by [[#RequestSendSystemUpdate]]/[[#RequestReceiveSystemUpdate]], besides HMAC validation. This is set to 0x8 on S2.
|-
|-
| 0x1A || 0x1 || PlatformRegion (0x00 = Unknown, 0x01 = Global, 0x02 = China).
| 0x1A || 0x1 || PlatformRegion (0x00 = Unknown, 0x01 = Global, 0x02 = China).
|-
|-
| 0x1B || 0xC5 || Unused by [[#RequestSendSystemUpdate]]/[[#RequestReceiveSystemUpdate]], besides HMAC validation.
| 0x1B || 0x1 || [20.0.0+] SystemDeliveryInfoPlatform. Loaded from [[System_Settings|system-setting]] <code>ns.systemupdate!system_delivery_info_platform</code>. Elsewhere this is compared against the sys-setting, etc.
|-
| 0x1C || 0x1 || [20.0.0+] NewSystemUpdateMetaIdFlag. When non-zero, NewSystemUpdateMetaId is used instead of SystemUpdateMetaId. Always set to 0x1 by [[#GetSystemDeliveryInfo]] with [20.0.0+].
|-
| 0x1D || 0x3 || Padding
|-
| 0x20 || 0x8 || [20.0.0+] NewSystemUpdateMetaId. See above. With [20.0.0+] [[#GetSystemDeliveryInfo]] now writes the Id here instead of SystemUpdateMetaId. On S2 this is set to the Ounce Id.
|-
| 0x28 || 0xB8 || Unused by [[#RequestSendSystemUpdate]]/[[#RequestReceiveSystemUpdate]], besides HMAC validation.
|-
|-
| 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes.
| 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes.