1
0
Fork 0

GUI: undo selection in Disassembly/Dump/Stack

This commit is contained in:
Mr. eXoDia 2014-07-05 22:01:46 +02:00
parent 574bc468e9
commit 5ad446451c
6 changed files with 69 additions and 0 deletions

View File

@ -101,6 +101,10 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
// Build Menu
wMenu->addMenu(mBinaryMenu);
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
wMenu->addAction(mUndoSelection);
wMenu->addAction(mSetLabel);
wMenu->addAction(mSetComment);
wMenu->addAction(mSetBookmark);
@ -255,6 +259,13 @@ void CPUDisassembly::setupRightClickContextMenu()
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
// Restore Selection
mUndoSelection = new QAction("&Restore selection", this);
mUndoSelection->setShortcutContext(Qt::WidgetShortcut);
mUndoSelection->setShortcut(QKeySequence("alt+backspace"));
this->addAction(mUndoSelection);
connect(mUndoSelection, SIGNAL(triggered()), this, SLOT(undoSelectionSlot()));
// Labels
mSetLabel = new QAction("Label", this);
mSetLabel->setShortcutContext(Qt::WidgetShortcut);
@ -895,3 +906,13 @@ void CPUDisassembly::binaryPasteSlot()
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}
void CPUDisassembly::undoSelectionSlot()
{
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(!DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
return;
DbgFunctions()->PatchRestoreRange(start, end);
reloadData();
}

View File

@ -63,6 +63,7 @@ public slots:
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
void undoSelectionSlot();
private:
@ -79,6 +80,7 @@ private:
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mUndoSelection;
QAction* mToggleInt3BpAction;
QAction* mSetHwBpAction;
QAction* mClearHwBpAction;

View File

@ -108,6 +108,13 @@ void CPUDump::setupContextMenu()
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
// Restore Selection
mUndoSelection = new QAction("&Restore selection", this);
mUndoSelection->setShortcutContext(Qt::WidgetShortcut);
mUndoSelection->setShortcut(QKeySequence("alt+backspace"));
this->addAction(mUndoSelection);
connect(mUndoSelection, SIGNAL(triggered()), this, SLOT(undoSelectionSlot()));
//Label
mSetLabelAction = new QAction("Set Label", this);
mSetLabelAction->setShortcutContext(Qt::WidgetShortcut);
@ -365,6 +372,10 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
return;
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addMenu(mBinaryMenu);
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
wMenu->addAction(mUndoSelection);
wMenu->addAction(mSetLabelAction);
wMenu->addMenu(mBreakpointMenu);
wMenu->addAction(mFindPatternAction);
@ -1083,3 +1094,13 @@ void CPUDump::findPattern()
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}
void CPUDump::undoSelectionSlot()
{
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(!DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
return;
DbgFunctions()->PatchRestoreRange(start, end);
reloadData();
}

View File

@ -77,6 +77,7 @@ public slots:
void binaryCopySlot();
void binaryPasteSlot();
void findPattern();
void undoSelectionSlot();
private:
QMenu* mBreakpointMenu;
@ -152,6 +153,7 @@ private:
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mFindPatternAction;
QAction* mUndoSelection;
QMenu* mSpecialMenu;
QMenu* mCustomMenu;

View File

@ -79,6 +79,13 @@ void CPUStack::setupContextMenu()
connect(mBinaryPasteAction, SIGNAL(triggered()), this, SLOT(binaryPasteSlot()));
mBinaryMenu->addAction(mBinaryPasteAction);
// Restore Selection
mUndoSelection = new QAction("&Restore selection", this);
mUndoSelection->setShortcutContext(Qt::WidgetShortcut);
mUndoSelection->setShortcut(QKeySequence("alt+backspace"));
this->addAction(mUndoSelection);
connect(mUndoSelection, SIGNAL(triggered()), this, SLOT(undoSelectionSlot()));
#ifdef _WIN64
mGotoSp = new QAction("Follow R&SP", this);
mGotoBp = new QAction("Follow R&BP", this);
@ -229,6 +236,10 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addMenu(mBinaryMenu);
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
wMenu->addAction(mUndoSelection);
wMenu->addAction(mFindPatternAction);
wMenu->addAction(mGotoSp);
wMenu->addAction(mGotoBp);
@ -432,3 +443,13 @@ void CPUStack::findPattern()
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}
void CPUStack::undoSelectionSlot()
{
int_t start = rvaToVa(getSelectionStart());
int_t end = rvaToVa(getSelectionEnd());
if(!DbgFunctions()->PatchInRange(start, end)) //nothing patched in selected range
return;
DbgFunctions()->PatchRestoreRange(start, end);
reloadData();
}

View File

@ -39,6 +39,7 @@ public slots:
void binaryCopySlot();
void binaryPasteSlot();
void findPattern();
void undoSelectionSlot();
private:
uint_t mCsp;
@ -48,6 +49,7 @@ private:
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mUndoSelection;
QAction* mGotoSp;
QAction* mGotoBp;
QAction* mGotoExpression;