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
| Name | Type | Dir | Description |
|---|---|---|---|
| Handle | HANDLE | in | Handle dont les attributs doivent être modifiés. |
| ObjectInformationClass | OBJECT_INFORMATION_CLASS | in | Typiquement ObjectHandleFlagInformation (4) — la seule classe acceptée par NtSetInformationObject. |
| ObjectInformation | PVOID | in | Pointeur vers OBJECT_HANDLE_FLAG_INFORMATION { BOOLEAN Inherit; BOOLEAN ProtectFromClose; }. |
| ObjectInformationLength | ULONG | in | Taille du buffer d'entrée ; sizeof(OBJECT_HANDLE_FLAG_INFORMATION) == 2. |
IDs de syscalls par version de Windows
| Version de Windows | ID de syscall | Build |
|---|---|---|
| Win10 1507 | 0x5C | win10-1507 |
| Win10 1607 | 0x5C | win10-1607 |
| Win10 1703 | 0x5C | win10-1703 |
| Win10 1709 | 0x5C | win10-1709 |
| Win10 1803 | 0x5C | win10-1803 |
| Win10 1809 | 0x5C | win10-1809 |
| Win10 1903 | 0x5C | win10-1903 |
| Win10 1909 | 0x5C | win10-1909 |
| Win10 2004 | 0x5C | win10-2004 |
| Win10 20H2 | 0x5C | win10-20h2 |
| Win10 21H1 | 0x5C | win10-21h1 |
| Win10 21H2 | 0x5C | win10-21h2 |
| Win10 22H2 | 0x5C | win10-22h2 |
| Win11 21H2 | 0x5C | win11-21h2 |
| Win11 22H2 | 0x5C | win11-22h2 |
| Win11 23H2 | 0x5C | win11-23h2 |
| Win11 24H2 | 0x5C | win11-24h2 |
| Server 2016 | 0x5C | winserver-2016 |
| Server 2019 | 0x5C | winserver-2019 |
| Server 2022 | 0x5C | winserver-2022 |
| Server 2025 | 0x5C | winserver-2025 |
Module noyau
APIs liées
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 ENDPcProtect 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