1
0
Fork 0

DBG+BRIDGE+GUI: warn when trying to render a graph with more than 5000 nodes

(closes #1321)
This commit is contained in:
mrexodia 2017-08-21 15:12:12 +02:00
parent c1c7910d8d
commit 652c61f7f7
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
6 changed files with 21 additions and 8 deletions

View File

@ -1552,9 +1552,9 @@ BRIDGE_IMPEXP void GuiFocusView(int hWindow)
_gui_sendmessage(GUI_FOCUS_VIEW, (void*)hWindow, nullptr);
}
BRIDGE_IMPEXP void GuiLoadGraph(BridgeCFGraphList* graph, duint addr)
BRIDGE_IMPEXP bool GuiLoadGraph(BridgeCFGraphList* graph, duint addr)
{
_gui_sendmessage(GUI_LOAD_GRAPH, graph, (void*)addr);
return !!_gui_sendmessage(GUI_LOAD_GRAPH, graph, (void*)addr);
}
BRIDGE_IMPEXP duint GuiGraphAt(duint addr)

View File

@ -1266,7 +1266,7 @@ BRIDGE_IMPEXP void GuiFocusView(int hWindow);
BRIDGE_IMPEXP bool GuiIsUpdateDisabled();
BRIDGE_IMPEXP void GuiUpdateEnable(bool updateNow);
BRIDGE_IMPEXP void GuiUpdateDisable();
BRIDGE_IMPEXP void GuiLoadGraph(BridgeCFGraphList* graph, duint addr);
BRIDGE_IMPEXP bool GuiLoadGraph(BridgeCFGraphList* graph, duint addr);
BRIDGE_IMPEXP duint GuiGraphAt(duint addr);
BRIDGE_IMPEXP void GuiUpdateGraphView();
BRIDGE_IMPEXP void GuiDisableLog();

View File

@ -126,7 +126,8 @@ bool cbInstrGraph(int argc, char* argv[])
return false;
}
auto graphList = graph->ToGraphList();
GuiLoadGraph(&graphList, sel);
if(!GuiLoadGraph(&graphList, sel))
return false;
}
GuiUpdateAllViews();
GuiFocusView(GUI_GRAPH);

View File

@ -684,7 +684,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
{
BridgeResult result;
emit loadGraph((BridgeCFGraphList*)param1, duint(param2));
result.Wait();
return (void*)result.Wait();
}
break;

View File

@ -1904,8 +1904,8 @@ void CPUDisassembly::setEncodeTypeSlot()
void CPUDisassembly::graphSlot()
{
DbgCmdExecDirect(QString("graph %1").arg(ToPtrString(rvaToVa(getSelectionStart()))).toUtf8().constData());
emit displayGraphWidget();
if(DbgCmdExecDirect(QString("graph %1").arg(ToPtrString(rvaToVa(getSelectionStart()))).toUtf8().constData()))
emit displayGraphWidget();
}
void CPUDisassembly::togglePreviewSlot()

View File

@ -1617,12 +1617,24 @@ void DisassemblerGraphView::loadCurrentGraph()
void DisassemblerGraphView::loadGraphSlot(BridgeCFGraphList* graphList, duint addr)
{
auto nodeCount = graphList->nodes.count;
if(nodeCount > 5000) //TODO: add configuration
{
auto title = tr("Large number of nodes");
auto message = tr("The graph you are trying to render has a large number of nodes (%1). This can cause x64dbg to hang or crash. It is recommended to save your data before you continue.\n\nDo you want to continue rendering this graph?").arg(nodeCount);
if(QMessageBox::question(this, title, message, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default) == QMessageBox::No)
{
Bridge::getBridge()->setResult(0);
return;
}
}
currentGraph = BridgeCFGraph(graphList, true);
currentBlockMap.clear();
this->cur_instr = addr ? addr : this->function;
this->forceCenter = true;
loadCurrentGraph();
Bridge::getBridge()->setResult();
Bridge::getBridge()->setResult(1);
}
void DisassemblerGraphView::graphAtSlot(duint addr)