Changes

1,366 bytes added ,  18:07, 29 July 2019
no edit summary
Line 15: Line 15:     
'''NRO0:''' the homebrew loader puts X0=loader_config_ptr, X1=0xFFFFFFFFFFFFFFFF.
 
'''NRO0:''' the homebrew loader puts X0=loader_config_ptr, X1=0xFFFFFFFFFFFFFFFF.
 +
 +
When X0 is non-zero and X1 is not 0xFFFFFFFFFFFFFFFF, the application must handle userland [[SVC#Exception_Handling|exceptions]] (with the same entrypoint args described there). This must be done without corrupting registers for this (x8..x29).
 +
 +
The loader should forward exceptions to the mapped NRO by just jumping to the NRO entrypoint, without the above register corruption. When the NRO is not mapped the loader can run: <code>svcReturnFromException(0xf801); while(1);</code>
    
=== Loader Config ===
 
=== Loader Config ===
Line 76: Line 80:     
* 14: [[#RandomSeed]]
 
* 14: [[#RandomSeed]]
 +
 +
* 15: [[#UserIdStorage]]
 +
 +
* 16: [[#HosVersion]]
    
==== EndOfList ====
 
==== EndOfList ====
EndOfList is the final entry in the LoaderConfig.
+
EndOfList is the final entry in the LoaderConfig. It also provides optional human readable information about the Homebrew loader.
    
* '''Key:''' 0
 
* '''Key:''' 0
* '''Value[0]:''' Ignored.
+
* '''Value[0]:''' Pointer to loader information string, or zero if not present.
* '''Value[1]:''' Ignored.
+
* '''Value[1]:''' Size in bytes of the information string, or zero if not present.
    
==== MainThreadHandle ====
 
==== MainThreadHandle ====
Line 89: Line 97:  
* '''Key:''' 1
 
* '''Key:''' 1
 
* '''Value[0]:''' Handle to the main thread.
 
* '''Value[0]:''' Handle to the main thread.
* '''Value[1]:''' Ignored.
+
* '''Value[1]:''' Reserved/should be zero.
 
* '''DefaultBehavior:''' Use main thread handle from entry function arguments.
 
* '''DefaultBehavior:''' Use main thread handle from entry function arguments.
   Line 108: Line 116:     
==== OverrideService ====
 
==== OverrideService ====
The NRO loader should be able to steal handles from more priliveged processes. In this case, the homebrew should use this handle instead of the normal one.
+
The NRO loader should be able to steal handles from more priliveged processes. In this case, homebrew should use this handle instead of the normal one.
   −
Homebrew should allow up to 32 service overrides.
+
Homebrew should allow at least 32 service overrides.
    
Note: Overridden service handles should not be converted to domains or closed. If they are domain, they should be converted to sessions before passed to the homebrew application.
 
Note: Overridden service handles should not be converted to domains or closed. If they are domain, they should be converted to sessions before passed to the homebrew application.
Line 127: Line 135:     
* '''Key:''' 5
 
* '''Key:''' 5
* '''Value[0]:''' Ignored.
+
* '''Value[0]:''' Reserved/should be zero.
 
* '''Value[1]:''' Argv string pointer.
 
* '''Value[1]:''' Argv string pointer.
 
* '''DefaultBehavior:''' Setting (argc == 1, argv[0] == "", argv[1] == NULL), or argv parsed in NSO0 fashion.
 
* '''DefaultBehavior:''' Setting (argc == 1, argv[0] == "", argv[1] == NULL), or argv parsed in NSO0 fashion.
Line 167: Line 175:  
* '''Key:''' 8
 
* '''Key:''' 8
 
* '''Value[0]:''' AppletResourceUserId
 
* '''Value[0]:''' AppletResourceUserId
* '''Value[1]:''' Ignored.
+
* '''Value[1]:''' Reserved/should be zero.
    
==== Reserved9 ====
 
==== Reserved9 ====
This was originally stdiosockets which couldn't work long term in clean environments the way this was designed. Now reserved for future use.
+
This key has been deleted/reserved for future use.
    
==== ProcessHandle ====
 
==== ProcessHandle ====
Line 177: Line 185:  
* '''Key:''' 10
 
* '''Key:''' 10
 
* '''Value[0]:''' Process handle.
 
* '''Value[0]:''' Process handle.
* '''Value[1]:''' Ignored.
+
* '''Value[1]:''' Reserved/should be zero.
    
==== LastLoadResult ====
 
==== LastLoadResult ====
Line 184: Line 192:  
* '''Key:''' 11
 
* '''Key:''' 11
 
* '''Value[0]:''' Result.
 
* '''Value[0]:''' Result.
* '''Value[1]:''' Ignored.
+
* '''Value[1]:''' Reserved/should be zero.
    
==== AllocPages ====
 
==== AllocPages ====
Line 220: Line 228:  
* '''Value[0]:''' Random data.
 
* '''Value[0]:''' Random data.
 
* '''Value[1]:''' More random data.
 
* '''Value[1]:''' More random data.
 +
 +
==== UserIdStorage ====
 +
This key is used to provide persistent storage space for the preselected user id when launching homebrew under an application that has an account selection screen.
 +
 +
* '''Key''': 15
 +
* '''Value[0]:''' Pointer to a buffer containing enough space (16 bytes) to store a user id.
 +
* '''Value[1]:''' Reserved/should be zero.
 +
 +
==== HosVersion ====
 +
This key provides the currently running version of Horizon OS.
 +
 +
* '''Key''': 16
 +
* '''Value[0]:''' HOS version, formatted using libnx's [https://github.com/switchbrew/libnx/blob/master/nx/include/switch/runtime/hosversion.h#L11 MAKEHOSVERSION macro].
 +
* '''Value[1]:''' Reserved/should be zero.