From 9fb8ba706f37a53c93eb68123612b7cdd8a62add Mon Sep 17 00:00:00 2001 From: GLindor Date: Thu, 18 Feb 2016 15:47:50 -0500 Subject: [PATCH 1/2] stack view follow in dump N implementation --- src/gui/Src/Gui/CPUStack.cpp | 38 ++++++++++++++++++++++++++++++++++- src/gui/Src/Gui/CPUStack.h | 9 ++++++++- src/gui/Src/Gui/CPUWidget.cpp | 2 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/gui/Src/Gui/CPUStack.cpp b/src/gui/Src/Gui/CPUStack.cpp index 4fbf7a03..ebb9c865 100644 --- a/src/gui/Src/Gui/CPUStack.cpp +++ b/src/gui/Src/Gui/CPUStack.cpp @@ -1,17 +1,20 @@ #include "CPUStack.h" +#include "CPUDump.h" #include #include "Configuration.h" #include "Bridge.h" #include "HexEditDialog.h" #include "WordEditDialog.h" +#include "CPUMultiDump.h" -CPUStack::CPUStack(QWidget* parent) : HexDump(parent) +CPUStack::CPUStack(CPUMultiDump* multiDump, QWidget* parent) : HexDump(parent) { setShowHeader(false); int charwidth = getCharWidth(); ColumnDescriptor_t wColDesc; DataDescriptor_t dDesc; bStackFrozen = false; + mMultiDump = multiDump; mForceColumn = 1; @@ -153,6 +156,21 @@ void CPUStack::setupContextMenu() mFollowDump = new QAction("Follow in &Dump", this); connect(mFollowDump, SIGNAL(triggered()), this, SLOT(followDumpSlot())); +#ifdef _WIN64 + mFollowInDumpMenu = new QMenu("&Follow QWORD in Dump", this); +#else //x86 + mFollowInDumpMenu = new QMenu("&Follow DWORD in Dump", this); +#endif //_WIN64 + + int maxDumps = mMultiDump->getMaxCPUTabs(); + for(int i = 0; i < maxDumps; i++) + { + QAction* action = new QAction(QString("Dump %1)").arg(i+1), this); + connect(action, SIGNAL(triggered()), this, SLOT(followinDumpNSlot())); + mFollowInDumpMenu->addAction(action); + mFollowInDumpActions.push_back(action); + } + mFollowStack = new QAction("Follow in &Stack", this); connect(mFollowStack, SIGNAL(triggered()), this, SLOT(followStackSlot())); @@ -363,6 +381,7 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event) else wMenu->addAction(mFollowDisasm); wMenu->addAction(mFollowDump); + wMenu->addMenu(mFollowInDumpMenu); } wMenu->addSeparator(); @@ -490,6 +509,23 @@ void CPUStack::followDumpSlot() } } +void CPUStack::followinDumpNSlot() +{ + duint selectedData; + if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(duint))) + if(DbgMemIsValidReadPtr(selectedData)) + { + for(int i = 0; i < mFollowInDumpActions.length(); i++) + { + if(mFollowInDumpActions[i] == sender()) + { + QString addrText = QString("%1").arg(selectedData, sizeof(duint)*2, 16, QChar('0')).toUpper(); + DbgCmdExec(QString("dump [%1], %2").arg(addrText.toUtf8().constData()).arg(i).toUtf8().constData()); + } + } + } +} + void CPUStack::followStackSlot() { duint selectedData; diff --git a/src/gui/Src/Gui/CPUStack.h b/src/gui/Src/Gui/CPUStack.h index 1af07d25..bcbb33b6 100644 --- a/src/gui/Src/Gui/CPUStack.h +++ b/src/gui/Src/Gui/CPUStack.h @@ -4,11 +4,14 @@ #include "HexDump.h" #include "GotoDialog.h" +//forward declaration +class CPUMultiDump; + class CPUStack : public HexDump { Q_OBJECT public: - explicit CPUStack(QWidget* parent = 0); + explicit CPUStack(CPUMultiDump* multiDump, QWidget* parent = 0); // Configuration virtual void updateColors(); @@ -33,6 +36,7 @@ public slots: void selectionSet(const SELECTIONDATA* selection); void followDisasmSlot(); void followDumpSlot(); + void followinDumpNSlot(); void followStackSlot(); void binaryEditSlot(); void binaryFillSlot(); @@ -66,8 +70,11 @@ private: QAction* mFollowDump; QAction* mFollowStack; QMenu* mPluginMenu; + QMenu* mFollowInDumpMenu; + QList mFollowInDumpActions; GotoDialog* mGoto; + CPUMultiDump* mMultiDump; }; #endif // CPUSTACK_H diff --git a/src/gui/Src/Gui/CPUWidget.cpp b/src/gui/Src/Gui/CPUWidget.cpp index 76769a37..e0ea59c5 100644 --- a/src/gui/Src/Gui/CPUWidget.cpp +++ b/src/gui/Src/Gui/CPUWidget.cpp @@ -52,7 +52,7 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget) mDump = new CPUMultiDump(mDisas, 5, 0); //dump widget ui->mBotLeftFrameLayout->addWidget(mDump); - mStack = new CPUStack(0); //stack widget + mStack = new CPUStack(mDump,0); //stack widget ui->mBotRightFrameLayout->addWidget(mStack); } From a7420ecfe03b4c16169264eb766f4f59c911ae99 Mon Sep 17 00:00:00 2001 From: GLindor Date: Thu, 18 Feb 2016 19:46:18 -0500 Subject: [PATCH 2/2] fixed wrong address being followed bug --- src/gui/Src/Gui/CPUStack.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/Src/Gui/CPUStack.cpp b/src/gui/Src/Gui/CPUStack.cpp index ebb9c865..b7ed2fae 100644 --- a/src/gui/Src/Gui/CPUStack.cpp +++ b/src/gui/Src/Gui/CPUStack.cpp @@ -511,19 +511,19 @@ void CPUStack::followDumpSlot() void CPUStack::followinDumpNSlot() { - duint selectedData; - if(mMemPage->read((byte_t*)&selectedData, getInitialSelection(), sizeof(duint))) - if(DbgMemIsValidReadPtr(selectedData)) + duint selectedData = rvaToVa(getInitialSelection()); + + if(DbgMemIsValidReadPtr(selectedData)) + { + for(int i = 0; i < mFollowInDumpActions.length(); i++) { - for(int i = 0; i < mFollowInDumpActions.length(); i++) + if(mFollowInDumpActions[i] == sender()) { - if(mFollowInDumpActions[i] == sender()) - { - QString addrText = QString("%1").arg(selectedData, sizeof(duint)*2, 16, QChar('0')).toUpper(); - DbgCmdExec(QString("dump [%1], %2").arg(addrText.toUtf8().constData()).arg(i).toUtf8().constData()); - } + QString addrText = QString("%1").arg(ToPtrString(selectedData)); + DbgCmdExec(QString("dump [%1], %2").arg(addrText.toUtf8().constData()).arg(i).toUtf8().constData()); } } + } } void CPUStack::followStackSlot()