Expand description
A library for manipulating memory regions
This crate provides several functions for handling memory pages and regions. It is implemented using platform specific APIs. The library exposes both low and high level functionality for manipulating pages.
Not all OS specific quirks are abstracted away. For instance; some OSs enforce memory pages to be readable whilst other may prevent pages from becoming executable (i.e DEP).
Note: a region is a collection of one or more pages laying consecutively in memory, with the same properties.
Installation
This crate is on crates.io and can be
used by adding region
to your dependencies in your project’s Cargo.toml
.
[dependencies]
region = "1.0"
and this to your crate root:
extern crate region;
Examples
-
Cross-platform equivalents.
let ret5 = [0xB8, 0x05, 0x00, 0x00, 0x00, 0xC3]; // 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(ret5.as_ptr())?; let qr = region::query_range(ret5.as_ptr(), ret5.len())?; // VirtualProtect | mprotect region::protect(ret5.as_ptr(), ret5.len(), Protection::ReadWriteExecute)?; // VirtualLock | mlock let guard = region::lock(ret5.as_ptr(), ret5.len())?;
Modules
Page related functions.
Structs
An RAII implementation of a “scoped lock”. When this structure is dropped
(falls out of scope), the virtual lock will be unlocked.
Memory page protection constants.
A descriptor for a memory region
Enums
A collection of possible errors.
Functions
Locks one or more memory regions to RAM.
Changes the memory protection of one or more pages.
Queries the OS with an address, returning the region it resides within.
Queries the OS with a range, returning the regions it contains.
Unlocks one or more memory regions from RAM.
Type Definitions
The result type used by this library.