diff --git a/iaito_win32 b/iaito_win32 index afccf190..48dbae99 160000 --- a/iaito_win32 +++ b/iaito_win32 @@ -1 +1 @@ -Subproject commit afccf1907acc8c0e2b6ff2071199de69d8ecf565 +Subproject commit 48dbae99de86c1b798f46c1ccdbe13312301a4ad diff --git a/radare2 b/radare2 index 12b7916d..99c0151a 160000 --- a/radare2 +++ b/radare2 @@ -1 +1 @@ -Subproject commit 12b7916db311f37c8c55a91c5683c42eafe3a7be +Subproject commit 99c0151a2d9dbff70ba0a6aa46ddec2e523c8f65 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 58551247..8560856f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,6 +58,7 @@ MainWindow::MainWindow(QWidget *parent, QRCore *kore) : ui->setupUi(this); doLock = false; + this->current_address = "entry0"; registerCustomFonts(); @@ -881,8 +882,10 @@ void MainWindow::seek(const QString &offset, const QString &name) { if (offset.length() == 0) return; - if (name != NULL) + if (name != NULL) { this->memoryDock->setWindowTitle(name); + this->current_address = name; + } this->hexdumpTopOffset = 0; this->hexdumpBottomOffset = 0; core->seek(offset); @@ -907,9 +910,12 @@ void MainWindow::refreshMem(QString off) { //add_debug_output("Refreshing to: " + off); //graphicsBar->refreshColorBar(); + /* this->memoryDock->refreshDisasm(off); this->memoryDock->refreshHexdump(off); this->memoryDock->create_graph(off); + */ + this->memoryDock->updateViews(); this->memoryDock->get_refs_data(off); this->memoryDock->setFcnName(off); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 3ba57742..fd83c36a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -56,6 +56,7 @@ public: SideBar *sideBar; bool responsive; + QString current_address; explicit MainWindow(QWidget *parent = 0, QRCore *kore = nullptr); ~MainWindow(); diff --git a/src/widgets/memorywidget.cpp b/src/widgets/memorywidget.cpp index 39c1bffb..c9913ea7 100644 --- a/src/widgets/memorywidget.cpp +++ b/src/widgets/memorywidget.cpp @@ -35,6 +35,9 @@ MemoryWidget::MemoryWidget(MainWindow *main) : this->memTabWidget = ui->memTabWidget; this->last_fcn = "entry0"; + this->last_disasm_fcn = "entry0"; + this->last_graph_fcn = "entry0"; + this->last_hexdump_fcn = "entry0"; // Increase asm text edit margin QTextDocument *asm_docu = this->disasTextEdit->document(); @@ -483,6 +486,7 @@ void MemoryWidget::refreshDisasm(const QString &offset) // Prevent further scroll disconnect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled())); + disconnect(this->disasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_disasTextEdit_2_cursorPositionChanged())); // Get disas at offset if (!offset.isEmpty()) @@ -522,24 +526,7 @@ void MemoryWidget::refreshDisasm(const QString &offset) } connect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled())); - - // Gett ALL disasm, dissabled - /* - int size; - QString txt; - size = main->core->get_size(); - QList> sections = main->core->get_exec_sections(); - - foreach (QList section, sections) { - // TODO: Remove later this check and add all sections - if (section[2].contains(".text")) { - this->main->core->cmd("s section." + section[2]); - this->main->core->cmd("b " + section[1]); - txt.append( this->main->core->cmd("pD") ); - } - } - */ - + connect(this->disasTextEdit, SIGNAL(cursorPositionChanged()), this, SLOT(on_disasTextEdit_2_cursorPositionChanged())); } void MemoryWidget::refreshHexdump(QString where) @@ -1524,7 +1511,7 @@ void MemoryWidget::create_graph(QString off) QString fcn = this->main->core->cmdFunctionAt(off); //this->main->add_debug_output("Graph Fcn: " + fcn); - ui->graphWebView->load(QUrl("qrc:/graph/html/graph/index.html#" + off)); + ui->graphWebView->setUrl(QUrl("qrc:/graph/html/graph/index.html#" + off)); QString port = this->main->core->config("http.port"); ui->graphWebView->page()->mainFrame()->evaluateJavaScript(QString("r2.root=\"http://localhost:" + port + "\"")); @@ -1612,8 +1599,9 @@ void MemoryWidget::on_disasTextEdit_2_cursorPositionChanged() ui->fcnNameEdit->setText(at); this->main->memoryDock->setWindowTitle(at); this->main->memoryDock->get_refs_data(ele); - this->main->memoryDock->create_graph(ele); + //this->main->memoryDock->create_graph(ele); this->setMiniGraph(at); + this->main->current_address = at; } } } @@ -1766,7 +1754,7 @@ bool MemoryWidget::eventFilter(QObject *obj, QEvent *event) if ((obj == ui->disasTextEdit_2 || obj == ui->disasTextEdit_2->viewport()) && event->type() == QEvent::MouseButtonDblClick) { QMouseEvent *mouseEvent = static_cast(event); - qDebug()<x()).arg(mouseEvent->y()); + //qDebug()<x()).arg(mouseEvent->y()); QTextCursor cursor = ui->disasTextEdit_2->cursorForPosition(QPoint(mouseEvent->x(), mouseEvent->y())); cursor.select(QTextCursor::LineUnderCursor); QString lastline = cursor.selectedText(); @@ -1937,3 +1925,42 @@ void MemoryWidget::frameLoadFinished(bool ok) } } } + +void MemoryWidget::on_memTabWidget_currentChanged(int index) +{ + /* + this->main->add_debug_output("Update index: " + QString::number(index) + " to function: " + this->main->current_address); + this->main->add_debug_output("Last disasm: " + this->last_disasm_fcn); + this->main->add_debug_output("Last graph: " + this->last_graph_fcn); + this->main->add_debug_output("Last hexdump: " + this->last_hexdump_fcn); + */ + this->updateViews(); +} + +void MemoryWidget::updateViews() { + // Update only the selected view to improve performance + + int index = ui->memTabWidget->tabBar()->currentIndex(); + if (index == 0) { + // Disasm + if (this->last_disasm_fcn != this->main->current_address) { + //this->main->add_debug_output("Doing disasm"); + this->refreshDisasm(this->main->current_address); + this->last_disasm_fcn = this->main->current_address; + } + } else if (index == 1) { + // Hex + if (this->last_hexdump_fcn != this->main->current_address) { + //this->main->add_debug_output("Doing hex"); + this->refreshHexdump(this->main->current_address); + this->last_hexdump_fcn = this->main->current_address; + } + } else if (index == 2) { + // Graph + if (this->last_graph_fcn != this->main->current_address) { + //this->main->add_debug_output("Doing graph"); + this->create_graph(this->main->current_address); + this->last_graph_fcn = this->main->current_address; + } + } +} diff --git a/src/widgets/memorywidget.h b/src/widgets/memorywidget.h index 6cf0e5bb..6a97e4ce 100644 --- a/src/widgets/memorywidget.h +++ b/src/widgets/memorywidget.h @@ -87,6 +87,8 @@ public slots: void frameLoadFinished(bool ok); + void updateViews(); + protected: void resizeEvent(QResizeEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override; @@ -97,6 +99,9 @@ private: ut64 hexdumpTopOffset; ut64 hexdumpBottomOffset; QString last_fcn; + QString last_disasm_fcn; + QString last_graph_fcn; + QString last_hexdump_fcn; private slots: void highlightCurrentLine(); @@ -170,6 +175,7 @@ private slots: void on_simpleGrapgToolButton_clicked(); void on_opcodeDescButton_clicked(); void seek_back(); + void on_memTabWidget_currentChanged(int index); }; #endif // MEMORYWIDGET_H