diff --git a/src/analthread.cpp b/src/analthread.cpp index 5c008f74..1d4c391c 100644 --- a/src/analthread.cpp +++ b/src/analthread.cpp @@ -18,10 +18,11 @@ AnalThread::~AnalThread() } } -void AnalThread::start(IaitoRCore *core, int level) +void AnalThread::start(IaitoRCore *core, int level, QList advanced) { this->core = core; this->level = level; + this->advanced = advanced; QThread::start(); } @@ -30,5 +31,5 @@ void AnalThread::start(IaitoRCore *core, int level) void AnalThread::run() { //qDebug() << "Anal level: " << this->level; - core->analyze(this->level); + core->analyze(this->level, this->advanced); } diff --git a/src/analthread.h b/src/analthread.h index e2283f5b..afb9e3d6 100644 --- a/src/analthread.h +++ b/src/analthread.h @@ -12,7 +12,7 @@ public: explicit AnalThread(QWidget *parent = 0); ~AnalThread(); - void start(IaitoRCore *core, int level); + void start(IaitoRCore *core, int level, QList advanced); protected: void run(); @@ -22,6 +22,7 @@ protected: private: IaitoRCore *core; int level; + QList advanced; }; #endif // ANALTHREAD_H diff --git a/src/iaitorcore.h b/src/iaitorcore.h index 3d1c2ca2..959a72a5 100644 --- a/src/iaitorcore.h +++ b/src/iaitorcore.h @@ -191,7 +191,7 @@ public: void setOptions(QString key); bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false); bool tryFile(QString path, bool rw); - void analyze(int level); + void analyze(int level, QList advanced); void seek(QString addr); void seek(ut64 offset); ut64 math(const QString &expr); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7bf0cc93..82cfde55 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,17 +286,17 @@ void MainWindow::initUI() connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshVisibleDockWidgets())); } -void MainWindow::openFile(const QString &fn, int anal_level) +void MainWindow::openFile(const QString &fn, int anal_level, QList advanced) { QString project_name = qhelpers::uniqueProjectName(fn); if (core->getProjectNames().contains(project_name)) openProject(project_name); else - openNewFile(fn, anal_level); + openNewFile(fn, anal_level, advanced); } -void MainWindow::openNewFile(const QString &fn, int anal_level) +void MainWindow::openNewFile(const QString &fn, int anal_level, QList advanced) { setFilename(fn); @@ -305,7 +305,7 @@ void MainWindow::openNewFile(const QString &fn, int anal_level) o->show(); if (anal_level >= 0) - o->setupAndStartAnalysis(anal_level); + o->setupAndStartAnalysis(anal_level, advanced); } void MainWindow::openProject(const QString &project_name) diff --git a/src/mainwindow.h b/src/mainwindow.h index f7f7e64d..21bac239 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -54,7 +54,7 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); - void openFile(const QString &fn, int anal_level = -1); + void openFile(const QString &fn, int anal_level = -1, QList advanced = QList()); void initUI(); void finalizeOpen(); @@ -210,7 +210,7 @@ private: RVA cursor_address; void openProject(const QString &project_name); - void openNewFile(const QString &fn, int anal_level); + void openNewFile(const QString &fn, int anal_level, QList advanced); void toggleDockWidget(DockWidget *dock_widget); diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index d7abb364..6d892ec7 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -17,7 +17,7 @@ OptionsDialog::OptionsDialog(MainWindow *main): ui(new Ui::OptionsDialog), analThread(this), main(main), - defaultAnalLevel(3) + defaultAnalLevel(1) { ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); @@ -41,6 +41,7 @@ OptionsDialog::OptionsDialog(MainWindow *main): ui->spacyCheckBox->setChecked(settings.value("bbline").toBool()); ui->hideFrame->setVisible(false); + ui->analoptionsFrame->setVisible(false); // Add this so the dialog resizes when widgets are shown/hidden //this->layout()->setSizeConstraint(QLayout::SetFixedSize); @@ -57,7 +58,7 @@ OptionsDialog::~OptionsDialog() delete ui; } -void OptionsDialog::setupAndStartAnalysis(int level) +void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) { ui->analSlider->setValue(level); @@ -143,7 +144,7 @@ void OptionsDialog::setupAndStartAnalysis(int level) // Threads stuff // connect signal/slot - analThread.start(main->core, level); + analThread.start(main->core, level, advanced); } void OptionsDialog::on_closeButton_clicked() @@ -153,7 +154,44 @@ void OptionsDialog::on_closeButton_clicked() void OptionsDialog::on_okButton_clicked() { - setupAndStartAnalysis(ui->analSlider->value()); + QList advanced = QList(); + if (ui->analSlider->value() == 3){ + if (ui->aa_symbols->isChecked()){ + advanced << "aa"; + } + if (ui->aar_references->isChecked()){ + advanced << "aar"; + } + if (ui->aac_calls->isChecked()){ + advanced << "aac"; + } + if (ui->aan_rename->isChecked()){ + advanced << "aan"; + } + if (ui->aae_emulate->isChecked()){ + advanced << "aae"; + } + if (ui->aat_consecutive->isChecked()){ + advanced << "aat"; + } + if (ui->afta_typeargument->isChecked()){ + advanced << "afta"; + } + if (ui->aaT_aftertrap->isChecked()){ + advanced << "aaT"; + } + if (ui->aap_preludes->isChecked()){ + advanced << "aap"; + } + if (ui->jmptbl->isChecked()){ + advanced << "e! anal.jmptbl"; + } + if (ui->pushret->isChecked()){ + advanced << "e! anal.pushret"; + } + } + + setupAndStartAnalysis(ui->analSlider->value(), advanced); } void OptionsDialog::anal_finished() @@ -192,15 +230,13 @@ QString OptionsDialog::analysisDescription(int level) switch (level) { case 0: - return tr("-"); + return tr("No analysis"); case 1: - return tr("Minimum"); + return tr("Auto-Analysis (aaa)"); case 2: - return tr("Basic"); + return tr("Auto-Analysis Experimental (aaaa)"); case 3: - return tr("Medium"); - case 4: - return tr("Full (Experimental)"); + return tr("Advanced"); default: return tr("Unknown"); } @@ -218,6 +254,14 @@ void OptionsDialog::on_analSlider_valueChanged(int value) { ui->analCheckBox->setChecked(true); ui->analCheckBox->setText("Analysis: Enabled"); + if (value==3) + { + ui->analoptionsFrame->setVisible(true); + } + else + { + ui->analoptionsFrame->setVisible(false); + } } } diff --git a/src/optionsdialog.h b/src/optionsdialog.h index 0acc2a7a..2fc6e7c8 100644 --- a/src/optionsdialog.h +++ b/src/optionsdialog.h @@ -24,7 +24,7 @@ public: RAnalFunction functionAt(ut64 addr); QStringList asm_plugins; - void setupAndStartAnalysis(int level); + void setupAndStartAnalysis(int level, QList advanced); private slots: void on_closeButton_clicked(); diff --git a/src/optionsdialog.ui b/src/optionsdialog.ui index 99833bd8..014229ab 100644 --- a/src/optionsdialog.ui +++ b/src/optionsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 414 - 657 + 576 + 1167 @@ -188,10 +188,20 @@ 5 - + 5 + + QLayout::SetDefaultConstraint + + + + + Qt::Vertical + + + @@ -214,13 +224,6 @@ - - - - Qt::Vertical - - - @@ -248,7 +251,7 @@ 0 - 4 + 3 1 @@ -267,6 +270,132 @@ + + + + true + + + + 0 + 0 + + + + + 6 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Analyze all symbols (aa) + + + true + + + + + + + Analyze for references (aar) + + + true + + + + + + + Analyze function calls (aac) + + + true + + + + + + + Autorename functions based on context (aan) + + + true + + + + + + + Experimental: + + + + + + + Emulate code to find computed references (aae) + + + + + + + Analyze for consecutive function (aat) + + + + + + + Type and Argument matching analysis (afta) + + + + + + + Analyze code after trap-sleds (aaT) + + + + + + + Analyze function preludes (aap) + + + + + + + Analyze jump tables in switch statements (e! anal.jmptbl) + + + + + + + Analyze push+ret as jmp (e! anal.pushret) + + + + + + @@ -289,6 +418,9 @@ 0 + + Qt::LeftToRight + background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); diff --git a/src/qrcore.cpp b/src/qrcore.cpp index 26c5b008..3e80403a 100644 --- a/src/qrcore.cpp +++ b/src/qrcore.cpp @@ -292,32 +292,28 @@ bool IaitoRCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo return true; } -void IaitoRCore::analyze(int level) +void IaitoRCore::analyze(int level, QList advanced) { CORE_LOCK(); /* * Levels - * Nivel 1: afr @ entry0 y main (afr@entry0;afr@main) - * Nivel 2: aa - * Nivel 3: aaa - * Nivel 4: aaaa + * Nivel 1: aaa + * Nivel 2: aaaa */ if (level == 1) { - r_core_cmd0(core_, "afr@entry0;afr@main"); + r_core_cmd0(core_, "aaa"); } else if (level == 2) { - r_core_cmd0(core_, "aa"); + r_core_cmd0(core_, "aaaa"); } else if (level == 3) { - r_core_cmd0(core_, "aaa"); - } - else if (level == 4) - { - r_core_cmd0(core_, "aaaa"); + foreach(QString option, advanced){ + r_core_cmd0(core_, option.toStdString().c_str()); + } } }