pub struct LibMappings<T> { /* private fields */ }
Expand description

Keeps track of mapped libraries in an address space. Stores a value for each mapping, and allows efficient lookup of that value based on an address.

Implementations§

source§

impl<T> LibMappings<T>

source

pub fn new() -> Self

Creates a new empty instance.

source

pub fn add_mapping( &mut self, start_avma: u64, end_avma: u64, relative_address_at_start: u32, value: T )

Add a mapping to this address space. Any existing mappings which overlap with the new mapping are removed.

start_avma and end_avma describe the address range that this mapping occupies.

AVMA = “actual virtual memory address”

relative_address_at_start is the “relative address” which corresponds to start_avma, in the library that is mapped in this mapping. This is zero if start_avm is the base address of the library.

A relative address is a u32 value which is relative to the library base address. So you will usually set relative_address_at_start to start_avma - base_avma.

For ELF binaries, the base address is the AVMA of the first segment, i.e. the start_avma of the mapping created by the first ELF LOAD command.

For mach-O binaries, the base address is the vmaddr of the __TEXT segment.

For Windows binaries, the base address is the image load address.

source

pub fn remove_mapping(&mut self, start_avma: u64) -> Option<(u32, T)>

Remove a mapping which starts at the given address. If found, this returns the relative_address_at_start and the associated value of the mapping.

source

pub fn clear(&mut self)

Clear all mappings.

source

pub fn convert_address(&self, avma: u64) -> Option<(u32, &T)>

Converts an absolute address (AVMA, actual virtual memory address) into a relative address and the mapping’s associated value.

Trait Implementations§

source§

impl<T: Clone> Clone for LibMappings<T>

source§

fn clone(&self) -> LibMappings<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for LibMappings<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for LibMappings<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for LibMappings<T>where T: RefUnwindSafe,

§

impl<T> Send for LibMappings<T>where T: Send,

§

impl<T> Sync for LibMappings<T>where T: Sync,

§

impl<T> Unpin for LibMappings<T>where T: Unpin,

§

impl<T> UnwindSafe for LibMappings<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.