MCPcopy Index your code
hub / github.com/darfink/region-rs

github.com/darfink/region-rs @v3.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.2 ↗ · + Follow
145 symbols 323 edges 17 files 6 documented · 4% updated 2y ago★ 1405 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

region-rs

Cross-platform virtual memory API

GitHub CI Status crates.io version Documentation License

This crate provides a cross-platform Rust API for allocating, querying and manipulating virtual memory. It is a thin abstraction, with the underlying interaction implemented using platform specific APIs (e.g VirtualQuery, VirtualAlloc, VirtualLock, mprotect, mmap, mlock).

Platforms

This library is continuously tested against these targets:

  • Linux
  • aarch64-linux-android
  • armv7-unknown-linux-gnueabihf
  • i686-unknown-linux-gnu
  • mips-unknown-linux-gnu
  • x86_64-unknown-linux-gnu
  • x86_64-unknown-linux-musl
  • Windows
  • i686-pc-windows-gnu
  • i686-pc-windows-msvc
  • x86_64-pc-windows-gnu
  • x86_64-pc-windows-msvc
  • macOS
  • x86_64-apple-darwin
  • NetBSD
  • x86_64-unknown-netbsd
  • FreeBSD
  • x86_64-unknown-freebsd
  • OpenBSD
  • x86_64-unknown-openbsd

... and continuously checked against these targets:

  • Illumos
  • x86_64-unknown-illumos

Beyond the aformentioned target triplets, the library is also expected to work against a multitude of omitted architectures.

Installation

Add this to your Cargo.toml:

[dependencies]
region = "3.0.2"

Example

  • Cross-platform equivalents:
let data = [0xDE, 0xAD, 0xBE, 0xEF];

// Page size
let pz = region::page::size();

// VirtualQuery | '/proc/self/maps'
let q  = region::query(data.as_ptr())?;
let qr = region::query_range(data.as_ptr(), data.len())?;

// VirtualAlloc | mmap
let alloc = region::alloc(100, Protection::READ_WRITE)?;

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

// ... you can also temporarily change one or more pages' protection
let handle = region::protect_with_handle(data.as_ptr(), data.len(), Protection::READ_WRITE_EXECUTE)?;

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

Core symbols most depended-on inside this repo

size
called by 33
src/page.rs
as_ptr
called by 17
src/lib.rs
alloc_pages
called by 10
src/lib.rs
query_range
called by 10
src/query.rs
round_to_page_boundaries
called by 8
src/util.rs
alloc
called by 8
src/alloc.rs
len
called by 7
src/lib.rs
query
called by 7
src/query.rs

Shape

Function 64
Method 64
Class 16
Enum 1

Languages

Rust100%

Modules by API surface

src/lib.rs23 symbols
src/alloc.rs16 symbols
src/query.rs14 symbols
src/os/windows.rs13 symbols
src/protect.rs11 symbols
src/os/unix.rs9 symbols
src/os/netbsd.rs8 symbols
src/os/linux.rs8 symbols
src/os/openbsd.rs7 symbols
src/os/illumos.rs7 symbols
src/os/freebsd.rs7 symbols
src/lock.rs7 symbols

For agents

$ claude mcp add region-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact