From 7181c81a2b8ca8356aa49aade2c7eae15b5227c1 Mon Sep 17 00:00:00 2001 From: fcasal Date: Wed, 11 Apr 2018 10:55:37 +0100 Subject: [PATCH] Added /v search ability and usage hints in the box (#435) --- src/widgets/SearchWidget.cpp | 24 ++++++++++++++++++++++++ src/widgets/SearchWidget.h | 1 + src/widgets/SearchWidget.ui | 3 --- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/widgets/SearchWidget.cpp b/src/widgets/SearchWidget.cpp index c23d22aa..98cf52a0 100644 --- a/src/widgets/SearchWidget.cpp +++ b/src/widgets/SearchWidget.cpp @@ -145,6 +145,9 @@ SearchWidget::SearchWidget(MainWindow *main, QAction *action) : refreshSearch(); }); + connect(ui->searchspaceCombo, QOverload::of(&QComboBox::currentIndexChanged), + [=](int index){ updatePlaceholderText(index);}); + } SearchWidget::~SearchWidget() {} @@ -172,6 +175,7 @@ void SearchWidget::refreshSearchspaces() ui->searchspaceCombo->addItem(tr("string"), QVariant("/j")); ui->searchspaceCombo->addItem(tr("hex string"), QVariant("/xj")); ui->searchspaceCombo->addItem(tr("ROP gadgets"), QVariant("/Rj")); + ui->searchspaceCombo->addItem(tr("32bit value"), QVariant("/vj")); if (cur_idx > 0) ui->searchspaceCombo->setCurrentIndex(cur_idx); @@ -196,3 +200,23 @@ void SearchWidget::setScrollMode() { qhelpers::setVerticalScrollMode(ui->searchTreeView); } + +void SearchWidget::updatePlaceholderText(int index) +{ + switch(index){ + case 1: // string + ui->filterLineEdit->setPlaceholderText("foobar"); + break; + case 2: // hex string + ui->filterLineEdit->setPlaceholderText("deadbeef"); + break; + case 3: // ROP gadgets + ui->filterLineEdit->setPlaceholderText("pop,,pop"); + break; + case 4: // 32bit value + ui->filterLineEdit->setPlaceholderText("0xdeadbeef"); + break; + default: + ui->filterLineEdit->setPlaceholderText("jmp rax"); + } +} diff --git a/src/widgets/SearchWidget.h b/src/widgets/SearchWidget.h index 3f67d38e..0f6b56fc 100644 --- a/src/widgets/SearchWidget.h +++ b/src/widgets/SearchWidget.h @@ -79,6 +79,7 @@ private: void refreshSearch(); void setScrollMode(); + void updatePlaceholderText(int index); }; #endif // SEARCHWIDGET_H diff --git a/src/widgets/SearchWidget.ui b/src/widgets/SearchWidget.ui index e94c4993..e184b5b4 100644 --- a/src/widgets/SearchWidget.ui +++ b/src/widgets/SearchWidget.ui @@ -75,9 +75,6 @@ - - jmp rax -