> Windows Syscalls
ntoskrnl.exeT1620T1106

NtExtendSection

Extiende una sección existente respaldada por pagefile o fichero hasta un tamaño máximo mayor.

Prototipo

NTSTATUS NtExtendSection(
  HANDLE         SectionHandle,
  PLARGE_INTEGER NewSectionSize
);

Argumentos

NameTypeDirDescription
SectionHandleHANDLEinHandle a la sección a extender. Debe tener acceso SECTION_EXTEND_SIZE.
NewSectionSizePLARGE_INTEGERin/outEn entrada: nuevo tamaño máximo solicitado. En salida: nuevo tamaño real (redondeado al límite de página).

IDs de syscalls por versión de Windows

Versión de WindowsID de syscallBuild
Win10 15070xD3win10-1507
Win10 16070xD6win10-1607
Win10 17030xD9win10-1703
Win10 17090xDAwin10-1709
Win10 18030xDBwin10-1803
Win10 18090xDCwin10-1809
Win10 19030xDDwin10-1903
Win10 19090xDDwin10-1909
Win10 20040xE2win10-2004
Win10 20H20xE2win10-20h2
Win10 21H10xE2win10-21h1
Win10 21H20xE3win10-21h2
Win10 22H20xE3win10-22h2
Win11 21H20xE8win11-21h2
Win11 22H20xE9win11-22h2
Win11 23H20xE9win11-23h2
Win11 24H20xEBwin11-24h2
Server 20160xD6winserver-2016
Server 20190xDCwinserver-2019
Server 20220xE7winserver-2022
Server 20250xEBwinserver-2025

Módulo del kernel

ntoskrnl.exeNtExtendSection

APIs relacionadas

NtCreateSectionNtMapViewOfSectionNtMapViewOfSectionExNtQuerySectionMapViewOfFile

Stub del syscall

4C 8B D1            mov r10, rcx
B8 EB 00 00 00      mov eax, 0xEB      ; 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

Notas no documentadas

Extiende el tamaño máximo committable de un objeto sección. Solo las secciones creadas con `SEC_RESERVE` o las respaldadas por pagefile (`SEC_COMMIT` sin handle de fichero) son típicamente extensibles — las secciones imagen (`SEC_IMAGE`) no lo son. El nuevo tamaño no puede exceder el del fichero de backing si la sección era respaldada por fichero sin `SEC_RESERVE`. El kernel redondea el tamaño solicitado al límite de página y lo reescribe vía `NewSectionSize`.

Uso común por malware

Lo usan los loaders de shellcode que construyen el payload por etapas sin commitar el tamaño final desde el principio. El loader crea una pequeña sección pagefile `SEC_RESERVE`, mapea una vista, escribe la primera etapa, luego llama a `NtExtendSection` cuando se conoce el tamaño de la segunda etapa y remapea una vista mayor — evitando una asignación RWX temprana de todo el tamaño final. Aparece también en canales IPC de búfer compartido entre implantes cooperantes que crecen dinámicamente. No es un IOC frecuente por sí solo, pero combinado con secciones pagefile `SEC_COMMIT` y mapping en proceso remoto, forma la espina dorsal de los loaders solo-memoria que nunca tocan disco.

Oportunidades de detección

Sin evento ETW dedicado. La detección combina `NtCreateSection` de una sección pagefile `SEC_RESERVE` seguida de `NtExtendSection` y luego `NtMapViewOfSection(Ex)` con protección `PAGE_EXECUTE_*` en el mismo proceso en poco tiempo. Los EDR que hookean `NtMapViewOfSection` pueden marcar mappings ejecutables de secciones pagefile — combinación prácticamente inexistente en aplicaciones legítimas fuera de motores JIT y algunos servidores de bases de datos.

Ejemplos de syscalls directos

cGrow a SEC_RESERVE pagefile section

// Initial 4 KiB reserve.
LARGE_INTEGER initialSize; initialSize.QuadPart = 0x1000;
HANDLE hSection;
NtCreateSection(&hSection, SECTION_ALL_ACCESS, NULL, &initialSize,
                PAGE_EXECUTE_READWRITE, SEC_RESERVE, NULL);

// ... map, write stage 1 ...

// Now grow to 1 MiB to fit stage 2 + relocations.
LARGE_INTEGER newSize; newSize.QuadPart = 0x100000;
NTSTATUS s = NtExtendSection(hSection, &newSize);
// newSize.QuadPart is updated to the actual rounded value.

asmx64 direct stub (Win11 24H2)

; NtExtendSection direct stub — SSN 0xEB on Win11 24H2
NtExtendSection PROC
    mov  r10, rcx
    mov  eax, 0EBh
    syscall
    ret
NtExtendSection ENDP

rustExtend via ntapi crate

use ntapi::ntmmapi::NtExtendSection;
use winapi::shared::ntdef::{HANDLE, LARGE_INTEGER};
use std::mem;

unsafe fn extend(section: HANDLE, new_bytes: i64) -> i64 {
    let mut li: LARGE_INTEGER = mem::zeroed();
    *li.QuadPart_mut() = new_bytes;
    let s = NtExtendSection(section, &mut li);
    assert!(s >= 0);
    *li.QuadPart()
}

Mapeos MITRE ATT&CK

Last verified: 2026-05-20