# VirtualAllocEx

```csharp
[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
public static extern unsafe void* VirtualAllocEx(
    HANDLE hProcess,
    [Optional] void* lpAddress,
    nuint dwSize,
    VIRTUAL_ALLOCATION_TYPE flAllocationType,
    PAGE_PROTECTION_FLAGS flProtect);
```

[virtual\_allocation\_type](https://www.pinvoke.dev/memory/virtual_allocation_type "mention")

[page\_protection\_flags](https://www.pinvoke.dev/memory/page_protection_flags "mention")
