Difference between revisions of "Loader services"

From Nintendo Switch Brew
Jump to navigation Jump to search
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
= ldr:shel =
 +
This is "nn::ldr::detail::IShellInterface".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! 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 title-id.
 +
 +
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 ==
 +
Clears the loaded processes waiting queue.
 +
 +
 
= ldr:dmnt =
 
= ldr:dmnt =
 +
This is "nn::ldr::detail::IDebugMonitorInterface".
 +
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || AddProcessToDebugLaunchQueue
+
| 0 || [[#SetProgramArgument]]
 
|-
 
|-
| 1 || ClearDebugLaunchQueue
+
| 1 || [[#FlushArguments]]
 
|-
 
|-
| 2 ||
+
| 2 || [[#GetProcessModuleInfo]]
 
|}
 
|}
  
== AddProcessToDebugLaunchQueue ==
+
== GetProcessModuleInfo ==
Same as [[Loader_services#AddProcessToLaunchQueue|AddProcessToLaunchQueue]] but for processes marked as debug.
+
Takes in a u64 Process ID, and a C descriptor out array of [[#ModuleInfos]]. Returns the number of ModuleInfos copied to output.
 +
 
 +
ModuleInfo is the same here as for ro:dmnt.
 +
 
 +
ModuleInfo has the following layout:
 +
 
 +
=== ModuleInfo ===
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x20
 +
| Build ID
 +
|-
 +
| 0x20
 +
| 0x8
 +
| Mapped Address
 +
|-
 +
| 0x28
 +
| 0x8
 +
| Mapped Size
 +
|-
 +
|}
  
== ClearDebugLaunchQueue ==
 
Same as [[Loader_services#ClearLaunchQueue|ClearLaunchQueue]] but for processes marked as debug.
 
  
 
= ldr:pm =
 
= ldr:pm =
 +
This is "nn::ldr::detail::IProcessManagerInterface".
 +
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 26: Line 75:
 
| 1 || [[#GetProgramInfo]]
 
| 1 || [[#GetProgramInfo]]
 
|-
 
|-
| 2 || [[#RegisterTitle]]
+
| 2 || [[#PinProgram]]
 
|-
 
|-
| 3 || [[#UnregisterTitle]]
+
| 3 || [[#UnpinProgram]]
 
|}
 
|}
  
 
== GetProgramInfo ==
 
== GetProgramInfo ==
Takes a TitleId + StorageId and writes output to a C descriptor buffer as follows:
+
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 42: Line 92:
 
| 0x0
 
| 0x0
 
| 0x1
 
| 0x1
| Arg1 to svcStartProcess
+
| MainThreadPrio. Arg1 to svcStartProcess
 
|-
 
|-
 
| 0x1
 
| 0x1
 +
| 0x1
 +
| DefaultCpuId. Arg2 to svcStartProcess
 +
|-
 
| 0x2
 
| 0x2
| Arg2 to svcStartProcess
+
| 0x1
 +
| ApplicationType, see [[Process Manager services|here]].
 
|-
 
|-
 
| 0x3
 
| 0x3
 
| 0x1
 
| 0x1
|
+
| Padding
 
|-
 
|-
 
| 0x4
 
| 0x4
 
| 0x4
 
| 0x4
| Arg3 to svcStartProcess
+
| MainThreadStackSize. Arg3 to svcStartProcess
 
|-
 
|-
 
| 0x8
 
| 0x8
 
| 0x8
 
| 0x8
| Title id
+
| TitleIdRange_Min
 
|-
 
|-
 
| 0x10
 
| 0x10
Line 93: Line 147:
 
|}
 
|}
  
== RegisterTitle ==
+
== PinProgram ==
Takes a TitleId + StorageId, returns an index.
+
Takes an ncm::ProgramLocation, returns a u64 "PinId".
 
 
== UnregisterTitle ==
 
Takes the index from [[#RegisterTitle]].
 
 
 
= ldr:shel =
 
{| class="wikitable" border="1"
 
|-
 
! Cmd || Name
 
|-
 
| 0 || [[#AddProcessToLaunchQueue]]
 
|-
 
| 1 || [[#ClearLaunchQueue]]
 
|}
 
 
 
== AddProcessToLaunchQueue ==
 
Takes a type-0x19 input buffer with launch arguments (as string), an u32 (size of arguments string), and an input title-id.
 
 
 
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.
 
  
== ClearLaunchQueue ==
+
== UnpinProgram ==
Clears the loaded processes waiting queue.
+
Takes a PinId from [[#PinProgram]].
 
 
= ldr:ro =
 
{| class="wikitable" border="1"
 
|-
 
! Cmd || Name
 
|-
 
| 0 || [[#LoadNro]]
 
|-
 
| 1 || UnloadNro
 
|-
 
| 2 || [[#LoadNrr]]
 
|-
 
| 3 || UnloadNrr
 
|-
 
| 4 || [[#Initialize]]
 
|}
 
 
 
== LoadNro ==
 
{| class="wikitable" border="1"
 
|-
 
! Word || Value
 
|-
 
| 0 || 0x00000004
 
|-
 
| 1 || 0x80000012
 
|-
 
| 2 || 0x00000001
 
|- style="border-top: double"
 
| 0-1 || Pid
 
|- style="border-top: double"
 
| 0 || "SCFI"
 
|-
 
| 1 || 0x00000000
 
|-
 
| 2 || Always 0.
 
|-
 
| 3 || Nro heap address
 
|-
 
| 4 || Nro size
 
|-
 
| 5 || Bss backing heap address
 
|-
 
| 6 || Bss size
 
|}
 
 
 
== LoadNrr ==
 
{| class="wikitable" border="1"
 
|-
 
! Word || Value
 
|-
 
| 0 || 0x00000004
 
|-
 
| 1 || 0x8000000E
 
|-
 
| 2 || 0x00000001
 
|-
 
|- style="border-top: double"
 
| 0-1 || Pid
 
|- style="border-top: double"
 
| 0 || "SFCI"
 
|-
 
| 1 || 0x00000002
 
|-
 
| 2 || Always 0.
 
|-
 
| 3 || Nrr address
 
|-
 
| 4 || Nrr size
 
|}
 
 
 
== Initialize ==
 
{| class="wikitable" border="1"
 
|-
 
! Word || Value
 
|-
 
| 0 || 0x00000004
 
|-
 
| 1 || 0x8000000A
 
|-
 
| 2 || 0x00000003
 
|- style="border-top: double"
 
| 0-1 || Pid
 
|-
 
| 2 || Process handle (0xFFFF8001)
 
|- style="border-top: double"
 
| 0 || "SFCI"
 
|-
 
| 1 || 0x00000004
 
|-
 
| 2 || Always 0.
 
|}
 
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 06:23, 28 October 2019

ldr:shel

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

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 title-id.

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

Clears the loaded processes waiting queue.


ldr:dmnt

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

Cmd Name
0 #SetProgramArgument
1 #FlushArguments
2 #GetProcessModuleInfo

GetProcessModuleInfo

Takes in a u64 Process ID, and a C descriptor out array of #ModuleInfos. Returns the number of ModuleInfos copied to output.

ModuleInfo is the same here as for ro:dmnt.

ModuleInfo has the following layout:

ModuleInfo

Offset Size Description
0x0 0x20 Build ID
0x20 0x8 Mapped Address
0x28 0x8 Mapped Size


ldr:pm

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

Cmd Name
0 CreateProcess
1 #GetProgramInfo
2 #PinProgram
3 #UnpinProgram

GetProgramInfo

Takes an ncm::ProgramLocation, parses the NPDM, and writes a #ProgramInfo to a C descriptor buffer as follows:

ProgramInfo

Offset Size Description
0x0 0x1 MainThreadPrio. Arg1 to svcStartProcess
0x1 0x1 DefaultCpuId. Arg2 to svcStartProcess
0x2 0x1 ApplicationType, see here.
0x3 0x1 Padding
0x4 0x4 MainThreadStackSize. Arg3 to svcStartProcess
0x8 0x8 TitleIdRange_Min
0x10 0x4 ACID Service Access Control list size
0x14 0x4 ACI0 Service Access Control list size
0x18 0x4 ACID FS Access Control buffer size
0x1C 0x4 ACI0 FS Access Control buffer size
0x20 <Varies> ACID Service Access Control list
<Varies> <Varies> ACI0 Service Access Control list
<Varies> <Varies> ACID FS Access Control buffer
<Varies> <Varies> ACI0 FS Access Control

PinProgram

Takes an ncm::ProgramLocation, returns a u64 "PinId".

UnpinProgram

Takes a PinId from #PinProgram.