1
0
Fork 0

GUI: added binary copy + binary paste in Dump/Stack/Disassembly

This commit is contained in:
Mr. eXoDia 2014-07-05 15:03:19 +02:00
parent 9b6dfae064
commit 6e662f484d
6 changed files with 138 additions and 1 deletions

View File

@ -239,7 +239,19 @@ void CPUDisassembly::setupRightClickContextMenu()
this->addAction(mBinaryEditAction);
mBinaryMenu->addAction(mBinaryEditAction);
connect(mBinaryEditAction, SIGNAL(triggered()), this, SLOT(binaryEditSlot()));
///Setup menu actions
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
mBinaryMenu->addAction(mBinaryCopyAction);
//Binary->Paste
mBinaryPasteAction = new QAction("&Paste", this);
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
// Labels
mSetLabel = new QAction("Label", this);
@ -805,3 +817,32 @@ void CPUDisassembly::binaryEditSlot()
mMemPage->write(patched.constData(), selStart, patched.size());
reloadData();
}
void CPUDisassembly::binaryCopySlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
hexEdit.mHexEdit->setData(QByteArray((const char*)data, selSize));
delete [] data;
Bridge::CopyToClipboard(hexEdit.mHexEdit->pattern(true).toUtf8().constData());
}
void CPUDisassembly::binaryPasteSlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
GuiAddStatusBarMessage(QString(hexEdit.mHexEdit->pattern(true) + "\n").toUtf8().constData());
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, selSize));
if(patched.size() < selSize)
selSize = patched.size();
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}

View File

@ -59,6 +59,8 @@ public slots:
void selectionSet(const SELECTIONDATA* selection);
void enableHighlightingMode();
void binaryEditSlot();
void binaryCopySlot();
void binaryPasteSlot();
private:
@ -72,6 +74,8 @@ private:
QMenu* mSearchMenu;
QAction* mBinaryEditAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mToggleInt3BpAction;
QAction* mSetHwBpAction;
QAction* mClearHwBpAction;

View File

@ -90,6 +90,19 @@ void CPUDump::setupContextMenu()
connect(mBinaryEditAction, SIGNAL(triggered()), this, SLOT(binaryEditSlot()));
mBinaryMenu->addAction(mBinaryEditAction);
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
mBinaryMenu->addAction(mBinaryCopyAction);
//Binary->Paste
mBinaryPasteAction = new QAction("&Paste", this);
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
//Label
mSetLabelAction = new QAction("Set Label", this);
mSetLabelAction->setShortcutContext(Qt::WidgetShortcut);
@ -992,3 +1005,32 @@ void CPUDump::binaryEditSlot()
mMemPage->write(patched.constData(), selStart, patched.size());
reloadData();
}
void CPUDump::binaryCopySlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
hexEdit.mHexEdit->setData(QByteArray((const char*)data, selSize));
delete [] data;
Bridge::CopyToClipboard(hexEdit.mHexEdit->pattern(true).toUtf8().constData());
}
void CPUDump::binaryPasteSlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, selSize));
if(patched.size() < selSize)
selSize = patched.size();
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}

View File

@ -70,6 +70,8 @@ public slots:
void selectionSet(const SELECTIONDATA* selection);
void binaryEditSlot();
void binaryCopySlot();
void binaryPasteSlot();
private:
QMenu* mBreakpointMenu;
@ -141,6 +143,8 @@ private:
QMenu* mBinaryMenu;
QAction* mBinaryEditAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QMenu* mSpecialMenu;
QMenu* mCustomMenu;

View File

@ -61,6 +61,19 @@ void CPUStack::setupContextMenu()
connect(mBinaryEditAction, SIGNAL(triggered()), this, SLOT(binaryEditSlot()));
mBinaryMenu->addAction(mBinaryEditAction);
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
mBinaryMenu->addAction(mBinaryCopyAction);
//Binary->Paste
mBinaryPasteAction = new QAction("&Paste", this);
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
#ifdef _WIN64
mGotoSp = new QAction("Follow R&SP", this);
mGotoBp = new QAction("Follow R&BP", this);
@ -332,3 +345,32 @@ void CPUStack::binaryEditSlot()
mMemPage->write(patched.constData(), selStart, patched.size());
reloadData();
}
void CPUStack::binaryCopySlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
hexEdit.mHexEdit->setData(QByteArray((const char*)data, selSize));
delete [] data;
Bridge::CopyToClipboard(hexEdit.mHexEdit->pattern(true).toUtf8().constData());
}
void CPUStack::binaryPasteSlot()
{
HexEditDialog hexEdit(this);
int_t selStart = getSelectionStart();
int_t selSize = getSelectionEnd() - selStart + 1;
QClipboard *clipboard = QApplication::clipboard();
hexEdit.mHexEdit->setData(clipboard->text());
byte_t* data = new byte_t[selSize];
mMemPage->read(data, selStart, selSize);
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, selSize));
if(patched.size() < selSize)
selSize = patched.size();
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}

View File

@ -32,12 +32,16 @@ public slots:
void followDumpSlot();
void followStackSlot();
void binaryEditSlot();
void binaryCopySlot();
void binaryPasteSlot();
private:
uint_t mCsp;
QMenu* mBinaryMenu;
QAction* mBinaryEditAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mGotoSp;
QAction* mGotoBp;
QAction* mGotoExpression;