diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 76e5daee..85908b91 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -314,6 +314,22 @@ void MainWindow::openNewFile(const QString &fn, int anal_level, QList a { setFilename(fn); + /* Reset config */ + core->resetDefaultAsmOptions(); + + /* Prompt to load filename.r2 script */ + QString script = QString("%1.r2").arg(this->filename); + if (r_file_exists(script.toStdString().data())) { + QMessageBox mb; + mb.setWindowTitle(tr("Script loading")); + mb.setText(tr("Do you want to load the '%1' script?").arg(script)); + mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + if (mb.exec() == QMessageBox::Yes) { + core->loadScript(script); + } + } + + /* Show analysis options dialog */ OptionsDialog *o = new OptionsDialog(this); o->setAttribute(Qt::WA_DeleteOnClose); o->show(); diff --git a/src/cutter.cpp b/src/cutter.cpp index 99c38892..5c02e0ab 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -1351,3 +1351,8 @@ QList CutterCore::disassembleLines(RVA offset, int lines) return r; } + +void CutterCore::loadScript(const QString &scriptname) +{ + r_core_cmd_file(core_, scriptname.toStdString().data()); +} diff --git a/src/cutter.h b/src/cutter.h index 2f825e8f..707545eb 100644 --- a/src/cutter.h +++ b/src/cutter.h @@ -333,6 +333,8 @@ public: void resetDefaultAsmOptions(); void saveDefaultAsmOptions(); + void loadScript(const QString &scriptname); + RCoreLocked core() const; /* fields */ diff --git a/src/dialogs/OptionsDialog.cpp b/src/dialogs/OptionsDialog.cpp index 32d867c7..bd812e3c 100644 --- a/src/dialogs/OptionsDialog.cpp +++ b/src/dialogs/OptionsDialog.cpp @@ -139,8 +139,6 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) main->initUI(); - core->resetDefaultAsmOptions(); - // Timer for showing elapsed analysis time. analTimer.setInterval(1000); analTimer.setSingleShot(false);