Fix bug where attempts to parse __argdata__ while running as an NRO

This commit is contained in:
plutoo 2018-02-04 03:29:21 +01:00
parent 2103e40448
commit 356a06fb94

View File

@ -1,6 +1,7 @@
#include <string.h>
#include <ctype.h>
#include "result.h"
#include "runtime/env.h"
#include "kernel/svc.h"
// System globals we define here
@ -35,11 +36,12 @@ void argvSetup(void)
__system_argc = 0;
__system_argv = NULL;
// TODO: Use envHasArgv() here for the NRO case.
if (envIsNso()) {
memset(&meminfo, 0, sizeof(meminfo));
rc = svcQueryMemory(&meminfo, &pageinfo, (u64)argdata);
// TODO: Use envHasArgv() here.
// This memory is only mapped when arguments were passed.
if (R_FAILED(rc) || meminfo.perm != 0x3)
return;
@ -116,5 +118,6 @@ void argvSetup(void)
}
__system_argv[__system_argc] = NULL;
}
}