NS services: Difference between revisions

No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1,680: Line 1,680:
==== GetApplicationDeliveryInfo ====
==== GetApplicationDeliveryInfo ====
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.
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 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.
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
Line 1,698: Line 1,702:
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,710: 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, otherwise an error is returned. 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 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.
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.
Line 1,723: Line 1,737:
==== 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.


The [[#ApplicationDeliveryInfo|ApplicationDeliveryInfo]] is validated (ApplicationDeliveryProtocolVersion/HMAC). An error is thrown when [[#ApplicationDeliveryInfo|ApplicationDeliveryAttributeTag]] bit0 is set.
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.
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
Line 1,734: Line 1,752:
==== 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,756: 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.


An error is thrown if a state ref-count is zero. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
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.
HasApplicationRecord is called with the input [[NCM_services#ApplicationId|ApplicationId]], an error is returned if the record isn't found.
Line 1,785: Line 1,807:
==== 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.
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
Line 1,791: Line 1,815:
Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#ReceiveApplicationProgress]].
Takes an input [[NCM_services#ApplicationId|ApplicationId]], returns an output [[#ReceiveApplicationProgress]].


An error is thrown if a state ref-count is zero. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
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,800: Line 1,826:
[[qlaunch]] uses value 55556 for the port.
[[qlaunch]] uses value 55556 for the port.


An error is thrown if a state ref-count is zero. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
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]] in the ContentMetaKey must match Patch.
The [[NCM_services#ContentMetaType|ContentMetaType]] in the ContentMetaKey must match Patch.
Line 1,832: 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 ====
==== Cmd2019 ====
Line 1,978: Line 2,016:
No input, returns an output bool.
No input, returns an output bool.


Various Deliver cmds now load the same flag used by this cmd (IsLocalContentShareEnabled), with an error being returned when it's not enabled.
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,929: Line 2,967:


See [[NIM_services|nim]] regarding the input addr/port usage, etc.
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 4,631: 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 || Padding
| 0x4 || 0x4 || Padding