NtCancelTimer2
Cancels a previously armed Timer2 object and reports whether it was still pending.
Prototype
NTSTATUS NtCancelTimer2( HANDLE TimerHandle, PT2_CANCEL_PARAMETERS Parameters );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| TimerHandle | HANDLE | in | Handle to a Timer2 object previously armed with NtSetTimer2. |
| Parameters | PT2_CANCEL_PARAMETERS | in/out | Optional structure: in carries Version, out reports whether the timer was still pending. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x8F | win10-1507 |
| Win10 1607 | 0x8F | win10-1607 |
| Win10 1703 | 0x90 | win10-1703 |
| Win10 1709 | 0x91 | win10-1709 |
| Win10 1803 | 0x92 | win10-1803 |
| Win10 1809 | 0x92 | win10-1809 |
| Win10 1903 | 0x92 | win10-1903 |
| Win10 1909 | 0x92 | win10-1909 |
| Win10 2004 | 0x94 | win10-2004 |
| Win10 20H2 | 0x94 | win10-20h2 |
| Win10 21H1 | 0x94 | win10-21h1 |
| Win10 21H2 | 0x94 | win10-21h2 |
| Win10 22H2 | 0x94 | win10-22h2 |
| Win11 21H2 | 0x94 | win11-21h2 |
| Win11 22H2 | 0x94 | win11-22h2 |
| Win11 23H2 | 0x94 | win11-23h2 |
| Win11 24H2 | 0x96 | win11-24h2 |
| Server 2016 | 0x8F | winserver-2016 |
| Server 2019 | 0x92 | winserver-2019 |
| Server 2022 | 0x94 | winserver-2022 |
| Server 2025 | 0x96 | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 96 00 00 00 mov eax, 0x96 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
Counterpart to `NtSetTimer2`. Internally `ExpCancelTimer2` removes the `EX_TIMER` from the per-PRCB second-generation queue via `KeCancelTimer2`. If the timer was still pending the kernel returns `STATUS_SUCCESS` and sets `Parameters` to reflect the prior state; if it had already expired and the callback either ran or is in flight, you get `STATUS_TIMER_RESUME_IGNORED`-style semantics — the call cannot un-deliver an APC that is already queued to a thread. Note that `NtCancelTimer2` is remarkably stable across builds (`0x8F` on 1507 → `0x96` on Win11 24H2): the original 1507 SSN survived all the way until the Win11 24H2 syscall-table reshuffle, because the row index reflects sorted alphabetical position relative to insertions/removals — and very little was inserted *before* `Cancel*` for years.
Common malware usage
Used as the symmetric teardown for Timer2-based sleep masks (Cronos, Zilean): right before the implant exits, or when it tears down a temporary mask cycle, `NtCancelTimer2` disarms the timer so the alertable wait completes cleanly. Some kits also use it defensively — if an EDR has begun walking thread-pool timer lists, cancelling the timer early *removes the object from the list* before the scan can correlate the callback pointer with private RWX. Low malware signal on its own.
Detection opportunities
There is no Sysmon event for Timer2 cancellation, and on its own the call is benign. Investigations only consider it as part of a *sequence*: `NtCreateTimer2(HIGH_RESOLUTION) → NtSetTimer2(period ≈ 50 ms, callback in RWX) → NtWaitForSingleObjectEx(Alertable=TRUE) → NtCancelTimer2` repeated tightly is the canonical Timer2 sleep-mask fingerprint. EDR vendors with kernel components (CrowdStrike Falcon, Defender for Endpoint via MAPS) inspect `EX_TIMER` lists directly rather than relying on syscall hooks for this one.
Direct syscall examples
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtCancelTimer2 (SSN 0x96 on Win11 24H2 / Server 2025)
NtCancelTimer2 PROC
mov r10, rcx ; syscall convention
mov eax, 96h ; SSN — drifts; resolve dynamically for portability
syscall
ret
NtCancelTimer2 ENDPcSleep-mask teardown
// Sleep-mask cycle teardown: disarm the timer and close the handle.
typedef struct _T2_CANCEL_PARAMETERS {
ULONG Version;
ULONG Reserved;
} T2_CANCEL_PARAMETERS, *PT2_CANCEL_PARAMETERS;
T2_CANCEL_PARAMETERS cp = { 0 };
NTSTATUS st = NtCancelTimer2(hTimer, &cp);
// If st == STATUS_SUCCESS the timer was still armed; otherwise the APC already fired.
NtClose(hTimer);MITRE ATT&CK mappings
Last verified: 2026-05-20