NtCreateKeyedEvent
Creates a keyed event object — a lightweight kernel sync primitive that pairs waits and wakes by virtual-address key.
Prototype
NTSTATUS NtCreateKeyedEvent( PHANDLE KeyedEventHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, ULONG Flags );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| KeyedEventHandle | PHANDLE | out | Receives a handle to the new keyed-event object. |
| DesiredAccess | ACCESS_MASK | in | KEYEDEVENT_WAIT (1), KEYEDEVENT_WAKE (2), or KEYEDEVENT_ALL_ACCESS. |
| ObjectAttributes | POBJECT_ATTRIBUTES | in | Optional name (e.g. \KernelObjects\CritSecOutOfMemoryEvent) + security descriptor. NULL for an unnamed instance. |
| Flags | ULONG | in | Reserved — must be 0. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0xA4 | win10-1507 |
| Win10 1607 | 0xA6 | win10-1607 |
| Win10 1703 | 0xA9 | win10-1703 |
| Win10 1709 | 0xAA | win10-1709 |
| Win10 1803 | 0xAB | win10-1803 |
| Win10 1809 | 0xAB | win10-1809 |
| Win10 1903 | 0xAC | win10-1903 |
| Win10 1909 | 0xAC | win10-1909 |
| Win10 2004 | 0xB0 | win10-2004 |
| Win10 20H2 | 0xB0 | win10-20h2 |
| Win10 21H1 | 0xB0 | win10-21h1 |
| Win10 21H2 | 0xB1 | win10-21h2 |
| Win10 22H2 | 0xB1 | win10-22h2 |
| Win11 21H2 | 0xB4 | win11-21h2 |
| Win11 22H2 | 0xB5 | win11-22h2 |
| Win11 23H2 | 0xB5 | win11-23h2 |
| Win11 24H2 | 0xB7 | win11-24h2 |
| Server 2016 | 0xA6 | winserver-2016 |
| Server 2019 | 0xAB | winserver-2019 |
| Server 2022 | 0xB3 | winserver-2022 |
| Server 2025 | 0xB7 | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 B7 00 00 00 mov eax, 0xB7 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
Keyed events are a deliberately minimal Windows synchronization primitive: a single keyed event can service an unbounded number of waiters because the rendezvous is done on a *key* (any pointer-sized value, conventionally a virtual address) rather than on the event object itself. The kernel maintains a per-event hash table keyed by `(process, key)`; `NtWaitForKeyedEvent` blocks until *some other thread* calls `NtReleaseKeyedEvent` with the same key. In practice almost every process uses the single global instance at `\KernelObjects\CritSecOutOfMemoryEvent`, which `ntdll.dll` opens during startup and stashes in `peb->KeyedEventHandle`. Creating a brand-new keyed event with `NtCreateKeyedEvent` is rare outside diagnostic tools and a handful of historical XP-era allocators (the global event has handled contention since Vista).
Common malware usage
Weak signal. The primary attraction for offensive use is *namelessness*: a keyed event created with NULL `ObjectAttributes` produces no named kernel object, no file handle, and no network footprint, and a sleep-mask or stage gate built on `NtWaitForKeyedEvent` (paired with `NtReleaseKeyedEvent` from a peer thread) is invisible to enumeration of named events / semaphores / mutexes that some sandbox detectors run. A few sleep-obfuscation designs (the Ekko / Ekko-lookalike family, some Foliage / TimerHandler-style designs) use the global `\KernelObjects\CritSecOutOfMemoryEvent` as a sync point rather than creating their own — that path doesn't even involve `NtCreateKeyedEvent`. Direct calls to `NtCreateKeyedEvent` from non-Microsoft code are unusual but not damning.
Detection opportunities
Essentially undetectable as a syscall. There is no Sysmon event for keyed-event creation and no ETW provider that surfaces it cleanly. Forensic enumeration via `!handle` in WinDbg or SystemInformer's handle view will show `KeyedEvent` objects per process, but the global event is held by nearly every process so the only useful artifact is an *unnamed* `KeyedEvent` handle in a process that has no business with low-level critical-section infrastructure. Even then, false positives from in-process allocators and instrumentation libraries are high.
Direct syscall examples
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtCreateKeyedEvent (SSN 0xB7 on Win11 24H2)
NtCreateKeyedEvent PROC
mov r10, rcx ; KeyedEventHandle
mov eax, 0B7h ; SSN — drifts per build
syscall
ret
NtCreateKeyedEvent ENDPcPrivate unnamed keyed event
// No public Win32 wrapper. Almost all callers use the global instance instead.
#include <windows.h>
#include <winternl.h>
#define KEYEDEVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x3)
typedef NTSTATUS (NTAPI *pNtCreateKeyedEvent)(
PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, ULONG);
HANDLE MakePrivateKeyedEvent(void) {
HANDLE h = NULL;
pNtCreateKeyedEvent fn = (pNtCreateKeyedEvent)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtCreateKeyedEvent");
fn(&h, KEYEDEVENT_ALL_ACCESS, NULL /* unnamed */, 0);
return h;
}MITRE ATT&CK mappings
Last verified: 2026-05-20