1
0
Fork 0

GUI: binary edit in disassembly

This commit is contained in:
Mr. eXoDia 2014-07-05 05:12:27 +02:00
parent 2e2be40529
commit 88b863ed98
3 changed files with 37 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include "CPUDisassembly.h"
#include "Configuration.h"
#include "HexEditDialog.h"
CPUDisassembly::CPUDisassembly(QWidget *parent) : Disassembly(parent)
{
@ -99,6 +100,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
// Build Menu
wMenu->addMenu(mBinaryMenu);
wMenu->addAction(mSetLabel);
wMenu->addAction(mSetComment);
wMenu->addAction(mSetBookmark);
@ -227,6 +229,16 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
************************************************************************************/
void CPUDisassembly::setupRightClickContextMenu()
{
//Binary
mBinaryMenu = new QMenu("&Binary", this);
//Binary->Edit
mBinaryEditAction = new QAction("&Edit", this);
mBinaryEditAction->setShortcutContext(Qt::WidgetShortcut);
mBinaryEditAction->setShortcut(QKeySequence("ctrl+e"));
this->addAction(mBinaryEditAction);
mBinaryMenu->addAction(mBinaryEditAction);
connect(mBinaryEditAction, SIGNAL(triggered()), this, SLOT(binaryEditSlot()));
///Setup menu actions
// Labels
@ -772,3 +784,24 @@ void CPUDisassembly::enableHighlightingMode()
mHighlightingMode=true;
reloadData();
}
void CPUDisassembly::binaryEditSlot()
{
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;
hexEdit.setWindowTitle("Edit code at " + QString("%1").arg(rvaToVa(selStart), sizeof(int_t) * 2, 16, QChar('0')).toUpper());
if(hexEdit.exec() != QDialog::Accepted)
return;
int_t dataSize = hexEdit.mHexEdit->data().size();
int_t newSize = selSize > dataSize ? selSize : dataSize;
data = new byte_t[newSize];
mMemPage->read(data, selStart, newSize);
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, newSize));
mMemPage->write(patched.constData(), selStart, patched.size());
reloadData();
}

View File

@ -58,10 +58,12 @@ public slots:
void selectionGet(SELECTIONDATA* selection);
void selectionSet(const SELECTIONDATA* selection);
void enableHighlightingMode();
void binaryEditSlot();
private:
// Menus
QMenu* mBinaryMenu;
QMenu* mGotoMenu;
QMenu* mFollowMenu;
QMenu* mBPMenu;
@ -69,6 +71,7 @@ private:
QMenu* mReferencesMenu;
QMenu* mSearchMenu;
QAction* mBinaryEditAction;
QAction* mToggleInt3BpAction;
QAction* mSetHwBpAction;
QAction* mClearHwBpAction;

View File

@ -990,4 +990,5 @@ void CPUDump::binaryEditSlot()
mMemPage->read(data, selStart, newSize);
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, newSize));
mMemPage->write(patched.constData(), selStart, patched.size());
reloadData();
}