PStack  2.0
Stack trace printer for MSVC and GCC binaries
psystem::dll_export_iterator Class Reference

Iterator type for Windows Dynamic Link-Library (DLL) exports. More...

#include <dll_export_iterator.hpp>

Construction / Destruction

 dll_export_iterator (uint8_t const *base_address, integral_address_t const va_offset, uint16_t const index, uint32_t const *export_rva, uint16_t const *idx_with_name, uint32_t const *export_name_rva) noexcept
 Construct an instance of this DLL export iterator. More...
 

Basic Iterator Interface and Random Access Iterator Interface

dll_export_iteratoroperator++ ()
 Prefix increment. More...
 
bool operator== (dll_export_iterator const &other) const
 Determine the equality of two instances. More...
 
bool operator!= (dll_export_iterator const &other) const
 Determine the inequality of two instances. More...
 

Extra Accessors

char const * get_export_name () const
 Retrieve the name of the current exported symbol. More...
 

Member Data

uint8_t const * m_base_address
 Address to the memory-mapped DLL image.
 
integral_address_t m_va_offset
 Offset required to translate the virtual address to a raw data pointer.
 
uint16_t const * m_idx_with_name
 Pointer in the array of export indices that have names. More...
 
uint16_t m_current_idx
 Index to the current exported symbol.
 
uint32_t const * m_export_rva
 Pointer to the array of addresses of the exported symbols. More...
 
uint32_t const * m_export_name_rva
 Pointer to the array of exported symbol names. More...
 

Detailed Description

Iterator type for Windows Dynamic Link-Library (DLL) exports.

Windows DLLs maintain their exported symbols in a "directory" of exports. In order to get names, this information must be correlated with a separate location. Because of these computations (and others), this "iterator" is not a true iterator, and cannot currently expose an operator*(). There is no single collection with all the required information, so such an operator would have to create an instance to hold the result, which defeats the purpose of having an iterator in my view (it should simply abstract access to something that exists in a container, rather than creating new instances to be accessed).

Author
Matt Bisson
Date
8 February, 2015
Since
PSystem 2.0
Version
PSystem 2.0
Todo:

Beef up this interface! It's really just the minimal set of what I use today.

Hide the public member data – this is a temporary hack for time.

Figure out how this could possibly be a "regular" iterator.

Constructor & Destructor Documentation

psystem::dll_export_iterator::dll_export_iterator ( uint8_t const *  base_address,
integral_address_t const  va_offset,
uint16_t const  index,
uint32_t const *  export_rva,
uint16_t const *  idx_with_name,
uint32_t const *  export_name_rva 
)
noexcept

Construct an instance of this DLL export iterator.

Parameters
[in]base_addressAddress to the memory-mapped DLL image.
[in]va_offsetOffset required to translate the virtual address to a raw data pointer.
[in]indexIndex to the current exported symbol.
[in]export_rvaPointer to the array of addresses of the exported symbols.
[in]idx_with_namePointer in the array of export indices (that have names).
[in]export_name_rvaPointer to the array of exported symbol names.
Todo:
Add ASSERTions here.

Member Function Documentation

char const* psystem::dll_export_iterator::get_export_name ( ) const
inline

Retrieve the name of the current exported symbol.

Returns
This method always returns the name, as un-named symbols are skipped
bool psystem::dll_export_iterator::operator!= ( dll_export_iterator const &  other) const

Determine the inequality of two instances.

Parameters
[in]otherThe instance to compare against this for non-equivalence.
Returns
false if both this and other examine the same location in the same container; true in all other cases.
psystem::dll_export_iterator & psystem::dll_export_iterator::operator++ ( )

Prefix increment.

Simply advance the iterator to the next position.

Returns
A reference to the current iterator.
bool psystem::dll_export_iterator::operator== ( dll_export_iterator const &  other) const

Determine the equality of two instances.

Parameters
[in]otherThe instance to compare against this for equivalence.
Returns
true if both this and other examine the same location in the same container; false in all other cases.

Member Data Documentation

uint32_t const* psystem::dll_export_iterator::m_export_name_rva

Pointer to the array of exported symbol names.

The array pointed to by this member contains the list of relative virtual addresses that point to the names of exported symbols. The array pointed to by m_idx_with_name indicates the indices associated with the names. There is not a 1:1 mapping between exported symbols and the list of names, as not all symbols have names. Addresses are relative to the virtual address of the "raw data" segment of the current (export table) section.

uint32_t const* psystem::dll_export_iterator::m_export_rva

Pointer to the array of addresses of the exported symbols.

The array pointed to by this member contains a list of the starting address of all the exported symbols from the DLL. Addresses are relative virtual addresses (RVA) that are relative to the starting virtual address of the .code segment.

uint16_t const* psystem::dll_export_iterator::m_idx_with_name

Pointer in the array of export indices that have names.

The array being pointed to by this member contains a list of indices for exported DLL symbols that have function-names. The array is sorted in ascending order.


The documentation for this class was generated from the following files: