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
| Name | Type | Dir | Description |
|---|---|---|---|
| SectionHandle | HANDLE | in | Handle a la sección a extender. Debe tener acceso SECTION_EXTEND_SIZE. |
| NewSectionSize | PLARGE_INTEGER | in/out | En 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 Windows | ID de syscall | Build |
|---|---|---|
| Win10 1507 | 0xD3 | win10-1507 |
| Win10 1607 | 0xD6 | win10-1607 |
| Win10 1703 | 0xD9 | win10-1703 |
| Win10 1709 | 0xDA | win10-1709 |
| Win10 1803 | 0xDB | win10-1803 |
| Win10 1809 | 0xDC | win10-1809 |
| Win10 1903 | 0xDD | win10-1903 |
| Win10 1909 | 0xDD | win10-1909 |
| Win10 2004 | 0xE2 | win10-2004 |
| Win10 20H2 | 0xE2 | win10-20h2 |
| Win10 21H1 | 0xE2 | win10-21h1 |
| Win10 21H2 | 0xE3 | win10-21h2 |
| Win10 22H2 | 0xE3 | win10-22h2 |
| Win11 21H2 | 0xE8 | win11-21h2 |
| Win11 22H2 | 0xE9 | win11-22h2 |
| Win11 23H2 | 0xE9 | win11-23h2 |
| Win11 24H2 | 0xEB | win11-24h2 |
| Server 2016 | 0xD6 | winserver-2016 |
| Server 2019 | 0xDC | winserver-2019 |
| Server 2022 | 0xE7 | winserver-2022 |
| Server 2025 | 0xEB | winserver-2025 |
Módulo del kernel
APIs relacionadas
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 ENDPrustExtend 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