# NtCreateSection

```csharp
[DllImport("ntdll.dll", ExactSpelling = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
public static extern unsafe NTSTATUS NtCreateSection(
    HANDLE* SectionHandle,
    uint DesiredAccess,
    [Optional] OBJECT_ATTRIBUTES* ObjectAttributes,
    [Optional] long* MaximumSize,
    uint SectionPageProtection,
    uint AllocationAttributes,
    [Optional] HANDLE FileHandle);
```

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

[PAGE\_PROTECTION\_FLAGS](/memory/page_protection_flags.md)

```csharp
// DesiredAccess
public const int SECTION_QUERY = 1;
public const int SECTION_MAP_WRITE = 2;
public const int SECTION_MAP_READ = 4;
public const int SECTION_MAP_EXECUTE = 8;
public const int SECTION_EXTEND_SIZE = 16;
public const int SECTION_MAP_EXECUTE_EXPLICIT = 32;

public const uint SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
                                       SECTION_MAP_WRITE | SECTION_MAP_READ |
                                       SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE;
```

```csharp
// AllocationAttributes
public const uint SEC_COMMIT = 0x8000000;
public const uint SEC_IMAGE = 0x1000000;
public const uint SEC_IMAGE_NO_EXECUTE = 0x11000000;
public const uint SEC_LARGE_PAGES = 0x80000000;
public const uint SEC_NOCACHE = 0x10000000;
public const uint SEC_RESERVE = 0x4000000;
public const uint SEC_WRITECOMBINE = 0x40000000;
```


---

# 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/ntcreatesection.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.
