mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 04:16:12 +00:00
Added colors to DisassemblyWidget
This commit is contained in:
parent
3c6f735832
commit
d2c50a803c
2
radare2
2
radare2
@ -1 +1 @@
|
|||||||
Subproject commit 3b2b592506809d4dcfed7c7cff29dd8fa2c2e9d1
|
Subproject commit 7e063d0b47878f0e9992fcef8756e6a3e29bdba9
|
@ -60,7 +60,6 @@
|
|||||||
#include "widgets/ConsoleWidget.h"
|
#include "widgets/ConsoleWidget.h"
|
||||||
#include "dialogs/OptionsDialog.h"
|
#include "dialogs/OptionsDialog.h"
|
||||||
#include "widgets/EntrypointWidget.h"
|
#include "widgets/EntrypointWidget.h"
|
||||||
#include "widgets/DisassemblerGraphView.h"
|
|
||||||
#include "dialogs/SaveProjectDialog.h"
|
#include "dialogs/SaveProjectDialog.h"
|
||||||
|
|
||||||
// graphics
|
// graphics
|
||||||
@ -204,8 +203,8 @@ void MainWindow::initUI()
|
|||||||
graphDock = new QDockWidget(tr("Graph"), this);
|
graphDock = new QDockWidget(tr("Graph"), this);
|
||||||
graphDock->setObjectName("Graph");
|
graphDock->setObjectName("Graph");
|
||||||
graphDock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
graphDock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||||
DisassemblerGraphView *gv = new DisassemblerGraphView(graphDock);
|
graphView = new DisassemblerGraphView(graphDock);
|
||||||
graphDock->setWidget(gv);
|
graphDock->setWidget(graphView);
|
||||||
dockWidgets.push_back(graphDock);
|
dockWidgets.push_back(graphDock);
|
||||||
|
|
||||||
// Add Sections dock panel
|
// Add Sections dock panel
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QList>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "cutter.h" // only needed for ut64
|
||||||
#include "widgets/DisassemblyWidget.h"
|
#include "widgets/DisassemblyWidget.h"
|
||||||
|
#include "widgets/DisassemblerGraphView.h"
|
||||||
#include "widgets/SidebarWidget.h"
|
#include "widgets/SidebarWidget.h"
|
||||||
#include "widgets/HexdumpWidget.h"
|
#include "widgets/HexdumpWidget.h"
|
||||||
#include "cutter.h" // only needed for ut64
|
|
||||||
#include "utils/Configuration.h"
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
class CutterCore;
|
class CutterCore;
|
||||||
class DockWidget;
|
class DockWidget;
|
||||||
class Omnibar;
|
class Omnibar;
|
||||||
@ -34,6 +37,7 @@ class QAction;
|
|||||||
class SectionsDock;
|
class SectionsDock;
|
||||||
class ConsoleWidget;
|
class ConsoleWidget;
|
||||||
class EntrypointWidget;
|
class EntrypointWidget;
|
||||||
|
class DisassemblerGraphView;
|
||||||
|
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
|
|
||||||
@ -186,6 +190,7 @@ private:
|
|||||||
SidebarWidget *sidebarDock;
|
SidebarWidget *sidebarDock;
|
||||||
HexdumpWidget *hexdumpDock;
|
HexdumpWidget *hexdumpDock;
|
||||||
QDockWidget *graphDock;
|
QDockWidget *graphDock;
|
||||||
|
DisassemblerGraphView *graphView;
|
||||||
QDockWidget *asmDock;
|
QDockWidget *asmDock;
|
||||||
QDockWidget *calcDock;
|
QDockWidget *calcDock;
|
||||||
Omnibar *omnibar;
|
Omnibar *omnibar;
|
||||||
|
@ -755,7 +755,6 @@ void CutterCore::getOpcodes()
|
|||||||
|
|
||||||
void CutterCore::setSettings()
|
void CutterCore::setSettings()
|
||||||
{
|
{
|
||||||
setConfig("scr.color", false);
|
|
||||||
setConfig("scr.interactive", false);
|
setConfig("scr.interactive", false);
|
||||||
setConfig("asm.lines", false);
|
setConfig("asm.lines", false);
|
||||||
// Intredazting...
|
// Intredazting...
|
||||||
@ -805,10 +804,9 @@ void CutterCore::setSettings()
|
|||||||
//setConfig("http.root","/usr/local/radare2/osx/share/radare2/1.1.0-git/www");
|
//setConfig("http.root","/usr/local/radare2/osx/share/radare2/1.1.0-git/www");
|
||||||
//setConfig("bin.rawstr", "true");
|
//setConfig("bin.rawstr", "true");
|
||||||
|
|
||||||
// Graph colors and design
|
// Colors
|
||||||
cmd("ec graph.true rgb:88FF88");
|
setConfig("scr.color", false);
|
||||||
cmd("ec graph.false rgb:FF6666");
|
setConfig("scr.truecolor", true);
|
||||||
cmd("ec graph.trufae rgb:4183D7");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<RVA> CutterCore::getSeekHistory()
|
QList<RVA> CutterCore::getSeekHistory()
|
||||||
|
@ -209,13 +209,16 @@ public:
|
|||||||
void analyze(int level, QList<QString> advanced);
|
void analyze(int level, QList<QString> advanced);
|
||||||
|
|
||||||
// Seek functions
|
// Seek functions
|
||||||
bool graphDisplay = false;
|
|
||||||
void seek(QString addr);
|
void seek(QString addr);
|
||||||
void seek(ut64 offset);
|
void seek(ut64 offset);
|
||||||
void seekPrev();
|
void seekPrev();
|
||||||
void seekNext();
|
void seekNext();
|
||||||
RVA getOffset();
|
RVA getOffset();
|
||||||
|
|
||||||
|
// Graph - Disassembly view priority
|
||||||
|
bool graphPriority = true;
|
||||||
|
bool graphDisplay = false;
|
||||||
|
|
||||||
ut64 math(const QString &expr);
|
ut64 math(const QString &expr);
|
||||||
QString itoa(ut64 num, int rdx = 16);
|
QString itoa(ut64 num, int rdx = 16);
|
||||||
|
|
||||||
|
@ -18,15 +18,15 @@ Configuration* Configuration::instance()
|
|||||||
|
|
||||||
void Configuration::loadDefaultColors()
|
void Configuration::loadDefaultColors()
|
||||||
{
|
{
|
||||||
//Core()->cmd("eco behelit");
|
Core()->cmd("eco cutter");
|
||||||
Core()->cmd("eco smyck");
|
|
||||||
QJsonObject colors = Core()->cmdj("ecj").object();
|
QJsonObject colors = Core()->cmdj("ecj").object();
|
||||||
for (auto color : colors.keys()) {
|
for (auto color : colors.keys()) {
|
||||||
QJsonArray rgb = colors[color].toArray();
|
QJsonArray rgb = colors[color].toArray();
|
||||||
QColor col = QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
|
QColor col = QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
|
||||||
s.setValue("colors." + color, col);
|
s.setValue("colors." + color, col);
|
||||||
}
|
}
|
||||||
//s.setValue("colors.gui.alt_background", QColor(255, 255, 255));
|
s.setValue("colors.gui.background", QColor(255, 255, 245));
|
||||||
|
s.setValue("colors.gui.alt_background", QColor(245, 250, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFont Configuration::getFont() const
|
const QFont Configuration::getFont() const
|
||||||
|
@ -1643,11 +1643,9 @@ void DisassemblerGraphView::on_seekChanged(RVA addr)
|
|||||||
Q_UNUSED(addr);
|
Q_UNUSED(addr);
|
||||||
loadCurrentGraph();
|
loadCurrentGraph();
|
||||||
Function f = this->analysis.functions[this->function];
|
Function f = this->analysis.functions[this->function];
|
||||||
if (f.blocks.size() > 0) {
|
Core()->graphDisplay = f.blocks.size() > 0;
|
||||||
Core()->graphDisplay = true;
|
if (Core()->graphDisplay && Core()->graphPriority) {
|
||||||
this->parentWidget()->raise();
|
this->parentWidget()->raise();
|
||||||
} else {
|
|
||||||
Core()->graphDisplay = false;
|
|
||||||
}
|
}
|
||||||
this->renderFunction(this->analysis.functions[this->function]);
|
this->renderFunction(this->analysis.functions[this->function]);
|
||||||
}
|
}
|
||||||
@ -1811,6 +1809,7 @@ void DisassemblerGraphView::followDisassemblerSlot()
|
|||||||
void DisassemblerGraphView::colorsUpdatedSlot()
|
void DisassemblerGraphView::colorsUpdatedSlot()
|
||||||
{
|
{
|
||||||
disassemblyBackgroundColor = ConfigColor("gui.background");
|
disassemblyBackgroundColor = ConfigColor("gui.background");
|
||||||
|
mDisabledBreakpointColor = disassemblyBackgroundColor;
|
||||||
graphNodeColor = ConfigColor("gui.border");
|
graphNodeColor = ConfigColor("gui.border");
|
||||||
backgroundColor = ConfigColor("gui.alt_background");
|
backgroundColor = ConfigColor("gui.alt_background");
|
||||||
disassemblySelectionColor = ConfigColor("gui.highlight");
|
disassemblySelectionColor = ConfigColor("gui.highlight");
|
||||||
|
@ -288,7 +288,6 @@ public slots:
|
|||||||
void seekPrev();
|
void seekPrev();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow* main;
|
|
||||||
QString status;
|
QString status;
|
||||||
Analysis analysis;
|
Analysis analysis;
|
||||||
duint function;
|
duint function;
|
||||||
|
@ -34,7 +34,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) :
|
|||||||
connect(mDisasTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
connect(mDisasTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||||
this, SLOT(showDisasContextMenu(const QPoint &)));
|
this, SLOT(showDisasContextMenu(const QPoint &)));
|
||||||
|
|
||||||
// x or X to show XRefs
|
// x to show XRefs
|
||||||
QShortcut *shortcut_x = new QShortcut(QKeySequence(Qt::Key_X), mDisasTextEdit);
|
QShortcut *shortcut_x = new QShortcut(QKeySequence(Qt::Key_X), mDisasTextEdit);
|
||||||
shortcut_x->setContext(Qt::WidgetShortcut);
|
shortcut_x->setContext(Qt::WidgetShortcut);
|
||||||
connect(shortcut_x, SIGNAL(activated()), this, SLOT(showXrefsDialog()));
|
connect(shortcut_x, SIGNAL(activated()), this, SLOT(showXrefsDialog()));
|
||||||
@ -52,6 +52,11 @@ DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :
|
|||||||
this->setWindowTitle(title);
|
this->setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* DisassemblyWidget::getTextWidget()
|
||||||
|
{
|
||||||
|
return mDisasTextEdit;
|
||||||
|
}
|
||||||
|
|
||||||
void DisassemblyWidget::highlightCurrentLine()
|
void DisassemblyWidget::highlightCurrentLine()
|
||||||
{
|
{
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||||
@ -159,7 +164,7 @@ bool DisassemblyWidget::loadMoreDisassembly()
|
|||||||
|
|
||||||
if (offset != RVA_INVALID)
|
if (offset != RVA_INVALID)
|
||||||
{
|
{
|
||||||
CutterCore::getInstance()->seek(offset);
|
//CutterCore::getInstance()->seek(offset);
|
||||||
QString raw = CutterCore::getInstance()->cmd("pd 200");
|
QString raw = CutterCore::getInstance()->cmd("pd 200");
|
||||||
QString txt = raw.section("\n", 1, -1);
|
QString txt = raw.section("\n", 1, -1);
|
||||||
//this->disasTextEdit->appendPlainText(" ;\n ; New content here\n ;\n " + txt.trimmed());
|
//this->disasTextEdit->appendPlainText(" ;\n ; New content here\n ;\n " + txt.trimmed());
|
||||||
@ -227,11 +232,14 @@ void DisassemblyWidget::refreshDisasm()
|
|||||||
disconnect(mDisasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
|
disconnect(mDisasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
|
||||||
disconnect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
|
disconnect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
|
||||||
|
|
||||||
QString disas = CutterCore::getInstance()->cmd("pd 200");
|
Core()->setConfig("scr.html", true);
|
||||||
|
Core()->setConfig("scr.color", true);
|
||||||
|
QString disas = Core()->cmd("pd 100");
|
||||||
|
Core()->setConfig("scr.html", false);
|
||||||
|
Core()->setConfig("scr.color", false);
|
||||||
|
|
||||||
mDisasTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
mDisasTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
mDisasTextEdit->setHtml(disas);
|
||||||
mDisasTextEdit->setPlainText(disas.trimmed());
|
|
||||||
|
|
||||||
auto cursor = mDisasTextEdit->textCursor();
|
auto cursor = mDisasTextEdit->textCursor();
|
||||||
cursor.setPosition(0);
|
cursor.setPosition(0);
|
||||||
@ -251,7 +259,7 @@ void DisassemblyWidget::refreshDisasm()
|
|||||||
connect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
|
connect(mDisasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_mDisasTextEdit_cursorPositionChanged()));
|
||||||
//this->on_mDisasTextEdit_cursorPositionChanged();
|
//this->on_mDisasTextEdit_cursorPositionChanged();
|
||||||
|
|
||||||
this->highlightDisasms();
|
//this->highlightDisasms();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisassemblyWidget::on_mDisasTextEdit_cursorPositionChanged()
|
void DisassemblyWidget::on_mDisasTextEdit_cursorPositionChanged()
|
||||||
@ -356,7 +364,7 @@ bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
void DisassemblyWidget::on_seekChanged(RVA offset)
|
void DisassemblyWidget::on_seekChanged(RVA offset)
|
||||||
{
|
{
|
||||||
Q_UNUSED(offset);
|
Q_UNUSED(offset);
|
||||||
if (!Core()->graphDisplay) {
|
if (!Core()->graphDisplay || !Core()->graphPriority) {
|
||||||
this->raise();
|
this->raise();
|
||||||
}
|
}
|
||||||
refreshDisasm();
|
refreshDisasm();
|
||||||
|
@ -12,6 +12,7 @@ class DisassemblyWidget : public QDockWidget
|
|||||||
public:
|
public:
|
||||||
explicit DisassemblyWidget(QWidget *parent = nullptr);
|
explicit DisassemblyWidget(QWidget *parent = nullptr);
|
||||||
explicit DisassemblyWidget(const QString &title, QWidget *parent = nullptr);
|
explicit DisassemblyWidget(const QString &title, QWidget *parent = nullptr);
|
||||||
|
QWidget* getTextWidget();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user