Created
October 23, 2023 12:45
-
-
Save peevees/aaa5816211c7340498989a8d77200a53 to your computer and use it in GitHub Desktop.
Debugger detection timing examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL IsDebuggerPresentUsingTickCount() | |
{ | |
DWORD tickReference = GetTickCount(); | |
Sleep(1500); // you can replace this with a function | |
DWORD currentTick = GetTickCount(); | |
DWORD elapsedTime = currentTick - tickReference; | |
if (elapsedTime > 2000) | |
return TRUE; | |
return FALSE; | |
} | |
BOOL IsDebuggerPresentUsingLocalTime() { | |
SYSTEMTIME sysStart, sysend; | |
FILETIME fStart, fEnd; | |
ULARGE_INTEGER uiStart, uiEnd; | |
GetLocalTime(&sysStart); | |
Sleep(1500); // you can replace this with a function | |
GetLocalTime(& sysend); | |
if (!SystemTimeToFileTime(&sysend„ &fEnd)) | |
return false; | |
if (!SystemTimeToFileTime(&sysStart, &fStart)) | |
return false; | |
uiStart.LowPart = fStart.dwLowDateTime; | |
uiStart.HighPart = fStart.dwHighDateTime; | |
uiEnd.LowPart = fEnd.dwLowDateTime; | |
uiEnd.HighPart = fEnd.dwHighDateTime; | |
return (((uiEnd.QuadPart - uiStart.QuadPart)*100)/1000000) > 2000; //convert filetime to milliseconds | |
} | |
BOOL IsDebuggerPresentUsingOPC() | |
{ | |
LARGE_INTEGER start, end, frequency; | |
QueryPerformanceCounter(&start); | |
QueryPerformanceFrequency(&frequency); | |
Sleep(1400); | |
QueryPerformanceCounter(&end); | |
return (end.QuadPart - start.QuadPart) * 1000 / frequency.QuadPart > 15; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment