NS services: Difference between revisions
(25 intermediate revisions by the same user not shown) | |||
Line 1,662: | Line 1,662: | ||
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], and returns an output s32. | Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], and returns an output s32. | ||
This determines the latest version from the input [[#ApplicationDeliveryInfo]] array, using value 0 if the array is empty. If this value is less than a state field, the state field value is used instead. Then this selects a [[#SystemDeliveryInfo]] with the latest version from the input array, where the minimum version is the previously mentioned value. The version must also be also be at least the version value from the type-0x15 [[#SystemDeliveryInfo]] buffer. This also does various validation, etc. The output s32 is an index in that array for the selected entry, -1 if none found. | This determines the latest version (RequiredSystemVersion) from the input [[#ApplicationDeliveryInfo]] array (ApplicationDeliveryProtocolVersion and the HMAC are also validated), using value 0 if the array is empty. | ||
[20.0.0+] When the SystemDeliveryInfoPlatform from the type-0x15 [[#SystemDeliveryInfo]] buffer matches the [[System_Settings|sys-setting]], it then loops through the [[#ApplicationDeliveryInfo]] array again: | |||
* A func is called with the [[#ApplicationDeliveryInfo]], returning error if this fails. This func essentially uses [[Shared_Database_services|pl:s]] GetFunctionBlackListSystemVersionToAuthorize with ApplicationFunctionAuthorizationId=0x5 and parses the output, using cached data if available. | |||
* tmp_version = out_u8 == 0 ? 0 : out_u32 + 0x10000; | |||
* Then the current latest-version value is updated with tmp_version, if tmp_version is higher. | |||
If this version value is less than a state field, the state field value is used instead (state field originates from [[System_Settings|system-setting]] <code>contents_delivery!required_system_version_to_deliver_application</code>). | |||
Then this selects a [[#SystemDeliveryInfo]] with the latest version from the input array, where the minimum version is the previously mentioned value. The version must also be also be at least the version value from the type-0x15 [[#SystemDeliveryInfo]] buffer. This also does various validation, etc. The output s32 is an index in that array for the selected entry, -1 if none found. | |||
==== VerifyDeliveryProtocolVersion ==== | ==== VerifyDeliveryProtocolVersion ==== | ||
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], no output. | Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], no output. | ||
This validates the [[#SystemDeliveryInfo]] HMAC and the protocol-version fields. Then | This validates the [[#SystemDeliveryInfo]] HMAC and the protocol-version fields. Then an error is returned when SystemUpdateMetaVersion is less than a state field, otherwise 0 is returned (state field originates from [[System_Settings|system-setting]] <code>contents_delivery!required_system_version_to_deliver_application</code>). | ||
==== GetApplicationDeliveryInfo ==== | ==== GetApplicationDeliveryInfo ==== | ||
Takes a type-0x6 output buffer containing an array of [[#ApplicationDeliveryInfo]], an input u32 bitmask <code>nn::ns::ApplicationDeliveryAttributeTag</code>, an [[NCM_services#ApplicationId|ApplicationId]], and returns an output s32 total_out. | Takes a type-0x6 output buffer containing an array of [[#ApplicationDeliveryInfo|ApplicationDeliveryInfo]], an input u32 bitmask <code>nn::ns::ApplicationDeliveryAttributeTag</code>, an [[NCM_services#ApplicationId|ApplicationId]], and returns an output s32 total_out. | ||
[11.0.0+] An error is thrown if LocalContentShare is not [[#IsLocalContentShareEnabled|enabled]]. | |||
An error is thrown if any bit is set in ApplicationDeliveryAttributeTag besides bit1, this must also be <=0x3. The output array-count must be at least 1: only 1 entry will be written to this array (hence on success total_out will also only be 1 on success). | |||
An error is thrown if a state ref-count is zero. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
HasApplicationRecord is called with the input [[NCM_services#ApplicationId|ApplicationId]], an error is returned if the record isn't found. | |||
[[#ApplicationDeliveryInfo|RequiredApplicationVersion]] is initially set to the output version from [[Shared_Database_services|avm]] GetLaunchRequiredVersion. Later when ContentMetaType == Application etc, it calls a func. This func uses [[NCM_services|ncm]] IContentMetaDatabase GetRequiredApplicationVersion. If the output version is higher than the [[#ApplicationDeliveryInfo|RequiredApplicationVersion]] field then the output version is written here. Immediately aferwards, it also checks whether the bit for Compacted is set from [[NCM_services|ncm]] IContentMetaDatabase GetAttributes, clearing [[#ApplicationDeliveryInfo|ApplicationVersion]] if the attribute is set. | |||
[20.0.0+] [[#ApplicationDeliveryInfo|ApplicationDeliveryInfo]] ContentMetaPlatform and ProperProgramExists are now set using data from [[NCM_services|ncm]]. | |||
[20.0.0+] [[Shared_Database_services|pl:s]] GetFunctionBlackListSystemVersionToAuthorize with ApplicationFunctionAuthorizationId=0x5 is now used, the output version is written to [[#ApplicationDeliveryInfo|RequiredSystemVersion]] when it's higher than the value previously written here. | |||
[20.0.0+] [[Shared_Database_services|pl:s]] GetRequiredApplicationVersion with ApplicationFunctionAuthorizationId=0x5 is now used, the output version is written to [[#ApplicationDeliveryInfo|RequiredApplicationVersion]] when it's higher than the value previously written here. | |||
==== HasAllContentsToDeliver ==== | ==== HasAllContentsToDeliver ==== | ||
Takes a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], returns an output u8 bool. | Takes a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], returns an output u8 bool. | ||
The array-count must match 1. After validating the [[#ApplicationDeliveryInfo]], the output bool is set to u32 [[#ApplicationDeliveryInfo]]+0x1C & 0x10000002 != 0x2, then this returns 0. | The array-count must match 1. | ||
This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
After validating the [[#ApplicationDeliveryInfo]], the output bool is set to u32 [[#ApplicationDeliveryInfo]]+0x1C & 0x10000002 != 0x2, then this returns 0. | |||
==== CompareApplicationDeliveryInfo ==== | ==== CompareApplicationDeliveryInfo ==== | ||
Takes two type-0x5 input buffers containing an array of [[#ApplicationDeliveryInfo]], returns an output s32. | Takes two type-0x5 input buffers containing an array of [[#ApplicationDeliveryInfo]], returns an output s32. | ||
This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
The array-count for both buffers must be 1, otherwise an error is returned. | The array-count for both buffers must be 1, otherwise an error is returned. | ||
Line 1,689: | Line 1,720: | ||
Takes two type-0x5 input buffers containing an array of [[#ApplicationDeliveryInfo]], returns an output u8 bool. | Takes two type-0x5 input buffers containing an array of [[#ApplicationDeliveryInfo]], returns an output u8 bool. | ||
The array-count for the second buffer must be 1 | The array-count for the second buffer must be 1, otherwise an error is returned. | ||
This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
The second [[#ApplicationDeliveryInfo]] buffer is validated. An error is thrown when u32 [[#ApplicationDeliveryInfo]] (second buffer) +0x1C & 0x3 != 0x2, likewise when bit28 is clear in this field (bitmask 0x10000000). | |||
The array-count for the first buffer must be <=1, otherwise an error is returned. If the array-count for the first buffer is 0, this will return 0 with the output bool set to 0. The first [[#ApplicationDeliveryInfo]] buffer is validated. An error is thrown when u32 [[#ApplicationDeliveryInfo]] (first buffer) +0x1C bit1 is clear or bit0 set. An error is thrown when u32 [[#ApplicationDeliveryInfo]] (second buffer) +0x1C bit1 is clear. | |||
When u32 [[#ApplicationDeliveryInfo]] (first or second buffer) +0x14 is higher than [[#ApplicationDeliveryInfo]] (second buffer) ApplicationVersion, this will return 0 with the output bool set to 0. | |||
When u32 [[#ApplicationDeliveryInfo]] (first buffer) +0x1C bit28 is set (bitmask 0x10000000): | |||
* When [[#ApplicationDeliveryInfo]] (first buffer) ApplicationVersion >= [[#ApplicationDeliveryInfo]] (second buffer) ApplicationVersion, write 0 to the output bool, otherwise write 1. Then return 0. | |||
Otherwise when the above bit28 is clear: | |||
* When [[#ApplicationDeliveryInfo]] (first buffer) ApplicationVersion > [[#ApplicationDeliveryInfo]] (second buffer) ApplicationVersion, write 0 to the output bool, otherwise write 1. Then return 0. | |||
==== ListContentMetaKeyToDeliverApplication ==== | ==== ListContentMetaKeyToDeliverApplication ==== | ||
Takes a type-0x6 output buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], a s32, and returns an output s32 total_out. | Takes a type-0x6 output buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], a s32, and returns an output s32 total_out. | ||
This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
The array-count for ContentMetaKey must be at least 1, and for ApplicationDeliveryInfo it must match 1. | The array-count for ContentMetaKey must be at least 1, and for ApplicationDeliveryInfo it must match 1. | ||
This will only return 1 ContentMetaKey entry. This will not output the entry when the input s32 is larger than 0 | The [[#ApplicationDeliveryInfo|ApplicationDeliveryInfo]] is validated (ApplicationDeliveryProtocolVersion/HMAC). An error is thrown when [[#ApplicationDeliveryInfo|ApplicationDeliveryAttributeTag]] bit0 is set. | ||
This uses the same ref-count check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
This will only return 1 ContentMetaKey entry. This will not output the entry when the input s32 is larger than 0, or when [[#ApplicationDeliveryInfo|ApplicationDeliveryAttributeTag]] bit1 is clear. | |||
==== NeedsSystemUpdateToDeliverApplication ==== | ==== NeedsSystemUpdateToDeliverApplication ==== | ||
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], and returns an output u8 bool. | Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], and returns an output u8 bool. | ||
This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
The array-count must match 1. | The array-count must match 1. | ||
After validation etc, this sets the output bool by comparing system-version fields in the [[#SystemDeliveryInfo]]/[[#ApplicationDeliveryInfo]] and with a state field. | After validation etc, this sets the output bool by comparing system-version fields in the [[#SystemDeliveryInfo]]/[[#ApplicationDeliveryInfo]] and with a state field (state field originates from [[System_Settings|system-setting]] <code>contents_delivery!required_system_version_to_deliver_application</code>). | ||
[20.0.0+] More validation was added. | |||
[20.0.0+] Prior to comparing the system-version fields, this now runs additional functionality similar to [[#SelectLatestSystemDeliveryInfo]]: | |||
* When the SystemDeliveryInfoPlatform from the input [[#SystemDeliveryInfo]] matches the [[System_Settings|sys-setting]], it does the following: | |||
* Calls the same func as [[#SelectLatestSystemDeliveryInfo]] for GetFunctionBlackListSystemVersionToAuthorize, returning the Result on failure. | |||
* The output bool is set to: out_u8!=0 && out_u32 >= [[#SystemDeliveryInfo]] SystemUpdateMetaVersion (only the upper 16bits are used from the SystemUpdateMetaVersion). | |||
==== EstimateRequiredSize ==== | ==== EstimateRequiredSize ==== | ||
Line 1,715: | Line 1,776: | ||
[[qlaunch]] uses value Any for the StorageId, and value 55556 for the port. | [[qlaunch]] uses value Any for the StorageId, and value 55556 for the port. | ||
This uses the same LocalContentShare and ref-count checks as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
HasApplicationRecord is called with the input [[NCM_services#ApplicationId|ApplicationId]], an error is returned if the record isn't found. | |||
This loops through the input [[NCM_services#ContentMetaKey|ContentMetaKey]] array, throwing an error if the [[NCM_services#ContentMetaType|ContentMetaType]] doesn't match Patch. The input array is copied into state which is used later by the thread for [[NIM_services|nim]] cmd53, max entries is 0x12. | This loops through the input [[NCM_services#ContentMetaKey|ContentMetaKey]] array, throwing an error if the [[NCM_services#ContentMetaType|ContentMetaType]] doesn't match Patch. The input array is copied into state which is used later by the thread for [[NIM_services|nim]] cmd53, max entries is 0x12. | ||
Line 1,725: | Line 1,790: | ||
** Uses [[NIM_services|nim]] cmd53, returning the Result on failure. | ** Uses [[NIM_services|nim]] cmd53, returning the Result on failure. | ||
** Uses [[NIM_services|nim]] cmd56, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ** Uses [[NIM_services|nim]] cmd56, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ||
*** When the Result from Get is an error, a func is called for filling in the [[#IAsyncResult|IAsyncResult]] ErrorContext with Type4. | |||
** Handles cleanup and returns. | ** Handles cleanup and returns. | ||
* On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | * On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | ||
** The EventId is "receive_app_contents" with ApplicationId <NS ProgramId>. | ** The EventId is "receive_app_contents" with ApplicationId <NS ProgramId>. | ||
** This report has the following fields: | |||
*** "ApplicationId" | |||
*** "DestinationVersion" | |||
*** "SourceVersion" | |||
*** "HasApplicationEntity" | |||
*** "HasPatchEntity" | |||
*** "ApplicationStorageId" | |||
*** "PatchStorageId" | |||
*** "Size" | |||
*** "ThroughputKBps" | |||
==== CommitReceiveApplication ==== | ==== CommitReceiveApplication ==== | ||
Takes an input [[NCM_services#ApplicationId|ApplicationId]], no output. | Takes an input [[NCM_services#ApplicationId|ApplicationId]], no output. | ||
This uses the same LocalContentShare and ref-count checks as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
==== GetReceiveApplicationProgress ==== | ==== GetReceiveApplicationProgress ==== | ||
Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#ReceiveApplicationProgress]]. | Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#ReceiveApplicationProgress]]. | ||
This uses the same ref-count check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
Uses [[NIM_services|nim]] cmd67, throwing an error if no task is returned. Then [[NIM_services|nim]] cmd57 is used, returning the error from there on failure. Lastly, this writes the 0x10-bytes from output+8 from the latter cmd to the output [[#ReceiveApplicationProgress]], and returns 0. | Uses [[NIM_services|nim]] cmd67, throwing an error if no task is returned. Then [[NIM_services|nim]] cmd57 is used, returning the error from there on failure. Lastly, this writes the 0x10-bytes from output+8 from the latter cmd to the output [[#ReceiveApplicationProgress]], and returns 0. | ||
Line 1,744: | Line 1,826: | ||
[[qlaunch]] uses value 55556 for the port. | [[qlaunch]] uses value 55556 for the port. | ||
This uses the same LocalContentShare and ref-count checks as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
The [[NCM_services#ContentMetaType|ContentMetaType]] must match Patch. | The [[NCM_services#ContentMetaType|ContentMetaType]] in the ContentMetaKey must match Patch. | ||
This does various setup and | This does various setup and loops through the input ContentMetaKey array for initializing the array passed to the nim cmd during the async task. This then creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation. Then the thread does: | ||
* Calls a func which does: | * Calls a func which does: | ||
Line 1,754: | Line 1,838: | ||
** Uses [[NIM_services|nim]] cmd60, returning the Result on failure. | ** Uses [[NIM_services|nim]] cmd60, returning the Result on failure. | ||
** Uses [[NIM_services|nim]] cmd61, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ** Uses [[NIM_services|nim]] cmd61, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ||
*** When the Result from Get is an error, a func is called for filling in the [[#IAsyncResult|IAsyncResult]] ErrorContext with Type4. | |||
** Handles cleanup and returns. | ** Handles cleanup and returns. | ||
* On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | * On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | ||
** The EventId is "send_app_contents" with ApplicationId <NS ProgramId>. | ** The EventId is "send_app_contents" with ApplicationId <NS ProgramId>. | ||
** This report has the following fields: | |||
*** "ApplicationId" | |||
*** "Version" | |||
*** "ApplicationStorageId" | |||
*** "PatchStorageId" | |||
==== GetSendApplicationProgress ==== | ==== GetSendApplicationProgress ==== | ||
Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#SendApplicationProgress]]. | Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#SendApplicationProgress]]. | ||
Same as [[#GetReceiveApplicationProgress]] except this is the Send version, and uses [[NIM_services|nim]] cmd68/cmd63 instead. | Same as [[#GetReceiveApplicationProgress]] except this is the Send version, and uses [[NIM_services|nim]] cmd68/cmd63 instead. The data copied to output is also swapped: u64 nim_out+0x8 is copied to out+0x8, and u64 nim_out+0x10 is copied to out+0x0. | ||
==== CompareSystemDeliveryInfo ==== | ==== CompareSystemDeliveryInfo ==== | ||
Line 1,770: | Line 1,860: | ||
==== ListNotCommittedContentMeta ==== | ==== ListNotCommittedContentMeta ==== | ||
Takes a type-0x6 output buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a s32, an [[NCM_services#ApplicationId|ApplicationId]], returns an output s32 total_out. | Takes a type-0x6 output buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a s32, an [[NCM_services#ApplicationId|ApplicationId]], returns an output s32 total_out. | ||
This uses the same ref-count check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task. | |||
==== RecoverDownloadTask ==== | ==== RecoverDownloadTask ==== | ||
Takes a type-0x5 input buffer containing an array of {unknown} and an input u64, no output. | Takes a type-0x5 input buffer containing an array of {unknown} and an input u64, no output. | ||
This uses the same LocalContentShare and ref-count checks as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | |||
==== GetApplicationDeliveryInfoHash ==== | ==== GetApplicationDeliveryInfoHash ==== | ||
Takes a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], returns an output 0x20-byte SHA256 hash. | Takes a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], returns an output 0x20-byte SHA256 hash. | ||
This extracts data from the input array for hashing with SHA256, with validation being done when handling each entry. | This uses the same LocalContentShare check as [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]]. | ||
This extracts data from the input array for hashing with SHA256, with validation being done when handling each entry (ApplicationDeliveryProtocolVersion/HMAC). | |||
The 0x14-bytes from [[#ApplicationDeliveryInfo|ApplicationDeliveryInfo]]+0x8 are copied into a 0x18-byte struct entry in an array buffer, with the last 4-bytes being cleared. Then each 0x18-byte struct entry is hashed. | |||
==== Cmd2019 ==== | |||
Takes a type-0x15 input buffer containing a [[#SystemDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], a type-0x5 input buffer containing an array of [[#ApplicationDeliveryInfo]], returns an output u8 bool. | |||
This is essentially an extended version of [[#CanDeliverApplication|CanDeliverApplication]], with additional functionality for determining platform compatibility. | |||
This calls a func for validating the [[#SystemDeliveryInfo]] from the type-0x15 buffer, returning the Result on failure. | |||
Then [[#CanDeliverApplication|CanDeliverApplication]] is called with the output bool and the input arrays, returning the Result on failure. | |||
If the output bool is set after calling the above, it then calls a func with the output bool, the second [[#ApplicationDeliveryInfo]] buffer, and the [[#SystemDeliveryInfo]] from the type-0x15 buffer. This func does the following: | |||
* When the SystemDeliveryInfoPlatform from the input [[#SystemDeliveryInfo]] matches the [[System_Settings|sys-setting]], it does the following: | |||
** Uses [[Shared_Database_services|pl:s]] RequestApplicationFunctionAuthorizationByApplicationId with the [[#ApplicationDeliveryInfo]] ApplicationId/ApplicationVersion and ApplicationFunctionAuthorizationId=0x5, handling the Result on failure. | |||
* When the platform fields from the input [[#SystemDeliveryInfo]]/[[#ApplicationDeliveryInfo]] match, write 1 to the output bool and return 0. Otherwise: | |||
** When the [[#SystemDeliveryInfo]] SystemDeliveryInfoPlatform is 0x1 (Ounce): *output = [[#ApplicationDeliveryInfo]] ContentMetaPlatform == 0 && [[#ApplicationDeliveryInfo]] ProperProgramExists == 0; | |||
** When the [[#SystemDeliveryInfo]] SystemDeliveryInfoPlatform is 0x0 (NX): write 0 to the output bool and return 0. | |||
** Otherwise, Abort. | |||
==== GetApplicationRightsOnClient ==== | ==== GetApplicationRightsOnClient ==== | ||
Line 1,899: | Line 2,016: | ||
No input, returns an output bool. | No input, returns an output bool. | ||
Various Deliver cmds now | Various Deliver cmds now run essentially the same code as IsLocalContentShareEnabled, with an error being returned when it's not enabled. | ||
==== Cmd4026 ==== | ==== Cmd4026 ==== | ||
Line 2,613: | Line 2,730: | ||
== OpenSystemUpdateControl == | == OpenSystemUpdateControl == | ||
No input, returns an [[#ISystemUpdateControl]]. | No input, returns an [[#ISystemUpdateControl]]. | ||
Only 1 ISystemUpdateControl can be open at a time. | |||
== NotifyExFatDriverRequired == | == NotifyExFatDriverRequired == | ||
Line 2,670: | Line 2,789: | ||
[[qlaunch]] uses value 55556 for the port. IP is normally a local-WLAN address, however this can be any address. port/addr are little-endian. | [[qlaunch]] uses value 55556 for the port. IP is normally a local-WLAN address, however this can be any address. port/addr are little-endian. | ||
[[NIM_services| | See [[NIM_services|nim]] regarding the input addr/port usage, etc. | ||
[11.0.0+] An error is thrown if LocalContentShare is not [[#IsLocalContentShareEnabled|enabled]]. | |||
This validates the [[#SystemDeliveryInfo]] and generates a [[NCM_services#ContentMetaKey|ContentMetaKey]] from that, and creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation. | |||
The above validation verifies that the HMAC and SystemDeliveryProtocolVersion are valid. The SystemUpdateMetaId ([20.0.0+] NewSystemUpdateMetaId, NewSystemUpdateMetaIdFlag ignored) must match the Id for the installed SystemUpdate as returned by [[NCM_services|ncm]]. | |||
Then the thread does: | |||
* Calls a func which does: | * Calls a func which does: | ||
** Uses [[NIM_services|nim]] | ** Uses [[NIM_services|nim]] CreateLocalCommunicationSendSystemUpdateTask, returning the Result on failure. | ||
** Uses [[NIM_services|nim]] | ** Uses [[NIM_services|nim]] RequestLocalCommunicationSendSystemUpdateTaskRun, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ||
** Handles cleanup and returns. | ** Handles cleanup and returns. | ||
* Unlike [[#RequestReceiveSystemUpdate]], this doesn't save a SystemPlayReport. | * Unlike [[#RequestReceiveSystemUpdate]], this doesn't save a SystemPlayReport. | ||
Line 2,682: | Line 2,807: | ||
No input, returns an output [[#SystemUpdateProgress]]. | No input, returns an output [[#SystemUpdateProgress]]. | ||
Same as [[#GetReceiveProgress]] except this uses nim | Same as [[#GetReceiveProgress]] except this uses nim ListLocalCommunicationSendSystemUpdateTask and GetLocalCommunicationSendSystemUpdateTaskInfo. The data copied to output is also swapped: u64 nim_out+0x8 is copied to out+0x8, and u64 nim_out+0x10 is copied to out+0x0. | ||
== ISystemUpdateControl == | == ISystemUpdateControl == | ||
Line 2,737: | Line 2,862: | ||
| 22 || [6.0.0+] [[#RequestCheckLatestUpdateIncludesRebootlessUpdate]] | | 22 || [6.0.0+] [[#RequestCheckLatestUpdateIncludesRebootlessUpdate]] | ||
|} | |} | ||
All Card cmds except SetupCardUpdate* require [[#SetupCardUpdate]]/[[#SetupCardUpdateViaSystemUpdater]] to be used previously. [[#GetPreparedCardUpdateEulaDataSize]]/[[#GetPreparedCardUpdateEulaData]] checks a different state flag. | All Card cmds except SetupCardUpdate* require [[#SetupCardUpdate]]/[[#SetupCardUpdateViaSystemUpdater]] to be used previously. [[#GetPreparedCardUpdateEulaDataSize]]/[[#GetPreparedCardUpdateEulaData]] checks a different state flag. | ||
Line 2,784: | Line 2,907: | ||
*** "DestinationExFatStatus" | *** "DestinationExFatStatus" | ||
*** "Rebootless" | *** "Rebootless" | ||
* Since | * Since BootImagePackage will be installed later, the two flags in [[Flash_Filesystem#System_Update_Control]] are set to 1. | ||
* Uses [[NIM_services|nim]] CommitSystemUpdateTask and [[NIM_services|nim]] DestroySystemUpdateTask. | * Uses [[NIM_services|nim]] CommitSystemUpdateTask and [[NIM_services|nim]] DestroySystemUpdateTask. | ||
* Installs | * Installs BootImagePackage. After installing each BootImagePackage, the associated flag in [[Flash_Filesystem#System_Update_Control]] is set to 0. | ||
* On newer system versions when an input flag is set, this uses [[Filesystem_services|NotifySystemDataUpdateEvent]], however this doesn't happen with ApplyDownloadedUpdate since that input flag is 0. | * On newer system versions when an input flag is set, this uses [[Filesystem_services|NotifySystemDataUpdateEvent]], however this doesn't happen with ApplyDownloadedUpdate since that input flag is 0. | ||
Line 2,842: | Line 2,965: | ||
No input, returns an output u8 bool. | No input, returns an output u8 bool. | ||
Same as [[#HasDownloaded]] except this uses [[NIM_services|nim]] | Same as [[#HasDownloaded]] except this uses [[NIM_services|nim]] ListLocalCommunicationReceiveSystemUpdateTask and GetLocalCommunicationReceiveSystemUpdateTaskInfo. | ||
=== RequestReceiveSystemUpdate === | === RequestReceiveSystemUpdate === | ||
Line 2,849: | Line 2,972: | ||
[[qlaunch]] uses the same value for the port as [[#RequestSendSystemUpdate]] (see [[#RequestSendSystemUpdate]] for addr as well). | [[qlaunch]] uses the same value for the port as [[#RequestSendSystemUpdate]] (see [[#RequestSendSystemUpdate]] for addr as well). | ||
[[NIM_services| | See [[NIM_services|nim]] regarding the input addr/port usage, etc. | ||
This validates the [[#SystemDeliveryInfo]] and generates a [[NCM_services#ContentMetaKey|ContentMetaKey]] from that, and creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation. Then the thread does: | This uses the same LocalContentShare check as [[#RequestSendSystemUpdate|RequestSendSystemUpdate]]. | ||
An error is thrown if a state flag is clear. | |||
This validates the [[#SystemDeliveryInfo]] (same as [[#RequestSendSystemUpdate|RequestSendSystemUpdate]]) and generates a [[NCM_services#ContentMetaKey|ContentMetaKey]] from that, and creates the [[#IAsyncResult]] + the async thread which handles the [[#IAsyncResult]] operation. | |||
Then the thread does: | |||
* Calls a func which does: | * Calls a func which does: | ||
** Throws an error if [[NIM_services#ListSystemUpdateTask|ListSystemUpdateTask]] returns any task. | ** Throws an error if [[NIM_services#ListSystemUpdateTask|ListSystemUpdateTask]] returns any task. | ||
** Checks whether a sysupdate is actually required using the previously generated [[NCM_services#ContentMetaKey|ContentMetaKey]], throwing an error if not. | ** Checks whether a sysupdate is actually required using the previously generated [[NCM_services#ContentMetaKey|ContentMetaKey]], throwing an error if not. | ||
** Uses [[NIM_services|nim]] | ** Uses [[NIM_services|nim]] CreateLocalCommunicationReceiveSystemUpdateTask, returning the Result on failure. | ||
** Uses [[NIM_services|nim]] | ** Uses [[NIM_services|nim]] RequestLocalCommunicationReceiveSystemUpdateTaskRun, returning the Result on failure. Waits for the IAsyncResult operation from this to finish, then uses the Get cmd to get the output Result. | ||
** Handles cleanup and returns. | ** Handles cleanup and returns. | ||
* On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | * On success, this loads various data which is then used for saving a SystemPlayReport when the cached [[System_Settings|system-setting]] "systemreport!enabled" is set. | ||
Line 2,878: | Line 3,007: | ||
No input, returns an output [[#SystemUpdateProgress]]. | No input, returns an output [[#SystemUpdateProgress]]. | ||
Same as [[#GetDownloadProgress]] except this uses [[NIM_services|nim]] | Same as [[#GetDownloadProgress]] except this uses [[NIM_services|nim]] ListLocalCommunicationReceiveSystemUpdateTask and GetLocalCommunicationReceiveSystemUpdateTaskInfo. | ||
=== ApplyReceivedUpdate === | === ApplyReceivedUpdate === | ||
No input/output. | No input/output. | ||
This uses the same LocalContentShare check as [[#RequestSendSystemUpdate|RequestSendSystemUpdate]]. | |||
=== GetReceivedEulaDataSize === | === GetReceivedEulaDataSize === | ||
Line 4,552: | Line 4,683: | ||
! Description | ! Description | ||
|- | |- | ||
| 0x0 || | | 0x0 || 0x4 || ApplicationDeliveryProtocolVersion. Loaded from [[System_Settings|system-setting]] <code>contents_delivery!application_delivery_protocol_version</code>. An error is thrown when [[System_Settings|system-setting]] <code>contents_delivery!application_delivery_protocol_version</code> < version, or when [[System_Settings|system-setting]] <code>contents_delivery!acceptable_application_delivery_protocol_version</code> > version. | ||
|- | |||
| 0x4 || 0x4 || Padding | |||
|- | |- | ||
| 0x8 || 0x8 || ApplicationId. | | 0x8 || 0x8 || ApplicationId. | ||
Line 4,558: | Line 4,691: | ||
| 0x10 || 0x4 || ApplicationVersion. | | 0x10 || 0x4 || ApplicationVersion. | ||
|- | |- | ||
| 0x14 || 0x4 || | | 0x14 || 0x4 || RequiredApplicationVersion. | ||
|- | |- | ||
| 0x18 || 0x4 || RequiredSystemVersion. | | 0x18 || 0x4 || RequiredSystemVersion. | ||
|- | |- | ||
| 0x1C || 0x4 || | | 0x1C || 0x4 || u32 bitmask <code>nn::ns::ApplicationDeliveryAttributeTag</code>. [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]] sets this to the input u32. Bit30 and bit28 are additionally set, depending on [[NCM_services|ContentMetaType]] == Patch, etc. | ||
|- | |||
| 0x20 || 0x1 || [20.0.0+] [[NCM_services|ContentMetaPlatform]]. Loaded from [[NCM_services|ncm]] IContentMetaDatabase GetPlatform. | |||
|- | |||
| 0x21 || 0x1 || [20.0.0+] ProperProgramExists. Set to whether the bit for ProperProgramExists is set from [[NCM_services|ncm]] IContentMetaDatabase GetAttributes. | |||
|- | |- | ||
| | | 0x22 || 0xBE || Reserved | ||
|- | |- | ||
| 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes. Uses a different key than [[#SystemDeliveryInfo]]. | | 0xE0 || 0x20 || HMAC-SHA256 over the previous 0xE0-bytes. Uses a different key than [[#SystemDeliveryInfo]]. |