> Windows Syscalls
ntoskrnl.exeT1497T1497.003T1106

NtQuerySystemTime

Returns the current system time as a 64-bit count of 100-ns intervals since 1601-01-01 UTC.

Prototype

NTSTATUS NtQuerySystemTime(
  PLARGE_INTEGER SystemTime
);

Arguments

NameTypeDirDescription
SystemTimePLARGE_INTEGERoutReceives current UTC system time in 100-ns units since 1601-01-01 (Windows FILETIME epoch).

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x5Awin10-1507
Win10 16070x5Awin10-1607
Win10 17030x5Awin10-1703
Win10 17090x5Awin10-1709
Win10 18030x5Awin10-1803
Win10 18090x5Awin10-1809
Win10 19030x5Awin10-1903
Win10 19090x5Awin10-1909
Win10 20040x5Awin10-2004
Win10 20H20x5Awin10-20h2
Win10 21H10x5Awin10-21h1
Win10 21H20x5Awin10-21h2
Win10 22H20x5Awin10-22h2
Win11 21H20x5Awin11-21h2
Win11 22H20x5Awin11-22h2
Win11 23H20x5Awin11-23h2
Win11 24H20x5Awin11-24h2
Server 20160x5Awinserver-2016
Server 20190x5Awinserver-2019
Server 20220x5Awinserver-2022
Server 20250x5Awinserver-2025

Kernel module

ntoskrnl.exeNtQuerySystemTime

Related APIs

GetSystemTimeAsFileTimeGetSystemTimeGetTickCount64QueryPerformanceCounterNtQueryPerformanceCounterNtQuerySystemTimePrecise

Syscall stub

4C 8B D1            mov r10, rcx
B8 5A 00 00 00      mov eax, 0x5A
F6 04 25 08 03 FE 7F 01   test byte ptr [0x7FFE0308], 1
75 03               jne short +3
0F 05               syscall
C3                  ret
CD 2E               int 2Eh
C3                  ret

Undocumented notes

Most modern code reads `KUSER_SHARED_DATA.SystemTime` (`0x7FFE0014`) directly without a syscall — `GetSystemTimeAsFileTime` does exactly that in user mode. `NtQuerySystemTime` still exists for callers that need an authoritative kernel-issued value (e.g. cryptographic time stamping, debuggers, or tests that must round-trip the dispatcher). The SSN has been `0x5A` across every shipping Windows 10/11 build.

Common malware usage

The classic use is sandbox-acceleration detection: pair `NtQuerySystemTime` with `NtDelayExecution` to verify wall-clock progress matches the requested sleep. Many automated sandboxes hook or skip `Sleep` to finish analysis faster — but they rarely fake `KeQuerySystemTime`, so the time delta reveals the discrepancy. Malware that wants an extra-defensive check will read both `KUSER_SHARED_DATA.SystemTime` *and* call `NtQuerySystemTime`; a mismatch implies a tampered shared page. It is also used as a benign-looking entropy source for seeding RNGs in stagers.

Detection opportunities

Hard to alert on in isolation — it is one of the most-called Native APIs in normal software. The interesting pattern is the *sequence*: short `NtDelayExecution` followed immediately by `NtQuerySystemTime`, repeated in a loop, from a process with no UI. ETW User-Mode `Microsoft-Windows-Kernel-Process` traces combined with stack-walking can surface this. Reading `KUSER_SHARED_DATA.SystemTime` from user-mode is invisible to syscall-tracing tools entirely, which is why most evasive malware prefers that path when it only needs an approximate clock.

Direct syscall examples

asmx64 direct stub

; Direct syscall stub for NtQuerySystemTime (SSN 0x5A, all Win10/11 builds)
NtQuerySystemTime PROC
    mov  r10, rcx          ; syscall convention
    mov  eax, 5Ah          ; SSN
    syscall
    ret
NtQuerySystemTime ENDP

cCross-check shared page vs syscall

// If KUSER_SHARED_DATA.SystemTime and NtQuerySystemTime disagree by
// more than a few seconds, the analysis environment has tampered
// with the shared page or with the syscall path.
#include <windows.h>
#include <winternl.h>

extern "C" NTSTATUS NTAPI NtQuerySystemTime(PLARGE_INTEGER);

BOOL SharedPageTamperedWith(void) {
    LARGE_INTEGER shared, kernel;
    // KUSER_SHARED_DATA.SystemTime is a tick-incrementing 8-byte field
    shared.QuadPart = *(volatile LONGLONG*)0x7FFE0014;
    NtQuerySystemTime(&kernel);
    LONGLONG deltaSec = (kernel.QuadPart - shared.QuadPart) / 10000000LL;
    return deltaSec > 5 || deltaSec < -5;
}

rustAnti-sandbox sleep delta

// Pair NtQuerySystemTime with NtDelayExecution to detect sandbox-accelerated sleeps.
use std::arch::asm;

#[unsafe(naked)]
unsafe extern "system" fn nt_query_system_time(_out: *mut i64) -> i32 {
    asm!("mov r10, rcx", "mov eax, 0x5A", "syscall", "ret", options(noreturn));
}
#[unsafe(naked)]
unsafe extern "system" fn nt_delay_execution(_a: u8, _i: *const i64) -> i32 {
    asm!("mov r10, rcx", "mov eax, 0x34", "syscall", "ret", options(noreturn));
}

pub fn sleep_was_skipped(seconds: i64) -> bool {
    let (mut t0, mut t1): (i64, i64) = (0, 0);
    let interval = -seconds * 10_000_000;
    unsafe {
        nt_query_system_time(&mut t0);
        nt_delay_execution(0, &interval);
        nt_query_system_time(&mut t1);
    }
    ((t1 - t0) / 10_000_000) < seconds - 1
}

MITRE ATT&CK mappings

Last verified: 2026-05-20