diff --git a/nx/include/switch/runtime/env.h b/nx/include/switch/runtime/env.h index af2e0d57..b21db618 100644 --- a/nx/include/switch/runtime/env.h +++ b/nx/include/switch/runtime/env.h @@ -85,3 +85,6 @@ Result envSetNextLoad(const char* path, const char* argv); /// Returns true if the environment supports envSetNextLoad. bool envHasNextLoad(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 6ceb6e31..1cc7eb44 100644 --- a/nx/source/runtime/env.c +++ b/nx/source/runtime/env.c @@ -16,6 +16,7 @@ static u64 g_syscallHints[2]; static Handle g_processHandle = INVALID_HANDLE; static char* g_nextLoadPath = NULL; static char* g_nextLoadArgv = NULL; +static Result g_lastLoadResult = 0; extern __attribute__((weak)) u32 __nx_applet_type; @@ -84,6 +85,10 @@ void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr) g_processHandle = ent->Value[0]; break; + case EntryType_LastLoadResult: + g_lastLoadResult = ent->Value[0]; + break; + default: if (ent->Flags & EntryFlag_IsMandatory) { @@ -164,3 +169,7 @@ Result envSetNextLoad(const char* path, const char* argv) bool envHasNextLoad(void) { return g_nextLoadPath != NULL; } + +Result envGetLastLoadResult(void) { + return g_lastLoadResult; +}