GUI: basic tokens of graph working
This commit is contained in:
parent
fdc08c6600
commit
027cb2f396
|
|
@ -277,7 +277,7 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
byte_t wBuffer[16];
|
||||
if(!DbgMemRead(parVA, wBuffer, 16))
|
||||
return 0;
|
||||
QBeaEngine disasm(-1);
|
||||
QBeaEngine disasm(int(ConfigUint("Disassembler", "MaxModuleSize")));
|
||||
Instruction_t instr = disasm.DisassembleAt(wBuffer, 16, 0, parVA);
|
||||
RichTextPainter::List richText;
|
||||
CapstoneTokenizer::TokenToRichText(instr.tokens, richText, 0);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QMimeData>
|
||||
#include "capstone_wrapper.h"
|
||||
|
||||
DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
|
||||
: QAbstractScrollArea(parent)
|
||||
|
|
@ -1168,7 +1167,7 @@ void DisassemblerGraphView::loadGraphSlot(BridgeCFGraphList* graphList)
|
|||
BridgeCFGraph graph(graphList);
|
||||
Bridge::getBridge()->setResult();
|
||||
Analysis anal;
|
||||
Capstone cp;
|
||||
QBeaEngine disasm(int(ConfigUint("Disassembler", "MaxModuleSize")));
|
||||
anal.update_id = this->update_id + 1;
|
||||
anal.entry = graph.entryPoint;
|
||||
anal.ready = true;
|
||||
|
|
@ -1195,13 +1194,15 @@ void DisassemblerGraphView::loadGraphSlot(BridgeCFGraphList* graphList)
|
|||
data[0] = 0xFF;
|
||||
memcpy(data, node.data.data() + i, qMin(sizeof(data), node.data.size() - i));
|
||||
auto addr = node.start + i;
|
||||
cp.Disassemble(addr, data);
|
||||
auto size = cp.Size();
|
||||
Instruction_t instrTok = disasm.DisassembleAt((byte_t*)data, sizeof(data), 0, addr);
|
||||
RichTextPainter::List richText;
|
||||
CapstoneTokenizer::TokenToRichText(instrTok.tokens, richText, 0);
|
||||
auto size = instrTok.length;
|
||||
instr.addr = addr;
|
||||
instr.opcode.resize(size);
|
||||
for(size_t j = 0; j < size; j++)
|
||||
instr.opcode[j] = data[j];
|
||||
instr.text = Text(cp.InstructionText().c_str(), Qt::black, instr.addr);
|
||||
instr.text = Text(richText, instr.addr);
|
||||
block.instrs.push_back(instr);
|
||||
i += size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <algorithm>
|
||||
#include <QMutex>
|
||||
#include "Bridge.h"
|
||||
#include "QBeaEngine.h"
|
||||
|
||||
class DisassemblerGraphView : public QAbstractScrollArea
|
||||
{
|
||||
|
|
@ -92,6 +93,7 @@ public:
|
|||
|
||||
struct Text
|
||||
{
|
||||
//TODO: replace with RichTextPainter
|
||||
std::vector<std::vector<Line>> lines;
|
||||
std::vector<std::vector<Token>> tokens;
|
||||
|
||||
|
|
@ -116,6 +118,28 @@ public:
|
|||
lines.push_back(lv);
|
||||
}
|
||||
|
||||
Text(const RichTextPainter::List & richText, duint addr)
|
||||
{
|
||||
std::vector<Token> tv;
|
||||
std::vector<Line> lv;
|
||||
int start = 0;
|
||||
for(const RichTextPainter::CustomRichText_t & rtok : richText)
|
||||
{
|
||||
Token tok;
|
||||
tok.start = start;
|
||||
start += tok.length = rtok.text.length();
|
||||
tok.addr = addr;
|
||||
tok.name = rtok.text;
|
||||
tv.push_back(tok);
|
||||
Line line;
|
||||
line.text = rtok.text;
|
||||
line.color = rtok.textColor;
|
||||
lv.push_back(line);
|
||||
}
|
||||
tokens.push_back(tv);
|
||||
lines.push_back(lv);
|
||||
}
|
||||
|
||||
QString ToQString() const
|
||||
{
|
||||
QString result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue