Windows C++ / CsrGetProcessID

Author External
Platform Windows
Language C++
Technique CsrGetProcessID

Code

#include <stdio.h>
#include <windows.h>
typedef HANDLE (*_CsrGetProcessId)();

int main(void)
{
    HMODULE nt=GetModuleHandle("ntdll.dll");
    _CsrGetProcessId CsrGetProcessId=(_CsrGetProcessId)GetProcAddress(nt,"CsrGetProcessId");
    HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS,FALSE,CsrGetProcessId());

    if(!proc)
    {
        printf("debugger is present!");
    }
}

Created

June 22, 2022

Last Revised

April 22, 2024