> Windows Syscalls
ntoskrnl.exeT1055.004T1497T1106

NtWaitForSingleObject

Waits until a dispatcher object becomes signaled or the optional timeout expires.

Prototype

NTSTATUS NtWaitForSingleObject(
  HANDLE         Handle,
  BOOLEAN        Alertable,
  PLARGE_INTEGER Timeout
);

Arguments

NameTypeDirDescription
HandleHANDLEinHandle to a waitable dispatcher object (event, mutex, thread, process, timer, semaphore, ...) with SYNCHRONIZE access.
AlertableBOOLEANinTRUE places the thread in an alertable state so queued user APCs may fire and abort the wait with STATUS_USER_APC.
TimeoutPLARGE_INTEGERinOptional timeout in 100-ns units; negative = relative, positive = absolute, NULL = INFINITE.

Syscall IDs by Windows version

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

Kernel module

ntoskrnl.exeNtWaitForSingleObject

Related APIs

WaitForSingleObjectWaitForSingleObjectExSleepExNtWaitForMultipleObjectsNtDelayExecutionNtSignalAndWaitForSingleObject

Syscall stub

4C 8B D1            mov r10, rcx
B8 04 00 00 00      mov eax, 0x4
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

Dispatches through `KeWaitForSingleObject` inside ntoskrnl.exe. SSN `0x04` is stable across every Win10/11 build — one of the most stable in the table. The `Alertable` flag is the linchpin: a non-alertable wait blocks only on the object, while an alertable wait additionally drains pending user APCs and returns `STATUS_USER_APC` (0x000000C0) when one fires. That is precisely why APC-injection chains (T1055.004) require the target thread to perform an alertable wait somewhere. Timeout is in NT 100-ns units; `LARGE_INTEGER` negative values are relative (e.g. `-10000000LL` == 1 second).

Common malware usage

Two completely different abuses share this syscall. (1) Alertable waits are the *delivery vehicle* for queued user APCs — Ekko sleep masks wait alertably on the event signaled by their timer APC; EarlyBird APC injection relies on `ntdll!LdrpInitializeProcess` performing an alertable wait. (2) Short-timeout polling on a synthetic handle is a cheap **anti-sandbox / time-acceleration probe**: malware compares wall-clock delta to expected wait duration; sandboxes that fast-forward sleeps fail the check. Some loaders also wait on a thread handle to serialize multi-stage decryption.

Detection opportunities

Wait calls are pervasive; raw counts are useless. The interesting signal is the *combination* of `NtWaitForSingleObject(..., Alertable=TRUE, ...)` on a handle whose object is a private-named event, performed by a thread whose code lies in unbacked / RWX memory — that is the Ekko / Foliage fingerprint. ETW Threat Intelligence does not emit a wait event but does emit the QueueApc event that pairs with it; correlating QueueApc to a subsequent alertable wait return in the same thread catches APC chains. Stack-walk on wait return is the gold standard.

Direct syscall examples

asmx64 direct stub

; Direct syscall stub for NtWaitForSingleObject (SSN 0x04, stable across Win10/11)
NtWaitForSingleObject PROC
    mov  r10, rcx          ; syscall convention
    mov  eax, 04h          ; SSN
    syscall
    ret
NtWaitForSingleObject ENDP

cAlertable INFINITE wait (APC delivery point)

// Block alertably on an event until either it signals or a queued APC fires.
NTSTATUS st;
do {
    st = NtWaitForSingleObject(hEvent, TRUE, NULL); // NULL == INFINITE
} while (st == STATUS_USER_APC); // re-enter wait after the APC ran
if (!NT_SUCCESS(st)) return st;

rustTime-acceleration sandbox probe

// Cargo: windows-sys = "0.59"
use windows_sys::Win32::System::Threading::{WaitForSingleObjectEx, INFINITE};
use std::time::Instant;

unsafe fn sandbox_speeds_up_sleeps(h_event: *mut core::ffi::c_void) -> bool {
    let start = Instant::now();
    // Wait 3s alertably on a never-signalled event.
    let _ = WaitForSingleObjectEx(h_event, 3000, 1);
    start.elapsed().as_millis() < 2500
}

MITRE ATT&CK mappings

Last verified: 2026-05-20