From 3c2b263de73e3dd273363e8dc526eb8db6c03af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 24 Jan 2021 14:11:46 +0100 Subject: [PATCH] Make SearchWidget set search.in only locally (#2578) --- .gitignore | 3 ++- src/core/Cutter.cpp | 9 +++++++-- src/core/Cutter.h | 2 +- src/widgets/SearchWidget.cpp | 15 ++++----------- src/widgets/SearchWidget.h | 1 - 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 42441039..ff7ca6d5 100644 --- a/.gitignore +++ b/.gitignore @@ -96,5 +96,6 @@ src/out # astyle backup .orig files *.orig -# Gdb's history +# Local gdb files .gdb_history +.gdbinit diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 2a361968..dd485909 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -3349,12 +3349,17 @@ bool CutterCore::isAddressMapped(RVA addr) return !Core()->cmdRawAt(QString("om."), addr).isEmpty(); } -QList CutterCore::getAllSearch(QString search_for, QString space) +QList CutterCore::getAllSearch(QString searchFor, QString space, QString in) { CORE_LOCK(); QList searchRef; - QJsonArray searchArray = cmdj(space + QString(" ") + search_for).array(); + QJsonArray searchArray; + { + TempConfig cfg; + cfg.set("search.in", in); + searchArray = cmdj(QString("%1 %2").arg(space, searchFor)).array(); + } if (space == "/Rj") { for (const QJsonValue &value : searchArray) { diff --git a/src/core/Cutter.h b/src/core/Cutter.h index 8462429e..ef3c4678 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -557,7 +557,7 @@ public: bool isAddressMapped(RVA addr); QList getMemoryMap(); - QList getAllSearch(QString search_for, QString space); + QList getAllSearch(QString searchFor, QString space, QString in); BlockStatistics getBlockStatistics(unsigned int blocksCount); QList getBreakpoints(); QList getAllProcesses(); diff --git a/src/widgets/SearchWidget.cpp b/src/widgets/SearchWidget.cpp index 72991633..97295293 100644 --- a/src/widgets/SearchWidget.cpp +++ b/src/widgets/SearchWidget.cpp @@ -227,7 +227,6 @@ void SearchWidget::updateSearchBoundaries() mapIter = boundaries.cbegin(); ui->searchInCombo->setCurrentIndex(ui->searchInCombo->findData(mapIter.key())); - Config()->setConfig("search.in", mapIter.key()); ui->searchInCombo->blockSignals(true); ui->searchInCombo->clear(); @@ -265,12 +264,12 @@ void SearchWidget::refreshSearchspaces() void SearchWidget::refreshSearch() { - QString search_for = ui->filterLineEdit->text(); - QVariant searchspace_data = ui->searchspaceCombo->currentData(); - QString searchspace = searchspace_data.toString(); + QString searchFor = ui->filterLineEdit->text(); + QString searchSpace = ui->searchspaceCombo->currentData().toString(); + QString searchIn = ui->searchInCombo->currentData().toString(); search_model->beginResetModel(); - search = Core()->getAllSearch(search_for, searchspace); + search = Core()->getAllSearch(searchFor, searchSpace, searchIn); search_model->endResetModel(); qhelpers::adjustColumns(ui->searchTreeView, 3, 0); @@ -313,9 +312,3 @@ void SearchWidget::updatePlaceholderText(int index) ui->filterLineEdit->setPlaceholderText("jmp rax"); } } - -void SearchWidget::on_searchInCombo_currentIndexChanged(int index) -{ - Config()->setConfig("search.in", - ui->searchInCombo->itemData(index).toString()); -} diff --git a/src/widgets/SearchWidget.h b/src/widgets/SearchWidget.h index 9fbad45e..ac836418 100644 --- a/src/widgets/SearchWidget.h +++ b/src/widgets/SearchWidget.h @@ -68,7 +68,6 @@ public: ~SearchWidget(); private slots: - void on_searchInCombo_currentIndexChanged(int index); void searchChanged(); void updateSearchBoundaries(); void refreshSearchspaces();