1
0
Fork 0

DBG: graph command

This commit is contained in:
Mr. eXoDia 2016-07-16 19:41:02 +02:00
parent dfd8909f73
commit 9c008f088c
3 changed files with 31 additions and 0 deletions

View File

@ -2787,3 +2787,32 @@ CMDRESULT cbInstrExinfo(int argc, char* argv[])
}
return STATUS_CONTINUE;
}
CMDRESULT cbInstrGraph(int argc, char* argv[])
{
duint entry;
if(argc < 2 || !valfromstring(argv[1], &entry))
entry = GetContextDataEx(hActiveThread, UE_CIP);
duint start, size;
if(FunctionGet(entry, &start))
entry = start;
auto base = MemFindBaseAddr(entry, &size);
if(!base || !MemIsValidReadPtr(entry))
{
dprintf("Invalid memory address " fhex "!\n", entry);
return STATUS_ERROR;
}
RecursiveAnalysis analysis(base, size, entry, 0);
analysis.Analyse();
analysis.SetMarkers();
auto graph = analysis.GetFunctionGraph(entry);
if(!graph)
{
dputs("No graph generated...");
return STATUS_ERROR;
}
auto graphList = graph->ToGraphList();
GuiLoadGraph(&graphList);
GuiUpdateAllViews();
return STATUS_CONTINUE;
}

View File

@ -100,5 +100,6 @@ CMDRESULT cbInstrEnableGuiUpdate(int argc, char* argv[]);
CMDRESULT cbInstrExhandlers(int argc, char* argv[]);
CMDRESULT cbInstrInstrUndo(int argc, char* argv[]);
CMDRESULT cbInstrExinfo(int argc, char* argv[]);
CMDRESULT cbInstrGraph(int argc, char* argv[]);
#endif // _INSTRUCTION_H

View File

@ -307,6 +307,7 @@ static void registercommands()
dbgcmdnew("analrecur\1analr", cbInstrAnalrecur, true); //analyze a single function
dbgcmdnew("analxrefs\1analx", cbInstrAnalxrefs, true); //analyze xrefs
dbgcmdnew("analadv", cbInstrAnalyseadv, true); //analyze xref,function and data
dbgcmdnew("graph", cbInstrGraph, true); //graph function
}
static bool cbCommandProvider(char* cmd, int maxlen)