DynamoRIO API
module_mapper_t Class Referencefinal

#include <raw2trace.h>

Public Member Functions

std::string get_last_error (void) const
 
const std::vector< module_t > & get_loaded_modules ()
 
app_pc find_mapped_trace_address (app_pc trace_address)
 
app_pc find_mapped_trace_bounds (app_pc trace_address, OUT app_pc *module_start, OUT size_t *module_size)
 
 ~module_mapper_t ()
 

Static Public Member Functions

static std::unique_ptr< module_mapper_tcreate (const char *module_map_in, const char *(*parse_cb)(const char *src, OUT void **data)=nullptr, std::string(*process_cb)(drmodtrack_info_t *info, void *data, void *user_data)=nullptr, void *process_cb_user_data=nullptr, void(*free_cb)(void *data)=nullptr, uint verbosity_in=0)
 

Detailed Description

module_mapper_t maps and unloads application modules. Using it assumes a dr_context has already been setup. This class is not thread-safe.

Constructor & Destructor Documentation

◆ ~module_mapper_t()

module_mapper_t::~module_mapper_t ( )

Unload modules loaded with read_and_map_modules(), freeing associated resources.

Member Function Documentation

◆ create()

static std::unique_ptr<module_mapper_t> module_mapper_t::create ( const char *  module_map_in,
const char *(*)(const char *src, OUT void **data)  parse_cb = nullptr,
std::string(*)(drmodtrack_info_t *info, void *data, void *user_data)  process_cb = nullptr,
void *  process_cb_user_data = nullptr,
void(*)(void *data)  free_cb = nullptr,
uint  verbosity_in = 0 
)
inlinestatic

Parses and iterates over the list of modules. This is provided to give the user a method for iterating modules in the presence of the custom field used by drmemtrace that prevents direct use of drmodtrack_offline_read(). Its parsing of the module data will invoke parse_cb, which should advance the module data pointer passed in src and return it as its return value (or nullptr on error), returning the resulting parsed data in data. The data pointer will afterwards be passed to both process_cb, which can update the module path inside info (and return a non-empty string on error), and free_cb, which can perform cleanup.

The callbacks will only be called during object construction.

On success, calls the process_cb function for every module in the list. On failure, get_last_error() is non-empty, and indicates the cause.

◆ find_mapped_trace_address()

app_pc module_mapper_t::find_mapped_trace_address ( app_pc  trace_address)

This interface is meant to be used with a final trace rather than a raw trace, using the module log file saved from the raw2trace conversion. After the a call to get_loaded_modules(), this routine may be used to convert an instruction program counter in a trace into an address in the current process where the instruction bytes for that instruction are mapped, allowing decoding for obtaining further information than is stored in the trace. Returns the mapped address. Check get_last_error() if an error occurred.

◆ find_mapped_trace_bounds()

app_pc module_mapper_t::find_mapped_trace_bounds ( app_pc  trace_address,
OUT app_pc *  module_start,
OUT size_t *  module_size 
)

This is identical to find_mapped_trace_address() but it also returns the bounds of the containing region, allowing the caller to perform its own mapping for any address that is also within those bounds.

◆ get_last_error()

std::string module_mapper_t::get_last_error ( void  ) const
inline

All APIs on this type, including constructor, may fail. get_last_error() returns the last error message. The object should be considered unusable if !get_last_error().empty().

◆ get_loaded_modules()

const std::vector<module_t>& module_mapper_t::get_loaded_modules ( )
inline

module_t vector corresponding to the application modules. Lazily loads and caches modules. If the object is invalid, returns an empty vector. The user may check get_last_error() to ensure no error has occurred, or get the applicable error message.


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