Add g_nroReturnPath

g_nroReturnPath is the path that nx-hbloader will load after the next NRO returns. If it is not set, the next NRO will simply return to sdmc:/hbmenu.nro
This commit is contained in:
friedkeenan 2019-01-02 00:15:26 -06:00 committed by GitHub
parent a182f3b496
commit b7ee0899d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -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);

View File

@ -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;
}