GUI: DisassemblerGraphView slot implementations
This commit is contained in:
parent
9c008f088c
commit
7e3ee588b2
|
|
@ -6,9 +6,8 @@
|
|||
#include <QApplication>
|
||||
#include <QMimeData>
|
||||
|
||||
DisassemblerGraphView::DisassemblerGraphView(const Analysis & analysis, QWidget* parent)
|
||||
: QAbstractScrollArea(parent),
|
||||
analysis(analysis)
|
||||
DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
|
||||
: QAbstractScrollArea(parent)
|
||||
{
|
||||
this->status = "Loading...";
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ DisassemblerGraphView::DisassemblerGraphView(const Analysis & analysis, QWidget*
|
|||
//Dummy
|
||||
|
||||
//Start disassembly view at the entry point of the binary
|
||||
this->function = this->analysis.entry;
|
||||
this->function = 0;
|
||||
this->update_id = 0;
|
||||
this->ready = false;
|
||||
this->desired_pos = nullptr;
|
||||
|
|
@ -47,6 +46,11 @@ DisassemblerGraphView::DisassemblerGraphView(const Analysis & analysis, QWidget*
|
|||
this->verticalScrollBar()->setSingleStep(this->charHeight);
|
||||
QSize areaSize = this->viewport()->size();
|
||||
this->adjustSize(areaSize.width(), areaSize.height());
|
||||
|
||||
//Connect to bridge
|
||||
connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*)), this, SLOT(loadGraphSlot(BridgeCFGraphList*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(graphAt(duint)), this, SLOT(graphAtSlot(duint)));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateGraph()), this, SLOT(updateGraphSlot()));
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::initFont()
|
||||
|
|
@ -1157,3 +1161,53 @@ void DisassemblerGraphView::fontChanged()
|
|||
this->renderFunction(this->analysis.functions[this->function]);
|
||||
}
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::loadGraphSlot(BridgeCFGraphList* graphList)
|
||||
{
|
||||
BridgeCFGraph graph(graphList);
|
||||
Bridge::getBridge()->setResult();
|
||||
Analysis anal;
|
||||
anal.update_id = this->update_id + 1;
|
||||
anal.entry = graph.entryPoint;
|
||||
anal.ready = true;
|
||||
{
|
||||
Function func;
|
||||
func.entry = graph.entryPoint;
|
||||
func.ready = true;
|
||||
func.update_id = anal.update_id;
|
||||
{
|
||||
for(const auto & nodeIt : graph.nodes)
|
||||
{
|
||||
const BridgeCFNode & node = nodeIt.second;
|
||||
Block block;
|
||||
block.entry = node.start;
|
||||
block.exits = node.exits;
|
||||
block.false_path = node.brfalse;
|
||||
block.true_path = node.brtrue;
|
||||
block.header_text = Text(ToPtrString(block.entry), Qt::red, block.entry);
|
||||
{
|
||||
//TODO: disassemble blocks
|
||||
Instr instr;
|
||||
instr.addr = node.end;
|
||||
instr.opcode.push_back(0x90);
|
||||
instr.text = Text(ToPtrString(instr.addr), Qt::blue, instr.addr);
|
||||
block.instrs.push_back(instr);
|
||||
}
|
||||
func.blocks.push_back(block);
|
||||
}
|
||||
}
|
||||
anal.functions.insert({func.entry, func});
|
||||
}
|
||||
this->analysis = anal;
|
||||
this->function = this->analysis.entry;
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::graphAtSlot(duint addr)
|
||||
{
|
||||
this->navigate(addr);
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::updateGraphSlot()
|
||||
{
|
||||
this->viewport()->update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ public:
|
|||
|
||||
bool find_instr(duint addr, duint & func, duint & instr)
|
||||
{
|
||||
//TODO implement
|
||||
Q_UNUSED(addr);
|
||||
Q_UNUSED(func);
|
||||
Q_UNUSED(instr);
|
||||
|
|
@ -210,7 +211,7 @@ public:
|
|||
//dummy class
|
||||
};
|
||||
|
||||
DisassemblerGraphView(const Analysis & analysis, QWidget* parent = nullptr);
|
||||
DisassemblerGraphView(QWidget* parent = nullptr);
|
||||
void initFont();
|
||||
void adjustSize(int width, int height);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
|
@ -249,6 +250,9 @@ public:
|
|||
|
||||
public slots:
|
||||
void updateTimerEvent();
|
||||
void loadGraphSlot(BridgeCFGraphList* graph);
|
||||
void graphAtSlot(duint addr);
|
||||
void updateGraphSlot();
|
||||
|
||||
private:
|
||||
QString status;
|
||||
|
|
|
|||
Loading…
Reference in New Issue