pub struct By<'a, P> { /* private fields */ }
Expand description
Export directory symbol lookup.
Implementations
sourceimpl<'a, P: Pe<'a>> By<'a, P>
impl<'a, P: Pe<'a>> By<'a, P>
sourcepub fn names(&self) -> &'a [Rva]
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.
sourcepub fn name_indices(&self) -> &'a [u16]
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.
sourcepub fn check_sorted(&self) -> Result<bool>
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.
sourcepub fn ordinal(&self, ordinal: Ordinal) -> Result<Export<'a>>
pub fn ordinal(&self, ordinal: Ordinal) -> Result<Export<'a>>
Looks up an Export
by its ordinal.
sourcepub fn name_linear<S: AsRef<[u8]> + ?Sized>(
&self,
name: &S
) -> Result<Export<'a>>
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.
sourcepub fn name<S: AsRef<[u8]> + ?Sized>(&self, name: &S) -> Result<Export<'a>>
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.
sourcepub fn import(&self, import: Import<'_>) -> Result<Export<'a>>
pub fn import(&self, import: Import<'_>) -> Result<Export<'a>>
Looks up an Export
by its import.
sourcepub fn hint_name<S: AsRef<[u8]> + ?Sized>(
&self,
hint: usize,
name: &S
) -> Result<Export<'a>>
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.
sourcepub fn name_of_hint(&self, hint: usize) -> Result<&'a CStr>
pub fn name_of_hint(&self, hint: usize) -> Result<&'a CStr>
Looks up the name for a hint.
sourcepub fn name_lookup(&self, index: usize) -> Result<Import<'a>>
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.
sourcepub fn iter<'s>(
&'s self
) -> impl 's + Clone + Iterator<Item = Result<Export<'a>>>
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.
Methods from Deref<Target = Exports<'a, P>>
sourcepub fn image(&self) -> &'a IMAGE_EXPORT_DIRECTORY
pub fn image(&self) -> &'a IMAGE_EXPORT_DIRECTORY
Returns the underlying export directory image.
sourcepub fn ordinal_base(&self) -> Ordinal
pub fn ordinal_base(&self) -> Ordinal
Gets the ordinal base for the exported functions.
sourcepub fn names(&self) -> Result<&'a [Rva]>
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.
sourcepub fn name_indices(&self) -> Result<&'a [u16]>
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.