NS services: Difference between revisions

 
(15 intermediate revisions by the same user not shown)
Line 406: Line 406:
These are "nn::ns::detail::IServiceGetterInterface".
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.
These commands check a state field for a command-specific bit and returns an error if not set, this is a permissions check for service+command.


[11.0.0+] ns:ro was added.
[11.0.0+] ns:ro was added.
Line 414: Line 414:
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Cmd || Name
! Cmd || Name || Permission bit
|-
|-
| 7988 || [6.0.0+] [[#IDynamicRightsInterface|GetDynamicRightsInterface]]
| 7988 || [6.0.0+] [[#IDynamicRightsInterface|GetDynamicRightsInterface]] || 10
|-
|-
| 7989 || [5.1.0+] [[#IReadOnlyApplicationControlDataInterface|GetReadOnlyApplicationControlDataInterface]]
| 7989 || [5.1.0+] [[#IReadOnlyApplicationControlDataInterface|GetReadOnlyApplicationControlDataInterface]] || 9
|-
|-
| 7991 || [5.0.0+] [[#IReadOnlyApplicationRecordInterface|GetReadOnlyApplicationRecordInterface]]
| 7991 || [5.0.0+] [[#IReadOnlyApplicationRecordInterface|GetReadOnlyApplicationRecordInterface]] || 8
|-
|-
| 7992 || [4.0.0+] [[#IECommerceInterface|GetECommerceInterface]]
| 7992 || [4.0.0+] [[#IECommerceInterface|GetECommerceInterface]] || 7
|-
|-
| 7993 || [4.0.0+] [[#IApplicationVersionInterface|GetApplicationVersionInterface]]
| 7993 || [4.0.0+] [[#IApplicationVersionInterface|GetApplicationVersionInterface]] || 6
|-
|-
| 7994 || [[#IFactoryResetInterface|GetFactoryResetInterface]]
| 7994 || [[#IFactoryResetInterface|GetFactoryResetInterface]] || 5
|-
|-
| 7995 || [[#IAccountProxyInterface|GetAccountProxyInterface]]
| 7995 || [[#IAccountProxyInterface|GetAccountProxyInterface]] || 4
|-
|-
| 7996 || [[#IApplicationManagerInterface|GetApplicationManagerInterface]]
| 7996 || [[#IApplicationManagerInterface|GetApplicationManagerInterface]] || 3
|-
|-
| 7997 || [[#IDownloadTaskInterface|GetDownloadTaskInterface]]
| 7997 || [[#IDownloadTaskInterface|GetDownloadTaskInterface]] || 1
|-
|-
| 7998 || [[#IContentManagementInterface|GetContentManagementInterface]]
| 7998 || [[#IContentManagementInterface|GetContentManagementInterface]] || 0
|-
|-
| 7999 || [[#IDocumentInterface|GetDocumentInterface]]
| 7999 || [[#IDocumentInterface|GetDocumentInterface]] || 2
|}
 
Permissions state field with each service:
 
{| class="wikitable" border="1"
|-
! Service || Permissions
|-
| ns:web || 0x304
|-
| ns:ec || 0x83
|-
| ns:sweb || 0x387
|-
| ns:rid || 0x10
|-
| ns:rt || 0x20
|-
| ns:ro || 0x301
|-
| ns:am2 || 0x7FF
|}
|}


Line 649: Line 670:
|-
|-
| 307 || TerminateOverlayApplet
| 307 || TerminateOverlayApplet
|-
| 308 || [S2]
|-
| 309 || [S2]
|-
|-
| 400 || [[#GetApplicationControlData]]
| 400 || [[#GetApplicationControlData]]
Line 667: Line 692:
|-
|-
| 408 || [8.0.0+] [[#ListApplicationIcon]]
| 408 || [8.0.0+] [[#ListApplicationIcon]]
|-
| 409 || [S2]
|-
| 410 || [S2]
|-
|-
| 411 || [19.0.0+]
| 411 || [19.0.0+]
Line 817: Line 846:
|-
|-
| 923 || [20.0.0+]
| 923 || [20.0.0+]
|-
| 924 || [S2]
|-
| 925 || [S2]
|-
| 926 || [S2]
|-
| 927 || [S2]
|-
|-
| 928 || [20.0.0+]
| 928 || [20.0.0+]
Line 1,132: Line 1,169:
| 3050 || [14.0.0+] ListAssignELicenseTaskResult
| 3050 || [14.0.0+] ListAssignELicenseTaskResult
|-
|-
| 3100 || [17.0.0+] GetSafeSystemVersionCheckInfo
| 3100 || [17.0.0+] [[#GetSafeSystemVersionCheckInfo|GetSafeSystemVersionCheckInfo]]
|-
|-
| 3101 || [17.0.0+] RequestUpdateSafeSystemVersionCheckInfo
| 3101 || [17.0.0+] [[#RequestUpdateSafeSystemVersionCheckInfo|RequestUpdateSafeSystemVersionCheckInfo]]
|-
|-
| 3102 || [17.0.0+] ResetSafeSystemVersionCheckInfo
| 3102 || [17.0.0+] [[#ResetSafeSystemVersionCheckInfo|ResetSafeSystemVersionCheckInfo]]
|-
|-
| 3104 || [18.0.0+] GetApplicationNintendoLogo
| 3104 || [18.0.0+] GetApplicationNintendoLogo
|-
|-
| 3105 || [18.0.0+] GetApplicationStartupMovie
| 3105 || [18.0.0+] GetApplicationStartupMovie
|-
| 3150 || [S2]
|-
|-
| 4000 || [20.0.0+]
| 4000 || [20.0.0+]
Line 1,393: Line 1,432:
==== GetRequestServerStopper ====
==== GetRequestServerStopper ====
No input, returns an output [[#IRequestServerStopper]].
No input, returns an output [[#IRequestServerStopper]].
This increfs a state ref-count, with decref being handled when the object is closed. This ref-count is checked by [[#GetApplicationDeliveryInfo|GetApplicationDeliveryInfo]] and related cmds.


==== CancelApplicationApplyDelta ====
==== CancelApplicationApplyDelta ====
Line 1,694: Line 1,735:
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.
[7.0.0+] An error is thrown if the state ref-count for [[#GetRequestServerStopper|RequestServerStopper]] is zero. [7.0.0-7.0.1] The func which checks this would also return success when a field prior to the previously mentioned field is 0 (checked before the ref-count).


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,841: Line 1,882:
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.
An error is thrown if [[NIM_services|nim]] ListApplicationApplyDeltaTask returns a task.


The [[NCM_services#ContentMetaType|ContentMetaType]] in the ContentMetaKey must match Patch.
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 loop does the following:
* Throws an error if the [[NCM_services#ContentMetaType|ContentMetaType]] in the ContentMetaKey doesn't match Patch.
* Calls a func with the ContentMetaKey and the ApplicationId, throwing an error if the output value is 0.
* Calls a func with the ContentMetaKey for getting the StorageId. This essentially loops through each valid ncm [[NCM_services|IContentMetaDatabase]] using cmd [[NCM_services|Has]] with the input ContentMetaKey, returning the relevant StorageId when found.
* The ContentMetaKey and the StorageId are copied into a tmp struct.
* if (ContentMetaType==Patch && StorageId==GameCard) { <call a func etc> }
* Copies the above tmp struct into the async task state array.


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:
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 2,262: Line 2,309:
|-
|-
| 92 || [5.0.0+] GetRunningApplicationProgramId
| 92 || [5.0.0+] GetRunningApplicationProgramId
|-
| 100 || [S2]
|-
| 101 || [S2]
|-
|-
| 2524 || [19.0.0+]  
| 2524 || [19.0.0+]  
|}
|}
==== Cmd100 ====
Takes a type-0x16 output buffer containing a 0x300-byte struct, an input u8, an u64. Returns two output u8s.
==== Cmd101 ====
Takes a type-0x16 output buffer containing a 0x300-byte struct, an input u8, an u64. Returns an output u8, an u8 [[Filesystem_services|ContentAttributes]], and a [[NCM_services#ProgramId|ProgramId]].
This is similar to Cmd2524. On [S2] this is used instead of Cmd2524.
==== Cmd2524 ====
Takes a type-0x16 output buffer containing a 0x300-byte struct, an input u8, an u64. Returns an output u8 [[Filesystem_services|ContentAttributes]] and a [[NCM_services#ProgramId|ProgramId]].
The user-process uses the output from this as the input for [[Filesystem_services|OpenFileSystemWithId]] (out-buffer is used as the [[Filesystem_services|FspPath]]).


=== IDownloadTaskInterface ===
=== IDownloadTaskInterface ===
Line 2,335: Line 2,399:
| 2 || [10.0.0+] IsDataCorruptedResult ||
| 2 || [10.0.0+] IsDataCorruptedResult ||
|-
|-
| 3 || [20.0.0+] ||
| 3 || [20.0.0+] [[#ListApplicationRecord|ListApplicationRecord]] ||
|}
|}


Line 2,668: Line 2,732:
| 1202 || [4.0.0+] [[#GetSafeSystemVersion]]
| 1202 || [4.0.0+] [[#GetSafeSystemVersion]]
|-
|-
| 3100 || [18.0.0+]  
| 3100 || [18.0.0+] [[#GetSafeSystemVersionCheckInfo|GetSafeSystemVersionCheckInfo]]
|-
|-
| 3101 || [18.0.0+]  
| 3101 || [18.0.0+] [[#RequestUpdateSafeSystemVersionCheckInfo|RequestUpdateSafeSystemVersionCheckInfo]]
|-
|-
| 3102 || [18.0.0+]  
| 3102 || [18.0.0+] [[#ResetSafeSystemVersionCheckInfo|ResetSafeSystemVersionCheckInfo]]
|}
|}


Line 2,678: Line 2,742:
No input, returns an output u8 bool flag.
No input, returns an output u8 bool flag.


Web-applets use this command to check if the system needs an update.
[S1] Web-applets use this command to check if the system needs an update.


== UpdateSafeSystemVersionForDebug ==
== UpdateSafeSystemVersionForDebug ==
Takes an input [[NCM_services#ApplicationId|ApplicationId]] and an u32 '''version'''.
Takes an input u32 '''version''' and an [[NCM_services#ApplicationId|ApplicationId]].


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 [[NCM_services#ApplicationId|ApplicationId]] 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 [[NCM_services#ApplicationId|ApplicationId]] and '''version''' in it.
Line 2,691: Line 2,755:
== GetSafeSystemVersion ==
== GetSafeSystemVersion ==
No input, returns an output [[NCM_services#ContentMetaKey|ContentMetaKey]] with the cached contents of "ns_ssversion:/entry" ([[NCM_services#ApplicationId|ApplicationId]], u32 '''version''' and u32 '''policy''' from <code>vulnerability!needs_update_vulnerability_policy</code>).
No input, returns an output [[NCM_services#ContentMetaKey|ContentMetaKey]] with the cached contents of "ns_ssversion:/entry" ([[NCM_services#ApplicationId|ApplicationId]], u32 '''version''' and u32 '''policy''' from <code>vulnerability!needs_update_vulnerability_policy</code>).
== GetSafeSystemVersionCheckInfo ==
No input, returns 0x10-bytes of output.
[S2] Used by web-applets via ns:vm.
== RequestUpdateSafeSystemVersionCheckInfo ==
No input, returns an output Event handle and an [[#IAsyncResult|IAsyncResult]].
[S2] Used by web-applets via ns:vm.
The async task thread uses [[NIM_services|nim]] RequestCheckSafeSystemVersion, etc.
== ResetSafeSystemVersionCheckInfo ==
No input/output.
This throws an error if [[Settings_services|GetDebugModeFlag]] returns false.


= ns:su =
= ns:su =
Line 2,732: Line 2,813:
|-
|-
| 18 || [4.0.0+] [[#GetSendSystemUpdateProgress]]
| 18 || [4.0.0+] [[#GetSendSystemUpdateProgress]]
|-
| 19 || [S2]
|-
| 20 || [S2]
|}
|}


Line 2,821: Line 2,906:


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.
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.
== Cmd19 ==
This is exclusive to S2.
No input/output.
== Cmd20 ==
This is exclusive to S2.
No input, returns an output u8.


== ISystemUpdateControl ==
== ISystemUpdateControl ==
Line 2,997: Line 3,092:
* 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]] (this func is also passed the below statefield as the last param), throwing an error if not.
*** [20.0.0+] The above check-sysupdate func was updated (which is also used elsewhere), flag handling during the loop was updated (which uses the last input param).
** Uses [[NIM_services|nim]] CreateLocalCommunicationReceiveSystemUpdateTask, returning the Result on failure.
** Uses [[NIM_services|nim]] CreateLocalCommunicationReceiveSystemUpdateTask, returning the Result on failure.
*** The input firmware_variation is from [[System_Settings|system-setting]] <code>ns.systemupdate!firmware_variation</code> or <code>ns.systemupdate!t_firmware_variation</code>, depending on the [[Settings_services|PlatformRegion]] (value 0xFF is used when the output setting-size is invalid).
*** The input firmware_variation is from [[System_Settings|system-setting]] <code>ns.systemupdate!firmware_variation</code> or <code>ns.systemupdate!t_firmware_variation</code>, depending on the [[Settings_services|PlatformRegion]] (value 0xFF is used when the output setting-size is invalid).