From 08e55827b7317b437c1138dd91e8d6c0e6247759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sat, 18 Aug 2018 20:45:49 +0200 Subject: [PATCH] Fix Default Anal Level --- src/dialogs/InitialOptionsDialog.cpp | 24 ++++++++++++++---------- src/dialogs/InitialOptionsDialog.h | 2 +- src/utils/InitialOptions.h | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/dialogs/InitialOptionsDialog.cpp b/src/dialogs/InitialOptionsDialog.cpp index 43c84684..f6d21214 100644 --- a/src/dialogs/InitialOptionsDialog.cpp +++ b/src/dialogs/InitialOptionsDialog.cpp @@ -16,13 +16,11 @@ InitialOptionsDialog::InitialOptionsDialog(MainWindow *main): QDialog(0), // parent must not be main ui(new Ui::InitialOptionsDialog), main(main), - core(Core()), - defaultAnalLevel(1) + core(Core()) { ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); ui->logoSvgWidget->load(Config()->getLogoFile()); - ui->analSlider->setValue(defaultAnalLevel); // Fill the plugins combo asm_plugins = core->getAsmPluginNames(); @@ -85,10 +83,13 @@ void InitialOptionsDialog::updateCPUComboBox() void InitialOptionsDialog::loadOptions(const InitialOptions &options) { if (options.analCmd.isEmpty()) { - ui->analSlider->setValue(0); + analLevel = 0; } else if (options.analCmd == QList({ "aaa" })) { - ui->analSlider->setValue(1); - } else if (options.analCmd == QList({ "aaaa" })){ + analLevel = 1; + } else if (options.analCmd == QList({ "aaaa" })) { + analLevel = 2; + } else { + analLevel = 3; // TODO: These checks must always be in sync with getSelectedAdvancedAnalCmds(), which is dangerous ui->aa_symbols->setChecked(options.analCmd.contains("aa")); ui->aar_references->setChecked(options.analCmd.contains("aar")); @@ -108,12 +109,14 @@ void InitialOptionsDialog::loadOptions(const InitialOptions &options) if (!options.script.isEmpty()) { ui->scriptCheckBox->setChecked(true); ui->scriptLineEdit->setText(options.script); - ui->analSlider->setValue(0); + analLevel = 0; } else { ui->scriptCheckBox->setChecked(false); ui->scriptLineEdit->setText(""); } + ui->analSlider->setValue(analLevel); + shellcode = options.shellcode; // TODO: all other options should also be applied to the ui @@ -353,9 +356,10 @@ void InitialOptionsDialog::on_AdvOptButton_clicked() void InitialOptionsDialog::on_analCheckBox_clicked(bool checked) { - if (!checked) - defaultAnalLevel = ui->analSlider->value(); - ui->analSlider->setValue(checked ? defaultAnalLevel : 0); + if (!checked) { + analLevel = ui->analSlider->value(); + } + ui->analSlider->setValue(checked ? analLevel : 0); } void InitialOptionsDialog::on_archComboBox_currentIndexChanged(int) diff --git a/src/dialogs/InitialOptionsDialog.h b/src/dialogs/InitialOptionsDialog.h index 385cec2d..544592b5 100644 --- a/src/dialogs/InitialOptionsDialog.h +++ b/src/dialogs/InitialOptionsDialog.h @@ -49,10 +49,10 @@ private: MainWindow *main; CutterCore *core; - int defaultAnalLevel; QString analysisDescription(int level); QString shellcode; + int analLevel; void updateCPUComboBox(); diff --git a/src/utils/InitialOptions.h b/src/utils/InitialOptions.h index de67e1e1..3224cea5 100644 --- a/src/utils/InitialOptions.h +++ b/src/utils/InitialOptions.h @@ -32,7 +32,7 @@ struct InitialOptions int bbsize = 0; - QList analCmd; + QList analCmd = { "aaa" }; QString shellcode; };