> Windows Syscalls
ntoskrnl.exeT1027T1106

NtReleaseKeyedEvent

Wakes exactly one thread waiting on the same (keyed-event, key) pair, blocking if no waiter is present yet.

Prototype

NTSTATUS NtReleaseKeyedEvent(
  HANDLE         KeyedEventHandle,
  PVOID          Key,
  BOOLEAN        Alertable,
  PLARGE_INTEGER Timeout
);

Arguments

NameTypeDirDescription
KeyedEventHandleHANDLEinHandle to a keyed event. NULL uses the per-process default at \KernelObjects\CritSecOutOfMemoryEvent.
KeyPVOIDinNaturally-aligned pointer-sized rendezvous value. Must match the Key used by exactly one waiter; otherwise the call itself blocks.
AlertableBOOLEANinTRUE allows the release to be interrupted by user-mode APCs while it waits for a matching waiter; almost always FALSE.
TimeoutPLARGE_INTEGERinOptional timeout for the implicit wait if no matching waiter is present (100-ns units, negative = relative). NULL = forever.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x154win10-1507
Win10 16070x15Bwin10-1607
Win10 17030x161win10-1703
Win10 17090x164win10-1709
Win10 18030x166win10-1803
Win10 18090x167win10-1809
Win10 19030x168win10-1903
Win10 19090x168win10-1909
Win10 20040x16Ewin10-2004
Win10 20H20x16Ewin10-20h2
Win10 21H10x16Ewin10-21h1
Win10 21H20x170win10-21h2
Win10 22H20x170win10-22h2
Win11 21H20x178win11-21h2
Win11 22H20x17Bwin11-22h2
Win11 23H20x17Bwin11-23h2
Win11 24H20x17Dwin11-24h2
Server 20160x15Bwinserver-2016
Server 20190x167winserver-2019
Server 20220x176winserver-2022
Server 20250x17Dwinserver-2025

Kernel module

ntoskrnl.exeNtReleaseKeyedEvent

Related APIs

NtCreateKeyedEventNtOpenKeyedEventNtWaitForKeyedEventWakeByAddressSingleWakeByAddressAllRtlLeaveCriticalSection

Syscall stub

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

The wake half of the keyed-event pair, and famously *symmetric* with `NtWaitForKeyedEvent`: a release with no matching waiter blocks the caller until a waiter shows up, rather than dropping the wake on the floor as a regular event would. This is what makes the primitive correct for `RtlEnterCriticalSection`'s out-of-pool path — releases and waits self-throttle, so a single global event services unbounded contention without losing wakes. The kernel handler is `ExpReleaseWaitForKeyedEvent` (a tiny inverse of `ExpWaitForKeyedEvent`); both consult the per-event hash table that pairs `(process, key)` tuples.

Common malware usage

Mirror of `NtWaitForKeyedEvent`. In sleep-obfuscation chains, this is the syscall that *wakes the beacon up* after the sleep mask has unprotected and decrypted itself. Some designs invoke it from an APC delivered by an `NtSetTimer2` callback, others from a ROP gadget chained off a fake context — either way the global handle on the PEB means no new named object is touched. Outside that very narrow design pattern, calls to `NtReleaseKeyedEvent` from non-Microsoft code are virtually nonexistent.

Detection opportunities

Same as `NtWaitForKeyedEvent` — there is no targeted ETW / Sysmon surface. Memory-introspection ETW (`Microsoft-Windows-Threat-Intelligence` `AllocVm` / `ProtectVm` events) catching an RW→RX flip on private pages *immediately followed by* a thread leaving `NtWaitForKeyedEvent` is a much stronger lead than tracing this syscall in isolation.

Direct syscall examples

asmx64 direct stub (Win11 24H2)

; Direct syscall stub for NtReleaseKeyedEvent (SSN 0x17D on Win11 24H2)
NtReleaseKeyedEvent PROC
    mov  r10, rcx          ; KeyedEventHandle
    mov  eax, 17Dh         ; SSN — drifts per build
    syscall
    ret
NtReleaseKeyedEvent ENDP

cWake a thread parked on the global keyed event

// Companion to the NtWaitForKeyedEvent low-memory critical-section example.
#include <windows.h>
#include <winternl.h>

typedef NTSTATUS (NTAPI *pNtReleaseKeyedEvent)(
    HANDLE, PVOID, BOOLEAN, PLARGE_INTEGER);

static pNtReleaseKeyedEvent g_release;

void WakeOnLockWord(volatile void **lockSlot) {
    if (!g_release) {
        g_release = (pNtReleaseKeyedEvent)GetProcAddress(
            GetModuleHandleA("ntdll.dll"), "NtReleaseKeyedEvent");
    }
    // NULL handle ⇒ kernel substitutes peb->KeyedEventHandle.
    // If no waiter exists yet, this call blocks until one shows up — that
    // symmetry is what keeps the global event correct under contention.
    g_release(NULL, (PVOID)lockSlot, FALSE, NULL);
}

rustwindows-sys: WakeByAddressSingle (recommended modern wake)

// On Win8+ this is the preferred user-mode wake primitive; underneath it
// resolves to keyed-event releases for the futex-style address path.
use windows_sys::Win32::System::Threading::WakeByAddressSingle;

unsafe fn wake_one(addr: *mut u32) {
    WakeByAddressSingle(addr as *const _ as _);
}

MITRE ATT&CK mappings

Last verified: 2026-05-20