Skip to content

Commit

Permalink
Add 'Copy instruction bytes' to disassembly context menu (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr committed Sep 6, 2023
1 parent fc3e7c6 commit 1e1c93d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/menus/DisassemblyContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main
actionEditBytes(this),
actionCopy(this),
actionCopyAddr(this),
actionCopyInstrBytes(this),
actionAddComment(this),
actionAnalyzeFunction(this),
actionEditFunction(this),
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/menus/DisassemblyContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -111,6 +113,7 @@ private slots:
QAction actionCopy;
QAction *copySeparator;
QAction actionCopyAddr;
QAction actionCopyInstrBytes;

QAction actionAddComment;
QAction actionAnalyzeFunction;
Expand Down

0 comments on commit 1e1c93d

Please sign in to comment.