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

This commit is contained in:
frmdstryr 2023-09-05 20:51:32 -04:00 committed by GitHub
parent fc3e7c6378
commit 1e1c93d9d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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);

View File

@ -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:
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:
QAction actionCopy;
QAction *copySeparator;
QAction actionCopyAddr;
QAction actionCopyInstrBytes;
QAction actionAddComment;
QAction actionAnalyzeFunction;