diff --git a/nx/include/switch/runtime/env.h b/nx/include/switch/runtime/env.h index 2576739e..212e6f57 100644 --- a/nx/include/switch/runtime/env.h +++ b/nx/include/switch/runtime/env.h @@ -28,7 +28,7 @@ enum { EntryType_OverrideHeap=3, ///< Provides heap override information. EntryType_OverrideService=4, ///< Provides service override information. EntryType_Argv=5, ///< Provides argv. - EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints. + EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints (SVCs 0x00..0x7F). EntryType_AppletType=7, ///< Provides APT applet type. EntryType_AppletWorkaround=8, ///< Indicates that APT is broken and should not be used. EntryType_Reserved9=9, ///< Unused/reserved entry type, formerly used by StdioSockets. @@ -37,6 +37,7 @@ enum { EntryType_RandomSeed=14, ///< Provides random data used to seed the pseudo-random number generator. EntryType_UserIdStorage=15, ///< Provides persistent storage for the preselected user id. EntryType_HosVersion=16, ///< Provides the currently running Horizon OS version. + EntryType_SyscallAvailableHint2=17, ///< Provides syscall availability hints (SVCs 0x80..0xBF). }; enum { @@ -81,7 +82,7 @@ void* envGetArgv(void); * @param svc Syscall number to test. * @returns true if the syscall is available. */ -bool envIsSyscallHinted(u8 svc); +bool envIsSyscallHinted(unsigned svc); /// Returns the handle to the running homebrew process. Handle envGetOwnProcessHandle(void); diff --git a/nx/source/runtime/env.c b/nx/source/runtime/env.c index eb67a841..8efbeba8 100644 --- a/nx/source/runtime/env.c +++ b/nx/source/runtime/env.c @@ -17,7 +17,7 @@ static LoaderReturnFn g_loaderRetAddr = NULL; static void* g_overrideHeapAddr = NULL; static u64 g_overrideHeapSize = 0; static void* g_overrideArgv = NULL; -static u64 g_syscallHints[2]; +static u64 g_syscallHints[3]; static Handle g_processHandle = INVALID_HANDLE; static char* g_nextLoadPath = NULL; static char* g_nextLoadArgv = NULL; @@ -37,7 +37,7 @@ void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr) g_isNso = true; g_mainThreadHandle = main_thread; g_loaderRetAddr = (LoaderReturnFn) &svcExitProcess; - g_syscallHints[0] = g_syscallHints[1] = UINT64_MAX; + g_syscallHints[0] = g_syscallHints[1] = g_syscallHints[2] = UINT64_MAX; return; } @@ -110,6 +110,10 @@ void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr) break; } + case EntryType_SyscallAvailableHint2: + g_syscallHints[2] = ent->Value[0]; + break; + default: if (ent->Flags & EntryFlag_IsMandatory) { @@ -170,7 +174,8 @@ void* envGetArgv(void) { return g_overrideArgv; } -bool envIsSyscallHinted(u8 svc) { +bool envIsSyscallHinted(unsigned svc) { + if (svc >= 0xC0) return false; return !!(g_syscallHints[svc/64] & (1ull << (svc%64))); }