mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Added option to swap conditional jmps (#373)
This commit is contained in:
parent
742690afd0
commit
3ef8218e49
@ -335,6 +335,12 @@ void CutterCore::nopInstruction(RVA addr)
|
||||
emit instructionChanged(addr);
|
||||
}
|
||||
|
||||
void CutterCore::jmpReverse(RVA addr)
|
||||
{
|
||||
cmd("wao recj @ " + RAddressString(addr));
|
||||
emit instructionChanged(addr);
|
||||
}
|
||||
|
||||
void CutterCore::editBytes(RVA addr, const QString &bytes)
|
||||
{
|
||||
cmd("wx " + bytes + " @ " + RAddressString(addr));
|
||||
|
@ -296,6 +296,7 @@ public:
|
||||
|
||||
void editInstruction(RVA addr, const QString &inst);
|
||||
void nopInstruction(RVA addr);
|
||||
void jmpReverse(RVA addr);
|
||||
|
||||
void editBytes(RVA addr, const QString &inst);
|
||||
|
||||
|
@ -14,7 +14,8 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent)
|
||||
offset(0),
|
||||
canCopy(false),
|
||||
actionEditInstruction(this),
|
||||
actionNopInstruction(this),
|
||||
actionNopInstruction(this),
|
||||
actionJmpReverse(this),
|
||||
actionEditBytes(this),
|
||||
actionCopy(this),
|
||||
actionAddComment(this),
|
||||
@ -92,10 +93,13 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent)
|
||||
editMenu->addAction(&actionNopInstruction);
|
||||
actionEditBytes.setText(tr("Bytes"));
|
||||
editMenu->addAction(&actionEditBytes);
|
||||
actionJmpReverse.setText(tr("Reverse Jump"));
|
||||
editMenu->addAction(&actionJmpReverse);
|
||||
|
||||
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(&actionJmpReverse, SIGNAL(triggered(bool)), this, SLOT(on_actionJmpReverse_triggered()));
|
||||
|
||||
connect(&actionSetBaseBinary, SIGNAL(triggered(bool)), this, SLOT(on_actionSetBaseBinary_triggered()));
|
||||
connect(&actionSetBaseOctal, SIGNAL(triggered(bool)), this, SLOT(on_actionSetBaseOctal_triggered()));
|
||||
@ -202,6 +206,10 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
||||
{
|
||||
actionRenameUsedHere.setVisible(false);
|
||||
}
|
||||
|
||||
// decide to show Reverse jmp option
|
||||
showReverseJmpQuery();
|
||||
|
||||
}
|
||||
|
||||
QKeySequence DisassemblyContextMenu::getCopySequence() const
|
||||
@ -262,6 +270,32 @@ void DisassemblyContextMenu::on_actionNopInstruction_triggered()
|
||||
Core()->nopInstruction(offset);
|
||||
}
|
||||
|
||||
void DisassemblyContextMenu::showReverseJmpQuery()
|
||||
{
|
||||
QString type;
|
||||
|
||||
QJsonArray array = Core()->cmdj("pdj 1 @ " + RAddressString(offset)).array();
|
||||
if (array.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
type = array.first().toObject()["type"].toString();
|
||||
if (type == "cjmp")
|
||||
{
|
||||
actionJmpReverse.setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
actionJmpReverse.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DisassemblyContextMenu::on_actionJmpReverse_triggered()
|
||||
{
|
||||
Core()->jmpReverse(offset);
|
||||
}
|
||||
|
||||
void DisassemblyContextMenu::on_actionEditBytes_triggered()
|
||||
{
|
||||
EditInstructionDialog *e = new EditInstructionDialog(this);
|
||||
|
@ -25,6 +25,8 @@ private slots:
|
||||
|
||||
void on_actionEditInstruction_triggered();
|
||||
void on_actionNopInstruction_triggered();
|
||||
void on_actionJmpReverse_triggered();
|
||||
void showReverseJmpQuery();
|
||||
void on_actionEditBytes_triggered();
|
||||
|
||||
void on_actionCopy_triggered();
|
||||
@ -72,6 +74,7 @@ private:
|
||||
QAction *editMenuAction;
|
||||
QAction actionEditInstruction;
|
||||
QAction actionNopInstruction;
|
||||
QAction actionJmpReverse;
|
||||
QAction actionEditBytes;
|
||||
|
||||
QAction actionCopy;
|
||||
|
Loading…
Reference in New Issue
Block a user