> Windows Syscalls
ntoskrnl.exeT1106

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

NameTypeDirDescription
KeyedEventHandlePHANDLEoutReceives a handle to the new keyed-event object.
DesiredAccessACCESS_MASKinKEYEDEVENT_WAIT (1), KEYEDEVENT_WAKE (2), or KEYEDEVENT_ALL_ACCESS.
ObjectAttributesPOBJECT_ATTRIBUTESinOptional name (e.g. \KernelObjects\CritSecOutOfMemoryEvent) + security descriptor. NULL for an unnamed instance.
FlagsULONGinReserved — must be 0.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070xA4win10-1507
Win10 16070xA6win10-1607
Win10 17030xA9win10-1703
Win10 17090xAAwin10-1709
Win10 18030xABwin10-1803
Win10 18090xABwin10-1809
Win10 19030xACwin10-1903
Win10 19090xACwin10-1909
Win10 20040xB0win10-2004
Win10 20H20xB0win10-20h2
Win10 21H10xB0win10-21h1
Win10 21H20xB1win10-21h2
Win10 22H20xB1win10-22h2
Win11 21H20xB4win11-21h2
Win11 22H20xB5win11-22h2
Win11 23H20xB5win11-23h2
Win11 24H20xB7win11-24h2
Server 20160xA6winserver-2016
Server 20190xABwinserver-2019
Server 20220xB3winserver-2022
Server 20250xB7winserver-2025

Kernel module

ntoskrnl.exeNtCreateKeyedEvent

Related APIs

NtOpenKeyedEventNtWaitForKeyedEventNtReleaseKeyedEventRtlInitializeCriticalSectionWaitOnAddressWakeByAddressSingle

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 ENDP

cPrivate 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