A Rust library for dealing with memory regions.
It is implemented using platform specific APIs (e.g VirtualQuery
,
VirtualLock
, mprotect
, mlock
).
This library provides CI for the following targets:
aarch64-linux-android
armv7-unknown-linux-gnueabihf
i686-unknown-linux-gnu
x86_64-unknown-linux-gnu
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-apple-darwin
x86_64-unknown-freebsd
Add this to your Cargo.toml
:
toml
[dependencies]
region = "2.2.0"
and this to your crate root:
rust
extern crate region;
// Page size let pz = region::page::size(); let pc = region::page::ceil(1234); let pf = region::page::floor(1234);
// VirtualQuery | '/proc/self/maps' let q = region::query(data.asptr())?; let qr = region::queryrange(data.as_ptr(), data.len())?;
// VirtualProtect | mprotect region::protect(data.asptr(), data.len(), Protection::READWRITE_EXECUTE)?;
// ... you can also temporarily change a region's protection let handle = region::protectwithhandle(data.asptr(), data.len(), Protection::READWRITE_EXECUTE)?;
// VirtualLock | mlock let guard = region::lock(data.as_ptr(), data.len())?; ```