diff --git a/src/AnalThread.cpp b/src/AnalThread.cpp index 196889a4..8a669144 100644 --- a/src/AnalThread.cpp +++ b/src/AnalThread.cpp @@ -46,7 +46,9 @@ void AnalThread::run() core->setCPU(optionsDialog->getSelectedArch(), optionsDialog->getSelectedCPU(), optionsDialog->getSelectedBits()); - bool rw = ui->writeCheckBox->isChecked(); + int perms = R_IO_READ | R_IO_EXEC; + if (ui->writeCheckBox->isChecked()) + perms |= R_IO_WRITE; bool loadBinInfo = !ui->binCheckBox->isChecked(); if (loadBinInfo) @@ -83,7 +85,7 @@ void AnalThread::run() QJsonArray openedFiles = Core()->getOpenedFiles(); if (!openedFiles.size()) { - core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, loadBinInfo, forceBinPlugin); + core->loadFile(main->getFilename(), loadaddr, mapaddr, perms, va, binidx, loadBinInfo, forceBinPlugin); } emit updateProgress("Analysis in progress."); diff --git a/src/cutter.cpp b/src/cutter.cpp index 6961acb2..d0c94f2b 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -209,7 +209,7 @@ QJsonDocument CutterCore::cmdj(const QString &str) return doc; } -bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int idx, bool loadbin, const QString &forceBinPlugin) +bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, int perms, int va, int idx, bool loadbin, const QString &forceBinPlugin) { Q_UNUSED(loadaddr); Q_UNUSED(idx); @@ -219,7 +219,7 @@ bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo if (va == 0 || va == 2) r_config_set_i(core_->config, "io.va", va); - f = r_core_file_open(core_, path.toUtf8().constData(), rw ? R_IO_RW : R_IO_READ, mapaddr); + f = r_core_file_open(core_, path.toUtf8().constData(), perms, mapaddr); if (!f) { eprintf("r_core_file_open failed\n"); @@ -326,13 +326,13 @@ void CutterCore::delFlag(RVA addr) void CutterCore::editInstruction(RVA addr, const QString &inst) { - cmd("wa " + inst); + cmd("wa " + inst + " @ " + RAddressString(addr)); emit instructionChanged(addr); } void CutterCore::editBytes(RVA addr, const QString &bytes) { - cmd("wx " + bytes); + cmd("wx " + bytes + " @ " + RAddressString(addr)); emit instructionChanged(addr); } diff --git a/src/cutter.h b/src/cutter.h index e32ef66e..2ccc6dbb 100644 --- a/src/cutter.h +++ b/src/cutter.h @@ -270,7 +270,7 @@ public: void setImmediateBase(const QString &r2BaseName, RVA offset = RVA_INVALID); void setCurrentBits(int bits, RVA offset = RVA_INVALID); - bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false, const QString &forceBinPlugin = nullptr); + bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, int perms = R_IO_READ, int va = 0, int idx = 0, bool loadbin = false, const QString &forceBinPlugin = nullptr); bool tryFile(QString path, bool rw); void analyze(int level, QList advanced);