NtAlpcSendWaitReceivePort
Sends an ALPC message on a port and optionally waits for a reply or the next inbound message.
Prototype
NTSTATUS NtAlpcSendWaitReceivePort( HANDLE PortHandle, ULONG Flags, PPORT_MESSAGE SendMessage, PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, PPORT_MESSAGE ReceiveMessage, PSIZE_T BufferLength, PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, PLARGE_INTEGER Timeout );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| PortHandle | HANDLE | in | Handle to an ALPC port (server or client side, communication or connection port). |
| Flags | ULONG | in | ALPC_MSGFLG_* (RELEASE_MESSAGE, SYNC_REQUEST, WAIT_USER_MODE, …) controlling send/receive semantics. |
| SendMessage | PPORT_MESSAGE | in | Optional outbound message; NULL to perform a pure receive. |
| SendMessageAttributes | PALPC_MESSAGE_ATTRIBUTES | in | Attributes for the outbound message (handle / context / view / security). |
| ReceiveMessage | PPORT_MESSAGE | out | Receives the inbound reply or next queued message. |
| BufferLength | PSIZE_T | in/out | On input, size of ReceiveMessage buffer; on output, size of the received message. |
| ReceiveMessageAttributes | PALPC_MESSAGE_ATTRIBUTES | in/out | Receives attribute metadata attached to the inbound message. |
| Timeout | PLARGE_INTEGER | in | Optional wait timeout (100-ns units, negative = relative). NULL = wait indefinitely. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x88 | win10-1507 |
| Win10 1607 | 0x88 | win10-1607 |
| Win10 1703 | 0x89 | win10-1703 |
| Win10 1709 | 0x89 | win10-1709 |
| Win10 1803 | 0x8A | win10-1803 |
| Win10 1809 | 0x8A | win10-1809 |
| Win10 1903 | 0x8A | win10-1903 |
| Win10 1909 | 0x8A | win10-1909 |
| Win10 2004 | 0x8C | win10-2004 |
| Win10 20H2 | 0x8C | win10-20h2 |
| Win10 21H1 | 0x8C | win10-21h1 |
| Win10 21H2 | 0x8C | win10-21h2 |
| Win10 22H2 | 0x8C | win10-22h2 |
| Win11 21H2 | 0x8C | win11-21h2 |
| Win11 22H2 | 0x8C | win11-22h2 |
| Win11 23H2 | 0x8C | win11-23h2 |
| Win11 24H2 | 0x8E | win11-24h2 |
| Server 2016 | 0x88 | winserver-2016 |
| Server 2019 | 0x8A | winserver-2019 |
| Server 2022 | 0x8C | winserver-2022 |
| Server 2025 | 0x8E | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 8E 00 00 00 mov eax, 0x8E 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
`NtAlpcSendWaitReceivePort` is the workhorse of ALPC: every RPC call over the `ncalrpc` transport ultimately becomes one or more invocations of this syscall. It implements four high-level patterns — send-only, receive-only, request/reply (synchronous), and reply/wait-next (server loop) — selected by Flags and which of SendMessage/ReceiveMessage are non-NULL. The `PORT_MESSAGE` header is followed by an optional `ALPC_MESSAGE_ATTRIBUTES` block that may carry duplicated handles, a security context blob, or a shared section view — these are the same attributes that make ALPC such a juicy LPE target.
Common malware usage
Two distinct abuse patterns: 1. **LPE exploitation**: every ALPC LPE chain ends in a crafted `SendMessage` that triggers a vulnerable code path on the server side. CVE-2018-8440 sent a forged `ALPC_MESSAGE_ATTRIBUTE_HANDLE` to the Task Scheduler ALPC port; CVE-2019-1322 (SVCMOVER) abused services.exe over ALPC; multiple PrintNightmare PoCs reach the Print Spooler ALPC endpoint via this syscall. 2. **Stealth IPC C2**: red-team frameworks occasionally build implant↔implant channels on top of an unnamed ALPC port (created with `NtAlpcCreatePort` then connected via `NtAlpcConnectPort`) because ALPC is invisible to Sysmon network telemetry. Throughput is small but enough for command-and-control.
Detection opportunities
Per-call detection is impractical — this syscall fires millions of times an hour on a busy host. Useful angles: ETW `Microsoft-Windows-Kernel-ALPC` (when enabled) attributes messages to port name and PID; large `ALPC_MESSAGE_ATTRIBUTE_HANDLE` payloads from non-privileged processes to system services are suspicious; correlation with `Microsoft-Windows-RPC` ETW (which sits *above* ALPC) gives the RPC interface UUID being invoked — an unexpected UUID from a non-Microsoft binary is the strongest signal. The historical ALPC LPE bugs were all caught post-disclosure by hunting for handle attributes pointing at SYSTEM-owned objects from user-context senders.
Direct syscall examples
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtAlpcSendWaitReceivePort (SSN 0x8E on Win11 24H2)
NtAlpcSendWaitReceivePort PROC
mov r10, rcx ; PortHandle
mov eax, 8Eh ; SSN — version-sensitive
syscall
ret
NtAlpcSendWaitReceivePort ENDPcServer receive-reply loop
// Minimal ALPC server pump — receive, dispatch, reply.
#include <windows.h>
#include <winternl.h>
typedef NTSTATUS (NTAPI *pNtAlpcSendWaitReceivePort)(
HANDLE, ULONG, PVOID, PVOID, PVOID, PSIZE_T, PVOID, PLARGE_INTEGER);
void ServerPump(HANDLE hPort) {
pNtAlpcSendWaitReceivePort fn = (pNtAlpcSendWaitReceivePort)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtAlpcSendWaitReceivePort");
BYTE recv[0x1000]; SIZE_T cb;
BYTE reply[0x1000];
for (;;) {
cb = sizeof(recv);
// Pure receive: SendMessage = NULL.
if (fn(hPort, 0, NULL, NULL, recv, &cb, NULL, NULL) != 0) break;
// ... build reply in 'reply' ...
// Send reply, wait for next request: ALPC_MSGFLG_RELEASE_MESSAGE = 0x10000.
cb = sizeof(recv);
fn(hPort, 0x10000, reply, NULL, recv, &cb, NULL, NULL);
}
}cClient SYNC_REQUEST (sync RPC)
// Synchronous request/reply on an already-connected ALPC port.
#include <windows.h>
#include <winternl.h>
#define ALPC_MSGFLG_SYNC_REQUEST 0x20000
typedef NTSTATUS (NTAPI *pNtAlpcSendWaitReceivePort)(
HANDLE, ULONG, PVOID, PVOID, PVOID, PSIZE_T, PVOID, PLARGE_INTEGER);
NTSTATUS Call(HANDLE hPort, PVOID req, SIZE_T reqLen, PVOID rsp, PSIZE_T rspLen) {
pNtAlpcSendWaitReceivePort fn = (pNtAlpcSendWaitReceivePort)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtAlpcSendWaitReceivePort");
LARGE_INTEGER to; to.QuadPart = -5LL * 10000000LL; // 5 s
return fn(hPort, ALPC_MSGFLG_SYNC_REQUEST, req, NULL, rsp, rspLen, NULL, &to);
}MITRE ATT&CK mappings
Last verified: 2026-05-20