> Windows Syscalls
ntoskrnl.exeT1055T1106

NtShutdownWorkerFactory

Signals a worker factory to stop creating new threads and reports how many workers are still pending.

Prototype

NTSTATUS NtShutdownWorkerFactory(
  HANDLE  WorkerFactoryHandle,
  LONG   *PendingWorkerCount
);

Arguments

NameTypeDirDescription
WorkerFactoryHandleHANDLEinHandle to the worker factory to shut down. Requires WORKER_FACTORY_SHUTDOWN access.
PendingWorkerCountLONG *in/outReturns the number of workers still alive after the shutdown flag was set. Threadpool teardown polls this to zero.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x199win10-1507
Win10 16070x1A2win10-1607
Win10 17030x1A8win10-1703
Win10 17090x1ABwin10-1709
Win10 18030x1ADwin10-1803
Win10 18090x1AEwin10-1809
Win10 19030x1AFwin10-1903
Win10 19090x1AFwin10-1909
Win10 20040x1B5win10-2004
Win10 20H20x1B5win10-20h2
Win10 21H10x1B5win10-21h1
Win10 21H20x1B7win10-21h2
Win10 22H20x1B7win10-22h2
Win11 21H20x1C0win11-21h2
Win11 22H20x1C4win11-22h2
Win11 23H20x1C4win11-23h2
Win11 24H20x1C7win11-24h2
Server 20160x1A2winserver-2016
Server 20190x1AEwinserver-2019
Server 20220x1BDwinserver-2022
Server 20250x1C7winserver-2025

Kernel module

ntoskrnl.exeNtShutdownWorkerFactory

Related APIs

CloseThreadpoolNtCreateWorkerFactoryNtQueryInformationWorkerFactoryNtSetInformationWorkerFactoryNtClose

Syscall stub

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

Setting the shutdown flag on a worker factory prevents the kernel from spawning further worker threads but lets existing ones drain to their natural exit. The returned `PendingWorkerCount` lets the caller poll for full quiescence before closing the underlying I/O completion port. `ntdll!TppWorkerFactoryShutdown` and `RtlpThreadpoolWorkerFactoryShutdown` both call this; user code rarely does so directly outside of CRT teardown or LdrShutdownProcess.

Common malware usage

After a PoolParty execution succeeds and the shellcode has done its work, the implant often calls NtShutdownWorkerFactory to gracefully tear down the foreign threadpool — leaving fewer artefacts than a hard `NtTerminateThread`. The same syscall can be weaponised defensively-by-the-attacker too: an attacker with `WORKER_FACTORY_SHUTDOWN` rights on a victim's threadpool can paralyse the victim's async pipelines (HTTP server worker pool, .NET ThreadPool, RPC dispatchers) without crashing the process — a stealthy denial-of-service. Public PoolParty PoCs include shutdown as the cleanup step.

Detection opportunities

Standalone NtShutdownWorkerFactory calls are noisy in normal teardown — every process exit issues some — so cross-process invocation is the meaningful signal. Pair it with the upstream NtCreateWorkerFactory event: a process that creates a worker factory in another process and shortly thereafter shuts it down is highly suspect. The kernel object manager records open handles to the WorkerFactory; ObRegisterCallbacks can intercept handle duplications across process boundaries.

Direct syscall examples

cCleanup after PoolParty payload

// Called by the loader after the shellcode signals 'done'.
LONG pending = 0;
NTSTATUS s = NtShutdownWorkerFactory(hWorkerFactory, &pending);
while (NT_SUCCESS(s) && pending > 0) {
    // Workers still draining — sleep, then re-query.
    Sleep(50);
    NtQueryInformationWorkerFactory(hWorkerFactory,
        WorkerFactoryBasicInformation,
        &basic, sizeof(basic), NULL);
    pending = basic.TotalWorkerCount;
}
NtClose(hWorkerFactory);
NtClose(hIoCompletion);

asmx64 direct stub (Win11 24H2 SSN 0x1C7)

NtShutdownWorkerFactory PROC
    mov  r10, rcx
    mov  eax, 1C7h     ; Win11 24H2 / Server 2025
    syscall
    ret
NtShutdownWorkerFactory ENDP

MITRE ATT&CK mappings

Last verified: 2026-05-20