diff --git a/nx/include/switch/runtime/env.h b/nx/include/switch/runtime/env.h index ac311e17..e5023d32 100644 --- a/nx/include/switch/runtime/env.h +++ b/nx/include/switch/runtime/env.h @@ -34,6 +34,7 @@ enum { EntryType_ProcessHandle=10, ///< Provides the process handle. EntryType_LastLoadResult=11, ///< Provides the last load result. EntryType_RandomSeed=14, ///< Provides random data used to seed the pseudo-random number generator. + EntryType_NroReturnPath=15 }; enum { @@ -94,6 +95,12 @@ Result envSetNextLoad(const char* path, const char* argv); /// Returns true if the environment supports envSetNextLoad. bool envHasNextLoad(void); +/// Sets the path of the NRO that will be loaded after the next one +Result envSetNroReturnPath(const char* path); + +///Returns true if the environment supports envSetNroReturnPath +bool envHasNroReturnPath(void); + /// Returns the Result from the last NRO. Result envGetLastLoadResult(void); diff --git a/nx/source/runtime/env.c b/nx/source/runtime/env.c index 7fe4fdfa..16ab1512 100644 --- a/nx/source/runtime/env.c +++ b/nx/source/runtime/env.c @@ -17,6 +17,7 @@ static u64 g_syscallHints[2]; static Handle g_processHandle = INVALID_HANDLE; static char* g_nextLoadPath = NULL; static char* g_nextLoadArgv = NULL; +static char* g_nroReturnPath=NULL; static Result g_lastLoadResult = 0; static bool g_hasRandomSeed = false; static u64 g_randomSeed[2] = { 0, 0 }; @@ -99,6 +100,10 @@ void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr) g_randomSeed[1] = ent->Value[1]; break; + case EntryType_NroReturnPath: + g_nroReturnPath = (char*) ent->Value[0]; + break; + default: if (ent->Flags & EntryFlag_IsMandatory) { @@ -184,6 +189,19 @@ bool envHasNextLoad(void) { return g_nextLoadPath != NULL; } +Result envSetNroReturnPath(const char* path) { + if (g_nroReturnPath == NULL) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + strcpy(g_nroReturnPath, path); + + return 0; +} + +bool envHasNroReturnPath(void) { + return g_nroReturnPath!=NULL; +} + Result envGetLastLoadResult(void) { return g_lastLoadResult; }