1
0
Fork 0

GUI: added goto start/end of page + added follow DWORD/QWORD in dump + shortcut for goto file offset

This commit is contained in:
Mr. eXoDia 2015-05-24 15:50:13 +02:00
parent 3bfacacd87
commit dcd4ee548f
5 changed files with 102 additions and 3 deletions

View File

@ -277,6 +277,7 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mSetNewOriginHere); wMenu->addAction(mSetNewOriginHere);
// Goto Menu // Goto Menu
mGotoMenu->clear();
mGotoMenu->addAction(mGotoOrigin); mGotoMenu->addAction(mGotoOrigin);
if(historyHasPrevious()) if(historyHasPrevious())
mGotoMenu->addAction(mGotoPrevious); mGotoMenu->addAction(mGotoPrevious);
@ -286,6 +287,8 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
char modname[MAX_MODULE_SIZE] = ""; char modname[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(wVA, modname)) if(DbgGetModuleAt(wVA, modname))
mGotoMenu->addAction(mGotoFileOffset); mGotoMenu->addAction(mGotoFileOffset);
mGotoMenu->addAction(mGotoStart);
mGotoMenu->addAction(mGotoEnd);
wMenu->addMenu(mGotoMenu); wMenu->addMenu(mGotoMenu);
wMenu->addSeparator(); wMenu->addSeparator();
@ -472,8 +475,22 @@ void CPUDisassembly::setupRightClickContextMenu()
// File offset action // File offset action
mGotoFileOffset = new QAction("File Offset", this); mGotoFileOffset = new QAction("File Offset", this);
mGotoFileOffset->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoFileOffset);
connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffset())); connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffset()));
// Goto->Start of page
mGotoStart = new QAction("Start of Page", this);
mGotoStart->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoStart);
connect(mGotoStart, SIGNAL(triggered()), this, SLOT(gotoStartSlot()));
// Goto->End of page
mGotoEnd = new QAction("End of Page", this);
mGotoEnd->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoEnd);
connect(mGotoEnd, SIGNAL(triggered()), this, SLOT(gotoEndSlot()));
//-------------------- Follow in Dump ---------------------------- //-------------------- Follow in Dump ----------------------------
// Menu // Menu
mFollowMenu = new QMenu("&Follow in Dump", this); mFollowMenu = new QMenu("&Follow in Dump", this);
@ -589,6 +606,9 @@ void CPUDisassembly::refreshShortcutsSlot()
mGotoPrevious->setShortcut(ConfigShortcut("ActionGotoPrevious")); mGotoPrevious->setShortcut(ConfigShortcut("ActionGotoPrevious"));
mGotoNext->setShortcut(ConfigShortcut("ActionGotoNext")); mGotoNext->setShortcut(ConfigShortcut("ActionGotoNext"));
mGotoExpression->setShortcut(ConfigShortcut("ActionGotoExpression")); mGotoExpression->setShortcut(ConfigShortcut("ActionGotoExpression"));
mGotoStart->setShortcut(ConfigShortcut("ActionGotoStart"));
mGotoEnd->setShortcut(ConfigShortcut("ActionGotoEnd"));
mGotoFileOffset->setShortcut(ConfigShortcut("ActionGotoFileOffset"));
mReferenceSelectedAddress->setShortcut(ConfigShortcut("ActionFindReferencesToSelectedAddress")); mReferenceSelectedAddress->setShortcut(ConfigShortcut("ActionFindReferencesToSelectedAddress"));
mSearchPattern->setShortcut(ConfigShortcut("ActionFindPattern")); mSearchPattern->setShortcut(ConfigShortcut("ActionFindPattern"));
mEnableHighlightingMode->setShortcut(ConfigShortcut("ActionHighlightingMode")); mEnableHighlightingMode->setShortcut(ConfigShortcut("ActionHighlightingMode"));
@ -968,6 +988,18 @@ void CPUDisassembly::gotoFileOffset()
DbgCmdExec(QString().sprintf("disasm \"%p\"", value).toUtf8().constData()); DbgCmdExec(QString().sprintf("disasm \"%p\"", value).toUtf8().constData());
} }
void CPUDisassembly::gotoStartSlot()
{
uint_t dest = mMemPage->getBase();
DbgCmdExec(QString().sprintf("disasm \"%p\"", dest).toUtf8().constData());
}
void CPUDisassembly::gotoEndSlot()
{
uint_t dest = mMemPage->getBase() + mMemPage->getSize() - (getViewableRowsCount() * 16);
DbgCmdExec(QString().sprintf("disasm \"%p\"", dest).toUtf8().constData());
}
void CPUDisassembly::followActionSlot() void CPUDisassembly::followActionSlot()
{ {
QAction* action = qobject_cast<QAction*>(sender()); QAction* action = qobject_cast<QAction*>(sender());

View File

@ -46,6 +46,8 @@ public slots:
void assembleAt(); void assembleAt();
void gotoExpression(); void gotoExpression();
void gotoFileOffset(); void gotoFileOffset();
void gotoStartSlot();
void gotoEndSlot();
void followActionSlot(); void followActionSlot();
void gotoPrevious(); void gotoPrevious();
void gotoNext(); void gotoNext();
@ -110,6 +112,8 @@ private:
QAction* mGotoFileOffset; QAction* mGotoFileOffset;
QAction* mGotoPrevious; QAction* mGotoPrevious;
QAction* mGotoNext; QAction* mGotoNext;
QAction* mGotoStart;
QAction* mGotoEnd;
QAction* mReferenceSelectedAddress; QAction* mReferenceSelectedAddress;
QAction* mSearchCommand; QAction* mSearchCommand;
QAction* mSearchConstant; QAction* mSearchConstant;

View File

@ -142,6 +142,14 @@ void CPUDump::setupContextMenu()
mFollowInDisasm = new QAction("Follow in Disassembler", this); mFollowInDisasm = new QAction("Follow in Disassembler", this);
connect(mFollowInDisasm, SIGNAL(triggered()), this, SLOT(followInDisasmSlot())); connect(mFollowInDisasm, SIGNAL(triggered()), this, SLOT(followInDisasmSlot()));
//Follow DWORD/QWORD
#ifdef _WIN64
mFollowData = new QAction("&Follow QWORD in Disassembler", this);
#else //x86
mFollowData = new QAction("&Follow DWORD in Disassembler", this);
#endif //_WIN64
connect(mFollowData, SIGNAL(triggered()), this, SLOT(followDataSlot()));
//Label //Label
mSetLabelAction = new QAction("Set Label", this); mSetLabelAction = new QAction("Set Label", this);
mSetLabelAction->setShortcutContext(Qt::WidgetShortcut); mSetLabelAction->setShortcutContext(Qt::WidgetShortcut);
@ -267,9 +275,25 @@ void CPUDump::setupContextMenu()
// Goto->File offset // Goto->File offset
mGotoFileOffset = new QAction("File Offset", this); mGotoFileOffset = new QAction("File Offset", this);
mGotoFileOffset->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoFileOffset);
connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffsetSlot())); connect(mGotoFileOffset, SIGNAL(triggered()), this, SLOT(gotoFileOffsetSlot()));
mGotoMenu->addAction(mGotoFileOffset); mGotoMenu->addAction(mGotoFileOffset);
// Goto->Start of page
mGotoStart = new QAction("Start of Page", this);
mGotoStart->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoStart);
connect(mGotoStart, SIGNAL(triggered()), this, SLOT(gotoStartSlot()));
mGotoMenu->addAction(mGotoStart);
// Goto->End of page
mGotoEnd = new QAction("End of Page", this);
mGotoEnd->setShortcutContext(Qt::WidgetShortcut);
this->addAction(mGotoEnd);
connect(mGotoEnd, SIGNAL(triggered()), this, SLOT(gotoEndSlot()));
mGotoMenu->addAction(mGotoEnd);
//Hex menu //Hex menu
mHexMenu = new QMenu("&Hex", this); mHexMenu = new QMenu("&Hex", this);
//Hex->Ascii //Hex->Ascii
@ -380,6 +404,9 @@ void CPUDump::refreshShortcutsSlot()
mFindPatternAction->setShortcut(ConfigShortcut("ActionFindPattern")); mFindPatternAction->setShortcut(ConfigShortcut("ActionFindPattern"));
mFindReferencesAction->setShortcut(ConfigShortcut("ActionFindReferences")); mFindReferencesAction->setShortcut(ConfigShortcut("ActionFindReferences"));
mGotoExpression->setShortcut(ConfigShortcut("ActionGotoExpression")); mGotoExpression->setShortcut(ConfigShortcut("ActionGotoExpression"));
mGotoStart->setShortcut(ConfigShortcut("ActionGotoStart"));
mGotoEnd->setShortcut(ConfigShortcut("ActionGotoEnd"));
mGotoFileOffset->setShortcut(ConfigShortcut("ActionGotoFileOffset"));
mYaraAction->setShortcut(ConfigShortcut("ActionYara")); mYaraAction->setShortcut(ConfigShortcut("ActionYara"));
} }
@ -472,6 +499,9 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
{ {
if(!DbgIsDebugging()) if(!DbgIsDebugging())
return; return;
int_t selectedAddr = rvaToVa(getInitialSelection());
QMenu* wMenu = new QMenu(this); //create context menu QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addMenu(mBinaryMenu); wMenu->addMenu(mBinaryMenu);
int_t start = rvaToVa(getSelectionStart()); int_t start = rvaToVa(getSelectionStart());
@ -481,6 +511,12 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
if(DbgMemIsValidReadPtr(start) && DbgMemFindBaseAddr(start, 0) == DbgMemFindBaseAddr(DbgValFromString("csp"), 0)) if(DbgMemIsValidReadPtr(start) && DbgMemFindBaseAddr(start, 0) == DbgMemFindBaseAddr(DbgValFromString("csp"), 0))
wMenu->addAction(mFollowStack); wMenu->addAction(mFollowStack);
wMenu->addAction(mFollowInDisasm); wMenu->addAction(mFollowInDisasm);
uint_t ptr = 0;
DbgMemRead(selectedAddr, (unsigned char*)&ptr, sizeof(uint_t));
if(DbgMemIsValidReadPtr(ptr))
wMenu->addAction(mFollowData);
wMenu->addAction(mSetLabelAction); wMenu->addAction(mSetLabelAction);
wMenu->addMenu(mBreakpointMenu); wMenu->addMenu(mBreakpointMenu);
wMenu->addAction(mFindPatternAction); wMenu->addAction(mFindPatternAction);
@ -496,7 +532,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
wMenu->addAction(mAddressAction); wMenu->addAction(mAddressAction);
wMenu->addAction(mDisassemblyAction); wMenu->addAction(mDisassemblyAction);
int_t selectedAddr = rvaToVa(getInitialSelection());
if((DbgGetBpxTypeAt(selectedAddr) & bp_hardware) == bp_hardware) //hardware breakpoint set if((DbgGetBpxTypeAt(selectedAddr) & bp_hardware) == bp_hardware) //hardware breakpoint set
{ {
mHardwareAccessMenu->menuAction()->setVisible(false); mHardwareAccessMenu->menuAction()->setVisible(false);
@ -625,6 +661,18 @@ void CPUDump::gotoFileOffsetSlot()
DbgCmdExec(QString().sprintf("dump \"%p\"", value).toUtf8().constData()); DbgCmdExec(QString().sprintf("dump \"%p\"", value).toUtf8().constData());
} }
void CPUDump::gotoStartSlot()
{
uint_t dest = mMemPage->getBase();
DbgCmdExec(QString().sprintf("dump \"%p\"", dest).toUtf8().constData());
}
void CPUDump::gotoEndSlot()
{
uint_t dest = mMemPage->getBase() + mMemPage->getSize() - (getViewableRowsCount() * getBytePerRowCount());
DbgCmdExec(QString().sprintf("dump \"%p\"", dest).toUtf8().constData());
}
void CPUDump::hexAsciiSlot() void CPUDump::hexAsciiSlot()
{ {
Config()->setUint("HexDump", "DefaultView", (uint_t)ViewHexAscii); Config()->setUint("HexDump", "DefaultView", (uint_t)ViewHexAscii);
@ -1343,6 +1391,12 @@ void CPUDump::followInDisasmSlot()
DbgCmdExec(QString("disasm " + addrText).toUtf8().constData()); DbgCmdExec(QString("disasm " + addrText).toUtf8().constData());
} }
void CPUDump::followDataSlot()
{
QString addrText = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(QString("disasm [%1]").arg(addrText).toUtf8().constData());
}
void CPUDump::selectionUpdatedSlot() void CPUDump::selectionUpdatedSlot()
{ {
QString selStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper(); QString selStart = QString("%1").arg(rvaToVa(getSelectionStart()), sizeof(int_t) * 2, 16, QChar('0')).toUpper();

View File

@ -41,6 +41,8 @@ public slots:
void setLabelSlot(); void setLabelSlot();
void gotoExpressionSlot(); void gotoExpressionSlot();
void gotoFileOffsetSlot(); void gotoFileOffsetSlot();
void gotoStartSlot();
void gotoEndSlot();
void hexAsciiSlot(); void hexAsciiSlot();
void hexUnicodeSlot(); void hexUnicodeSlot();
@ -78,6 +80,7 @@ public slots:
void followStackSlot(); void followStackSlot();
void findReferencesSlot(); void findReferencesSlot();
void followInDisasmSlot(); void followInDisasmSlot();
void followDataSlot();
void selectionUpdatedSlot(); void selectionUpdatedSlot();
void yaraSlot(); void yaraSlot();
@ -118,6 +121,8 @@ private:
QMenu* mGotoMenu; QMenu* mGotoMenu;
QAction* mGotoExpression; QAction* mGotoExpression;
QAction* mGotoFileOffset; QAction* mGotoFileOffset;
QAction* mGotoStart;
QAction* mGotoEnd;
QAction* mFollowInDisasm; QAction* mFollowInDisasm;
@ -167,6 +172,7 @@ private:
QAction* mYaraAction; QAction* mYaraAction;
QAction* mDataCopyAction; QAction* mDataCopyAction;
QAction* mUndoSelection; QAction* mUndoSelection;
QAction* mFollowData;
QMenu* mSpecialMenu; QMenu* mSpecialMenu;
QMenu* mCustomMenu; QMenu* mCustomMenu;

View File

@ -251,6 +251,9 @@ Configuration::Configuration() : QObject()
defaultShortcuts.insert("ActionGotoPrevious", Shortcut(tr("Actions -> Goto Previous"), "-")); defaultShortcuts.insert("ActionGotoPrevious", Shortcut(tr("Actions -> Goto Previous"), "-"));
defaultShortcuts.insert("ActionGotoNext", Shortcut(tr("Actions -> Goto Next"), "+")); defaultShortcuts.insert("ActionGotoNext", Shortcut(tr("Actions -> Goto Next"), "+"));
defaultShortcuts.insert("ActionGotoExpression", Shortcut(tr("Actions -> Goto Expression"), "Ctrl+G")); defaultShortcuts.insert("ActionGotoExpression", Shortcut(tr("Actions -> Goto Expression"), "Ctrl+G"));
defaultShortcuts.insert("ActionGotoStart", Shortcut(tr("Actions -> Goto Start of Page"), "Home"));
defaultShortcuts.insert("ActionGotoEnd", Shortcut(tr("Actions -> Goto End of Page"), "End"));
defaultShortcuts.insert("ActionGotoFileOffset", Shortcut(tr("Actions -> Goto File Offset"), "Ctrl+Shift+G"));
defaultShortcuts.insert("ActionFindReferencesToSelectedAddress", Shortcut(tr("Actions -> Find References to Selected Address"), "Ctrl+R")); defaultShortcuts.insert("ActionFindReferencesToSelectedAddress", Shortcut(tr("Actions -> Find References to Selected Address"), "Ctrl+R"));
defaultShortcuts.insert("ActionFindPattern", Shortcut(tr("Actions -> Find Pattern"), "Ctrl+B")); defaultShortcuts.insert("ActionFindPattern", Shortcut(tr("Actions -> Find Pattern"), "Ctrl+B"));
defaultShortcuts.insert("ActionFindReferences", Shortcut(tr("Actions -> Find References"), "Ctrl+R")); defaultShortcuts.insert("ActionFindReferences", Shortcut(tr("Actions -> Find References"), "Ctrl+R"));