Struct mmap_rs::MemoryArea
source · pub struct MemoryArea { /* private fields */ }
Expand description
Describes a memory area of a process.
Implementations§
source§impl MemoryArea
impl MemoryArea
sourcepub fn start(&self) -> usize
pub fn start(&self) -> usize
The start address of the area.
Examples found in repository?
examples/areas.rs (line 10)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
sourcepub fn end(&self) -> usize
pub fn end(&self) -> usize
The end address of the area.
Examples found in repository?
examples/areas.rs (line 11)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
sourcepub fn protection(&self) -> Protection
pub fn protection(&self) -> Protection
The protection with which the memory area has been mapped.
Examples found in repository?
examples/areas.rs (line 12)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
The share mode of the memory area.
Examples found in repository?
examples/areas.rs (line 27)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
sourcepub fn path(&self) -> Option<&PathBuf>
pub fn path(&self) -> Option<&PathBuf>
The path to the file that backs this memory area, if backed by a file.
Examples found in repository?
examples/areas.rs (line 34)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
sourcepub fn file_offset(&self) -> Option<u64>
pub fn file_offset(&self) -> Option<u64>
The file offset, if backed by a file.
Examples found in repository?
examples/areas.rs (line 33)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn main() -> Result<(), Error> {
let maps = MemoryAreas::open(None)?;
for area in maps {
let area = area?;
println!("{:x}-{:x} {}{}{}{}{}",
area.start(),
area.end(),
if area.protection().contains(Protection::READ) {
"r"
} else {
"-"
},
if area.protection().contains(Protection::WRITE) {
"w"
} else {
"-"
},
if area.protection().contains(Protection::EXECUTE) {
"x"
} else {
"-"
},
if area.share_mode() == ShareMode::Shared {
"s"
} else {
"p"
},
format!(" {:x} {}",
area.file_offset().unwrap_or(0),
area.path().map(|path| path.display().to_string()).unwrap_or(String::new()),
),
);
}
Ok(())
}
Trait Implementations§
source§impl Clone for MemoryArea
impl Clone for MemoryArea
source§fn clone(&self) -> MemoryArea
fn clone(&self) -> MemoryArea
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more