> Windows Syscalls
ntoskrnl.exeT1622T1106T1497

NtSetInformationThread

Sets a property on a thread via the THREADINFOCLASS enum — most famously ThreadHideFromDebugger.

Prototype

NTSTATUS NtSetInformationThread(
  HANDLE          ThreadHandle,
  THREADINFOCLASS ThreadInformationClass,
  PVOID           ThreadInformation,
  ULONG           ThreadInformationLength
);

Arguments

NameTypeDirDescription
ThreadHandleHANDLEinHandle to the target thread. Use NtCurrentThread() ((HANDLE)-2) for the calling thread.
ThreadInformationClassTHREADINFOCLASSinEnum selecting the property to set, e.g. ThreadHideFromDebugger (0x11), ThreadBreakOnTermination (0x12).
ThreadInformationPVOIDinBuffer with the new value. For ThreadHideFromDebugger this is ignored and may be NULL.
ThreadInformationLengthULONGinSize in bytes of the ThreadInformation buffer. 0 for ThreadHideFromDebugger.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070xDwin10-1507
Win10 16070xDwin10-1607
Win10 17030xDwin10-1703
Win10 17090xDwin10-1709
Win10 18030xDwin10-1803
Win10 18090xDwin10-1809
Win10 19030xDwin10-1903
Win10 19090xDwin10-1909
Win10 20040xDwin10-2004
Win10 20H20xDwin10-20h2
Win10 21H10xDwin10-21h1
Win10 21H20xDwin10-21h2
Win10 22H20xDwin10-22h2
Win11 21H20xDwin11-21h2
Win11 22H20xDwin11-22h2
Win11 23H20xDwin11-23h2
Win11 24H20xDwin11-24h2
Server 20160xDwinserver-2016
Server 20190xDwinserver-2019
Server 20220xDwinserver-2022
Server 20250xDwinserver-2025

Kernel module

ntoskrnl.exeNtSetInformationThread

Related APIs

SetThreadInformationNtQueryInformationThreadNtSetInformationProcessNtContinueDbgUiRemoteBreakin

Syscall stub

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

Undocumented notes

The SSN for NtSetInformationThread is `0xD` across every modern Windows build, which makes it a favorite anchor for hand-rolled syscall stubs. The interesting surface is the `THREADINFOCLASS` enum: `ThreadHideFromDebugger = 0x11` causes KiDispatchException to skip notifying any attached debugger of exceptions raised by that thread, effectively rendering breakpoint and single-step events invisible. `ThreadBreakOnTermination = 0x12` flips the EPROCESS BreakOnTermination bit so that thread teardown bug-checks the system — sometimes weaponized as a crude anti-tamper trip-wire. Many other classes (ThreadIdealProcessor, ThreadPriorityBoost) are entirely benign.

Common malware usage

ThreadHideFromDebugger is *the* canonical user-mode anti-debug primitive — invoked on the main thread (and often every worker) at startup to silence usermode debuggers like x64dbg, WinDbg, and IDA's local debugger. Commercial packers (VMProtect, Themida, Enigma) call it; so do most off-the-shelf crypters, document droppers, and Cobalt Strike post-ex tools that want to evade analyst sandboxes. Some malware also abuses ThreadBreakOnTermination so that if an EDR forcibly kills the implant thread, the host blue-screens — a destructive evasion sometimes seen in wipers and aggressive rootkits.

VMProtect-packed loadersThemida-packed loadersCobalt StrikeFinFisherQakbotGuLoader

Detection opportunities

On Windows 10 1809+ the kernel emits an ETW Threat Intelligence event (`EtwTiLogSetInformationThread`) whenever ThreadHideFromDebugger is set, which Defender for Endpoint and most modern EDRs consume — this is the highest-fidelity signal available because direct-syscall callers cannot suppress it from user mode. Microsoft-Windows-Threat-Intelligence is a protected ETW provider, so PPL/AntiMalware Light enrollment is required to subscribe. Userland EDR hooks on `ntdll!NtSetInformationThread` are routinely bypassed via direct syscalls, so kernel telemetry is the only reliable layer. Correlate with ThreadInformationClass == 0x11 to keep noise low.

Direct syscall examples

asmThreadHideFromDebugger direct stub

; SSN 0xD on all modern builds. ThreadInformationClass = 0x11 (ThreadHideFromDebugger).
HideCurrentThread PROC
    sub  rsp, 28h
    mov  rcx, -2              ; NtCurrentThread()
    mov  edx, 11h             ; ThreadHideFromDebugger
    xor  r8, r8               ; ThreadInformation = NULL
    xor  r9d, r9d             ; ThreadInformationLength = 0
    mov  r10, rcx
    mov  eax, 0Dh
    syscall
    add  rsp, 28h
    ret
HideCurrentThread ENDP

cIndirect syscall via ntdll lookup

// Resolves ntdll!NtSetInformationThread and calls it as-is so EDR
// hooks on the prologue still see the call — useful when only the
// ThreadHideFromDebugger event matters and the loader doesn't want
// to look suspicious otherwise.
typedef NTSTATUS(NTAPI* fnNtSetInformationThread)(
    HANDLE, ULONG, PVOID, ULONG);

void HideFromDebugger(void) {
    HMODULE h = GetModuleHandleA("ntdll.dll");
    fnNtSetInformationThread p = (fnNtSetInformationThread)
        GetProcAddress(h, "NtSetInformationThread");
    p((HANDLE)-2, 0x11 /* ThreadHideFromDebugger */, NULL, 0);
}

rustwindows-sys + naked stub

// Cargo: windows-sys = "0.59"
use std::arch::asm;

#[unsafe(naked)]
unsafe extern "system" fn nt_set_information_thread_stub(
    _thread: isize,
    _class: u32,
    _info: *mut u8,
    _len: u32,
) -> i32 {
    asm!(
        "mov r10, rcx",
        "mov eax, 0xD",
        "syscall",
        "ret",
        options(noreturn),
    );
}

pub fn hide_from_debugger() -> i32 {
    unsafe { nt_set_information_thread_stub(-2, 0x11, core::ptr::null_mut(), 0) }
}

MITRE ATT&CK mappings

Last verified: 2026-05-20