1
0
Fork 0

Add Follow in Dump N menu to the Registers view (#1046)

* Add Follow in Dump N menu to the Registers view

* cleaned up unused variables

* Move menu creation to constructor so we don't create a hell hole of menu pointers.
This commit is contained in:
genuine_ 2016-09-05 02:37:57 -04:00 committed by Duncan Ogilvie
parent 00c25b1b30
commit b536b7ee26
3 changed files with 47 additions and 6 deletions

View File

@ -47,7 +47,10 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
connect(mDisas, SIGNAL(selectionChanged(dsint)), mInfo, SLOT(disasmSelectionChanged(dsint)));
mGeneralRegs = new RegistersView(this);
mDump = new CPUMultiDump(mDisas, 5, 0); //dump widget
ui->mBotLeftFrameLayout->addWidget(mDump);
mGeneralRegs = new RegistersView(this, mDump);
mGeneralRegs->setFixedWidth(1000);
mGeneralRegs->ShowFPU(true);
mGeneralRegs->setFixedHeight(mGeneralRegs->getEstimateHeight());
@ -74,9 +77,6 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
ui->mTopRightLowerFrameLayout->addWidget(mArgumentWidget);
mDump = new CPUMultiDump(mDisas, 5, 0); //dump widget
ui->mBotLeftFrameLayout->addWidget(mDump);
mStack = new CPUStack(mDump, 0); //stack widget
ui->mBotRightFrameLayout->addWidget(mStack);

View File

@ -5,6 +5,7 @@
#include "RegistersView.h"
#include "CPUWidget.h"
#include "CPUDisassembly.h"
#include "CPUMultiDump.h"
#include "Configuration.h"
#include "WordEditDialog.h"
#include "LineEditDialog.h"
@ -431,7 +432,7 @@ static QAction* setupAction(const QString & text, RegistersView* this_object)
return action;
}
RegistersView::RegistersView(CPUWidget* parent) : QScrollArea(parent), mVScrollOffset(0), mParent(parent)
RegistersView::RegistersView(CPUWidget* parent, CPUMultiDump* multiDump) : QScrollArea(parent), mVScrollOffset(0), mParent(parent)
{
mChangeViewButton = NULL;
@ -457,6 +458,8 @@ RegistersView::RegistersView(CPUWidget* parent) : QScrollArea(parent), mVScrollO
wCM_Push = setupAction(tr("Push"), this);
wCM_Pop = setupAction(tr("Pop"), this);
wCM_Highlight = setupAction(tr("Highlight"), this);
mMultiDump = multiDump;
mFollowInDumpMenu = CreateDumpNMenu();
// general purposes register (we allow the user to modify the value)
mGPR.insert(CAX);
@ -1244,6 +1247,22 @@ bool RegistersView::identifyRegister(const int line, const int offset, REGISTER_
return found_flag;
}
QMenu *RegistersView::CreateDumpNMenu()
{
auto followInDumpName = ArchValue(tr("Follow DWORD in &Dump"), tr("Follow QWord in &Dump"));
QMenu *dumpMenu = new QMenu(followInDumpName, this);
int maxDumps = mMultiDump->getMaxCPUTabs();
for(int i = 0; i < maxDumps; i++)
{
QAction *action = new QAction(tr("Dump %1").arg(i + 1), this);
connect(action, SIGNAL(triggered()), this, SLOT(onFollowInDumpN()));
dumpMenu->addAction(action);
action->setData(i + 1);
}
return dumpMenu;
}
void RegistersView::mousePressEvent(QMouseEvent* event)
{
if(!DbgIsDebugging())
@ -2350,6 +2369,20 @@ void RegistersView::onFollowInDump()
}
}
void RegistersView::onFollowInDumpN()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
{
QAction* action = qobject_cast<QAction*>(sender());
int numDump = action->data().toInt();
DbgCmdExec(QString("dump %1, .%2").arg(addr).arg(numDump).toUtf8().constData());
}
}
}
void RegistersView::onFollowInStack()
{
if(mCANSTOREADDRESS.contains(mSelected))
@ -2416,6 +2449,7 @@ void RegistersView::displayCustomContextMenuSlot(QPoint pos)
if(DbgMemIsValidReadPtr(addr))
{
wMenu.addAction(wCM_FollowInDump);
wMenu.addMenu(mFollowInDumpMenu);
wMenu.addAction(wCM_FollowInDisassembly);
duint size = 0;
duint base = DbgMemFindBaseAddr(DbgValFromString("csp"), &size);

View File

@ -9,6 +9,7 @@
#define IsCharacterRegister(x) ((x>=CAX && x<CIP))
class CPUWidget;
class CPUMultiDump;
typedef struct
{
@ -91,7 +92,7 @@ public:
};
explicit RegistersView(CPUWidget* parent);
explicit RegistersView(CPUWidget* parent, CPUMultiDump* multiDump);
~RegistersView();
QSize sizeHint() const;
@ -125,6 +126,7 @@ protected:
void setRegisters(REGDUMP* reg);
char* registerValue(const REGDUMP* regd, const REGISTER_NAME reg);
bool identifyRegister(const int y, const int x, REGISTER_NAME* clickedReg);
QMenu *CreateDumpNMenu();
void displayEditDialog();
@ -143,6 +145,7 @@ protected slots:
void onCopyAllAction();
void onFollowInDisassembly();
void onFollowInDump();
void onFollowInDumpN();
void onFollowInStack();
void onIncrementPtrSize();
void onDecrementPtrSize();
@ -214,6 +217,8 @@ private:
// font measures (TODO: create a class that calculates all thos values)
unsigned int mRowHeight, mCharWidth;
// context menu actions
QMenu* mFollowInDumpMenu;
QAction* mFollowInDump;
QAction* wCM_Increment;
QAction* wCM_Decrement;
QAction* wCM_IncrementPtrSize;
@ -235,6 +240,8 @@ private:
QAction* wCM_ChangeFPUView;
QAction* wCM_Highlight;
dsint mCip;
CPUMultiDump* mMultiDump;
};
#endif // REGISTERSVIEW_H