pub unsafe fn protect_with_handle(
    address: *const u8,
    size: usize,
    protection: Protection
) -> Result<ProtectGuard>
Expand description

Changes the memory protection of one or more pages temporarily.

The address range may overlap one or more pages, and if so, all pages within the range will be modified. The protection flags will be reset when the handle is dropped.

This function uses query_range internally and is therefore less performant than protect. Prefer this function only if a memory protection reset is desired.

  • The range is [address, address + size)
  • The address may not be null.
  • The address is rounded down to the closest page boundary.
  • The size may not be zero.
  • The size is rounded up to the closest page boundary, relative to the address.

Safety

This is unsafe since it can change read-only properties of constants and/or modify the executable properties of any code segments.