region

Azure build Status Cirrus build status crates.io version Documentation Language (Rust)

A Rust library for dealing with memory regions.

It is implemented using platform specific APIs (e.g VirtualQuery, VirtualLock, mprotect, mlock).

Platforms

This library has (so far) support for: - Windows - Linux & Android - macOS & iOS - FreeBSD

Installation

Add this to your Cargo.toml:

toml [dependencies] region = "2.1.1"

and this to your crate root:

rust extern crate region;

Example

// 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.asptr())?; let qr = region::queryrange(ret5.as_ptr(), ret5.len())?;

// VirtualProtect | mprotect region::protect(ret5.as_ptr(), ret5.len(), Protection::ReadWriteExecute)?;

// ... you can also temporarily change a region's protection let handle = region::protectwithhandle(ret5.as_ptr(), ret5.len(), Protection::ReadWriteExecute)?;

// VirtualLock | mlock let guard = region::lock(ret5.as_ptr(), ret5.len())?; ```