diff --git a/docs/source/images/analysis_dialog.png b/docs/source/images/analysis_dialog.png index 51c990a8..2844ebbb 100644 Binary files a/docs/source/images/analysis_dialog.png and b/docs/source/images/analysis_dialog.png differ diff --git a/docs/source/user-docs/preferences/analysis.rst b/docs/source/user-docs/preferences/analysis.rst index 5229bfe4..377afb5a 100644 --- a/docs/source/user-docs/preferences/analysis.rst +++ b/docs/source/user-docs/preferences/analysis.rst @@ -19,6 +19,19 @@ command, taking into account the configured values of the analysis options. **Steps to open:** ``Edit -> Preferences -> Analysis`` +Search boundaries for analysis +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Select the boundaries in which the analyis will be performed. The different options are: + +- All executable maps (``io.maps.x``) +- All maps (``io.maps``) +- Current map (``io.map``) +- Raw (``raw``) +- Current mapped section (``bin.section``) +- All mapped sections (``bin.sections``) + +**Configuration variable:** ``anal.in`` + Speculatively set a name for the functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Try to name functions without symbols by using artifacts in the functions such as API calls and strings. @@ -72,3 +85,15 @@ Print warnings encountered while preforming type analysis. These warnings can he wrong in the analysis. **Configuration variable:** ``anal.types.verbose`` + +Pointer depth +~~~~~~~~~~~~~ +The maximum number of nested pointers to follow in analysis. + +**Configuration variable:** ``anal.ptrdepth`` + +Functions prelude +~~~~~~~ +Hex value that represents certain opcodes that will be used to identify functions. + +**Configuration variable:** ``anal.prelude`` diff --git a/src/dialogs/preferences/AnalOptionsWidget.cpp b/src/dialogs/preferences/AnalOptionsWidget.cpp index 2ea6df5a..51d83c90 100644 --- a/src/dialogs/preferences/AnalOptionsWidget.cpp +++ b/src/dialogs/preferences/AnalOptionsWidget.cpp @@ -8,6 +8,15 @@ #include "core/MainWindow.h" +static const QHash analBoundaries { + {"io.maps.x", "All executable maps"}, + {"io.maps", "All maps"}, + {"io.map", "Current map"}, + {"raw", "Raw"}, + {"bin.section", "Current mapped section"}, + {"bin.sections", "All mapped sections"}, +}; + AnalOptionsWidget::AnalOptionsWidget(PreferencesDialog *dialog) : QDialog(dialog), ui(new Ui::AnalOptionsWidget) @@ -24,6 +33,9 @@ AnalOptionsWidget::AnalOptionsWidget(PreferencesDialog *dialog) { ui->verboseCheckBox, "anal.verbose" } }; + // Create list of options for the anal.in selector + createAnalInOptionsList(); + // Connect each checkbox from "checkboxes" to the generic signal "checkboxEnabler" for (ConfigCheckbox &confCheckbox : checkboxes) { QString val = confCheckbox.config; @@ -33,7 +45,13 @@ AnalOptionsWidget::AnalOptionsWidget(PreferencesDialog *dialog) ui->analyzePushButton->setToolTip("Analyze the program using radare2's \"aaa\" command"); auto *mainWindow = new MainWindow(this); - connect(ui->analyzePushButton, &QPushButton::clicked, mainWindow, &MainWindow::on_actionAnalyze_triggered); + connect(ui->analyzePushButton, &QPushButton::clicked, mainWindow, + &MainWindow::on_actionAnalyze_triggered); + connect(ui->analInComboBox, &QComboBox::currentIndexChanged, this, + &AnalOptionsWidget::updateAnalIn); + connect(ui->ptrDepthSpinBox, &QSpinBox::valueChanged, this, + &AnalOptionsWidget::updateAnalPtrDepth); + connect(ui->preludeLineEdit, &QLineEdit::textChanged, this, &AnalOptionsWidget::updateAnalPrelude); updateAnalOptionsFromVars(); } @@ -49,4 +67,37 @@ void AnalOptionsWidget::updateAnalOptionsFromVars() for (ConfigCheckbox &confCheckbox : checkboxes) { qhelpers::setCheckedWithoutSignals(confCheckbox.checkBox, Core()->getConfigb(confCheckbox.config)); } -} \ No newline at end of file + + // Update the rest of analysis options that are not checkboxes + ui->analInComboBox->setCurrentIndex(ui->analInComboBox->findData(Core()->getConfig("anal.in"))); + ui->ptrDepthSpinBox->setValue(Core()->getConfigi("anal.ptrdepth")); + ui->preludeLineEdit->setText(Core()->getConfig("anal.prelude")); +} + +void AnalOptionsWidget::updateAnalIn(int index) +{ + Config()->setConfig("anal.in", ui->analInComboBox->itemData(index).toString()); +} + +void AnalOptionsWidget::updateAnalPtrDepth(int value) +{ + Config()->setConfig("anal.ptrdepth", value); +} + +void AnalOptionsWidget::updateAnalPrelude(const QString &prelude) +{ + Config()->setConfig("anal.prelude", prelude); +} + +void AnalOptionsWidget::createAnalInOptionsList() +{ + QHash::const_iterator mapIter; + + mapIter = analBoundaries.cbegin(); + ui->analInComboBox->blockSignals(true); + ui->analInComboBox->clear(); + for (; mapIter != analBoundaries.cend(); ++mapIter) { + ui->analInComboBox->addItem(mapIter.value(), mapIter.key()); + } + ui->analInComboBox->blockSignals(false); +} diff --git a/src/dialogs/preferences/AnalOptionsWidget.h b/src/dialogs/preferences/AnalOptionsWidget.h index a21f0a75..b7aa65b8 100644 --- a/src/dialogs/preferences/AnalOptionsWidget.h +++ b/src/dialogs/preferences/AnalOptionsWidget.h @@ -28,6 +28,11 @@ private: }; QList checkboxes; + /** + * @brief This function creates the list with the different options shown in the selector for anal.in + */ + void createAnalInOptionsList(); + private slots: /** * @brief A slot to display the options in the dialog according to the current anal.* configuration @@ -41,6 +46,24 @@ private slots: * @param config - the configuration string to be toggled */ static void checkboxEnabler(QCheckBox *checkbox, const QString &config); + + /** + * @brief A slot to update the value of anal.in when a different option is selected + * @param index - The index of the selected option for anal.in + */ + void updateAnalIn(int index); + + /** + * @brief A slot to update the value of anal.ptrdepth when a new value is selected + * @param value - The new value for anal.ptrdepth + */ + static void updateAnalPtrDepth(int value); + + /** + * @brief slot to update the value of anal.prelude when a new value is introduced in the corresponding textbox + * @param prelude - The new value for anal.prelude + */ + static void updateAnalPrelude(const QString &prelude); }; #endif // ANALOPTIONSWIDGET_H diff --git a/src/dialogs/preferences/AnalOptionsWidget.ui b/src/dialogs/preferences/AnalOptionsWidget.ui index 501f6ec6..5e272051 100644 --- a/src/dialogs/preferences/AnalOptionsWidget.ui +++ b/src/dialogs/preferences/AnalOptionsWidget.ui @@ -46,7 +46,7 @@ 10 - 190 + 240 601 23 @@ -59,7 +59,7 @@ 10 - 130 + 180 601 23 @@ -72,7 +72,7 @@ 10 - 160 + 210 601 23 @@ -85,7 +85,7 @@ 10 - 10 + 60 601 23 @@ -98,7 +98,7 @@ 10 - 40 + 90 601 23 @@ -111,7 +111,7 @@ 10 - 70 + 120 601 23 @@ -124,7 +124,7 @@ 10 - 100 + 150 601 23 @@ -133,6 +133,125 @@ Analyze jump tables in switch statements (anal.jmp.tbl) + + + + 10 + 20 + 581 + 27 + + + + + QFormLayout::ExpandingFieldsGrow + + + + + true + + + + 0 + 0 + + + + Search boundaries for analysis (anal.in): + + + + + + + + + + + + 10 + 270 + 581 + 28 + + + + + QFormLayout::ExpandingFieldsGrow + + + + + true + + + + 0 + 0 + + + + Pointer depth (anal.ptrdepth): + + + + + + + 0 + + + 0 + + + + + + + + + 10 + 300 + 581 + 28 + + + + + QFormLayout::ExpandingFieldsGrow + + + + + true + + + + 0 + 0 + + + + Functions Prelude (anal.prelude): + + + + + + + + 0 + 0 + + + + e.g.: 0x554889e5 + + + + +