isdebuggerpresent.cpp
来自「此为本书的配套光盘.本书结合实例」· C++ 代码 · 共 35 行
CPP
35 行
/*--------------------------------------------------------------
IsDebuggerPresent.cpp -- 检测用户模式调试器(如OllyDbg)
(c) www.pediy.com code by 段钢, 2003.11
--------------------------------------------------------------*/
#include <windows.h>
BOOL IsInDebugger();
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
if( IsInDebugger() )
MessageBox(NULL,TEXT ("u are debugging me !"),TEXT ("OK"),MB_ICONEXCLAMATION);
else
MessageBox(NULL,TEXT ("not debugged!"),TEXT ("OK"),MB_ICONEXCLAMATION);
return 0;
}
//////////////////////////////////////////////////////////////////////
BOOL IsInDebugger()
{
HINSTANCE hInst = LoadLibrary("kernel32.dll");
if (hInst != NULL)
{
FARPROC pIsDebuggerPresent = GetProcAddress(hInst, "IsDebuggerPresent");
if (pIsDebuggerPresent != NULL)
return pIsDebuggerPresent();
}
return FALSE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?