From f98a175c5c71da24c1412c2cf55a8609228c1fa1 Mon Sep 17 00:00:00 2001 From: xarkes Date: Tue, 14 Aug 2018 17:07:52 +0200 Subject: [PATCH] Set bits for analysis after loading the binary (#618) --- src/AnalTask.cpp | 5 +++-- src/Cutter.cpp | 8 ++++++-- src/widgets/HexdumpWidget.cpp | 6 ++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/AnalTask.cpp b/src/AnalTask.cpp index 40d766b0..4bbd90b2 100644 --- a/src/AnalTask.cpp +++ b/src/AnalTask.cpp @@ -26,8 +26,6 @@ void AnalTask::runTask() log(tr("Loading Binary...\n")); openFailed = false; - Core()->setCPU(options.arch, options.cpu, options.bits); - int perms = R_IO_READ | R_IO_EXEC; if (options.writeEnabled) perms |= R_IO_WRITE; @@ -54,6 +52,9 @@ void AnalTask::runTask() } } + // r_core_bin_load might change asm.bits, so let's set that after the bin is loaded + Core()->setCPU(options.arch, options.cpu, options.bits); + if (isInterrupted()) { return; } diff --git a/src/Cutter.cpp b/src/Cutter.cpp index e233ddb9..9265f4c1 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -609,8 +609,12 @@ void CutterCore::setConfig(const QString &k, const QVariant &v) void CutterCore::setCPU(QString arch, QString cpu, int bits) { - setConfig("asm.arch", arch); - setConfig("asm.cpu", cpu); + if (arch != nullptr) { + setConfig("asm.arch", arch); + } + if (cpu != nullptr) { + setConfig("asm.cpu", cpu); + } setConfig("asm.bits", bits); } diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 743e652f..d07b95e9 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -1068,15 +1068,13 @@ void HexdumpWidget::on_copySHA1_clicked() void HexdumpWidget::selectHexPreview() { // Pre-select arch and bits in the hexdump sidebar - QString arch = Core()->cmd("e asm.arch").trimmed(); - QString bits = Core()->cmd("e asm.bits").trimmed(); + QString arch = Core()->getConfig("asm.arch"); + QString bits = Core()->getConfig("asm.bits"); - //int arch_index = ui->hexArchComboBox_2->findText(arch); if (ui->parseArchComboBox->findText(arch) != -1) { ui->parseArchComboBox->setCurrentIndex(ui->parseArchComboBox->findText(arch)); } - //int bits_index = ui->hexBitsComboBox_2->findText(bits); if (ui->parseBitsComboBox->findText(bits) != -1) { ui->parseBitsComboBox->setCurrentIndex(ui->parseBitsComboBox->findText(bits)); }