GetLocalTime, GetSystemTime, timeGetTime, NtQueryPerformanceCounter

Created the Monday 18 March 2019. Updated 3 years, 6 months ago.

When a debugger is present, and used to single-step through the code, there is a significant delay between the executions of the individual instructions, when compared to native execution.

Technique Identifiers

U0110 U1308

Code Snippets

bool IsDebugged(DWORD64 qwNativeElapsed)
    SYSTEMTIME stStart, stEnd;
    FILETIME ftStart, ftEnd;
    ULARGE_INTEGER uiStart, uiEnd;

    // ... some work

    if (!SystemTimeToFileTime(&stStart, &ftStart))
        return false;
    if (!SystemTimeToFileTime(&stEnd, &ftEnd))
        return false;

    uiStart.LowPart  = ftStart.dwLowDateTime;
    uiStart.HighPart = ftStart.dwHighDateTime;
    uiEnd.LowPart  = ftEnd.dwLowDateTime;
    uiEnd.HighPart = ftEnd.dwHighDateTime;
    return (uiEnd.QuadPart - uiStart.QuadPart) > qwNativeElapsed;

Detection Rules

    name: check for time delay via QueryPerformanceCounter
    namespace: anti-analysis/anti-debugging/debugger-detection
    scope: function
      - Anti-Behavioral Analysis::Debugger Detection::Timing/Delay Check QueryPerformanceCounter [B0001.033]
      - Practical Malware Analysis Lab 16-03.exe_:0x4011e0
    - and:
      - count(api(kernel32.QueryPerformanceCounter)): 2 or more

Additional Resources

External Links

Subscribe to our Newsletter

The information entered into this form is mandatory. It will be subjected to computer processing. It is processed by computer in order to support our users and readers. The recipients of the data will be :

According to the Data Protection Act of January 6th, 1978, you have at any time, a right of access to and rectification of all of your personal data. If you wish to exercise this right and gain access to your personal data, please write to Thomas Roccia at

You may also oppose, for legitimate reasons, the processing of your personal data.