pub fn protection_guard<T>(
    address: *mut (),
    size: usize,
    protection: MemoryProtection,
    callback: impl FnOnce() -> T
) -> T
Expand description

Protects memory of given size with new protection, calls callback and then restores previous protection.

Panics

  • Can not protect memory.
  • Can not restore previous protection.
  • Previous protection can not be represented with [MemoryProtection].