1
0
Fork 0

GUI: added binary fill (with wildcard support) on Dump/Stack/Disassembly

This commit is contained in:
Mr. eXoDia 2014-07-05 15:37:49 +02:00
parent ed823e494b
commit 24915f551b
6 changed files with 82 additions and 1 deletions

View File

@ -243,6 +243,11 @@ void CPUDisassembly::setupRightClickContextMenu()
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Fill
mBinaryFillAction = new QAction("&Fill...", this);
connect(mBinaryFillAction, SIGNAL(triggered()), this, SLOT(binaryFillSlot()));
mBinaryMenu->addAction(mBinaryFillAction);
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
@ -818,6 +823,26 @@ void CPUDisassembly::binaryEditSlot()
reloadData();
}
void CPUDisassembly::binaryFillSlot()
{
HexEditDialog hexEdit(this);
hexEdit.mHexEdit->setOverwriteMode(false);
int_t selStart = getSelectionStart();
hexEdit.setWindowTitle("Fill data at " + QString("%1").arg(rvaToVa(selStart), sizeof(int_t) * 2, 16, QChar('0')).toUpper());
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
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.mHexEdit->fill(0, QString(pattern));
QByteArray patched(hexEdit.mHexEdit->data());
mMemPage->write(patched, selStart, patched.size());
reloadData();
}
void CPUDisassembly::binaryCopySlot()
{
HexEditDialog hexEdit(this);
@ -837,7 +862,7 @@ void CPUDisassembly::binaryPasteSlot()
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));

View File

@ -59,6 +59,7 @@ public slots:
void selectionSet(const SELECTIONDATA* selection);
void enableHighlightingMode();
void binaryEditSlot();
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
@ -74,6 +75,7 @@ private:
QMenu* mSearchMenu;
QAction* mBinaryEditAction;
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mToggleInt3BpAction;

View File

@ -93,6 +93,11 @@ void CPUDump::setupContextMenu()
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Fill
mBinaryFillAction = new QAction("&Fill...", this);
connect(mBinaryFillAction, SIGNAL(triggered()), this, SLOT(binaryFillSlot()));
mBinaryMenu->addAction(mBinaryFillAction);
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
@ -1006,6 +1011,26 @@ void CPUDump::binaryEditSlot()
reloadData();
}
void CPUDump::binaryFillSlot()
{
HexEditDialog hexEdit(this);
hexEdit.mHexEdit->setOverwriteMode(false);
int_t selStart = getSelectionStart();
hexEdit.setWindowTitle("Fill data at " + QString("%1").arg(rvaToVa(selStart), sizeof(int_t) * 2, 16, QChar('0')).toUpper());
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
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.mHexEdit->fill(0, QString(pattern));
QByteArray patched(hexEdit.mHexEdit->data());
mMemPage->write(patched, selStart, patched.size());
reloadData();
}
void CPUDump::binaryCopySlot()
{
HexEditDialog hexEdit(this);

View File

@ -70,6 +70,7 @@ public slots:
void selectionSet(const SELECTIONDATA* selection);
void binaryEditSlot();
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
@ -143,6 +144,7 @@ private:
QMenu* mBinaryMenu;
QAction* mBinaryEditAction;
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;

View File

@ -64,6 +64,11 @@ void CPUStack::setupContextMenu()
//Binary->Separator
mBinaryMenu->addSeparator();
//Binary->Fill
mBinaryFillAction = new QAction("&Fill...", this);
connect(mBinaryFillAction, SIGNAL(triggered()), this, SLOT(binaryFillSlot()));
mBinaryMenu->addAction(mBinaryFillAction);
//Binary->Copy
mBinaryCopyAction = new QAction("&Copy", this);
connect(mBinaryCopyAction, SIGNAL(triggered()), this, SLOT(binaryCopySlot()));
@ -346,6 +351,26 @@ void CPUStack::binaryEditSlot()
reloadData();
}
void CPUStack::binaryFillSlot()
{
HexEditDialog hexEdit(this);
hexEdit.mHexEdit->setOverwriteMode(false);
int_t selStart = getSelectionStart();
hexEdit.setWindowTitle("Fill data at " + QString("%1").arg(rvaToVa(selStart), sizeof(int_t) * 2, 16, QChar('0')).toUpper());
if(hexEdit.exec() != QDialog::Accepted)
return;
QString pattern = hexEdit.mHexEdit->pattern();
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.mHexEdit->fill(0, QString(pattern));
QByteArray patched(hexEdit.mHexEdit->data());
mMemPage->write(patched, selStart, patched.size());
reloadData();
}
void CPUStack::binaryCopySlot()
{
HexEditDialog hexEdit(this);

View File

@ -32,6 +32,7 @@ public slots:
void followDumpSlot();
void followStackSlot();
void binaryEditSlot();
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
@ -40,6 +41,7 @@ private:
QMenu* mBinaryMenu;
QAction* mBinaryEditAction;
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mGotoSp;