mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Detect 5.0.0 properly
This commit is contained in:
parent
bf216aa667
commit
6c72bf8273
@ -13,5 +13,7 @@ bool kernelAbove200(void);
|
|||||||
bool kernelAbove300(void);
|
bool kernelAbove300(void);
|
||||||
/// Returns true if the kernel version is equal to or above 4.0.0.
|
/// Returns true if the kernel version is equal to or above 4.0.0.
|
||||||
bool kernelAbove400(void);
|
bool kernelAbove400(void);
|
||||||
|
/// Returns true if the kernel version is equal to or above 5.0.0.
|
||||||
|
bool kernelAbove500(void);
|
||||||
/// Returns true if the process has a debugger attached.
|
/// Returns true if the process has a debugger attached.
|
||||||
bool detectDebugger(void);
|
bool detectDebugger(void);
|
||||||
|
@ -1,24 +1,39 @@
|
|||||||
// Copyright 2017 plutoo
|
// Copyright 2017 plutoo
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "kernel/detect.h"
|
#include "kernel/detect.h"
|
||||||
|
#include "kernel/mutex.h"
|
||||||
#include "kernel/svc.h"
|
#include "kernel/svc.h"
|
||||||
|
|
||||||
static bool g_IsAbove200;
|
static bool g_IsAbove200;
|
||||||
static bool g_IsAbove300;
|
static bool g_IsAbove300;
|
||||||
static bool g_IsAbove400;
|
static bool g_IsAbove400;
|
||||||
|
static bool g_IsAbove500;
|
||||||
static bool g_HasCached = 0;
|
static bool g_HasCached = 0;
|
||||||
|
static Mutex g_Mutex;
|
||||||
|
|
||||||
static void _CacheValues(void)
|
static void _CacheValues(void)
|
||||||
{
|
{
|
||||||
// This is actually thread safe, might cache twice but that's fine.
|
if (g_HasCached)
|
||||||
if (!g_HasCached)
|
return;
|
||||||
{
|
|
||||||
|
mutexLock(&g_Mutex);
|
||||||
|
|
||||||
|
if (g_HasCached)
|
||||||
|
return;
|
||||||
|
|
||||||
u64 tmp;
|
u64 tmp;
|
||||||
g_IsAbove200 = (svcGetInfo(&tmp, 12, INVALID_HANDLE, 0) != 0xF001);
|
g_IsAbove200 = (svcGetInfo(&tmp, 12, INVALID_HANDLE, 0) != 0xF001);
|
||||||
g_IsAbove300 = (svcGetInfo(&tmp, 18, INVALID_HANDLE, 0) != 0xF001);
|
g_IsAbove300 = (svcGetInfo(&tmp, 18, INVALID_HANDLE, 0) != 0xF001);
|
||||||
g_IsAbove400 = (svcGetInfo(&tmp, 19, INVALID_HANDLE, 0) != 0xF001);
|
g_IsAbove400 = (svcGetInfo(&tmp, 19, INVALID_HANDLE, 0) != 0xF001);
|
||||||
|
g_IsAbove500 = (svcGetInfo(&tmp, 20, INVALID_HANDLE, 0) != 0xF001);
|
||||||
|
|
||||||
|
g_IsAbove400 |= g_IsAbove500;
|
||||||
|
g_IsAbove300 |= g_IsAbove400;
|
||||||
|
g_IsAbove200 |= g_IsAbove300;
|
||||||
|
|
||||||
g_HasCached = true;
|
g_HasCached = true;
|
||||||
}
|
|
||||||
|
mutexUnlock(&g_Mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool kernelAbove200(void) {
|
bool kernelAbove200(void) {
|
||||||
@ -36,6 +51,11 @@ bool kernelAbove400(void) {
|
|||||||
return g_IsAbove400;
|
return g_IsAbove400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool kernelAbove500(void) {
|
||||||
|
_CacheValues();
|
||||||
|
return g_IsAbove500;
|
||||||
|
}
|
||||||
|
|
||||||
bool detectDebugger(void) {
|
bool detectDebugger(void) {
|
||||||
u64 tmp;
|
u64 tmp;
|
||||||
svcGetInfo(&tmp, 8, 0, 0);
|
svcGetInfo(&tmp, 8, 0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user