Expand description
Queries the OS with an address, returning the region it resides within.
The implementation uses VirtualQuery
on Windows, mach_vm_region
on macOS,
kinfo_getvmmap
on FreeBSD, and parses proc/[pid]/maps
on Linux.
- The enclosing region can be of multiple page sizes.
- The address is rounded down to the closest page boundary.
- The address may not be null.
Examples
use region::{Protection};
let data = [0; 100];
let region = region::query(data.as_ptr()).unwrap();
assert_eq!(region.protection, Protection::READ_WRITE);