mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add function to test OFW behavior under CFW
This commit is contained in:
parent
fc557cbf2a
commit
17731d750e
@ -22,3 +22,5 @@ bool detectDebugger(void);
|
||||
|
||||
/// Returns true if the kernel is patched to allow self-process-jit.
|
||||
bool detectCfwJitPatch(void);
|
||||
/// After this has been called, libnx will pretend that CFW is not present. For testing purposes only.
|
||||
void detectPretendNotCfwForTesting(void);
|
||||
|
@ -71,6 +71,7 @@ static void _CacheCfwJit(void)
|
||||
{
|
||||
// On an unpatched kernel on 5.0.0 and above, this would return 0xD401.
|
||||
// It is not allowed for the creator-process of a CodeMemory object to use svcControlCodeMemory on it.
|
||||
// If the patch is present, the function should return 0xF001, because -1 is not a valid enum CodeOperation.
|
||||
rc = svcControlCodeMemory(code, -1, 0, 0x1000, 0);
|
||||
|
||||
g_CfwJitPatchDetected = (rc == 0xF001);
|
||||
@ -120,3 +121,10 @@ bool detectCfwJitPatch(void) {
|
||||
_CacheCfwJit();
|
||||
return g_CfwJitPatchDetected;
|
||||
}
|
||||
|
||||
void detectPretendNotCfwForTesting(void) {
|
||||
mutexLock(&g_CfwJitMutex);
|
||||
g_CfwJitPatchDetected = false;
|
||||
__atomic_store_n(&g_CfwJitCached, true, __ATOMIC_SEQ_CST);
|
||||
mutexUnlock(&g_CfwJitMutex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user