> Windows Syscalls
ntoskrnl.exeT1622T1106

NtSetInformationObject

Establece atributos a nivel de handle (herencia, protección contra cierre) sobre un handle de objeto del kernel.

Prototipo

NTSTATUS NtSetInformationObject(
  HANDLE                   Handle,
  OBJECT_INFORMATION_CLASS ObjectInformationClass,
  PVOID                    ObjectInformation,
  ULONG                    ObjectInformationLength
);

Argumentos

NameTypeDirDescription
HandleHANDLEinHandle cuyos atributos se van a modificar.
ObjectInformationClassOBJECT_INFORMATION_CLASSinTípicamente ObjectHandleFlagInformation (4) — la única clase aceptada por NtSetInformationObject.
ObjectInformationPVOIDinPuntero a OBJECT_HANDLE_FLAG_INFORMATION { BOOLEAN Inherit; BOOLEAN ProtectFromClose; }.
ObjectInformationLengthULONGinTamaño del buffer de entrada; sizeof(OBJECT_HANDLE_FLAG_INFORMATION) == 2.

IDs de syscalls por versión de Windows

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

Módulo del kernel

ntoskrnl.exeNtSetInformationObject

APIs relacionadas

SetHandleInformationNtQueryObjectNtCloseNtDuplicateObject

Stub del syscall

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

El SSN `0x5C` es estable en todos los builds cubiertos. NtSetInformationObject solo acepta realmente la clase **ObjectHandleFlagInformation (4)** con una estructura de 2 bytes: dos BOOLEAN, `Inherit` y `ProtectFromClose`. Es la primitiva del kernel detrás del Win32 `SetHandleInformation`. Activar `ProtectFromClose=TRUE` hace que NtClose posteriores sobre ese handle devuelvan STATUS_HANDLE_NOT_CLOSABLE sin liberar la referencia — el kernel mantiene la entrada, y un re-flip a FALSE vuelve a permitir el cierre. Inherit solo importa en CreateProcess (el handle pasa a la tabla del hijo).

Uso común por malware

Conocido como contramedida contra la sonda anti-debug clásica `NtClose(0xDEADBEEF) -> STATUS_INVALID_HANDLE`: el malware activa `ProtectFromClose` en sus propios handles reales antes de invocar defensivamente NtClose sobre ellos, de modo que sobreviven aunque un depurador altere la ruta de cierre (Themida y VMProtect llevan este truco). También es pieza de la **contra-contramedida anti-NtClose**: poner `ProtectFromClose=TRUE` sobre un handle voluntariamente inválido silencia STATUS_INVALID_HANDLE bajo depurador adjunto. Uso más oscuro: manipular herencia justo antes de CreateProcessAsUser para controlar exactamente qué handles se filtran a un hijo sandboxeado (lo usan algunos loaders sandbox-aware para pasar un token privilegiado sin conceder PROCESS_DUP_HANDLE al hijo).

Oportunidades de detección

Volumen muy bajo en software legítimo fuera de Office, WSL y hosts de consola. Sysmon no registra este syscall actualmente, pero está expuesto vía ETW Microsoft-Windows-Kernel-Audit-API-Calls y alcanzable desde ObRegisterCallbacks. Detección de alto valor: **ProtectFromClose=TRUE aplicado a handles estándar (0xFFFFFFFE/-1 = pseudo del proceso actual) o a handles dentro de un proceso cuyo padre mapeó ntdll de forma sospechosa recientemente** — outliers extremos. Los vendors correlacionan también flips de ProtectFromClose seguidos inmediatamente de NtClose con retorno no cero (patrón anti-debug).

Ejemplos de syscalls directos

asmx64 direct stub

; Direct syscall stub for NtSetInformationObject (SSN 0x5C, all builds)
NtSetInformationObject PROC
    mov  r10, rcx          ; syscall convention
    mov  eax, 5Ch          ; SSN
    syscall
    ret
NtSetInformationObject ENDP

cProtect a handle from NtClose tampering

// Defeat NtClose-based anti-debug probes by marking the handle non-closable
// before any defensive NtClose() call.
#include <windows.h>

#define ObjectHandleFlagInformation 4

typedef struct _OBJECT_HANDLE_FLAG_INFORMATION {
    BOOLEAN Inherit;
    BOOLEAN ProtectFromClose;
} OBJECT_HANDLE_FLAG_INFORMATION;

typedef NTSTATUS (NTAPI *pNtSetInformationObject)(
    HANDLE, ULONG, PVOID, ULONG);

BOOL ProtectHandle(HANDLE h) {
    pNtSetInformationObject NtSetInformationObject = (pNtSetInformationObject)
        GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtSetInformationObject");
    OBJECT_HANDLE_FLAG_INFORMATION info = { FALSE, TRUE };
    NTSTATUS s = NtSetInformationObject(h, ObjectHandleFlagInformation,
                                        &info, sizeof(info));
    return NT_SUCCESS(s);
}

rustStrip inherit flag before sandbox spawn

// Cargo: ntapi = "0.4"
// Make a privileged token handle non-inheritable just before spawning a
// low-integrity child via CreateProcessAsUser. Combined with bInheritHandles=
// FALSE this gives belt-and-braces leak control.
use ntapi::ntobapi::NtSetInformationObject;

const ObjectHandleFlagInformation: u32 = 4;

#[repr(C)]
struct ObjectHandleFlagInfo { inherit: u8, protect_from_close: u8 }

pub unsafe fn strip_inherit(h: isize) {
    let info = ObjectHandleFlagInfo { inherit: 0, protect_from_close: 0 };
    let _ = NtSetInformationObject(
        h as _,
        ObjectHandleFlagInformation as _,
        &info as *const _ as _,
        std::mem::size_of::<ObjectHandleFlagInfo>() as u32,
    );
}

Mapeos MITRE ATT&CK

Last verified: 2026-05-20