MemoryMap

Struct MemoryMap 

Source
pub struct MemoryMap { /* private fields */ }
Expand description

Memory map object

Implementations§

Source§

impl MemoryMap

Source

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.

Source

pub fn ranges(&self) -> Vec<MemoryRange>

Return memory ranges Vec<MemoryRange>

Source

pub fn translations(&self) -> HashMap<LPVOID, u64>

Return translations HashMap<LPVOID, u64>

Source

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  
    }
};

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.