1
0
Fork 0

GUI: find pattern in Dump+Stack

This commit is contained in:
Mr. eXoDia 2014-07-05 17:12:18 +02:00
parent f62c38fb97
commit bb78771c70
7 changed files with 66 additions and 4 deletions

View File

@ -200,6 +200,13 @@ void CPUDump::setupContextMenu()
connect(mMemoryRemove, SIGNAL(triggered()), this, SLOT(memoryRemoveSlot()));
mBreakpointMenu->addAction(mMemoryRemove);
//Find Pattern
mFindPatternAction = new QAction("&Find Pattern...", this);
mFindPatternAction->setShortcutContext(Qt::WidgetShortcut);
mFindPatternAction->setShortcut(QKeySequence("ctrl+b"));
this->addAction(mFindPatternAction);
connect(mFindPatternAction, SIGNAL(triggered()), this, SLOT(findPattern()));
//Goto menu
mGotoMenu = new QMenu("&Goto", this);
//Goto->Expression
@ -360,6 +367,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
wMenu->addMenu(mBinaryMenu);
wMenu->addAction(mSetLabelAction);
wMenu->addMenu(mBreakpointMenu);
wMenu->addAction(mFindPatternAction);
wMenu->addMenu(mGotoMenu);
wMenu->addSeparator();
wMenu->addMenu(mHexMenu);
@ -1059,3 +1067,19 @@ void CPUDump::binaryPasteSlot()
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}
void CPUDump::findPattern()
{
HexEditDialog hexEdit(this);
hexEdit.showEntireBlock(true);
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle("Find Pattern...");
if(hexEdit.exec() != QDialog::Accepted)
return;
int_t addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText=QString("%1").arg(addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}

View File

@ -21,6 +21,9 @@ public:
void setupContextMenu();
void contextMenuEvent(QContextMenuEvent* event);
signals:
void displayReferencesWidget();
public slots:
void memoryAccessSingleshootSlot();
void memoryAccessRestoreSlot();
@ -73,6 +76,7 @@ public slots:
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
void findPattern();
private:
QMenu* mBreakpointMenu;
@ -147,6 +151,7 @@ private:
QAction* mBinaryFillAction;
QAction* mBinaryCopyAction;
QAction* mBinaryPasteAction;
QAction* mFindPatternAction;
QMenu* mSpecialMenu;
QMenu* mCustomMenu;

View File

@ -92,6 +92,13 @@ void CPUStack::setupContextMenu()
connect(mGotoSp, SIGNAL(triggered()), this, SLOT(gotoSpSlot()));
connect(mGotoBp, SIGNAL(triggered()), this, SLOT(gotoBpSlot()));
//Find Pattern
mFindPatternAction = new QAction("&Find Pattern...", this);
mFindPatternAction->setShortcutContext(Qt::WidgetShortcut);
mFindPatternAction->setShortcut(QKeySequence("ctrl+b"));
this->addAction(mFindPatternAction);
connect(mFindPatternAction, SIGNAL(triggered()), this, SLOT(findPattern()));
mGotoExpression = new QAction("&Expression", this);
mGotoExpression->setShortcutContext(Qt::WidgetShortcut);
mGotoExpression->setShortcut(QKeySequence("ctrl+g"));
@ -213,6 +220,7 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addMenu(mBinaryMenu);
wMenu->addAction(mFindPatternAction);
wMenu->addAction(mGotoSp);
wMenu->addAction(mGotoBp);
wMenu->addAction(mGotoExpression);
@ -399,3 +407,19 @@ void CPUStack::binaryPasteSlot()
mMemPage->write(patched.constData(), selStart, selSize);
reloadData();
}
void CPUStack::findPattern()
{
HexEditDialog hexEdit(this);
hexEdit.showEntireBlock(true);
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle("Find Pattern...");
if(hexEdit.exec() != QDialog::Accepted)
return;
int_t addr = rvaToVa(getSelectionStart());
if(hexEdit.entireBlock())
addr = DbgMemFindBaseAddr(addr, 0);
QString addrText=QString("%1").arg(addr, sizeof(int_t)*2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("findall " + addrText + ", " + hexEdit.mHexEdit->pattern() + ", &data&").toUtf8().constData());
emit displayReferencesWidget();
}

View File

@ -21,6 +21,9 @@ public:
void setupContextMenu();
signals:
void displayReferencesWidget();
public slots:
void stackDumpAt(uint_t addr, uint_t csp);
void gotoSpSlot();
@ -35,6 +38,7 @@ public slots:
void binaryFillSlot();
void binaryCopySlot();
void binaryPasteSlot();
void findPattern();
private:
uint_t mCsp;
@ -47,6 +51,7 @@ private:
QAction* mGotoSp;
QAction* mGotoBp;
QAction* mGotoExpression;
QAction* mFindPatternAction;
QAction* mFollowDisasm;
QAction* mFollowDump;
QAction* mFollowStack;

View File

@ -39,11 +39,11 @@ CPUWidget::CPUWidget(QWidget *parent) :QWidget(parent), ui(new Ui::CPUWidget)
ui->mTopRightFrameLayout->addWidget(mRegsTab);
CPUDump* hx = new CPUDump(0); //dump widget
ui->mBotLeftFrameLayout->addWidget(hx);
mDump = new CPUDump(0); //dump widget
ui->mBotLeftFrameLayout->addWidget(mDump);
CPUStack* st = new CPUStack(0); //stack widget
ui->mBotRightFrameLayout->addWidget(st);
mStack = new CPUStack(0); //stack widget
ui->mBotRightFrameLayout->addWidget(mStack);
}
CPUWidget::~CPUWidget()

View File

@ -33,6 +33,8 @@ public:
public:
CPUSideBar* mSideBar;
CPUDisassembly* mDisas;
CPUDump* mDump;
CPUStack* mStack;
RegistersView* mGeneralRegs;
CPUInfoBox* mInfo;
QTabWidget* mRegsTab;

View File

@ -145,6 +145,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(Bridge::getBridge(), SIGNAL(menuAddSeparator(int)), this, SLOT(addSeparator(int)));
connect(Bridge::getBridge(), SIGNAL(menuClearMenu(int)), this, SLOT(clearMenu(int)));
connect(mCpuWidget->mDisas, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
connect(mCpuWidget->mDump, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
connect(mCpuWidget->mStack, SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
connect(Bridge::getBridge(), SIGNAL(getStrWindow(QString,QString*)), this, SLOT(getStrWindow(QString,QString*)));
//Set default setttings (when not set)