libnx  v4.2.0
detect.h
Go to the documentation of this file.
1 /**
2  * @file detect.h
3  * @brief Kernel capability detection
4  * @author plutoo
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../result.h"
10 #include "svc.h"
11 
12 /// Returns true if the process has a debugger attached.
14  u64 tmp = 0;
16  return R_SUCCEEDED(rc) && tmp != 0;
17 }
18 
19 /// Returns true if the underlying kernel is Mesosphère.
21  u64 dummy = 0;
22  Result rc = svcGetInfo(&dummy, 65000, INVALID_HANDLE, 0); // InfoType_MesosphereMeta
23  return R_SUCCEEDED(rc);
24 }
InfoType_DebuggerAttached
@ InfoType_DebuggerAttached
Whether current process is being debugged.
Definition: svc.h:190
INVALID_HANDLE
#define INVALID_HANDLE
Invalid handle.
Definition: types.h:92
svcGetInfo
Result svcGetInfo(u64 *out, u32 id0, Handle handle, u64 id1)
Retrieves information about the system, or a certain kernel object.
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
Result
u32 Result
Function error code result type.
Definition: types.h:44
detectDebugger
static bool detectDebugger(void)
Returns true if the process has a debugger attached.
Definition: detect.h:13
svc.h
Wrappers for kernel syscalls.
detectMesosphere
static bool detectMesosphere(void)
Returns true if the underlying kernel is Mesosphère.
Definition: detect.h:20
R_SUCCEEDED
#define R_SUCCEEDED(res)
Checks whether a result code indicates success.
Definition: result.h:10
NX_INLINE
#define NX_INLINE
Flags a function as (always) inline.
Definition: types.h:82