Detect Debugger Present in C

IsDebuggerPresent

if(IsDebuggerPresent())
    ExitProcess(0);

CheckRemoteDebuggerPresent

//..
BOOL IsDbgPresent = 0;
//..
CheckRemoteDebuggerPresent(GetCurrentProcess(), &IsDbgPresent);
if(IsDbgPresent)
    ExitProcess(0);

Using the PEB

__asm 
{
	mov eax, fs:[30h]
	mov eax, [eax + 68h]
	mov NtGlobalFlags, eax
}
 
if(NtGlobalFlags & 0x70)
	ExitProcess(0);
Categories: C Tags: , ,
%d bloggers like this: