Using raw permissions rather than rw

This commit is contained in:
xarkes 2018-02-27 11:20:48 +01:00
parent 4b3c709a8c
commit a0a3f9278d
3 changed files with 9 additions and 7 deletions

View File

@ -46,7 +46,9 @@ void AnalThread::run()
core->setCPU(optionsDialog->getSelectedArch(), optionsDialog->getSelectedCPU(), optionsDialog->getSelectedBits()); 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(); bool loadBinInfo = !ui->binCheckBox->isChecked();
if (loadBinInfo) if (loadBinInfo)
@ -83,7 +85,7 @@ void AnalThread::run()
QJsonArray openedFiles = Core()->getOpenedFiles(); QJsonArray openedFiles = Core()->getOpenedFiles();
if (!openedFiles.size()) 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."); emit updateProgress("Analysis in progress.");

View File

@ -209,7 +209,7 @@ QJsonDocument CutterCore::cmdj(const QString &str)
return doc; 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(loadaddr);
Q_UNUSED(idx); Q_UNUSED(idx);
@ -219,7 +219,7 @@ bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo
if (va == 0 || va == 2) if (va == 0 || va == 2)
r_config_set_i(core_->config, "io.va", va); 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) if (!f)
{ {
eprintf("r_core_file_open failed\n"); eprintf("r_core_file_open failed\n");
@ -326,13 +326,13 @@ void CutterCore::delFlag(RVA addr)
void CutterCore::editInstruction(RVA addr, const QString &inst) void CutterCore::editInstruction(RVA addr, const QString &inst)
{ {
cmd("wa " + inst); cmd("wa " + inst + " @ " + RAddressString(addr));
emit instructionChanged(addr); emit instructionChanged(addr);
} }
void CutterCore::editBytes(RVA addr, const QString &bytes) void CutterCore::editBytes(RVA addr, const QString &bytes)
{ {
cmd("wx " + bytes); cmd("wx " + bytes + " @ " + RAddressString(addr));
emit instructionChanged(addr); emit instructionChanged(addr);
} }

View File

@ -270,7 +270,7 @@ public:
void setImmediateBase(const QString &r2BaseName, RVA offset = RVA_INVALID); void setImmediateBase(const QString &r2BaseName, RVA offset = RVA_INVALID);
void setCurrentBits(int bits, 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); bool tryFile(QString path, bool rw);
void analyze(int level, QList<QString> advanced); void analyze(int level, QList<QString> advanced);