pub struct MemoryMap { /* private fields */ }Expand description
Memory map object
Implementations§
Source§impl MemoryMap
impl MemoryMap
Sourcepub unsafe fn snapshot() -> Result<Self, SpfError>
pub unsafe fn snapshot() -> Result<Self, SpfError>
Returns a snapshot of a current system memory map.
§Details
Gets a physical memory ranges for current system, and builds a translation map.
Translation map usually consist of around 1 million entries (this depents on amount of phyiscal memory available on your system), so the building may take some time and consume a significant amount of memory, consider it when using.
Also if you perform a lot of snapshot, make shure to drop the memory map right after you done with it.
§Note
Memory maps may become invalid after some time, so I recommend you to take a snapshot right before the VA to PA translation.
Sourcepub fn ranges(&self) -> Vec<MemoryRange>
pub fn ranges(&self) -> Vec<MemoryRange>
Return memory ranges Vec<MemoryRange>
Sourcepub fn translations(&self) -> HashMap<LPVOID, u64>
pub fn translations(&self) -> HashMap<LPVOID, u64>
Return translations HashMap<LPVOID, u64>
Sourcepub fn translate(&self, address: LPVOID) -> Result<u64, SpfError>
pub fn translate(&self, address: LPVOID) -> Result<u64, SpfError>
Translate a virtual address to a physical address
§Description
Translates memory vitrual address to physical one, using the tranlsation map from the snapshot made.
§Example usage
let some_va: LPVOID = //...some virtual address
let some_pa = match mm.translate(some_va) {
Ok(p) => p,
Err(e: SpfError) => {
//...do something about the error
}
};