> Windows Syscalls
ntoskrnl.exeT1057T1014T1003.001

NtQuerySystemInformation

Recupera una clase de información a nivel sistema — lista de procesos, tabla de handles del kernel, lista de drivers cargados, estado de integridad de código, y más.

Prototipo

NTSTATUS NtQuerySystemInformation(
  SYSTEM_INFORMATION_CLASS SystemInformationClass,
  PVOID                    SystemInformation,
  ULONG                    SystemInformationLength,
  PULONG                   ReturnLength
);

Argumentos

NameTypeDirDescription
SystemInformationClassSYSTEM_INFORMATION_CLASSinEnum que selecciona el conjunto de datos. Notables: SystemProcessInformation=5, SystemModuleInformation=11, SystemHandleInformation=16, SystemExtendedHandleInformation=64, SystemBigPoolInformation=66, SystemBootEnvironmentInformation=90, SystemCodeIntegrityInformation=103.
SystemInformationPVOIDoutBuffer proporcionado por el llamador que recibe los datos devueltos. El formato es específico de la clase.
SystemInformationLengthULONGinTamaño en bytes del buffer SystemInformation.
ReturnLengthPULONGoutPuntero opcional que recibe los bytes escritos, o el tamaño requerido en STATUS_INFO_LENGTH_MISMATCH (patrón canónico de bucle de dimensionado).

IDs de syscalls por versión de Windows

Versión de WindowsID de syscallBuild
Win10 15070x36win10-1507
Win10 16070x36win10-1607
Win10 17030x36win10-1703
Win10 17090x36win10-1709
Win10 18030x36win10-1803
Win10 18090x36win10-1809
Win10 19030x36win10-1903
Win10 19090x36win10-1909
Win10 20040x36win10-2004
Win10 20H20x36win10-20h2
Win10 21H10x36win10-21h1
Win10 21H20x36win10-21h2
Win10 22H20x36win10-22h2
Win11 21H20x36win11-21h2
Win11 22H20x36win11-22h2
Win11 23H20x36win11-23h2
Win11 24H20x36win11-24h2
Server 20160x36winserver-2016
Server 20190x36winserver-2019
Server 20220x36winserver-2022
Server 20250x36winserver-2025

Módulo del kernel

ntoskrnl.exeNtQuerySystemInformation

APIs relacionadas

EnumProcessesEnumDeviceDriversGetSystemInfoCreateToolhelp32SnapshotNtQueryInformationProcessNtDuplicateObject

Stub del syscall

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

Otro peso pesado de SSN congelado: 0x36 desde Windows 10 1507 hasta Windows 11 24H2. La enumeración de clases es enorme (200+ valores en kernels recientes) y es la base de casi toda API Win32 de 'enumerar estado del sistema': EnumProcesses (clase 5), GetSystemInfo (clase 0), GetNativeSystemInfo, EnumDeviceDrivers (clase 11) y el no-oficialmente-expuesto NtQuerySystemInformation(SystemHandleInformation=16). La clase 16 es el layout de handle de 16 bits heredado; la clase 64 (SystemExtendedHandleInformation) es la variante ancha moderna — las herramientas modernas deberían usar esta última. El patrón de llamada canónico es un bucle de dimensionado: llamar con NULL/0 para obtener el tamaño requerido en ReturnLength, asignar, llamar de nuevo, repetir si el sistema creció bajo los pies (STATUS_INFO_LENGTH_MISMATCH en condición de carrera).

Uso común por malware

