From 75bf8cf5b6814b47622ca1280dbe7612a1894a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 1 Feb 2018 15:15:16 +0100 Subject: [PATCH] Use agJ for graph --- src/widgets/DisassemblerGraphView.cpp | 63 ++++++++++++--------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index a2335efc..2863ba1a 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -7,11 +7,13 @@ #include #include #include +#include #include "cutter.h" #include "utils/Colors.h" #include "utils/Configuration.h" #include "utils/CachedFontMetrics.h" +#include "utils/TempConfig.h" DisassemblerGraphView::DisassemblerGraphView(QWidget *parent) : GraphView(parent), @@ -109,7 +111,9 @@ void DisassemblerGraphView::refreshView() void DisassemblerGraphView::loadCurrentGraph() { - QJsonDocument functionsDoc = Core()->cmdj("agj"); + TempConfig tempConfig; + tempConfig.set("scr.html", true); + QJsonDocument functionsDoc = Core()->cmdj("agJ@e:scr.html=true"); QJsonArray functions = functionsDoc.array(); disassembly_blocks.clear(); @@ -138,6 +142,7 @@ void DisassemblerGraphView::loadCurrentGraph() for (QJsonValueRef blockRef : func["blocks"].toArray()) { QJsonObject block = blockRef.toObject(); RVA block_entry = block["offset"].toVariant().toULongLong(); + RVA block_size = block["size"].toVariant().toULongLong(); RVA block_fail = block["fail"].toVariant().toULongLong(); RVA block_jump = block["jump"].toVariant().toULongLong(); @@ -160,50 +165,36 @@ void DisassemblerGraphView::loadCurrentGraph() } gb.exits.push_back(block_jump); } - for (QJsonValueRef opRef : block["ops"].toArray()) + QJsonArray opArray = block["ops"].toArray(); + for (int opIndex=0; opIndexgetConfigb("asm.esil")) - disas = op["esil"].toString(); - else - disas = op["disasm"].toString(); + disas = op["text"].toString(); - Colors::colorizeAssembly(richText, disas, op["type_num"].toVariant().toULongLong()); + QTextDocument textDoc; + textDoc.setHtml(disas); - if (op["comment"].toString().length()) - { - RichTextPainter::CustomRichText_t comment; - comment.text = QString(" ; %1").arg(QByteArray::fromBase64(op["comment"].toString().toLocal8Bit()).data()); - comment.textColor = mCommentColor; - comment.flags = RichTextPainter::FlagColor; - richText.insert(richText.end(), comment); - } - - if (Core()->getConfigb("asm.bytes")) - { - RichTextPainter::CustomRichText_t bytes; - bytes.text = op["bytes"].toVariant().toString(); - - if (Core()->getConfigb("asm.bytespace")) - for (int i = 2; i <= bytes.text.size(); i += 2+1) - bytes.text.insert(i, ' '); - - if (Core()->getConfigb("asm.lbytes")) - bytes.text = bytes.text.leftJustified(24, ' '); - else - bytes.text = bytes.text.rightJustified(24, ' '); - - bytes.textColor = Config()->getColor("bin"); - bytes.flags = RichTextPainter::FlagColor; - richText.insert(richText.begin(), bytes); - } + Colors::colorizeAssembly(richText, textDoc.toPlainText(), 0); bool cropped; int blockLength = Config()->getGraphBlockMaxChars() + Core()->getConfigb("asm.bytes") * 24 + Core()->getConfigb("asm.emu") * 10;