NtWaitForSingleObject
Waits until a dispatcher object becomes signaled or the optional timeout expires.
Prototype
NTSTATUS NtWaitForSingleObject( HANDLE Handle, BOOLEAN Alertable, PLARGE_INTEGER Timeout );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| Handle | HANDLE | in | Handle to a waitable dispatcher object (event, mutex, thread, process, timer, semaphore, ...) with SYNCHRONIZE access. |
| Alertable | BOOLEAN | in | TRUE places the thread in an alertable state so queued user APCs may fire and abort the wait with STATUS_USER_APC. |
| Timeout | PLARGE_INTEGER | in | Optional timeout in 100-ns units; negative = relative, positive = absolute, NULL = INFINITE. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x4 | win10-1507 |
| Win10 1607 | 0x4 | win10-1607 |
| Win10 1703 | 0x4 | win10-1703 |
| Win10 1709 | 0x4 | win10-1709 |
| Win10 1803 | 0x4 | win10-1803 |
| Win10 1809 | 0x4 | win10-1809 |
| Win10 1903 | 0x4 | win10-1903 |
| Win10 1909 | 0x4 | win10-1909 |
| Win10 2004 | 0x4 | win10-2004 |
| Win10 20H2 | 0x4 | win10-20h2 |
| Win10 21H1 | 0x4 | win10-21h1 |
| Win10 21H2 | 0x4 | win10-21h2 |
| Win10 22H2 | 0x4 | win10-22h2 |
| Win11 21H2 | 0x4 | win11-21h2 |
| Win11 22H2 | 0x4 | win11-22h2 |
| Win11 23H2 | 0x4 | win11-23h2 |
| Win11 24H2 | 0x4 | win11-24h2 |
| Server 2016 | 0x4 | winserver-2016 |
| Server 2019 | 0x4 | winserver-2019 |
| Server 2022 | 0x4 | winserver-2022 |
| Server 2025 | 0x4 | winserver-2025 |
Kernel module
Related APIs
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 ENDPcAlertable 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