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