Added <file>.r2 auto loading

This commit is contained in:
xarkes 2017-12-14 13:45:03 +01:00
parent f357303090
commit 33732291e7
4 changed files with 23 additions and 2 deletions

View File

@ -314,6 +314,22 @@ void MainWindow::openNewFile(const QString &fn, int anal_level, QList<QString> 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();

View File

@ -1351,3 +1351,8 @@ QList<DisassemblyLine> CutterCore::disassembleLines(RVA offset, int lines)
return r;
}
void CutterCore::loadScript(const QString &scriptname)
{
r_core_cmd_file(core_, scriptname.toStdString().data());
}

View File

@ -333,6 +333,8 @@ public:
void resetDefaultAsmOptions();
void saveDefaultAsmOptions();
void loadScript(const QString &scriptname);
RCoreLocked core() const;
/* fields */

View File

@ -139,8 +139,6 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
main->initUI();
core->resetDefaultAsmOptions();
// Timer for showing elapsed analysis time.
analTimer.setInterval(1000);
analTimer.setSingleShot(false);