NtCreateThreadEx
Creates a new thread in a target process, optionally suspended, with rich attribute list support.
Prototype
NTSTATUS NtCreateThreadEx( PHANDLE ThreadHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, HANDLE ProcessHandle, PVOID StartRoutine, PVOID Argument, ULONG CreateFlags, SIZE_T ZeroBits, SIZE_T StackSize, SIZE_T MaximumStackSize, PPS_ATTRIBUTE_LIST AttributeList );
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| ThreadHandle | PHANDLE | out | Receives the handle to the newly created thread. |
| DesiredAccess | ACCESS_MASK | in | Rights for the returned handle, usually THREAD_ALL_ACCESS for full control. |
| ObjectAttributes | POBJECT_ATTRIBUTES | in | Object attributes for the new thread (typically NULL). |
| ProcessHandle | HANDLE | in | Handle to the target process that will host the thread. |
| StartRoutine | PVOID | in | Address of the thread entry point in the target process. |
| Argument | PVOID | in | Single pointer-sized argument passed to StartRoutine. |
| CreateFlags | ULONG | in | Flags. THREAD_CREATE_FLAGS_CREATE_SUSPENDED (0x1) is by far the most common. |
| ZeroBits | SIZE_T | in | Number of high-order zero bits in the stack base (typically 0). |
| StackSize | SIZE_T | in | Initial committed stack size; 0 lets the kernel choose the default. |
| MaximumStackSize | SIZE_T | in | Maximum reserved stack size; 0 lets the kernel choose the default. |
| AttributeList | PPS_ATTRIBUTE_LIST | in | Optional list of PS_ATTRIBUTE entries (CLIENT_ID, TEB address, etc.). NULL for defaults. |
Syscall IDs by Windows version
| Windows version | Syscall ID | Build |
|---|---|---|
| Win10 1507 | 0xB3 | win10-1507 |
| Win10 1607 | 0xB6 | win10-1607 |
| Win10 1703 | 0xB9 | win10-1703 |
| Win10 1709 | 0xBA | win10-1709 |
| Win10 1803 | 0xBB | win10-1803 |
| Win10 1809 | 0xBC | win10-1809 |
| Win10 1903 | 0xBD | win10-1903 |
| Win10 1909 | 0xBD | win10-1909 |
| Win10 2004 | 0xC1 | win10-2004 |
| Win10 20H2 | 0xC1 | win10-20h2 |
| Win10 21H1 | 0xC1 | win10-21h1 |
| Win10 21H2 | 0xC2 | win10-21h2 |
| Win10 22H2 | 0xC2 | win10-22h2 |
| Win11 21H2 | 0xC6 | win11-21h2 |
| Win11 22H2 | 0xC7 | win11-22h2 |
| Win11 23H2 | 0xC7 | win11-23h2 |
| Win11 24H2 | 0xC9 | win11-24h2 |
| Server 2016 | 0xB6 | winserver-2016 |
| Server 2019 | 0xBC | winserver-2019 |
| Server 2022 | 0xC5 | winserver-2022 |
| Server 2025 | 0xC9 | winserver-2025 |
Kernel module
Related APIs
Syscall stub
4C 8B D1 mov r10, rcx B8 C2 00 00 00 mov eax, 0xC2 ; win10-22h2 / win11-21h2 differ 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
Unlike many of its siblings, `NtCreateThreadEx` has a SSN that *moves on every feature update*: `0xC2` on Win10 21H2/22H2, `0xC6` on Win11 21H2, `0xC7` on 22H2/23H2, `0xC9` on 24H2 and Server 2025. Hardcoding this number is fragile — Hell's Gate or Halo's Gate dynamic resolution is strongly recommended. The function is the kernel-side workhorse behind `CreateRemoteThread`, `CreateRemoteThreadEx` and `CreateThread`; the older `NtCreateThread` is essentially deprecated. Passing a `PS_ATTRIBUTE_LIST` with `PsAttributeIdealProcessor` or `PsAttributeClientId` lets the caller pin the thread or assign it a forged CID.
Common malware usage
The execution step in classic remote injection: after `NtAllocateVirtualMemory` + `NtWriteVirtualMemory` + `NtProtectVirtualMemory`, this syscall is what actually runs the payload in the remote process. Often called with `CREATE_SUSPENDED` so that the implant can install a custom `CONTEXT` (PEB walking, stack spoof) via `NtSetContextThread` before `NtResumeThread`. Variants include using `LoadLibraryA` as `StartRoutine` (oldschool DLL injection), `RtlExitUserThread` decoys, or a JOP/ROP gadget chain that pivots inside the target.
Detection opportunities
Sysmon Event ID 8 (`CreateRemoteThread`) is the headline event — it fires whenever the source and target process differ, with `SourceImage`, `TargetImage`, `StartAddress`, and a stack hash. ETW Threat Intelligence emits `EtwTiLogCreateThread` for remote thread creation and is consumed by major EDRs. `PsSetCreateThreadNotifyRoutine`/`PsSetCreateThreadNotifyRoutineEx` kernel callbacks fire synchronously and cannot be bypassed by userland direct syscalls. A `StartAddress` that does not resolve to a loaded image (i.e. lives in private memory) is the strongest single signal.
Direct syscall examples
asmx64 direct stub (Win11 24H2)
; Direct syscall stub for NtCreateThreadEx (SSN 0xC9 on Win11 24H2 / Server 2025).
; WARNING: this SSN moves between feature updates — prefer dynamic resolution.
NtCreateThreadEx PROC
mov r10, rcx ; syscall convention
mov eax, 0C9h ; SSN for win11-24h2
syscall
ret
NtCreateThreadEx ENDPcSuspended remote thread + context patch
// Spawn the thread suspended so we can rewrite RIP / RSP before resuming.
HANDLE hThread = NULL;
NTSTATUS st = NtCreateThreadEx(&hThread, THREAD_ALL_ACCESS, NULL,
hRemote, payload_rva, NULL,
THREAD_CREATE_FLAGS_CREATE_SUSPENDED,
0, 0, 0, NULL);
if (!NT_SUCCESS(st)) return st;
CONTEXT ctx = { .ContextFlags = CONTEXT_FULL };
NtGetContextThread(hThread, &ctx);
ctx.Rip = (DWORD64)real_entry; // pivot away from the decoy StartRoutine
NtSetContextThread(hThread, &ctx);
NtResumeThread(hThread, NULL);cHell's Gate dynamic lookup
// Hardcoding 0xC2/0xC6/0xC7/0xC9 across builds is fragile — resolve at runtime.
typedef NTSTATUS (NTAPI *pNtCreateThreadEx)(
PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, HANDLE, PVOID, PVOID,
ULONG, SIZE_T, SIZE_T, SIZE_T, PVOID);
DWORD ssn = GetSyscallNumber(GetProcAddress(GetModuleHandleA("ntdll.dll"),
"NtCreateThreadEx"));
set_ssn(ssn);
indirect_syscall_invoke(/* ... */);MITRE ATT&CK mappings
- T1055Process Injection
- T1055.002Portable Executable Injection
- T1055.012Process Hollowing
- T1620Reflective Code Loading
Last verified: 2026-05-20