NtReplyWaitReceivePort
Server-side LPC primitive: atomically reply to the previous request and block for the next one.
Prototype
NTSTATUS NtReplyWaitReceivePort( HANDLE PortHandle, PVOID *PortContext, PPORT_MESSAGE ReplyMessage, PPORT_MESSAGE ReceiveMessage );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| PortHandle | HANDLE | in | Handle to the server port returned by NtCreatePort; the thread blocks on this port's queue. |
| PortContext | PVOID* | out | Optional; receives the per-client context pointer that was stored at NtAcceptConnectPort time. |
| ReplyMessage | PPORT_MESSAGE | in | Optional reply to send for the previously received request (NULL on first call / no pending reply). |
| ReceiveMessage | PPORT_MESSAGE | out | Caller-allocated buffer that receives the next incoming PORT_MESSAGE; must be ≥ MaxMessageLength. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0xB | win10-1507 |
| Win10 1607 | 0xB | win10-1607 |
| Win10 1703 | 0xB | win10-1703 |
| Win10 1709 | 0xB | win10-1709 |
| Win10 1803 | 0xB | win10-1803 |
| Win10 1809 | 0xB | win10-1809 |
| Win10 1903 | 0xB | win10-1903 |
| Win10 1909 | 0xB | win10-1909 |
| Win10 2004 | 0xB | win10-2004 |
| Win10 20H2 | 0xB | win10-20h2 |
| Win10 21H1 | 0xB | win10-21h1 |
| Win10 21H2 | 0xB | win10-21h2 |
| Win10 22H2 | 0xB | win10-22h2 |
| Win11 21H2 | 0xB | win11-21h2 |
| Win11 22H2 | 0xB | win11-22h2 |
| Win11 23H2 | 0xB | win11-23h2 |
| Win11 24H2 | 0xB | win11-24h2 |
| Server 2016 | 0xB | winserver-2016 |
| Server 2019 | 0xB | winserver-2019 |
| Server 2022 | 0xB | winserver-2022 |
| Server 2025 | 0xB | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 0B 00 00 00 mov eax, 0x0B 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
NtReplyWaitReceivePort is the canonical *server main loop* of legacy LPC: it atomically delivers the reply to the request handled in the previous iteration and blocks on the incoming queue until the next request arrives. The `PortContext` out-param yields the per-client context pointer registered at NtAcceptConnectPort, letting one server thread multiplex any number of clients. The SSN `0x0B` is frozen since Windows 10 1507 — even lower than NtRequestWaitReplyPort because the original LPC dispatch routines were placed early in the table.
Common malware usage
An attacker would call NtReplyWaitReceivePort only after standing up a custom LPC server via NtCreatePort + NtAcceptConnectPort + NtCompleteConnectPort. That pattern is *vanishingly rare* in modern malware — practical IPC for implants is named-pipes, ALPC, or shared sections. Historical / academic interest only: pre-Vista user-mode rootkits used the LPC server loop as a low-noise in-host C2 stage. Any non-OS process sitting in NtReplyWaitReceivePort on Windows 10/11 is itself worth investigating.
Detection opportunities
No dedicated ETW provider for legacy LPC; detection requires kernel callbacks or driver-level syscall hooks. The strongest blue-team approach is enumerating live `Port` objects under `\RPC Control` and `\Sessions\<n>\Windows` (SystemInformer / WinObj) and flagging owners that aren't csrss, lsass, smss or the RPC subsystem. A user-mode thread permanently blocked inside `ntdll!NtReplyWaitReceivePort` with no matching Microsoft binary on its stack is high signal.
Direct syscall examples
asmx64 direct stub
; Direct syscall stub for NtReplyWaitReceivePort (SSN 0x0B, stable Win10 1507+)
NtReplyWaitReceivePort PROC
mov r10, rcx ; PortHandle
mov eax, 0Bh ; SSN
syscall
ret
NtReplyWaitReceivePort ENDPcMinimal LPC server loop
// Skeleton of a custom LPC server. Error handling elided for brevity.
#include <windows.h>
#include <winternl.h>
typedef NTSTATUS (NTAPI *pNtReplyWaitReceivePort)(
HANDLE, PVOID*, PVOID /*PPORT_MESSAGE*/, PVOID /*PPORT_MESSAGE*/);
void ServerLoop(HANDLE hServerPort) {
BYTE reqBuf[0x100], replyBuf[0x100];
PVOID ctx = NULL;
BOOL havePendingReply = FALSE;
pNtReplyWaitReceivePort fn = (pNtReplyWaitReceivePort)GetProcAddress(
GetModuleHandleA("ntdll.dll"), "NtReplyWaitReceivePort");
for (;;) {
NTSTATUS s = fn(hServerPort, &ctx,
havePendingReply ? replyBuf : NULL,
reqBuf);
if (s < 0) break;
// ... dispatch on reqBuf, populate replyBuf, set havePendingReply = TRUE ...
havePendingReply = TRUE;
}
}rustFFI declaration via ntapi
// Cargo: ntapi = "0.4"
use ntapi::ntlpcapi::NtReplyWaitReceivePort;
use winapi::shared::ntdef::{HANDLE, NTSTATUS, PVOID};
unsafe fn recv(port: HANDLE, ctx_out: *mut PVOID, reply: *mut u8, recv: *mut u8) -> NTSTATUS {
NtReplyWaitReceivePort(port, ctx_out, reply as *mut _, recv as *mut _)
}MITRE ATT&CK mappings
Last verified: 2026-05-20