DBG: various fixes in RecursiveAnalysis
This commit is contained in:
parent
79cdced6fe
commit
e24d8c21a3
|
@ -33,6 +33,8 @@ void RecursiveAnalysis::SetMarkers()
|
||||||
duint icount = 0;
|
duint icount = 0;
|
||||||
for(const auto & node : function.nodes)
|
for(const auto & node : function.nodes)
|
||||||
{
|
{
|
||||||
|
if(!inRange(node.second.start))
|
||||||
|
continue;
|
||||||
icount += node.second.icount;
|
icount += node.second.icount;
|
||||||
start = min(node.second.start, start);
|
start = min(node.second.start, start);
|
||||||
end = max(node.second.end, end);
|
end = max(node.second.end, end);
|
||||||
|
@ -64,11 +66,18 @@ void RecursiveAnalysis::analyzeFunction(duint entryPoint)
|
||||||
{
|
{
|
||||||
auto start = queue.front();
|
auto start = queue.front();
|
||||||
queue.pop();
|
queue.pop();
|
||||||
if(visited.count(start) || !inRange(start)) //already visited or out of range
|
if(visited.count(start)) //already visited
|
||||||
continue;
|
continue;
|
||||||
visited.insert(start);
|
visited.insert(start);
|
||||||
|
|
||||||
CFNode node(graph.entryPoint, start, start);
|
CFNode node(graph.entryPoint, start, start);
|
||||||
|
|
||||||
|
if(!inRange(start)) //out of range
|
||||||
|
{
|
||||||
|
graph.AddNode(node);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
node.icount++;
|
node.icount++;
|
||||||
|
@ -151,7 +160,7 @@ void RecursiveAnalysis::analyzeFunction(duint entryPoint)
|
||||||
addr += size;
|
addr += size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//third pass: correct the parents + add brtrue and brfalse to the exits
|
//third pass: correct the parents + add brtrue and brfalse to the exits + get data
|
||||||
graph.parents.clear();
|
graph.parents.clear();
|
||||||
for(auto & nodeIt : graph.nodes)
|
for(auto & nodeIt : graph.nodes)
|
||||||
{
|
{
|
||||||
|
@ -162,6 +171,14 @@ void RecursiveAnalysis::analyzeFunction(duint entryPoint)
|
||||||
node.exits.push_back(node.brtrue);
|
node.exits.push_back(node.brtrue);
|
||||||
if(node.brfalse)
|
if(node.brfalse)
|
||||||
node.exits.push_back(node.brfalse);
|
node.exits.push_back(node.brfalse);
|
||||||
|
if(node.brtrue && !node.brfalse)
|
||||||
|
node.brtrue = 0;
|
||||||
|
if(!node.icount)
|
||||||
|
continue;
|
||||||
|
auto size = node.end - node.start + (mCp.Disassemble(node.end, translateAddr(node.end)) ? mCp.Size() : 1);
|
||||||
|
node.data.resize(size);
|
||||||
|
for(duint i = 0; i < size; i++)
|
||||||
|
node.data[i] = inRange(node.start + i) ? *translateAddr(node.start + i) : 0x90;
|
||||||
}
|
}
|
||||||
mFunctions.push_back(graph);
|
mFunctions.push_back(graph);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2804,7 +2804,6 @@ CMDRESULT cbInstrGraph(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
RecursiveAnalysis analysis(base, size, entry, 0);
|
RecursiveAnalysis analysis(base, size, entry, 0);
|
||||||
analysis.Analyse();
|
analysis.Analyse();
|
||||||
analysis.SetMarkers();
|
|
||||||
auto graph = analysis.GetFunctionGraph(entry);
|
auto graph = analysis.GetFunctionGraph(entry);
|
||||||
if(!graph)
|
if(!graph)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue