By

Struct By 

Source
pub struct By<'a, P> { /* private fields */ }
Expand description

Export directory symbol lookup.

Implementations§

Source§

impl<'a, P: Pe<'a>> By<'a, P>

Source

pub fn functions(&self) -> &'a [Rva]

Gets the export address table.

Source

pub fn names(&self) -> &'a [Rva]

Gets the name address table.

The values are RVAs to the exported function’s name, to find its export look at the name index table with the same index.

The names are sorted allowing binary search lookup.

Source

pub fn name_indices(&self) -> &'a [u16]

Gets the name index table.

The values are indices (not ordinals!) into the export address table matching name with the same index in the name address table.

Source

pub fn check_sorted(&self) -> Result<bool>

Validates and checks if the name table is sorted.

The PE specification says that the list of names should be sorted to allow binary search. This function checks if the names table is actually sorted, if not then various name based lookup functions may fail to find certain exports.

Returns an error if a name entry cannot be read or is otherwise corrupt.

Source

pub fn ordinal(&self, ordinal: Ordinal) -> Result<Export<'a>>

Looks up an Export by its ordinal.

Source

pub fn name_linear<S: AsRef<[u8]> + ?Sized>( &self, name: &S, ) -> Result<Export<'a>>

Looks up an Export by its name.

Does a linear scan over the name table. If the name table isn’t sorted this will still be able to find exported functions by name.

Gracefully handles corrupted name entries by ignoring them.

Source

pub fn name<S: AsRef<[u8]> + ?Sized>(&self, name: &S) -> Result<Export<'a>>

Looks up an Export by its name.

If the name table isn’t sorted, certain exported functions may fail to be found.

Source

pub fn import(&self, import: Import<'_>) -> Result<Export<'a>>

Looks up an Export by its import.

Source

pub fn index(&self, index: usize) -> Result<Export<'a>>

Looks up an export by its index.

Source

pub fn hint(&self, hint: usize) -> Result<Export<'a>>

Looks up an export by its hint.

Source

pub fn hint_name<S: AsRef<[u8]> + ?Sized>( &self, hint: usize, name: &S, ) -> Result<Export<'a>>

Looks up an export by its hint and falls back to the name if the hint is incorrect.

Source

pub fn name_of_hint(&self, hint: usize) -> Result<&'a CStr>

Looks up the name for a hint.

Source

pub fn name_lookup(&self, index: usize) -> Result<Import<'a>>

Given an index in the functions array, gets the named export.

Note that this does a linear scan to find its name, if this is called in a loop over all the exported functions you are accidentally quadratic.

See iter_names to iterate over the exported names in linear time.

Source

pub fn iter<'s>( &'s self, ) -> impl 's + Clone + Iterator<Item = Result<Export<'a>>>

Iterate over exported functions.

Not every exported function has a name, some are exported by ordinal. Looking up the exported function’s name with name_lookup results in quadratic performance. If the exported function’s name is important consider building a cache or using iter_names instead.

Source

pub fn iter_names<'s>( &'s self, ) -> impl 's + Clone + Iterator<Item = (Result<&'a CStr>, Result<Export<'a>>)>

Iterate over functions exported by name.

Source

pub fn iter_name_indices<'s>( &'s self, ) -> impl 's + Clone + Iterator<Item = (Result<&'a CStr>, usize)>

Iterate over functions exported by name, returning their name and index in the functions table.

Methods from Deref<Target = Exports<'a, P>>§

Source

pub fn pe(&self) -> P

Gets the PE instance.

Source

pub fn image(&self) -> &'a IMAGE_EXPORT_DIRECTORY

Returns the underlying export directory image.

Source

pub fn dll_name(&self) -> Result<&'a CStr>

Gets the export directory’s name for this library.

Source

pub fn ordinal_base(&self) -> Ordinal

Gets the ordinal base for the exported functions.

Source

pub fn functions(&self) -> Result<&'a [Rva]>

Gets the export address table.

Source

pub fn names(&self) -> Result<&'a [Rva]>

Gets the name address table.

The values are RVAs to the exported function’s name, to find its export look at the name index table with the same index.

The names are sorted allowing binary search lookup.

Source

pub fn name_indices(&self) -> Result<&'a [u16]>

Gets the name index table.

The values are indices (not ordinals!) into the export address table matching name with the same index in the name address table.

Source

pub fn by(&self) -> Result<By<'a, P>>

Query the exports.

This specifically validates whether the functions, names and name indices are valid.

Trait Implementations§

Source§

impl<'a, P: Clone> Clone for By<'a, P>

Source§

fn clone(&self) -> By<'a, P>

Returns a duplicate 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<'a, P: Pe<'a>> Debug for By<'a, P>

Source§

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

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

impl<'a, P: Pe<'a>> Deref for By<'a, P>

Source§

type Target = Exports<'a, P>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Exports<'a, P>

Dereferences the value.
Source§

impl<'a, P: Copy> Copy for By<'a, P>

Auto Trait Implementations§

§

impl<'a, P> Freeze for By<'a, P>
where P: Freeze,

§

impl<'a, P> RefUnwindSafe for By<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for By<'a, P>
where P: Send,

§

impl<'a, P> Sync for By<'a, P>
where P: Sync,

§

impl<'a, P> Unpin for By<'a, P>
where P: Unpin,

§

impl<'a, P> UnwindSafe for By<'a, P>
where P: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.