Changes

2,787 bytes added ,  18:29, 10 November 2019
Line 404: Line 404:  
| 0x1
 
| 0x1
 
| 0x1
 
| 0x1
| u8 "installedStorage" / [[Filesystem_services|StorageId]] (String is from web-applet)
+
| u8 "installedStorage" / [[NCM_services#StorageId|StorageId]] (String is from web-applet)
 
|-
 
|-
 
| 0x2
 
| 0x2
Line 838: Line 838:  
| 2005 || [4.0.0+] [[#CompareApplicationDeliveryInfo]]
 
| 2005 || [4.0.0+] [[#CompareApplicationDeliveryInfo]]
 
|-
 
|-
| 2006 || [4.0.0+] CanDeliverApplication
+
| 2006 || [4.0.0+] [[#CanDeliverApplication]]
 
|-
 
|-
| 2007 || [4.0.0+] ListContentMetaKeyToDeliverApplication
+
| 2007 || [4.0.0+] [[#ListContentMetaKeyToDeliverApplication]]
 
|-
 
|-
| 2008 || [4.0.0+] NeedsSystemUpdateToDeliverApplication
+
| 2008 || [4.0.0+] [[#NeedsSystemUpdateToDeliverApplication]]
 
|-
 
|-
| 2009 || [4.0.0+] EstimateRequiredSize
+
| 2009 || [4.0.0+] [[#EstimateRequiredSize]]
 
|-
 
|-
 
| 2010 || [4.0.0+] [[#RequestReceiveApplication]]
 
| 2010 || [4.0.0+] [[#RequestReceiveApplication]]
Line 856: Line 856:  
| 2014 || [4.0.0+] [[#GetSendApplicationProgress]]
 
| 2014 || [4.0.0+] [[#GetSendApplicationProgress]]
 
|-
 
|-
| 2015 || [4.0.0+] CompareSystemDeliveryInfo
+
| 2015 || [4.0.0+] [[#CompareSystemDeliveryInfo]]
 
|-
 
|-
| 2016 || [4.0.0+] ListNotCommittedContentMeta
+
| 2016 || [4.0.0+] [[#ListNotCommittedContentMeta]]
 
|-
 
|-
| 2017 || [4.0.0+] RecoverDownloadTask
+
| 2017 || [4.0.0+] [[#RecoverDownloadTask]]
 
|-
 
|-
| 2018 || [5.0.0+] GetApplicationDeliveryInfoHash
+
| 2018 || [5.0.0+] [[#GetApplicationDeliveryInfoHash]]
 
|-
 
|-
 
| 2050 || [6.0.0+] GetApplicationRightsOnClient
 
| 2050 || [6.0.0+] GetApplicationRightsOnClient
Line 1,003: Line 1,003:     
==== SelectLatestSystemDeliveryInfo ====
 
==== SelectLatestSystemDeliveryInfo ====
Takee 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 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.
Line 1,027: Line 1,027:  
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.
   −
Both [[#ApplicationDeliveryInfo]] are validated, then the u32 at +0x10 in the first/second buffer are compared. The output s32 is set to the comparsion result: 0 for less than, -1 for equal, and 1 for higher than.
+
Both [[#ApplicationDeliveryInfo]] are validated, then the application-version in the first/second buffer are compared. The output s32 is set to the comparison result: -1 for less than, 0 for equal, and 1 for higher than.
 +
 
 +
==== CanDeliverApplication ====
 +
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 and 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.
 +
 
 +
==== 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.
 +
 
 +
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. This also does other validation, etc.
 +
 
 +
==== 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.
 +
 
 +
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.
 +
 
 +
==== EstimateRequiredSize ====
 +
Takes a type-0x5 input buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], returns an output s64.
 +
 
 +
When the array-count is less than 1, this will return 0 with the s64 set to 0.
    
==== RequestReceiveApplication ====
 
==== RequestReceiveApplication ====
Takes a type-0x5 input buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], an u8 [[Filesystem_services#StorageId|StorageId]], an u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, returns an output Event handle and an [[#IAsyncResult]].
+
Takes a type-0x5 input buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a [[NCM_services#StorageId|StorageId]], an u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, returns an output Event handle and an [[#IAsyncResult]].
   −
An error is thrown if a state flag is not set. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
+
[[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 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,052: Line 1,078:  
Takes an input u64 <code>nn::ncm::ApplicationId</code>, returns an output [[#ReceiveApplicationProgress]].
 
Takes an input u64 <code>nn::ncm::ApplicationId</code>, returns an output [[#ReceiveApplicationProgress]].
   −
An error is thrown if a state flag is not set. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
+
An error is thrown if a state ref-count is zero. 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,059: Line 1,085:  
Takes a type-0x5 input buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], an u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, returns an output Event handle and an [[#IAsyncResult]].
 
Takes a type-0x5 input buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], an u16 port, an u32 Ipv4Address, an u64 <code>nn::ncm::ApplicationId</code>, returns an output Event handle and an [[#IAsyncResult]].
   −
An error is thrown if a state flag is not set. An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
+
[[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.
    
The [[NCM_services#ContentMetaType|ContentMetaType]] must match Patch.
 
The [[NCM_services#ContentMetaType|ContentMetaType]] must match Patch.
Line 1,077: Line 1,105:     
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.
 +
 +
==== CompareSystemDeliveryInfo ====
 +
Takes two type-0x15 input buffers containing a [[#SystemDeliveryInfo]], returns an output s32.
 +
 +
This is essentially the same as [[#CompareApplicationDeliveryInfo]], except this compares the [[#SystemDeliveryInfo]] SystemUpdate version.
 +
 +
==== ListNotCommittedContentMeta ====
 +
Takes a type-0x6 output buffer containing an array of [[NCM_services#ContentMetaKey|ContentMetaKey]], a s32, an u64 <code>nn::ncm::ApplicationId</code>, returns an output s32 total_out.
 +
 +
==== RecoverDownloadTask ====
 +
Takes a type-0x5 input buffer containing an array of {unknown} and an input u64, no output.
 +
 +
==== GetApplicationDeliveryInfoHash ====
 +
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.
    
=== IApplicationVersionInterface ===
 
=== IApplicationVersionInterface ===
Line 1,323: Line 1,367:  
This command is not available for retail units. On a debug unit, if the [[System_Settings|system setting]] <code>vulnerability!enable_debug</code> is set, this mounts the system savegame [[Flash_Filesystem#System_Savegames|0x8000000000000049]] as "ns_ssversion:/", opens the file "ns_ssversion:/entry" and writes the supplied '''titleID''' and '''version''' in it.
 
This command is not available for retail units. On a debug unit, if the [[System_Settings|system setting]] <code>vulnerability!enable_debug</code> is set, this mounts the system savegame [[Flash_Filesystem#System_Savegames|0x8000000000000049]] as "ns_ssversion:/", opens the file "ns_ssversion:/entry" and writes the supplied '''titleID''' and '''version''' in it.
   −
Finally, it calls [[NCM_services#ncm|OpenContentMetaDatabase]] with [[Filesystem_services#StorageId|StorageID]] 3, then calls [[NCM_services#IContentMetaDatabase|GetLatestContentMetaKey]] with the supplied '''titleID''' and compares the version field from the returned [[CNMT#Content_Meta_Records|Content Meta Record]] with the supplied '''version'''.
+
Finally, it calls [[NCM_services#ncm|OpenContentMetaDatabase]] with [[NCM_services#StorageId|StorageId]] 3, then calls [[NCM_services#IContentMetaDatabase|GetLatestContentMetaKey]] with the supplied '''titleID''' and compares the version field from the returned [[CNMT#Content_Meta_Records|Content Meta Record]] with the supplied '''version'''.
    
If the supplied '''version''' is higher than the one in NCM's database, the value returned by [[NS_Services#NeedsUpdateVulnerability|NeedsUpdateVulnerability]] is set to "true".
 
If the supplied '''version''' is higher than the one in NCM's database, the value returned by [[NS_Services#NeedsUpdateVulnerability|NeedsUpdateVulnerability]] is set to "true".
Line 1,856: Line 1,900:  
! Description
 
! Description
 
|-
 
|-
| 0x0 || 0xE0 || ?
+
| 0x0 || 0x10 || ?
 +
|-
 +
| 0x10 || 0x4 || Application version.
 +
|-
 +
| 0x14 || 0x4 || ?
 +
|-
 +
| 0x18 || 0x4 || Required system version.
 +
|-
 +
| 0x1C || 0x4 || ?
 +
|-
 +
| 0x20 || 0xC0 || ?
 
|-
 
|-
 
| 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]].