From: Christoph Egger Date: Wed, 14 Jan 2015 17:00:28 +0000 (+0100) Subject: Make function/jump targets clickable X-Git-Tag: v0.1~128 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=1b95144814ee74e611fd8a3806e54f064b120460;p=frida%2Ffrida.git Make function/jump targets clickable --- diff --git a/src/disassembler/Disassembler.hxx b/src/disassembler/Disassembler.hxx index 4636ed9..5af2eac 100644 --- a/src/disassembler/Disassembler.hxx +++ b/src/disassembler/Disassembler.hxx @@ -20,7 +20,8 @@ public: virtual void forEachFunction(std::function callback) = 0; virtual void printEachInstruction(uint64_t start, uint64_t end, - std::function fun) = 0; + std::function fun) = 0; protected: virtual bool isFunctionCall(uint64_t address) = 0; virtual bool isJump(uint64_t address) = 0; diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 7d4da01..9ab2844 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -429,8 +429,9 @@ void LLVMDisassembler::forEachFunction(std::function void LLVMDisassembler::printEachInstruction(uint64_t start, uint64_t end, - std::function fun) { + std::function fun) { SectionRef text_section = sections[".text"]; uint64_t base_address; text_section.getAddress(base_address); @@ -453,17 +454,24 @@ void LLVMDisassembler::printEachInstruction(uint64_t start, uint64_t end, ref.readBytes(current_address, inst_size, bytes); uint64_t jmptarget; + std::string ref(""); + IP->printInst(&inst, s, ""); if (MIA->evaluateBranch(inst, current_address, inst_size, jmptarget)) { std::stringstream stream; + if (MIA->isCall(inst)) + stream << "function:"; + else + stream << "block:"; + stream << std::hex << (base_address + jmptarget); - IP->printInst(&inst, s, stream.str()); - } else - IP->printInst(&inst, s, ""); + ref = stream.str(); + } + - fun(bytes, inst_size, s.str()); + fun(bytes, inst_size, s.str(), ref); } else { LOG4CXX_WARN(logger, "Invalid byte at" << std::hex << current_address + base_address); - fun(NULL, 0, "Invalid Byte"); + fun(NULL, 0, "Invalid Byte", ""); inst_size = 1; } diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 9063181..59f7349 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -29,7 +29,8 @@ public: void forEachFunction(std::function callback); void printEachInstruction(uint64_t start, uint64_t end, - std::function fun); + std::function fun); BasicBlock * getBasicBlock(uint64_t address) { return blocks[address]; diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index 9f1d353..5931a83 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -137,8 +137,11 @@ namespace { block->getEndAddress(), [&](uint8_t* bytes, size_t byte_count, - const std::string& line) { - widget->addItem(bytes, byte_count, line.c_str() + 1); + const std::string& line, + const std::string& ref) { + widget->addItem(bytes, byte_count, + line.c_str() + 1, // remove \t + ref.c_str()); }); BasicBlockWidget *tmp, *nextl(NULL), *nextr(NULL); diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index e65b6e2..cceb2ff 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -14,7 +14,7 @@ BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block) } void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, - const QString& line) { + QString line, const QString& href) { QString bytestring; for (size_t i(0); i < num_bytes; ++i) { @@ -28,10 +28,16 @@ void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, if (old_text == "") { old_text = ""; } + + line = line.toHtmlEscaped(); + if (href != "") { + line = "" + line + ""; + } + QString new_text = old_text.remove("
") + "" + bytestring + - "" + line.toHtmlEscaped() + + "" + line + "" + "" + ""; diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 9b2df93..0087e05 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -13,7 +13,7 @@ class BasicBlockWidget : public QGraphicsItem public: BasicBlockWidget(const QString& name, BasicBlock * block); - void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); + void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href); QRectF boundingRect() const { qreal penWidth = 1;