一 参考网址
windows反调试技术-动态反调试
windows下常见的反调试方法
二 实现
DWORD ExplorerId = 0;
PROCESSENTRY32 pe32 = {0};
CString str;
BOOL bIsDebug = FALSE;
DWORD ProcessId = GetCurrentProcessId();
// 获取 Explorer 进程ID
::GetWindowThreadProcessId(::FindWindow(L"Progman", NULL), &ExplorerId);
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (hProcessSnap != INVALID_HANDLE_VALUE)
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
do
{
if (ProcessId == pe32.th32ProcessID)
{
str.Format(L"进程ID:%d 父进程ID:%d Explorer进程ID:%d", ProcessId, pe32.th32ParentProcessID, ExplorerId);
if (pe32.th32ParentProcessID != ExplorerId)
{
bIsDebug = TRUE;
break;
}
}
}
while (Process32Next(hProcessSnap, &pe32));
}
AfxMessageBox(str);
}
if (bIsDebug)
{
AfxMessageBox(L"检测到调试器");
}
else
{
AfxMessageBox(L"没有检测到调试器");
}
CloseHandle (hProcessSnap);