From 28ff13729f4d12624298de30779032d6c8a3da5d Mon Sep 17 00:00:00 2001 From: xarkes Date: Sat, 10 Feb 2018 23:31:15 +0100 Subject: [PATCH] Made "load bin" checkbox more understandble It is also now doing as the -n option of radare --- src/AnalThread.cpp | 3 ++- src/cutter.cpp | 6 +++--- src/cutter.h | 2 +- src/dialogs/OptionsDialog.ui | 10 +++++----- src/utils/Helpers.cpp | 2 ++ src/widgets/Dashboard.cpp | 19 +++---------------- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/AnalThread.cpp b/src/AnalThread.cpp index 720b5e35..c3d9e51a 100644 --- a/src/AnalThread.cpp +++ b/src/AnalThread.cpp @@ -47,7 +47,7 @@ void AnalThread::run() core->setCPU(optionsDialog->getSelectedArch(), optionsDialog->getSelectedCPU(), optionsDialog->getSelectedBits()); bool rw = false; - bool loadBinInfo = ui->binCheckBox->isChecked(); + bool loadBinInfo = !ui->binCheckBox->isChecked(); if (loadBinInfo) { @@ -61,6 +61,7 @@ void AnalThread::run() } else { + Core()->setConfig("file.info", "false"); va = false; loadaddr = mapaddr = 0; } diff --git a/src/cutter.cpp b/src/cutter.cpp index 1efe8dc3..707b89d6 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -715,10 +715,9 @@ QString CutterCore::getDecompiledCode(QString addr) return cmd("pdc @ " + addr); } -QString CutterCore::getFileInfo() +QJsonDocument CutterCore::getFileInfo() { - QString info = cmd("ij"); - return info; + return cmdj("ij"); } QStringList CutterCore::getStats() @@ -1055,6 +1054,7 @@ QList CutterCore::getAllStrings() { CORE_LOCK(); QList ret; + return ret; QJsonDocument stringsDoc = cmdj("izzj"); QJsonObject stringsObj = stringsDoc.object(); QJsonArray stringsArray = stringsObj["strings"].toArray(); diff --git a/src/cutter.h b/src/cutter.h index 937e2cfa..be8ced95 100644 --- a/src/cutter.h +++ b/src/cutter.h @@ -316,7 +316,7 @@ public: RVA getOffsetJump(RVA addr); QString getDecompiledCode(RVA addr); QString getDecompiledCode(QString addr); - QString getFileInfo(); + QJsonDocument getFileInfo(); QStringList getStats(); QString getSimpleGraph(QString function); diff --git a/src/dialogs/OptionsDialog.ui b/src/dialogs/OptionsDialog.ui index 2cdda856..a37de1e7 100644 --- a/src/dialogs/OptionsDialog.ui +++ b/src/dialogs/OptionsDialog.ui @@ -225,9 +225,9 @@ 0 - -611 - 565 - 856 + -379 + 564 + 786 @@ -438,10 +438,10 @@ - Load bin information + Do not load bin information (-n) - true + false diff --git a/src/utils/Helpers.cpp b/src/utils/Helpers.cpp index f61fdd08..e8de34f9 100644 --- a/src/utils/Helpers.cpp +++ b/src/utils/Helpers.cpp @@ -26,6 +26,8 @@ namespace qhelpers QString formatBytecount(const long bytecount) { + if (bytecount == 0) + return "0"; const int exp = log(bytecount) / log(1000); constexpr char suffixes[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E'}; diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index 0f82ce5b..aa39bf3e 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -27,19 +27,9 @@ Dashboard::~Dashboard() {} void Dashboard::updateContents() { - // Parse and add JSON file info - QString info = CutterCore::getInstance()->getFileInfo(); - - QJsonDocument docu = QJsonDocument::fromJson(info.toUtf8()); - QJsonObject object = docu.object(); - QJsonValue value_core = object.value(QString("core")); - QJsonObject item = value_core.toObject(); - //qDebug() << tr("QJsonObject of description: ") << item; - - QJsonValue value_bin = object.value(QString("bin")); - //qDebug() << value; - QJsonObject item2 = value_bin.toObject(); - //qDebug() << tr("QJsonObject of description: ") << item; + QJsonDocument docu = Core()->getFileInfo(); + QJsonObject item = docu.object()["core"].toObject(); + QJsonObject item2 = docu.object()["bin"].toObject(); this->ui->fileEdit->setText(item["file"].toString()); this->ui->formatEdit->setText(item["format"].toString()); @@ -82,7 +72,6 @@ void Dashboard::updateContents() else { this->ui->canaryEdit->setText("False"); - //this->ui->canaryEdit->setStyleSheet("color: rgb(255, 0, 0);"); } if (item2["crypto"].toBool() == true) { @@ -99,7 +88,6 @@ void Dashboard::updateContents() else { this->ui->nxEdit->setText("False"); - //this->ui->nxEdit->setStyleSheet("color: rgb(255, 0, 0);"); } if (item2["pic"].toBool() == true) { @@ -108,7 +96,6 @@ void Dashboard::updateContents() else { this->ui->picEdit->setText("False"); - //this->ui->picEdit->setStyleSheet("color: rgb(255, 0, 0);"); } if (item2["static"].toBool() == true) {