> Windows Syscalls
ntoskrnl.exeT1622T1106

NtSetInformationObject

Définit des attributs de niveau handle (héritage, protection contre fermeture) sur un handle d'objet noyau.

Prototype

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

Arguments

NameTypeDirDescription
HandleHANDLEinHandle dont les attributs doivent être modifiés.
ObjectInformationClassOBJECT_INFORMATION_CLASSinTypiquement ObjectHandleFlagInformation (4) — la seule classe acceptée par NtSetInformationObject.
ObjectInformationPVOIDinPointeur vers OBJECT_HANDLE_FLAG_INFORMATION { BOOLEAN Inherit; BOOLEAN ProtectFromClose; }.
ObjectInformationLengthULONGinTaille du buffer d'entrée ; sizeof(OBJECT_HANDLE_FLAG_INFORMATION) == 2.

IDs de syscalls par version de Windows

Version 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

Module noyau

ntoskrnl.exeNtSetInformationObject

APIs liées

SetHandleInformationNtQueryObjectNtCloseNtDuplicateObject

Stub du 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

Notes non documentées

Le SSN `0x5C` est stable sur tous les builds couverts. NtSetInformationObject n'accepte vraiment que la classe **ObjectHandleFlagInformation (4)** avec une structure de 2 octets : deux BOOLEAN, `Inherit` et `ProtectFromClose`. C'est la primitive noyau derrière Win32 `SetHandleInformation`. Mettre `ProtectFromClose=TRUE` fait que les appels NtClose ultérieurs sur ce handle renvoient STATUS_HANDLE_NOT_CLOSABLE sans libérer la référence — le noyau conserve l'entrée, et un re-flip vers FALSE rend la fermeture à nouveau possible. Inherit ne joue qu'au moment de CreateProcess (le handle entre dans la table de l'enfant).

Usage courant par les malwares

Connu comme contre-mesure à la sonde anti-debug classique `NtClose(0xDEADBEEF) -> STATUS_INVALID_HANDLE` : le malware pose `ProtectFromClose` sur ses propres handles réels avant d'appeler défensivement NtClose dessus, pour qu'ils survivent même si un débogueur perturbe le chemin de fermeture (Themida et VMProtect embarquent ce trick). C'est aussi une pièce de la **contre-contre-mesure anti-NtClose** : poser `ProtectFromClose=TRUE` sur un handle volontairement invalide fait taire STATUS_INVALID_HANDLE sous débogueur attaché. Usage plus obscur : manipuler l'héritage juste avant CreateProcessAsUser pour contrôler précisément quels handles fuient vers un enfant sandboxé (utilisé par certains loaders sandbox-aware pour transférer un token privilégié sans accorder PROCESS_DUP_HANDLE à l'enfant).

Opportunités de détection

Volume très faible en logiciel légitime hors Office, WSL et hôtes console. Sysmon ne loggue pas ce syscall actuellement, mais il est exposé via ETW Microsoft-Windows-Kernel-Audit-API-Calls et atteignable par ObRegisterCallbacks. La détection à haute valeur : **ProtectFromClose=TRUE appliqué à des handles standards (0xFFFFFFFE/-1 = pseudo-handle du processus courant) ou à des handles dans un processus dont le parent vient de mapper ntdll de façon suspecte** — extrêmes outliers. Les vendors corrèlent aussi des flips ProtectFromClose suivis immédiatement d'appels NtClose retournant non-zéro (pattern anti-debug).

Exemples de syscalls directs

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,
    );
}

Mappings MITRE ATT&CK

Last verified: 2026-05-20