> Windows Syscalls
ntoskrnl.exeT1055T1106

NtQueryInformationWorkerFactory

Interroge la configuration et l'état d'exécution d'une worker factory, y compris la StartRoutine actuelle et le nombre de workers.

Prototype

NTSTATUS NtQueryInformationWorkerFactory(
  HANDLE                     WorkerFactoryHandle,
  WORKERFACTORYINFOCLASS     WorkerFactoryInformationClass,
  PVOID                      WorkerFactoryInformation,
  ULONG                      WorkerFactoryInformationLength,
  PULONG                     ReturnLength
);

Arguments

NameTypeDirDescription
WorkerFactoryHandleHANDLEinHandle vers la worker factory. Nécessite l'accès WORKER_FACTORY_QUERY_INFORMATION.
WorkerFactoryInformationClassWORKERFACTORYINFOCLASSinSélecteur de classe — le plus souvent WorkerFactoryBasicInformation (0).
WorkerFactoryInformationPVOIDoutBuffer fourni par l'appelant qui reçoit la structure interrogée.
WorkerFactoryInformationLengthULONGinTaille en octets du buffer fourni.
ReturnLengthPULONGoutPointeur optionnel recevant le nombre d'octets écrits. Peut être NULL.

IDs de syscalls par version de Windows

Version de WindowsID de syscallBuild
Win10 15070x136win10-1507
Win10 16070x13Cwin10-1607
Win10 17030x142win10-1703
Win10 17090x145win10-1709
Win10 18030x147win10-1803
Win10 18090x148win10-1809
Win10 19030x149win10-1903
Win10 19090x149win10-1909
Win10 20040x14Fwin10-2004
Win10 20H20x14Fwin10-20h2
Win10 21H10x14Fwin10-21h1
Win10 21H20x150win10-21h2
Win10 22H20x150win10-22h2
Win11 21H20x156win11-21h2
Win11 22H20x159win11-22h2
Win11 23H20x159win11-23h2
Win11 24H20x15Bwin11-24h2
Server 20160x13Cwinserver-2016
Server 20190x148winserver-2019
Server 20220x155winserver-2022
Server 20250x15Bwinserver-2025

Module noyau

ntoskrnl.exeNtQueryInformationWorkerFactory

APIs liées

NtCreateWorkerFactoryNtSetInformationWorkerFactoryNtShutdownWorkerFactoryQueryThreadpoolStackInformation

Stub du syscall

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

Notes non documentées

Le pendant en lecture de NtSetInformationWorkerFactory. `WorkerFactoryBasicInformation` renvoie une structure `WORKER_FACTORY_BASIC_INFORMATION` (cf. ntexapi.h / phnt) incluant la `StartRoutine` actuelle, `StartParameter`, `ProcessId`, le nombre de threads, les timeouts et le binding count. C'est l'une des rares façons documentées d'observer programmatiquement ce qu'une worker factory de threadpool est actuellement configurée pour exécuter — utile pour le diagnostic (taskmgr, PerfView) et pour la reconnaissance offensive d'un processus déjà ciblé.

Usage courant par les malwares

Utilisé par les variantes PoolParty avec réécriture de StartRoutine comme étape de lecture avant d'écrire une structure mutée via NtSetInformationWorkerFactory. Également utilisé par des outils qui énumèrent les worker factories d'une victime — une fois un handle dupliqué (via NtDuplicateObject), l'interrogation indique à l'attaquant quel threadpool est le plus chargé, dans quel processus cible il vit, et quelle StartRoutine il dispatche actuellement. Identification d'EDR possible aussi à l'inverse : un attaquant peut interroger les worker factories de son *propre* processus pour voir si une DLL tierce a hooké ou remplacé la StartRoutine.

Opportunités de détection

Les opérations de query sont en lecture seule et omniprésentes dans la maintenance normale du threadpool — ce syscall seul n'est pas un signal utile. Il devient pertinent couplé à un NtSetInformationWorkerFactory subséquent sur le même handle (le schéma classique read-modify-write), ou émis en inter-processus. Les callbacks noyau sur le type d'objet WorkerFactory peuvent corréler la paire query/set ; la télémétrie utilisateur est essentiellement inaccessible car les hooks EDR côté query sont systématiquement contournés par syscalls directs.

Exemples de syscalls directs

cSnapshot a worker factory

WORKER_FACTORY_BASIC_INFORMATION info;
ULONG ret = 0;
NTSTATUS s = NtQueryInformationWorkerFactory(
    hWf, WorkerFactoryBasicInformation,
    &info, sizeof(info), &ret);
if (NT_SUCCESS(s)) {
    printf("StartRoutine = %p in PID %llu, %u workers (%u waiting)\n",
           info.StartRoutine, (uint64_t)info.ProcessId,
           info.TotalWorkerCount, info.WaitingWorkerCount);
}

rustRecon over a duplicated remote handle

// hWfRemote was opened in our process via NtDuplicateObject(target, source, ours, ...)
// and now points to the *victim's* worker factory.
use ntapi::ntexapi::{NtQueryInformationWorkerFactory, WORKER_FACTORY_BASIC_INFORMATION};
let mut info: WORKER_FACTORY_BASIC_INFORMATION = unsafe { core::mem::zeroed() };
let mut ret: u32 = 0;
let status = unsafe {
    NtQueryInformationWorkerFactory(
        h_wf_remote,
        0, // WorkerFactoryBasicInformation
        &mut info as *mut _ as *mut _,
        core::mem::size_of_val(&info) as u32,
        &mut ret,
    )
};
assert_eq!(status, 0);
println!("victim StartRoutine: {:p}", info.StartRoutine);

Mappings MITRE ATT&CK

Last verified: 2026-05-20