Skip to main content

procmod_core/
region.rs

1/// A contiguous region of virtual memory in a process.
2#[derive(Debug, Clone)]
3pub struct MemoryRegion {
4    /// Base address of the region.
5    pub base: usize,
6
7    /// Size of the region in bytes.
8    pub size: usize,
9
10    /// Memory protection flags.
11    pub protection: Protection,
12}
13
14/// Memory protection flags for a region.
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub struct Protection {
17    pub read: bool,
18    pub write: bool,
19    pub execute: bool,
20}
21
22impl std::fmt::Display for Protection {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        write!(
25            f,
26            "{}{}{}",
27            if self.read { "r" } else { "-" },
28            if self.write { "w" } else { "-" },
29            if self.execute { "x" } else { "-" },
30        )
31    }
32}