Difference between revisions of "Loader services"

From Nintendo Switch Brew
Jump to navigation Jump to search
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
= ldr:shel =
 
= ldr:shel =
 
This is "nn::ldr::detail::IShellInterface".
 
This is "nn::ldr::detail::IShellInterface".
 +
 +
This service has IPC max_sessions 3.
  
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 11: Line 13:
 
|}
 
|}
  
== AddProcessToLaunchQueue ==
+
== SetProgramArgument ==
Takes a type-0x9 input buffer with launch arguments (as string), an u32 (size of arguments string), and an input title-id.
+
Takes a type-0x9 input buffer with launch arguments (as string), an u32 (size of arguments string), and an input [[NCM_services#ProgramId|ProgramId]]. No output.
 +
 
 +
[11.0.0+] Now takes a type-0x5 buffer instead of type-0x9. Now takes a total of 8-bytes of input, instead of 0x10-bytes total.
  
 
Loads a process for the specified title-id and passes along the supplied arguments.
 
Loads a process for the specified title-id and passes along the supplied arguments.
 
Loaded processes are kept in a queue waiting for PM to launch them. The maximum number of waiting processes in this list is 10.
 
Loaded processes are kept in a queue waiting for PM to launch them. The maximum number of waiting processes in this list is 10.
  
== ClearLaunchQueue ==
+
== FlushArguments ==
 +
No input/output.
 +
 
 
Clears the loaded processes waiting queue.
 
Clears the loaded processes waiting queue.
 
  
 
= ldr:dmnt =
 
= ldr:dmnt =
 
This is "nn::ldr::detail::IDebugMonitorInterface".
 
This is "nn::ldr::detail::IDebugMonitorInterface".
 +
 +
This service has IPC max_sessions 2.
  
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 28: Line 35:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || [[#SetProgramArgument]]
+
| 0 || [[#SetProgramArgument2]]
 
|-
 
|-
| 1 || [[#FlushArguments]]
+
| 1 || [[#FlushArguments2]]
 
|-
 
|-
 
| 2 || [[#GetProcessModuleInfo]]
 
| 2 || [[#GetProcessModuleInfo]]
 
|}
 
|}
  
== GetProcessModuleInfo==
+
== SetProgramArgument2 ==
Takes in a u64 Process ID, and a C descriptor out array of [[#ModuleInfos]]. Returns the number of ModuleInfos copied to output.
+
Same as [[#SetProgramArgument]].
  
ModuleInfo is the same here as for ro:dmnt.
+
== FlushArguments2 ==
 +
Same as [[#FlushArguments]].
  
ModuleInfo has the following layout:
+
== GetProcessModuleInfo ==
 +
Takes a type-0xA output buffer of [[#ModuleInfo]] and an input u64 ProcessId. Returns an output s32.
 +
 
 +
= ldr:pm =
 +
This is "nn::ldr::detail::IProcessManagerInterface".
 +
 
 +
This service has IPC max_sessions 1.
  
=== ModuleInfo ===
 
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Offset
+
! Cmd || Name
! Size
+
|-
! Description
+
| 0 || [[#CreateProcess]]
 
|-
 
|-
| 0x0
+
| 1 || [[#GetProgramInfo]]
| 0x20
 
| Build ID
 
 
|-
 
|-
| 0x20
+
| 2 || [[#PinProgram]]
| 0x8
 
| Mapped Address
 
 
|-
 
|-
| 0x28
+
| 3 || [[#UnpinProgram]]
| 0x8
 
| Mapped Size
 
 
|-
 
|-
 +
| 4 || [10.0.0+] [[#SetEnabledProgramVerification]]
 
|}
 
|}
  
 +
== CreateProcess ==
 +
Takes an input [[#PinId]], an input [[#CreateProcessFlag]] and an input ResourceLimit handle. Returns an output Process handle.
 +
 +
== GetProgramInfo ==
 +
Takes a type-0x1A output buffer containing a [[#ProgramInfo]] and a [[NCM_services#ProgramLocation|ProgramLocation]]. No output.
 +
 +
== PinProgram ==
 +
Takes a [[NCM_services#ProgramLocation|ProgramLocation]]. Returns an output [[#PinId]].
 +
 +
== UnpinProgram ==
 +
Takes an input [[#PinId]]. No output.
 +
 +
== SetEnabledProgramVerification ==
 +
Takes an input bool. No output.
  
= ldr:pm =
+
When the flag is zero, it will set ret=0 instead of ret={error} when verifying the fixed-key [[NPDM]] ACID signature fails. This also skips verifying the [[NCA#Header|NCA Header]] signature using the ACID key. Note that if verifying the fixed-key ACID signature is successful, and verifying the ACID-key NCA header signature fails, it will throw an error and abort.
This is "nn::ldr::detail::IProcessManagerInterface".
 
  
 +
= CreateProcessFlag =
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Cmd || Name
+
! Value
 +
!  Description
 +
|-
 +
| 0 || EnableDebug
 +
|-
 +
| 1 || DisableAslr
 +
|}
 +
 
 +
= PinId =
 +
This is an u64.
 +
 
 +
= ModuleInfo =
 +
{| class="wikitable" border="1"
 
|-
 
|-
| 0 || CreateProcess
+
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
| 1 || [[#GetProgramInfo]]
+
| 0x0
 +
| 0x20
 +
| ModuleId
 
|-
 
|-
| 2 || [[#PinProgram]]
+
| 0x20
 +
| 0x8
 +
| Address
 
|-
 
|-
| 3 || [[#UnpinProgram]]
+
| 0x28
 +
| 0x8
 +
| Size
 
|}
 
|}
  
== GetProgramInfo ==
+
= ProgramInfo =
Takes an ncm::ProgramLocation, parses the NPDM, and writes a [[#ProgramInfo]] to a C descriptor buffer as follows:
 
 
 
=== ProgramInfo ===
 
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 92: Line 131:
 
| 0x0
 
| 0x0
 
| 0x1
 
| 0x1
| MainThreadPrio. Arg1 to svcStartProcess
+
| MainThreadPriority
 
|-
 
|-
 
| 0x1
 
| 0x1
 
| 0x1
 
| 0x1
| DefaultCpuId. Arg2 to svcStartProcess
+
| DefaultCpuId
 
|-
 
|-
 
| 0x2
 
| 0x2
| 0x1
+
| 0x2
| ApplicationType, see [[Process Manager services|here]].
+
| Flags
|-
 
| 0x3
 
| 0x1
 
| Padding
 
 
|-
 
|-
 
| 0x4
 
| 0x4
 
| 0x4
 
| 0x4
| MainThreadStackSize. Arg3 to svcStartProcess
+
| MainThreadStackSize
 
|-
 
|-
 
| 0x8
 
| 0x8
 
| 0x8
 
| 0x8
| TitleIdRange_Min
+
| [[NCM_services#ProgramId|ProgramId]]
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 0x4
 
| 0x4
| ACID [[NPDM#Service Access Control|Service Access Control]] list size
+
| AcidSacSize
 
|-
 
|-
 
| 0x14
 
| 0x14
 
| 0x4
 
| 0x4
| ACI0 [[NPDM#Service Access Control|Service Access Control]] list size
+
| AciSacSize
 
|-
 
|-
 
| 0x18
 
| 0x18
 
| 0x4
 
| 0x4
| ACID [[NPDM#FS Access Control|FS Access Control]] buffer size
+
| AcidFacSize
 
|-
 
|-
 
| 0x1C
 
| 0x1C
 
| 0x4
 
| 0x4
| ACI0 [[NPDM#FS Access Control|FS Access Control]] buffer size
+
| AciFacSize
 
|-
 
|-
 
| 0x20
 
| 0x20
| <Varies>
+
| 0x10
| ACID [[NPDM#Service Access Control|Service Access Control]] list
+
| [19.0.0+] Reserved
 +
|-
 +
| [19.0.0+] 0x30 ([1.0.0-18.1.0] 0x20)
 +
| Variable
 +
| AcidSac
 
|-
 
|-
| <Varies>
+
| Variable
| <Varies>
+
| Variable
| ACI0 [[NPDM#Service Access Control|Service Access Control]] list
+
| AciSac
 
|-
 
|-
| <Varies>
+
| Variable
| <Varies>
+
| Variable
| ACID [[NPDM#FS Access Control|FS Access Control]] buffer
+
| AcidFac
 
|-
 
|-
| <Varies>
+
| Variable
| <Varies>
+
| Variable
| ACI0 [[NPDM#FS Access Control|FS Access Control]]
+
| AciFac
 
|}
 
|}
 
== PinProgram ==
 
Takes an ncm::ProgramLocation, returns a u64 "PinId".
 
 
== UnpinProgram ==
 
Takes a PinId from [[#PinProgram]].
 
  
 
[[Category:Services]]
 
[[Category:Services]]

Latest revision as of 22:12, 23 October 2024

ldr:shel

This is "nn::ldr::detail::IShellInterface".

This service has IPC max_sessions 3.

Cmd Name
0 #SetProgramArgument
1 #FlushArguments

SetProgramArgument

Takes a type-0x9 input buffer with launch arguments (as string), an u32 (size of arguments string), and an input ProgramId. No output.

[11.0.0+] Now takes a type-0x5 buffer instead of type-0x9. Now takes a total of 8-bytes of input, instead of 0x10-bytes total.

Loads a process for the specified title-id and passes along the supplied arguments. Loaded processes are kept in a queue waiting for PM to launch them. The maximum number of waiting processes in this list is 10.

FlushArguments

No input/output.

Clears the loaded processes waiting queue.

ldr:dmnt

This is "nn::ldr::detail::IDebugMonitorInterface".

This service has IPC max_sessions 2.

Cmd Name
0 #SetProgramArgument2
1 #FlushArguments2
2 #GetProcessModuleInfo

SetProgramArgument2

Same as #SetProgramArgument.

FlushArguments2

Same as #FlushArguments.

GetProcessModuleInfo

Takes a type-0xA output buffer of #ModuleInfo and an input u64 ProcessId. Returns an output s32.

ldr:pm

This is "nn::ldr::detail::IProcessManagerInterface".

This service has IPC max_sessions 1.

Cmd Name
0 #CreateProcess
1 #GetProgramInfo
2 #PinProgram
3 #UnpinProgram
4 [10.0.0+] #SetEnabledProgramVerification

CreateProcess

Takes an input #PinId, an input #CreateProcessFlag and an input ResourceLimit handle. Returns an output Process handle.

GetProgramInfo

Takes a type-0x1A output buffer containing a #ProgramInfo and a ProgramLocation. No output.

PinProgram

Takes a ProgramLocation. Returns an output #PinId.

UnpinProgram

Takes an input #PinId. No output.

SetEnabledProgramVerification

Takes an input bool. No output.

When the flag is zero, it will set ret=0 instead of ret={error} when verifying the fixed-key NPDM ACID signature fails. This also skips verifying the NCA Header signature using the ACID key. Note that if verifying the fixed-key ACID signature is successful, and verifying the ACID-key NCA header signature fails, it will throw an error and abort.

CreateProcessFlag

Value Description
0 EnableDebug
1 DisableAslr

PinId

This is an u64.

ModuleInfo

Offset Size Description
0x0 0x20 ModuleId
0x20 0x8 Address
0x28 0x8 Size

ProgramInfo

Offset Size Description
0x0 0x1 MainThreadPriority
0x1 0x1 DefaultCpuId
0x2 0x2 Flags
0x4 0x4 MainThreadStackSize
0x8 0x8 ProgramId
0x10 0x4 AcidSacSize
0x14 0x4 AciSacSize
0x18 0x4 AcidFacSize
0x1C 0x4 AciFacSize
0x20 0x10 [19.0.0+] Reserved
[19.0.0+] 0x30 ([1.0.0-18.1.0] 0x20) Variable AcidSac
Variable Variable AciSac
Variable Variable AcidFac
Variable Variable AciFac