Uninformed: Informative Information for the Uninformed

Vol 7» 2007.May


Implementation

The implementation of the DBI approach is really just as easy as the design description makes it sound. To cooperate with DynamoRIO, an analysis library must implement a well-defined routine named dynamorio_basic_block which is called by DynamoRIO when a fragment is being created. This routine is passed an instruction list which contains the set of instructions taken from the native binary. Using this instruction list, the analysis library can make a determination as to whether or not any of the operands of an instruction either explicitly or implicitly reference memory. If an instruction does access memory, then instrumentation code must be inserted.

Inserting instrumentation code with DynamoRIO is a pretty painless process. DynamoRIO provides a number of macros that encapsulate the process of creating and inserting instructions into the instruction list. For example, INSTR_CREATE_add will create an add instruction with a specific set of arguments and instrlist_meta_preinsert will insert an instruction prior to another instruction within the instruction list.

A proof of concept implementation is included with the source code provided along with this paper.