Added message box when r_core_file_open fails

This commit is contained in:
xarkes 2018-05-08 22:44:53 +02:00
parent 8ab3a3664c
commit 43b147c6eb
9 changed files with 31 additions and 13 deletions

View File

@ -78,8 +78,14 @@ void AnalThread::run()
// Do not reload the file if already loaded
QJsonArray openedFiles = Core()->getOpenedFiles();
if (!openedFiles.size()) {
Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo,
bool fileLoaded = Core()->loadFile(main->getFilename(), binLoadAddr, mapAddr, perms, va, loadBinInfo,
forceBinPlugin);
if (!fileLoaded) {
// Something wrong happened, fallback to open dialog
emit openFileFailed();
interrupted = true;
return;
}
}
// Set asm OS configuration

View File

@ -29,6 +29,7 @@ protected:
signals:
void updateProgress(QString str);
void openFileFailed();
private:
int level;

View File

@ -214,7 +214,6 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int
f = r_core_file_open(core_, path.toUtf8().constData(), perms, mapaddr);
if (!f) {
// @TODO pop warning msg
eprintf("r_core_file_open failed\n");
return false;
}

View File

@ -108,7 +108,7 @@ bool CutterApplication::event(QEvent *e)
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(e);
if (openEvent) {
if (m_FileAlreadyDropped) {
// we already dropped a file in macOS, let's spawn another instance
// We already dropped a file in macOS, let's spawn another instance
// (Like the File -> Open)
QString fileName = openEvent->file();
QProcess process(this);

View File

@ -239,6 +239,17 @@ void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> ad
displayAnalysisOptionsDialog(analLevel, advancedOptions);
}
void MainWindow::openNewFileFailed()
{
displayNewFileDialog();
QMessageBox mb(this);
mb.setIcon(QMessageBox::Critical);
mb.setStandardButtons(QMessageBox::Ok);
mb.setWindowTitle(tr("Cannot open file!"));
mb.setText(tr("Could not open the file! Make sure the file exists and that you have the correct permissions."));
mb.exec();
}
void MainWindow::displayNewFileDialog()
{
NewFileDialog *n = new NewFileDialog();
@ -294,7 +305,6 @@ void MainWindow::finalizeOpen()
addOutput(tr(" > Finished, happy reversing :)"));
// Add fortune message
addOutput("\n" + core->cmd("fo"));
//previewDock->setWindowTitle("entry0");
showMaximized();
}

View File

@ -113,6 +113,8 @@ public slots:
void toggleResponsive(bool maybe);
void openNewFileFailed();
private slots:
void on_actionAbout_triggered();

View File

@ -61,7 +61,7 @@ OptionsDialog::OptionsDialog(MainWindow *main):
// Add this so the dialog resizes when widgets are shown/hidden
//this->layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
connect(&analThread, SIGNAL(finished()), this, SLOT(analysisFinished()));
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
ui->programLineEdit->setText(main->getFilename());
@ -171,6 +171,7 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList<QString> advanced)
// Threads stuff, connect signal/slot
connect(&analThread, &AnalThread::updateProgress, this, &OptionsDialog::updateProgress);
connect(&analThread, &AnalThread::openFileFailed, main, &MainWindow::openNewFileFailed);
analThread.start(main, level, advanced);
}
@ -246,14 +247,15 @@ void OptionsDialog::on_okButton_clicked()
setupAndStartAnalysis(ui->analSlider->value(), advanced);
}
void OptionsDialog::anal_finished()
void OptionsDialog::analysisFinished()
{
if (analThread.isInterrupted()) {
done(0);
updateProgress(tr("Analysis aborted."));
done(1);
return;
}
ui->statusLabel->setText(tr("Loading interface"));
updateProgress(tr("Loading interface..."));
main->addOutput(tr(" > Analysis finished"));
main->finalizeOpen();

View File

@ -40,7 +40,7 @@ private slots:
void updatePDBLayout();
void updateScriptLayout();
void anal_finished();
void analysisFinished();
protected:
void closeEvent(QCloseEvent *event) override;

View File

@ -47,9 +47,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const
return res.name;
case ADDRESS:
return RAddressString(res.addr);
default:
break;
}
break;
case VTableDescriptionRole:
return QVariant::fromValue(res);
default:
@ -63,9 +62,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const
return tr("VTable ") + QString::number(index.row() + 1);
case ADDRESS:
return RAddressString(vtables->at(index.row()).addr);
default:
break;
}
break;
case VTableDescriptionRole: {
const VTableDescription &res = vtables->at(index.row());
return QVariant::fromValue(res);