Kernel32VirtualAllocExNuma(IntPtr, UIntPtr, UIntPtr, MemoryAllocationType, MemoryProtectionOptions, UInt32) Method

Reserves, commits, or changes the state of a region of memory within the virtual address space of the specified process, and specifies the NUMA node for the physical memory.

The function initializes the memory it allocates to zero.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", ExactSpelling = true, SetLastError = true)]
public static UIntPtr VirtualAllocExNuma(
	IntPtr hProcess,
	UIntPtr address,
	UIntPtr size,
	MemoryAllocationType allocationType,
	MemoryProtectionOptions protection,
	uint nndPreferred
)

Parameters

hProcess  IntPtr
The handle to a process.

The function allocates memory within the virtual address space of this process.

The handle must have the VirtualMemoryOperation access right

address  UIntPtr
The pointer that specifies a desired starting address for the region of pages that you want to allocate.

If you are reserving memory, the function rounds this address down to the nearest multiple of the allocation granularity.

If you are committing memory that is already reserved, the function rounds this address down to the nearest page boundary.

To determine the size of a page and the allocation granularity on the host computer, use the GetSystemInfo function.

If address is Zero, the function determines where to allocate the region.

size  UIntPtr
The size of the region of memory to allocate, in bytes.

If address is Zero, the function rounds size up to the next page boundary.

If address is not Zero, the function allocates all pages that contain one or more bytes in the range from address to address+size. This means, for example, that a 2-byte range that straddles a page boundary causes the function to allocate both pages.

allocationType  MemoryAllocationType
The type of memory allocation.
protection  MemoryProtectionOptions
The memory protection for the region of pages to be allocated.

Protection attributes specified when protecting a page cannot conflict with those specified when allocating a page.

nndPreferred  UInt32
The NUMA node where the physical memory should reside.

Used only when allocating a new virtual address (VA) region (either committed or reserved). Otherwise this parameter is ignored when the API is used to commit pages in a region that already exists.

Return Value

UIntPtr
If the function succeeds, the return value is the base address of the allocated region of pages.

If the function fails, the return value is Zero.

To get extended error information, call GetLastWin32Error.

Remarks

See Also