diff --git a/src/common/Configuration.cpp b/src/common/Configuration.cpp index f1e98fa8..9ec85c69 100644 --- a/src/common/Configuration.cpp +++ b/src/common/Configuration.cpp @@ -817,6 +817,16 @@ bool Configuration::getPreviewValue() const return s.value("asm.preview").toBool(); } +void Configuration::setShowRawStrings(bool enabled) +{ + s.setValue("showRawStrings", enabled); +} + +bool Configuration::getShowRawStrings() const +{ + return s.value("showRawStrings", false).toBool(); +} + void Configuration::setShowVarTooltips(bool enabled) { s.setValue("showVarTooltips", enabled); diff --git a/src/common/Configuration.h b/src/common/Configuration.h index 31139b55..3189d65d 100644 --- a/src/common/Configuration.h +++ b/src/common/Configuration.h @@ -245,6 +245,14 @@ public: void setPreviewValue(bool checked); bool getPreviewValue() const; + // Strings + + /** + * @brief Set whether to show raw strings in @ref StringsWidget + */ + void setShowRawStrings(bool enabled); + bool getShowRawStrings() const; + // Tooltip /** diff --git a/src/common/StringsTask.h b/src/common/StringsTask.h index e1d6d447..309c6c3d 100644 --- a/src/common/StringsTask.h +++ b/src/common/StringsTask.h @@ -12,6 +12,7 @@ class StringsTask : public AsyncTask Q_OBJECT public: + explicit StringsTask(bool raw) : raw(raw) {} QString getTitle() const override { return tr("Searching for Strings"); } signals: @@ -20,9 +21,12 @@ signals: protected: void runTask() override { - auto strings = Core()->getAllStrings(); + auto strings = Core()->getAllStrings(raw); emit stringSearchFinished(strings); } + +private: + bool raw; }; #endif // STRINGSTASK_H diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 6d1669f1..62dc363a 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -3476,7 +3476,7 @@ QList CutterCore::getAllRelocs() return ret; } -QList CutterCore::getAllStrings() +QList CutterCore::getAllStrings(bool raw) { CORE_LOCK(); RzBinFile *bf = rz_bin_cur(core->bin); @@ -3488,7 +3488,13 @@ QList CutterCore::getAllStrings() return {}; } - const RzPVector *strings = rz_core_bin_whole_strings(core, bf); + const RzPVector *strings = nullptr; + if (raw) { + strings = rz_core_bin_whole_strings(core, bf); + } else if (auto *bf = rz_bin_cur(core->bin)) { + strings = rz_bin_object_get_strings(bf->o); + } + if (!strings) { return {}; } diff --git a/src/core/Cutter.h b/src/core/Cutter.h index 30d05aa5..e1547c97 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -745,7 +745,7 @@ public: QList getSignaturesDB(); QList getAllComments(const QString &filterType); QList getAllRelocs(); - QList getAllStrings(); + QList getAllStrings(bool raw); QList getAllFlagspaces(); QList getAllFlags(const QString &flagspace = QString()); QList getAllSections(); diff --git a/src/dialogs/XrefsDialog.cpp b/src/dialogs/XrefsDialog.cpp index df0ea8b8..45d8d317 100644 --- a/src/dialogs/XrefsDialog.cpp +++ b/src/dialogs/XrefsDialog.cpp @@ -205,6 +205,7 @@ void XrefsDialog::hideXrefFromSection() { ui->labelXFrom->hide(); ui->fromTreeWidget->hide(); + ui->fromQuickFilter->hide(); } void XrefsDialog::fillRefsForAddress(RVA addr, const QString &name, bool whole_function) @@ -375,7 +376,7 @@ bool XrefFilterProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) { const QModelIndex index = sourceModel()->index(row, 0, parent); const auto xref = index.data(XrefModel::flagDescriptionRole).value(); - return qhelpers::filterStringContains(to ? xref.toStr : xref.fromStr, this); + return qhelpers::filterStringContains(to ? xref.fromStr : xref.toStr, this); } bool XrefFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const diff --git a/src/widgets/StringsWidget.cpp b/src/widgets/StringsWidget.cpp index a4840d5b..020bf7b0 100644 --- a/src/widgets/StringsWidget.cpp +++ b/src/widgets/StringsWidget.cpp @@ -187,7 +187,14 @@ StringsWidget::StringsWidget(MainWindow *main) ui->stringsTreeView->setModel(static_cast(proxyModel)); ui->stringsTreeView->sortByColumn(-1, Qt::AscendingOrder); - // + ui->rawStringsCheckBox->setChecked(Config()->getShowRawStrings()); + ui->rawStringsCheckBox->setStyleSheet("QCheckBox {" + " padding-left: 10px;" + " padding-right: 10px;" + " padding-top: 5px;" + " padding-bottom: 0px;" + "}"); + auto menu = ui->stringsTreeView->getItemContextMenu(); menu->addAction(ui->actionCopyString); @@ -219,11 +226,15 @@ StringsWidget::StringsWidget(MainWindow *main) ui->quickFilterView->setItemCount(proxyModel->rowCount()); }); - auto header = ui->stringsTreeView->header(); - header->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); - header->setSectionResizeMode(StringsModel::StringColumn, QHeaderView::ResizeMode::Stretch); - header->setStretchLastSection(false); - header->setResizeContentsPrecision(256); + auto showRawStringsChecked = [this](bool checked) { + Config()->setShowRawStrings(checked); + refreshStrings(); + }; +#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) + connect(ui->rawStringsCheckBox, &QCheckBox::checkStateChanged, this, showRawStringsChecked); +#else + connect(ui->rawStringsCheckBox, &QCheckBox::stateChanged, this, showRawStringsChecked); +#endif } StringsWidget::~StringsWidget() {} @@ -234,7 +245,7 @@ void StringsWidget::refreshStrings() task->wait(); } - task = std::shared_ptr(new StringsTask()); + task = std::shared_ptr(new StringsTask(ui->rawStringsCheckBox->isChecked())); connect(task.get(), &StringsTask::stringSearchFinished, this, &StringsWidget::stringSearchFinished); Core()->getAsyncTaskManager()->start(task); @@ -262,6 +273,8 @@ void StringsWidget::stringSearchFinished(const QList &strings model->strings = strings; model->endResetModel(); + qhelpers::adjustColumns(ui->stringsTreeView, StringsModel::ColumnCount, 0); + // set the initial item count ui->quickFilterView->setItemCount(proxyModel->rowCount()); diff --git a/src/widgets/StringsWidget.ui b/src/widgets/StringsWidget.ui index 4dd3c59d..b14b2657 100644 --- a/src/widgets/StringsWidget.ui +++ b/src/widgets/StringsWidget.ui @@ -14,7 +14,7 @@ Strings - + 0 @@ -60,14 +60,21 @@ - - - - 0 - 0 - + + + 0 - + + + + Show Raw Strings + + + + + + +