diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index b2cb760da..9879a16ed 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -31,6 +31,7 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main actionEditBytes(this), actionCopy(this), actionCopyAddr(this), + actionCopyInstrBytes(this), actionAddComment(this), actionAnalyzeFunction(this), actionEditFunction(this), @@ -76,6 +77,10 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main getCopyAddressSequence()); addAction(&actionCopyAddr); + initAction(&actionCopyInstrBytes, tr("Copy instruction bytes"), + SLOT(on_actionCopyInstrBytes_triggered()), getCopyInstrBytesSequence()); + addAction(&actionCopyInstrBytes); + initAction(&showInSubmenu, tr("Show in"), nullptr); addAction(&showInSubmenu); @@ -643,6 +648,11 @@ QKeySequence DisassemblyContextMenu::getCopyAddressSequence() const return { Qt::CTRL | Qt::SHIFT | Qt::Key_C }; } +QKeySequence DisassemblyContextMenu::getCopyInstrBytesSequence() const +{ + return { Qt::CTRL | Qt::ALT | Qt::Key_C }; +} + QKeySequence DisassemblyContextMenu::getSetToCodeSequence() const { return { Qt::Key_C }; @@ -793,6 +803,12 @@ void DisassemblyContextMenu::on_actionCopyAddr_triggered() clipboard->setText(RzAddressString(offset)); } +void DisassemblyContextMenu::on_actionCopyInstrBytes_triggered() +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(Core()->getInstructionBytes(offset)); +} + void DisassemblyContextMenu::on_actionAddBreakpoint_triggered() { Core()->toggleBreakpoint(offset); diff --git a/src/menus/DisassemblyContextMenu.h b/src/menus/DisassemblyContextMenu.h index e6c0773da..0cf915561 100644 --- a/src/menus/DisassemblyContextMenu.h +++ b/src/menus/DisassemblyContextMenu.h @@ -42,6 +42,7 @@ private slots: void on_actionCopy_triggered(); void on_actionCopyAddr_triggered(); + void on_actionCopyInstrBytes_triggered(); void on_actionAddComment_triggered(); void on_actionAnalyzeFunction_triggered(); void on_actionRename_triggered(); @@ -79,6 +80,7 @@ private slots: QKeySequence getCopySequence() const; QKeySequence getCommentSequence() const; QKeySequence getCopyAddressSequence() const; + QKeySequence getCopyInstrBytesSequence() const; QKeySequence getGlobalVarSequence() const; QKeySequence getSetToCodeSequence() const; QKeySequence getSetAsStringSequence() const; @@ -111,6 +113,7 @@ private slots: QAction actionCopy; QAction *copySeparator; QAction actionCopyAddr; + QAction actionCopyInstrBytes; QAction actionAddComment; QAction actionAnalyzeFunction;