pub struct MapRange {
pub offset: usize,
pub dev: String,
pub flags: String,
pub inode: usize,
/* private fields */
}
Expand description
A struct representing a single virtual memory region.
While this structure is only for Linux, the macOS, Windows, and FreeBSD variants have identical exposed methods
Fields§
§offset: usize
§dev: String
§flags: String
§inode: usize
Implementations§
Source§impl MapRange
impl MapRange
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of this MapRange in bytes
Examples found in repository?
examples/print_maps.rs (line 26)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Sourcepub fn start(&self) -> usize
pub fn start(&self) -> usize
Returns the address this MapRange starts at
Examples found in repository?
examples/print_maps.rs (line 26)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Sourcepub fn filename(&self) -> Option<&Path>
pub fn filename(&self) -> Option<&Path>
Returns the filename of the loaded module
Examples found in repository?
examples/print_maps.rs (line 23)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Sourcepub fn is_exec(&self) -> bool
pub fn is_exec(&self) -> bool
Returns whether this range contains executable code
Examples found in repository?
examples/print_maps.rs (line 22)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Sourcepub fn is_write(&self) -> bool
pub fn is_write(&self) -> bool
Returns whether this range contains writeable memory
Examples found in repository?
examples/print_maps.rs (line 21)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Sourcepub fn is_read(&self) -> bool
pub fn is_read(&self) -> bool
Returns whether this range contains readable memory
Examples found in repository?
examples/print_maps.rs (line 20)
3fn main() {
4 let args: Vec<String> = std::env::args().collect();
5
6 let pid = if args.len() > 1 {
7 args[1].parse().expect("invalid pid")
8 } else {
9 panic!("Usage: print_maps <PID>");
10 };
11
12 println!(
13 "{:^30} {:^16} {:^7} {}",
14 "ADDRESSES", "SIZE", "MODES", "PATH"
15 );
16
17 let empty_path = std::path::Path::new("");
18 let maps = proc_maps::get_process_maps(pid).expect("failed to get proc maps");
19 for map in maps {
20 let r_flag = if map.is_read() { "R" } else { "-" };
21 let w_flag = if map.is_write() { "W" } else { "-" };
22 let x_flag = if map.is_exec() { "X" } else { "-" };
23 let filename = map.filename().unwrap_or(empty_path).to_str().unwrap_or("-");
24 println!(
25 "{:>30} {:>16} [{} {} {}] {}",
26 format!("{:#x}-{:#x}", map.start(), map.start() + map.size()),
27 map.size(),
28 r_flag,
29 w_flag,
30 x_flag,
31 filename,
32 );
33 }
34}
Trait Implementations§
impl StructuralPartialEq for MapRange
Auto Trait Implementations§
impl Freeze for MapRange
impl RefUnwindSafe for MapRange
impl Send for MapRange
impl Sync for MapRange
impl Unpin for MapRange
impl UnwindSafe for MapRange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more