NS services: Difference between revisions
No edit summary |
|||
(20 intermediate revisions by the same user not shown) | |||
Line 1,676: | Line 1,676: | ||
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. | ||
An error is thrown if any bit is set in ApplicationDeliveryAttributeTag besides bit1. 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). | [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,698: | 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. | ||
Line 1,731: | 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,741: | 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,760: | 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,770: | 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,786: | 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,915: | 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,686: | Line 2,787: | ||
[[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. | ||
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 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: | ||
* 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,698: | Line 2,799: | ||
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. | ||
== ISystemUpdateControl == | == ISystemUpdateControl == | ||
Line 2,800: | Line 2,901: | ||
*** "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,858: | Line 2,959: | ||
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,865: | Line 2,966: | ||
[[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. | ||
[11.0.0+] An error is thrown if LocalContentShare is not [[#IsLocalContentShareEnabled|enabled]]. | |||
An error is thrown if a state flag is clear. | |||
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 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: | ||
Line 2,872: | Line 2,977: | ||
** 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,894: | Line 2,999: | ||
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 === | ||
Line 4,568: | Line 4,673: | ||
! Description | ! Description | ||
|- | |- | ||
| 0x0 || 0x4 || ApplicationDeliveryProtocolVersion. | | 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 || | | 0x4 || 0x4 || Padding | ||
|- | |- | ||
| 0x8 || 0x8 || ApplicationId. | | 0x8 || 0x8 || ApplicationId. | ||
Line 4,576: | Line 4,681: | ||
| 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]]. |