VirtualProtect function kernel32

Win32Result<bool> VirtualProtect(
  1. Pointer<NativeType> lpAddress,
  2. int dwSize,
  3. PAGE_PROTECTION_FLAGS flNewProtect,
  4. Pointer<Uint32> lpflOldProtect,
)

Changes the protection on a region of committed pages in the virtual address space of the calling process.

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

Implementation

Win32Result<bool> VirtualProtect(
  Pointer lpAddress,
  int dwSize,
  PAGE_PROTECTION_FLAGS flNewProtect,
  Pointer<Uint32> lpflOldProtect,
) {
  final result_ = VirtualProtect_Wrapper(
    lpAddress,
    dwSize,
    flNewProtect,
    lpflOldProtect,
  );
  return Win32Result(value: result_.value.i32 != FALSE, error: result_.error);
}