DBG: use some typedefs to have cleaner code
This commit is contained in:
parent
540a3cbda0
commit
37850b03f5
|
@ -283,14 +283,14 @@ void AnalysisRunner::emulateInstructions()
|
|||
functionInfo = new FunctionInfo;
|
||||
|
||||
// run through instructions in a linear way - each instruction once
|
||||
std::map<duint, Instruction_t>::iterator it = instructionsCache.begin();
|
||||
InstructionMap::iterator it = instructionsCache.begin();
|
||||
while(it != instructionsCache.end())
|
||||
{
|
||||
// save important values
|
||||
Stack->emulate(&(it->second.BeaStruct));
|
||||
Register->emulate(&(it->second.BeaStruct));
|
||||
|
||||
for(std::vector<ClientInterface*>::iterator itt = interfaces.begin(); itt != interfaces.end(); itt++)
|
||||
for(ClientInterfaceList::iterator itt = interfaces.begin(); itt != interfaces.end(); itt++)
|
||||
{
|
||||
(*itt)->see(it->second, Register, Stack);
|
||||
}
|
||||
|
|
|
@ -16,15 +16,17 @@ class RegisterEmulator;
|
|||
class FunctionInfo;
|
||||
class FlowGraph;
|
||||
|
||||
|
||||
typedef std::set<unknownRegion> UnkownRegionSet;
|
||||
typedef std::map<duint, Instruction_t> InstructionMap;
|
||||
typedef std::vector<ClientInterface*> ClientInterfaceList;
|
||||
|
||||
|
||||
class AnalysisRunner
|
||||
{
|
||||
// we will place all VA here that should be a start address for disassembling
|
||||
std::set< unknownRegion > explorationSpace;
|
||||
UnkownRegionSet explorationSpace;
|
||||
// all known disassemling should be cached
|
||||
std::map<duint, Instruction_t> instructionsCache;
|
||||
InstructionMap instructionsCache;
|
||||
// baseaddress for current thread
|
||||
duint baseAddress;
|
||||
// size of code for security while disassembling
|
||||
|
@ -43,8 +45,8 @@ class AnalysisRunner
|
|||
bool codeWasCopied;
|
||||
|
||||
FunctionDB* DB;
|
||||
ClientInterfaceList interfaces;
|
||||
|
||||
std::vector<ClientInterface*> interfaces;
|
||||
|
||||
StackEmulator* Stack;
|
||||
RegisterEmulator* Register;
|
||||
|
|
|
@ -23,8 +23,8 @@ void FlowGraph::insertEdge(duint startAddress, duint endAddress, EdgeType btype)
|
|||
Node_t* workEnd = new Node_t(endAddress);
|
||||
|
||||
|
||||
std::pair<std::map<duint, Node_t*>::iterator, bool> sn = nodes.insert(std::pair<duint, Node_t*>(startAddress, workStart));
|
||||
std::pair<std::map<duint, Node_t*>::iterator, bool> en = nodes.insert(std::pair<duint, Node_t*>(endAddress, workEnd));
|
||||
std::pair<NodeMap::iterator, bool> sn = nodes.insert(std::pair<duint, Node_t*>(startAddress, workStart));
|
||||
std::pair<NodeMap::iterator, bool> en = nodes.insert(std::pair<duint, Node_t*>(endAddress, workEnd));
|
||||
|
||||
if(!sn.second)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ void FlowGraph::insertEdge(duint startAddress, duint endAddress, EdgeType btype)
|
|||
|
||||
Edge_t* edge = new Edge_t(workStart, workEnd, btype);
|
||||
|
||||
std::pair<std::map<duint, Edge_t*>::iterator, bool> e = edges.insert(std::pair<duint, Edge_t*>(startAddress, edge));
|
||||
std::pair<EdgeMap::iterator, bool> e = edges.insert(std::pair<duint, Edge_t*>(startAddress, edge));
|
||||
|
||||
if(!e.second)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ bool FlowGraph::find(const duint va , Node_t* node)
|
|||
{
|
||||
if(contains(nodes, va))
|
||||
{
|
||||
std::map<duint, Node_t*>::iterator iter = nodes.find(va);
|
||||
NodeMap::iterator iter = nodes.find(va);
|
||||
node = (iter->second);
|
||||
return true;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ Node_t* FlowGraph::node(const duint va)
|
|||
{
|
||||
if(contains(nodes, va))
|
||||
{
|
||||
std::map<duint, Node_t*>::iterator iter = nodes.find(va);
|
||||
NodeMap::iterator iter = nodes.find(va);
|
||||
Node_t* node = (iter->second);
|
||||
return node;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ Node_t* FlowGraph::node(const duint va)
|
|||
|
||||
void FlowGraph::fillNodes()
|
||||
{
|
||||
for(std::map<duint, Node_t*>::iterator i = nodes.begin(); i != nodes.end(); i++)
|
||||
for(NodeMap::iterator i = nodes.begin(); i != nodes.end(); i++)
|
||||
{
|
||||
i->second->hasInstr = true;
|
||||
i->second->instruction = analysis->instruction(i->first);
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
namespace fa
|
||||
{
|
||||
|
||||
|
||||
typedef std::map<duint, Edge_t*> EdgeMap;
|
||||
typedef std::map<duint, Node_t*> NodeMap;
|
||||
|
||||
class FlowGraph
|
||||
{
|
||||
// this class represents the program flow including branches likes JMP, JNE, ... , CALL, RET
|
||||
// all existing edges
|
||||
std::map<duint, Edge_t*> edges;
|
||||
EdgeMap edges;
|
||||
// all existing nodes
|
||||
std::map<duint, Node_t*> nodes;
|
||||
NodeMap nodes;
|
||||
|
||||
AnalysisRunner* analysis;
|
||||
public:
|
||||
|
|
|
@ -7,11 +7,14 @@
|
|||
namespace fa
|
||||
{
|
||||
class Edge_t;
|
||||
|
||||
typedef std::set<Edge_t*> EdgeSet;
|
||||
|
||||
class Node_t
|
||||
{
|
||||
public:
|
||||
Edge_t* outgoing;
|
||||
std::set<Edge_t*> incoming;
|
||||
EdgeSet incoming;
|
||||
|
||||
const Instruction_t* instruction;
|
||||
|
||||
|
|
Loading…
Reference in New Issue