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
| Name | Type | Dir | Description |
|---|---|---|---|
| WorkerFactoryHandle | HANDLE | in | Handle to the worker factory to shut down. Requires WORKER_FACTORY_SHUTDOWN access. |
| PendingWorkerCount | LONG * | in/out | Returns the number of workers still alive after the shutdown flag was set. Threadpool teardown polls this to zero. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0x199 | win10-1507 |
| Win10 1607 | 0x1A2 | win10-1607 |
| Win10 1703 | 0x1A8 | win10-1703 |
| Win10 1709 | 0x1AB | win10-1709 |
| Win10 1803 | 0x1AD | win10-1803 |
| Win10 1809 | 0x1AE | win10-1809 |
| Win10 1903 | 0x1AF | win10-1903 |
| Win10 1909 | 0x1AF | win10-1909 |
| Win10 2004 | 0x1B5 | win10-2004 |
| Win10 20H2 | 0x1B5 | win10-20h2 |
| Win10 21H1 | 0x1B5 | win10-21h1 |
| Win10 21H2 | 0x1B7 | win10-21h2 |
| Win10 22H2 | 0x1B7 | win10-22h2 |
| Win11 21H2 | 0x1C0 | win11-21h2 |
| Win11 22H2 | 0x1C4 | win11-22h2 |
| Win11 23H2 | 0x1C4 | win11-23h2 |
| Win11 24H2 | 0x1C7 | win11-24h2 |
| Server 2016 | 0x1A2 | winserver-2016 |
| Server 2019 | 0x1AE | winserver-2019 |
| Server 2022 | 0x1BD | winserver-2022 |
| Server 2025 | 0x1C7 | winserver-2025 |
Kernel module
Related APIs
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 ENDPMITRE ATT&CK mappings
Last verified: 2026-05-20