# NtCreateThreadEx

```csharp
[DllImport("ntdll.dll", ExactSpelling = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
public static extern unsafe NTSTATUS NtCreateThreadEx(
    HANDLE* threadHandle,
    uint desiredAccess,
    [Optional] OBJECT_ATTRIBUTES* objectAttributes,
    HANDLE processHandle,
    USER_THREAD_START_ROUTINE startRoutine,
    [Optional] void* argument,
    uint createFlags,
    nuint zeroBits,
    nuint stackSize,
    nuint maximumStackSize,
    [Optional] PS_ATTRIBUTE_LIST* attributeList);
```

[OBJECT\_ATTRIBUTES](/foundation/object_attributes.md)

[USER\_THREAD\_START\_ROUTINE](/foundation/user_thread_start_routine.md)

[PS\_ATTRIBUTE\_LIST](/foundation/ps_attribute_list.md)

```csharp
// Desired Access
public const uint THREAD_CREATE_FLAGS_CREATE_SUSPENDED = 0x00000001;
public const uint THREAD_CREATE_FLAGS_SKIP_THREAD_ATTACH = 0x00000002;
public const uint THREAD_CREATE_FLAGS_HIDE_FROM_DEBUGGER = 0x00000004;
public const uint THREAD_CREATE_FLAGS_LOADER_WORKER = 0x00000010;
public const uint THREAD_CREATE_FLAGS_SKIP_LOADER_INIT = 0x00000020;
public const uint THREAD_CREATE_FLAGS_BYPASS_PROCESS_FREEZE = 0x00000040;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pinvoke.dev/ntdll/ntcreatethreadex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
