VirtualAllocEx function kernel32

Win32Result<Pointer<NativeType>> VirtualAllocEx(
  1. HANDLE hProcess,
  2. Pointer<NativeType>? lpAddress,
  3. int dwSize,
  4. VIRTUAL_ALLOCATION_TYPE flAllocationType,
  5. PAGE_PROTECTION_FLAGS flProtect,
)

Reserves, commits, or changes the state of a region of memory within the virtual address space of a specified process.

The function initializes the memory it allocates to zero.

To learn more, see learn.microsoft.com/windows/win32/api/memoryapi/nf-memoryapi-virtualallocex.

Implementation

Win32Result<Pointer> VirtualAllocEx(
  HANDLE hProcess,
  Pointer? lpAddress,
  int dwSize,
  VIRTUAL_ALLOCATION_TYPE flAllocationType,
  PAGE_PROTECTION_FLAGS flProtect,
) {
  final result_ = VirtualAllocEx_Wrapper(
    hProcess,
    lpAddress ?? nullptr,
    dwSize,
    flAllocationType,
    flProtect,
  );
  return Win32Result(value: result_.value.ptr, error: result_.error);
}