GUI: binary edit in disassembly
This commit is contained in:
parent
2e2be40529
commit
88b863ed98
|
@ -1,5 +1,6 @@
|
||||||
#include "CPUDisassembly.h"
|
#include "CPUDisassembly.h"
|
||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
|
#include "HexEditDialog.h"
|
||||||
|
|
||||||
CPUDisassembly::CPUDisassembly(QWidget *parent) : Disassembly(parent)
|
CPUDisassembly::CPUDisassembly(QWidget *parent) : Disassembly(parent)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +100,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
|
||||||
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
|
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
|
||||||
|
|
||||||
// Build Menu
|
// Build Menu
|
||||||
|
wMenu->addMenu(mBinaryMenu);
|
||||||
wMenu->addAction(mSetLabel);
|
wMenu->addAction(mSetLabel);
|
||||||
wMenu->addAction(mSetComment);
|
wMenu->addAction(mSetComment);
|
||||||
wMenu->addAction(mSetBookmark);
|
wMenu->addAction(mSetBookmark);
|
||||||
|
@ -227,6 +229,16 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
void CPUDisassembly::setupRightClickContextMenu()
|
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
|
///Setup menu actions
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
|
@ -772,3 +784,24 @@ void CPUDisassembly::enableHighlightingMode()
|
||||||
mHighlightingMode=true;
|
mHighlightingMode=true;
|
||||||
reloadData();
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -58,10 +58,12 @@ public slots:
|
||||||
void selectionGet(SELECTIONDATA* selection);
|
void selectionGet(SELECTIONDATA* selection);
|
||||||
void selectionSet(const SELECTIONDATA* selection);
|
void selectionSet(const SELECTIONDATA* selection);
|
||||||
void enableHighlightingMode();
|
void enableHighlightingMode();
|
||||||
|
void binaryEditSlot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
|
QMenu* mBinaryMenu;
|
||||||
QMenu* mGotoMenu;
|
QMenu* mGotoMenu;
|
||||||
QMenu* mFollowMenu;
|
QMenu* mFollowMenu;
|
||||||
QMenu* mBPMenu;
|
QMenu* mBPMenu;
|
||||||
|
@ -69,6 +71,7 @@ private:
|
||||||
QMenu* mReferencesMenu;
|
QMenu* mReferencesMenu;
|
||||||
QMenu* mSearchMenu;
|
QMenu* mSearchMenu;
|
||||||
|
|
||||||
|
QAction* mBinaryEditAction;
|
||||||
QAction* mToggleInt3BpAction;
|
QAction* mToggleInt3BpAction;
|
||||||
QAction* mSetHwBpAction;
|
QAction* mSetHwBpAction;
|
||||||
QAction* mClearHwBpAction;
|
QAction* mClearHwBpAction;
|
||||||
|
|
|
@ -990,4 +990,5 @@ void CPUDump::binaryEditSlot()
|
||||||
mMemPage->read(data, selStart, newSize);
|
mMemPage->read(data, selStart, newSize);
|
||||||
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, newSize));
|
QByteArray patched = hexEdit.mHexEdit->applyMaskedData(QByteArray((const char*)data, newSize));
|
||||||
mMemPage->write(patched.constData(), selStart, patched.size());
|
mMemPage->write(patched.constData(), selStart, patched.size());
|
||||||
|
reloadData();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue