From 0fa6165ab77ad69b869b6017e0d7c8b4621fb44c Mon Sep 17 00:00:00 2001 From: mrexodia Date: Thu, 30 Mar 2017 04:32:24 +0200 Subject: [PATCH 1/6] display icon in tray for main window --- src/createnewdialog.cpp | 4 ++-- src/newfiledialog.cpp | 6 +++--- src/optionsdialog.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/createnewdialog.cpp b/src/createnewdialog.cpp index 8dea4945..825c8334 100644 --- a/src/createnewdialog.cpp +++ b/src/createnewdialog.cpp @@ -9,7 +9,7 @@ createNewDialog::createNewDialog(QWidget *parent) : ui(new Ui::createNewDialog) { ui->setupUi(this); - w = new MainWindow(this); + w = new MainWindow(nullptr); w->core = new QRCore (); } @@ -22,7 +22,7 @@ void createNewDialog::on_pushButton_2_clicked() { // Close dialog and open OptionsDialog close(); - NewFileDialog* n = new NewFileDialog(this); + NewFileDialog* n = new NewFileDialog(nullptr); n->show(); } diff --git a/src/newfiledialog.cpp b/src/newfiledialog.cpp index be42702f..4f9f667f 100644 --- a/src/newfiledialog.cpp +++ b/src/newfiledialog.cpp @@ -100,7 +100,7 @@ void NewFileDialog::on_loadFileButton_clicked() } else { // Close dialog and open OptionsDialog close(); - OptionsDialog* o = new OptionsDialog(this); + OptionsDialog* o = new OptionsDialog(nullptr); o->setFilename (fname, this->strippedName(fname)); o->exec(); } @@ -145,7 +145,7 @@ void NewFileDialog::on_recentsList_itemDoubleClicked(QListWidgetItem *item) QString sitem = data.toString(); // Close dialog and open OptionsDialog close(); - OptionsDialog* o = new OptionsDialog(this); + OptionsDialog* o = new OptionsDialog(nullptr); o->setFilename (sitem, this->strippedName(sitem)); o->exec(); } @@ -177,7 +177,7 @@ void NewFileDialog::on_createButton_clicked() { // Close dialog and open create new file dialog close(); - createNewDialog* n = new createNewDialog(this); + createNewDialog* n = new createNewDialog(nullptr); n->exec(); } diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index 3b32f028..2d1d00f9 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -73,7 +73,7 @@ void OptionsDialog::on_okButton_clicked() //ui->progressBar->setValue(5); // Close dialog and open OptionsDialog - this->w = new MainWindow(this); + this->w = new MainWindow(nullptr); this->w->core = this->core; // Fill asm plugins in hexdump combo @@ -234,7 +234,7 @@ void OptionsDialog::on_cancelButton_clicked() this->core = NULL; // implicit by delete? // Close dialog and open OptionsDialog close(); - NewFileDialog* n = new NewFileDialog(this); + NewFileDialog* n = new NewFileDialog(nullptr); n->show(); } From 1b45cbd8ea2f5c6e68e25d82775022f383b1c927 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Thu, 30 Mar 2017 04:32:51 +0200 Subject: [PATCH 2/6] fixed escaping in mdhighlighter regex --- src/mdhighlighter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mdhighlighter.cpp b/src/mdhighlighter.cpp index 4cfa95e1..2865d8ad 100644 --- a/src/mdhighlighter.cpp +++ b/src/mdhighlighter.cpp @@ -11,7 +11,7 @@ MdHighlighter::MdHighlighter(QTextDocument *parent) keywordFormat.setFontWeight(QFont::Bold); QStringList keywordPatterns; - keywordPatterns << "^\#{1,6}[ A-Za-z]+\\b" << "\\*\\*([^\\\\]+)\\*\\*" + keywordPatterns << "^\\#{1,6}[ A-Za-z]+\\b" << "\\*\\*([^\\\\]+)\\*\\*" << "\\*([^\\\\]+)\\*" << "\\_([^\\\\]+)\\_" << "\\_\\_([^\\\\]+)\\_\\_"; From 6d36756c7a665837b1d6987f89122fd04e0ebad8 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Thu, 30 Mar 2017 04:33:09 +0200 Subject: [PATCH 3/6] removed incorrect assumption --- src/optionsdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index 2d1d00f9..f3126c6e 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -231,7 +231,7 @@ void OptionsDialog::anal_finished() void OptionsDialog::on_cancelButton_clicked() { delete this->core; - this->core = NULL; // implicit by delete? + this->core = NULL; // Close dialog and open OptionsDialog close(); NewFileDialog* n = new NewFileDialog(nullptr); From 0f2f037977d177a02e1b0dbe95821fd65adb55f2 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Thu, 30 Mar 2017 04:49:04 +0200 Subject: [PATCH 4/6] better bounds checking in memorywidget --- src/widgets/memwidget/memorywidget.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/widgets/memwidget/memorywidget.cpp b/src/widgets/memwidget/memorywidget.cpp index b10f489a..375bdbcc 100644 --- a/src/widgets/memwidget/memorywidget.cpp +++ b/src/widgets/memwidget/memorywidget.cpp @@ -1345,7 +1345,9 @@ void MemoryWidget::fillOffsetInfo( QString off) { // Add opcode description QStringList description = this->main->core->cmd("?d. @ " + off).split(": "); - ui->opcodeDescText->setPlainText("# " + description[0] + ":\n" + description[1]); + if(description.length() >= 2) { + ui->opcodeDescText->setPlainText("# " + description[0] + ":\n" + description[1]); + } } void MemoryWidget::create_graph(QString off) { @@ -1379,14 +1381,13 @@ void MemoryWidget::setFcnName(QString addr) { // TDOD: FIX ME, ugly if (addr.contains("0x")) { - fcn = this->main->core->functionAt(addr.toLong(&ok, 16)); - if (fcn->name != "") { + fcn = this->main->core->functionAt(addr.toULongLong(&ok, 16)); + if (ok && fcn && fcn->name != "") { QString segment = this->main->core->cmd("S. @ " + addr).split(" ").last(); - ui->fcnNameEdit->setText(segment.trimmed() + ":"+ fcn->name); + addr = segment.trimmed() + ":"+ fcn->name; } - } else { - ui->fcnNameEdit->setText(addr); } + ui->fcnNameEdit->setText(addr); } void MemoryWidget::on_disasTextEdit_2_cursorPositionChanged() @@ -1398,7 +1399,6 @@ void MemoryWidget::on_disasTextEdit_2_cursorPositionChanged() QString ele = lastline.split(" ", QString::SkipEmptyParts)[0]; if (ele.contains("0x")) { this->fillOffsetInfo(ele); - QString at = this->main->core->cmdFunctionAt(ele); QString deco = this->main->core->getDecompiledCode(at); @@ -1579,6 +1579,7 @@ bool MemoryWidget::eventFilter(QObject *obj, QEvent *event) { } } } + return false; //allow the event to be handled further } void MemoryWidget::on_actionXRefs_triggered() From c7367b74b88eca7fc34f03a53016c831cae14f3c Mon Sep 17 00:00:00 2001 From: mrexodia Date: Thu, 30 Mar 2017 04:49:43 +0200 Subject: [PATCH 5/6] fix compile errors with functions not returning anything --- src/qrdisasm.cpp | 1 + src/widgets/commentswidget.cpp | 1 + src/widgets/functionswidget.cpp | 1 + src/widgets/sectionswidget.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/src/qrdisasm.cpp b/src/qrdisasm.cpp index 68c55790..ae7a50a4 100644 --- a/src/qrdisasm.cpp +++ b/src/qrdisasm.cpp @@ -10,4 +10,5 @@ QRDisasm::QRDisasm(QRCore *core) bool QRDisasm::disassembleAt (ut64 addr, QRDisasmOption opt, QRDisasmRow &dr) { printf ("FUCK\n"); + return false; } diff --git a/src/widgets/commentswidget.cpp b/src/widgets/commentswidget.cpp index 1dd3e85e..5b303636 100644 --- a/src/widgets/commentswidget.cpp +++ b/src/widgets/commentswidget.cpp @@ -134,4 +134,5 @@ bool CommentsWidget::eventFilter(QObject *obj, QEvent *event) { } } } + return false; //allow the event to be handled further } diff --git a/src/widgets/functionswidget.cpp b/src/widgets/functionswidget.cpp index bf941cc2..209381b1 100644 --- a/src/widgets/functionswidget.cpp +++ b/src/widgets/functionswidget.cpp @@ -377,4 +377,5 @@ bool FunctionsWidget::eventFilter(QObject *obj, QEvent *event) { } } } + return false; //allow the event to be handled further } diff --git a/src/widgets/sectionswidget.cpp b/src/widgets/sectionswidget.cpp index 660fa258..0930a06a 100644 --- a/src/widgets/sectionswidget.cpp +++ b/src/widgets/sectionswidget.cpp @@ -113,4 +113,5 @@ bool SectionsWidget::eventFilter(QObject *obj, QEvent *event) { } } } + return false; //allow the event to be handled further } From a42db155eaf9648a410f0659d1c6864b55900fdb Mon Sep 17 00:00:00 2001 From: Hugo Teso Date: Thu, 30 Mar 2017 18:47:50 +0200 Subject: [PATCH 6/6] Set r2 settings after loading a project. --- src/optionsdialog.cpp | 2 + src/qrcore.cpp | 110 ++++++++++++++++++++++-------------------- src/qrcore.h | 1 + 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index c902cd4a..38231266 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -190,6 +190,8 @@ void OptionsDialog::anal_finished() //fprintf(stderr, "anal done"); //ui->progressBar->setValue(70); this->w->core->cmd("Po " + this->shortfn); + // Set settings to override any incorrect saved in the project + this->core->setSettings(); ui->statusLabel->setText("Loading interface"); this->w->add_output(" > Analysis finished"); QString initial_seek = ui->entry_initialSeek->text(); diff --git a/src/qrcore.cpp b/src/qrcore.cpp index b6759475..340b8f2d 100644 --- a/src/qrcore.cpp +++ b/src/qrcore.cpp @@ -11,59 +11,9 @@ QRCore::QRCore(QObject *parent) : this->core = r_core_new (); r_core_loadlibs (this->core, R_CORE_LOADLIBS_ALL, NULL); // IMPLICIT r_bin_iobind (core->bin, core->io); - config("scr.color", "false"); + + // Otherwise r2 may ask the user for input and Iaito would freeze config("scr.interactive","false"); - config("asm.lines","false"); - // Intredazting... - //config("asm.linesright", "true"); - //config("asm.lineswidth", "15"); - //config("asm.functions", "false"); - config("hex.pairs", "false"); - config("asm.bytespace", "true"); - config("asm.cmtflgrefs", "false"); - config("asm.cmtright", "true"); - config("asm.cmtcol", "70"); - config("asm.xrefs", "false"); - config("asm.fcnlines", "false"); - - config("asm.tabs", "10"); - config("asm.tabsonce", "true"); - config("asm.tabsoff", "5"); - config("asm.nbytes", "10"); - - config("anal.hasnext", "true"); - config("asm.fcncalls", "false"); - config("asm.calls", "false"); - config("asm.lines.call","false"); - config("asm.flgoff", "true"); - config("anal.autoname", "true"); - - // Highlight current node in graphviz - config("graph.gv.current", "true"); - - // Fucking pancake xD - config("cfg.fortunes.tts", "false"); - - // Experimenting with asm options - //config("asm.spacy", "true"); // We need to handle blank lines on scroll - //config("asm.section", "true"); // Breaks the disasm and navigation - //config("asm.invhex", "true"); // Needs further testing - //config("asm.flags", "false"); // Add with default true in future - - // Used by the HTML5 graph - config("http.cors","true"); - config("http.sandbox", "false"); - config("http.port", "14170"); - - // Temporary fixes - //config("http.root","/usr/local/share/radare2/last/www"); - //config("http.root","/usr/local/radare2/osx/share/radare2/1.1.0-git/www"); - //config("bin.rawstr", "true"); - - // Graph colors and design - cmd("ec graph.true rgb:88FF88"); - cmd("ec graph.false rgb:FF6666"); - cmd("ec graph.trufae rgb:4183D7"); this->db = sdb_new (NULL, NULL, 0); // WTF NOES } @@ -684,3 +634,59 @@ void QRCore::getOpcodes() { this->regs = registers.split("\n"); this->regs.removeLast(); } + +void QRCore::setSettings() { + config("scr.color", "false"); + config("scr.interactive","false"); + config("asm.lines","false"); + // Intredazting... + //config("asm.linesright", "true"); + //config("asm.lineswidth", "15"); + //config("asm.functions", "false"); + config("hex.pairs", "false"); + config("asm.bytespace", "true"); + config("asm.cmtflgrefs", "false"); + config("asm.cmtright", "true"); + config("asm.cmtcol", "70"); + config("asm.xrefs", "false"); + config("asm.fcnlines", "false"); + + config("asm.tabs", "10"); + config("asm.tabsonce", "true"); + config("asm.tabsoff", "5"); + config("asm.nbytes", "10"); + + config("anal.hasnext", "true"); + config("asm.fcncalls", "false"); + config("asm.calls", "false"); + config("asm.lines.call","false"); + config("asm.flgoff", "true"); + config("anal.autoname", "true"); + + // Highlight current node in graphviz + config("graph.gv.current", "true"); + + // Fucking pancake xD + config("cfg.fortunes.tts", "false"); + + // Experimenting with asm options + //config("asm.spacy", "true"); // We need to handle blank lines on scroll + //config("asm.section", "true"); // Breaks the disasm and navigation + //config("asm.invhex", "true"); // Needs further testing + //config("asm.flags", "false"); // Add with default true in future + + // Used by the HTML5 graph + config("http.cors","true"); + config("http.sandbox", "false"); + config("http.port", "14170"); + + // Temporary fixes + //config("http.root","/usr/local/share/radare2/last/www"); + //config("http.root","/usr/local/radare2/osx/share/radare2/1.1.0-git/www"); + //config("bin.rawstr", "true"); + + // Graph colors and design + cmd("ec graph.true rgb:88FF88"); + cmd("ec graph.false rgb:FF6666"); + cmd("ec graph.trufae rgb:4183D7"); +} diff --git a/src/qrcore.h b/src/qrcore.h index 3a297049..26bf5f35 100644 --- a/src/qrcore.h +++ b/src/qrcore.h @@ -73,6 +73,7 @@ public: void getOpcodes(); QList opcodes; QList regs; + void setSettings(); /* fields */ RCore *core;