Tres usos de alto impacto de OPSEC y reconocimiento. (1) SystemProcessInformation (5) devuelve una lista contigua única de cada proceso y *todos sus hilos* — usada para encontrar objetivos de inyección sin tocar el ruidoso CreateToolhelp32Snapshot; también la primitiva de descubrimiento detrás de 'encontrar TID de lsass.exe con espera ALERTABLE' para Early Bird APC. (2) SystemHandleInformation / SystemExtendedHandleInformation (16/64) enumera cada handle en cada proceso — usada por herramientas sigilosas de credential-dumping (HandleKatz, variantes NanoDump) para encontrar un handle PROCESS_VM_READ existente a lsass.exe en poder de otro proceso y *duplicarlo* vía NtDuplicateObject, evitando completamente NtOpenProcess sobre lsass. (3) SystemModuleInformation (11) enumera módulos del kernel cargados con sus direcciones base — derrota KASLR para cualquier llamador no-LowIL, usada por ataques BYOVD para calcular offsets en memoria de funciones de driver objetivo, y por detectores de rootkits. SystemCodeIntegrityInformation (103) permite a un payload detectar si HVCI / DSE está aplicado antes de intentar cargar un driver no firmado. SystemBootEnvironmentInformation (90) revela si la ruta de arranque es BIOS o UEFI Secure Boot y es muestreada por bootkits para condicionar su estrategia de persistencia.

Oportunidades de detección

El volumen de la clase 5 (SystemProcessInformation) es enorme en uso normal — así enumeran Task Manager, Process Explorer, cualquier agente de monitorización y el propio runtime. El discriminador es el número de clase más la confianza del proceso llamador: las clases 16/64 (enum de handles) y 11 (enum de módulos) desde cualquier proceso no de sistema y no firmado por Microsoft son sospechosas. ETW Microsoft-Windows-Threat-Intelligence NO expone este syscall de forma granular; hay que instrumentar vía ETW del lado de ntdll (Microsoft-Windows-Win32k-Threat-Intelligence) o un callback de kernel. La señal más fuerte es el comportamiento post-llamada: un proceso que llama NtQuerySystemInformation(64) y en milisegundos llama NtDuplicateObject con un handle origen cuyo PID es lsass.exe está casi seguro haciendo credential-dumping.

Ejemplos de syscalls directos

cSizing loop for SystemExtendedHandleInformation

// Classic two-step: ask for size, allocate, ask for data.
ULONG len = 0x10000;
PVOID buf = NULL;
NTSTATUS st;
for (;;) {
    buf = HeapAlloc(GetProcessHeap(), 0, len);
    st = NtQuerySystemInformation(SystemExtendedHandleInformation /*64*/,
                                  buf, len, &len);
    if (st != STATUS_INFO_LENGTH_MISMATCH) break;
    HeapFree(GetProcessHeap(), 0, buf);
    len *= 2;
}
// buf now holds SYSTEM_HANDLE_INFORMATION_EX with NumberOfHandles + entries
// Iterate and find an entry with UniqueProcessId == lsass_pid and
// GrantedAccess == PROCESS_VM_READ | PROCESS_QUERY_INFORMATION -> dup it.

cKASLR defeat via SystemModuleInformation

// Discloses every loaded kernel module's base address from medium-IL or higher.
// Used by BYOVD attacks to compute target driver function offsets.
RTL_PROCESS_MODULES *mods = HeapAlloc(GetProcessHeap(), 0, 0x10000);
ULONG ret = 0;
NtQuerySystemInformation(SystemModuleInformation /*11*/,
                         mods, 0x10000, &ret);
for (ULONG i = 0; i < mods->NumberOfModules; i++) {
    if (strstr((char*)mods->Modules[i].FullPathName, "ntoskrnl.exe")) {
        // mods->Modules[i].ImageBase = current ntoskrnl base — KASLR defeated.
    }
}

rustDetect HVCI / Code Integrity

// Returns SYSTEM_CODEINTEGRITY_INFORMATION { Length, CodeIntegrityOptions }.
// Check options for CODEINTEGRITY_OPTION_ENABLED | HVCI_ENABLED before
// even attempting an unsigned-driver load.
use windows_sys::Wdk::System::SystemInformation::*;

#[repr(C)] struct CodeIntegrityInfo { length: u32, options: u32 }
let mut ci = CodeIntegrityInfo { length: 8, options: 0 };
let mut ret = 0u32;
unsafe {
    nt_query_system_information(103 /*SystemCodeIntegrityInformation*/,
        &mut ci as *mut _ as *mut _, 8, &mut ret);
}
let hvci_on = ci.options & 0x400 != 0;

Mapeos MITRE ATT&CK

Last verified: 2026-05-20