> Windows Syscalls
ntoskrnl.exeT1055T1106

NtSetIoCompletion

Posts a completion packet to an I/O completion port — the kernel side of PostQueuedCompletionStatus and the delivery vector for PoolParty's forged work items.

Prototype

NTSTATUS NtSetIoCompletion(
  HANDLE     IoCompletionHandle,
  PVOID      KeyContext,
  PVOID      ApcContext,
  NTSTATUS   IoStatus,
  ULONG_PTR  IoStatusInformation
);

Arguments

NameTypeDirDescription
IoCompletionHandleHANDLEinHandle to the target completion port. Requires IO_COMPLETION_MODIFY_STATE.
KeyContextPVOIDinCaller-defined CompletionKey returned to the dequeuer via lpCompletionKey.
ApcContextPVOIDinCaller-defined pointer returned as lpOverlapped — usually an OVERLAPPED* in legitimate code, attacker-controlled in PoolParty.
IoStatusNTSTATUSinStatus code written into the packet's IO_STATUS_BLOCK.Status field.
IoStatusInformationULONG_PTRinCaller-defined value written into IO_STATUS_BLOCK.Information — typically a transferred byte count.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x185win10-1507
Win10 16070x18Ewin10-1607
Win10 17030x194win10-1703
Win10 17090x197win10-1709
Win10 18030x199win10-1803
Win10 18090x19Awin10-1809
Win10 19030x19Bwin10-1903
Win10 19090x19Bwin10-1909
Win10 20040x1A1win10-2004
Win10 20H20x1A1win10-20h2
Win10 21H10x1A1win10-21h1
Win10 21H20x1A3win10-21h2
Win10 22H20x1A3win10-22h2
Win11 21H20x1ACwin11-21h2
Win11 22H20x1B0win11-22h2
Win11 23H20x1B0win11-23h2
Win11 24H20x1B3win11-24h2
Server 20160x18Ewinserver-2016
Server 20190x19Awinserver-2019
Server 20220x1A9winserver-2022
Server 20250x1B3winserver-2025

Kernel module

ntoskrnl.exeNtSetIoCompletion

Related APIs

PostQueuedCompletionStatusNtCreateIoCompletionNtRemoveIoCompletionNtRemoveIoCompletionExNtWaitForWorkViaWorkerFactorySubmitThreadpoolWork

Syscall stub

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

Direct equivalent of `PostQueuedCompletionStatus`. The packet is appended to the port's KQUEUE and one waiter (in NtRemoveIoCompletion, NtRemoveIoCompletionEx, or NtWaitForWorkViaWorkerFactory) is woken. The kernel does not interpret `KeyContext` or `ApcContext` — they are echoed back verbatim. That opacity is what makes the syscall so versatile both for legitimate async I/O dispatch and for malicious forged-packet injection.

Common malware usage

The 'Worker via Completion Port' PoolParty variant: open the victim's threadpool completion port (often via a leaked handle or NtDuplicateObject), then issue NtSetIoCompletion with `ApcContext` pointing at a structure shaped like a `TP_DIRECT` — when ntdll!TppWorkerThread dequeues the packet, its dispatcher will follow the pointers and call the function the attacker chose. Crucially, no new memory needs to be allocated in the victim if a usable gadget already exists; the entire injection collapses to a single syscall once the handle is obtained. Forged completion packets have also been used historically by exploit chains targeting Win32k callback flaws and by various sandbox escapes in browsers (Chromium's IO thread, Edge's broker).

Detection opportunities

Like NtCreateIoCompletion, the syscall is far too common in legitimate code to alert on directly. The cross-process variant is the actionable signal: NtSetIoCompletion on a handle whose underlying object's owning process differs from the caller is essentially never legitimate. ETW Microsoft-Windows-Kernel-IoCompletion can expose post events at high cost; a lower-overhead approach is ObRegisterCallbacks on the IoCompletion object type, gating on cross-process handle duplications. Forged-packet content inspection is theoretically possible but expensive — TP_DIRECT-shaped contexts dereferenced into RWX VAD regions are a credible heuristic.

Direct syscall examples

cForged delivery — PoolParty 'Worker via Completion Port'

// hRemoteIocp is a handle in OUR address space that maps to the VICTIM's
// threadpool completion port (obtained via NtDuplicateObject or handle leak).
// pVictimGadget is a writable+executable address in the victim already shaped
// like a TP_DIRECT entry whose callback field points at shellcode.
NTSTATUS s = NtSetIoCompletion(
    hRemoteIocp,
    NULL,                  // KeyContext — irrelevant for TP_DIRECT path
    pVictimGadget,         // ApcContext — what TppWorkerThread will dispatch through
    STATUS_SUCCESS,
    0);                    // Information

cBenign use — wake a custom worker

// Plain PostQueuedCompletionStatus equivalent — every server you've written
// uses this under the hood.
NtSetIoCompletion(hIocp,
                  (PVOID)42,           // your CompletionKey
                  (PVOID)pOverlapped,  // your OVERLAPPED*
                  STATUS_SUCCESS,
                  bytesTransferred);

asmx64 direct stub (Win11 24H2 SSN 0x1B3)

NtSetIoCompletion PROC
    mov  r10, rcx
    mov  eax, 1B3h
    syscall
    ret
NtSetIoCompletion ENDP

MITRE ATT&CK mappings

Last verified: 2026-05-20