Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Copy instruction bytes' to disassembly context menu #3242

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading