Added option to Nop instructions (#355)

This commit is contained in:
fcasal 2018-03-05 14:20:55 +00:00 committed by xarkes
parent 4a8352169b
commit fa7da352cf
4 changed files with 19 additions and 0 deletions

View File

@ -329,6 +329,12 @@ void CutterCore::editInstruction(RVA addr, const QString &inst)
emit instructionChanged(addr); emit instructionChanged(addr);
} }
void CutterCore::nopInstruction(RVA addr)
{
cmd("wao nop @ " + RAddressString(addr));
emit instructionChanged(addr);
}
void CutterCore::editBytes(RVA addr, const QString &bytes) void CutterCore::editBytes(RVA addr, const QString &bytes)
{ {
cmd("wx " + bytes + " @ " + RAddressString(addr)); cmd("wx " + bytes + " @ " + RAddressString(addr));

View File

@ -262,6 +262,8 @@ public:
void delFlag(RVA addr); void delFlag(RVA addr);
void editInstruction(RVA addr, const QString &inst); void editInstruction(RVA addr, const QString &inst);
void nopInstruction(RVA addr);
void editBytes(RVA addr, const QString &inst); void editBytes(RVA addr, const QString &inst);
void setComment(RVA addr, const QString &cmt); void setComment(RVA addr, const QString &cmt);

View File

@ -14,6 +14,7 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent)
offset(0), offset(0),
canCopy(false), canCopy(false),
actionEditInstruction(this), actionEditInstruction(this),
actionNopInstruction(this),
actionEditBytes(this), actionEditBytes(this),
actionCopy(this), actionCopy(this),
actionAddComment(this), actionAddComment(this),
@ -87,10 +88,13 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent)
editMenuAction = addMenu(editMenu); editMenuAction = addMenu(editMenu);
actionEditInstruction.setText(tr("Instruction")); actionEditInstruction.setText(tr("Instruction"));
editMenu->addAction(&actionEditInstruction); editMenu->addAction(&actionEditInstruction);
actionNopInstruction.setText(tr("Nop Instruction"));
editMenu->addAction(&actionNopInstruction);
actionEditBytes.setText(tr("Bytes")); actionEditBytes.setText(tr("Bytes"));
editMenu->addAction(&actionEditBytes); editMenu->addAction(&actionEditBytes);
connect(&actionEditInstruction, SIGNAL(triggered(bool)), this, SLOT(on_actionEditInstruction_triggered())); connect(&actionEditInstruction, SIGNAL(triggered(bool)), this, SLOT(on_actionEditInstruction_triggered()));
connect(&actionNopInstruction, SIGNAL(triggered(bool)), this, SLOT(on_actionNopInstruction_triggered()));
connect(&actionEditBytes, SIGNAL(triggered(bool)), this, SLOT(on_actionEditBytes_triggered())); connect(&actionEditBytes, SIGNAL(triggered(bool)), this, SLOT(on_actionEditBytes_triggered()));
connect(&actionSetBaseBinary, SIGNAL(triggered(bool)), this, SLOT(on_actionSetBaseBinary_triggered())); connect(&actionSetBaseBinary, SIGNAL(triggered(bool)), this, SLOT(on_actionSetBaseBinary_triggered()));
@ -253,6 +257,11 @@ void DisassemblyContextMenu::on_actionEditInstruction_triggered()
} }
} }
void DisassemblyContextMenu::on_actionNopInstruction_triggered()
{
Core()->nopInstruction(offset);
}
void DisassemblyContextMenu::on_actionEditBytes_triggered() void DisassemblyContextMenu::on_actionEditBytes_triggered()
{ {
EditInstructionDialog *e = new EditInstructionDialog(this); EditInstructionDialog *e = new EditInstructionDialog(this);

View File

@ -24,6 +24,7 @@ private slots:
void aboutToShowSlot(); void aboutToShowSlot();
void on_actionEditInstruction_triggered(); void on_actionEditInstruction_triggered();
void on_actionNopInstruction_triggered();
void on_actionEditBytes_triggered(); void on_actionEditBytes_triggered();
void on_actionCopy_triggered(); void on_actionCopy_triggered();
@ -70,6 +71,7 @@ private:
QMenu *editMenu; QMenu *editMenu;
QAction *editMenuAction; QAction *editMenuAction;
QAction actionEditInstruction; QAction actionEditInstruction;
QAction actionNopInstruction;
QAction actionEditBytes; QAction actionEditBytes;
QAction actionCopy; QAction actionCopy;