diff --git a/src/bridge/bridgemain.cpp b/src/bridge/bridgemain.cpp index 1e0a5644..0f75cf3a 100644 --- a/src/bridge/bridgemain.cpp +++ b/src/bridge/bridgemain.cpp @@ -1773,6 +1773,16 @@ BRIDGE_IMPEXP void GuiSelectInSymbolsTab(duint addr) _gui_sendmessage(GUI_SELECT_IN_SYMBOLS_TAB, (void*)addr, nullptr); } +BRIDGE_IMPEXP void GuiGotoTrace(duint index) +{ + _gui_sendmessage(GUI_GOTO_TRACE, (void*)index, nullptr); +} + +BRIDGE_IMPEXP void GuiShowTrace() +{ + _gui_sendmessage(GUI_SHOW_TRACE, nullptr, nullptr); +} + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hInst = hinstDLL; diff --git a/src/bridge/bridgemain.h b/src/bridge/bridgemain.h index 68756c2b..224efac2 100644 --- a/src/bridge/bridgemain.h +++ b/src/bridge/bridgemain.h @@ -1205,6 +1205,8 @@ typedef enum GUI_GET_CURRENT_GRAPH, // param1=BridgeCFGraphList*, param2=unused GUI_SHOW_REF, // param1=unused, param2=unused GUI_SELECT_IN_SYMBOLS_TAB, // param1=duint addr, param2=unused + GUI_GOTO_TRACE, // param1=duint index, param2=unused + GUI_SHOW_TRACE, // param1=unused, param2=unused } GUIMSG; //GUI Typedefs @@ -1388,6 +1390,8 @@ BRIDGE_IMPEXP void GuiExecuteOnGuiThreadEx(GUICALLBACKEX cbGuiThread, void* user BRIDGE_IMPEXP void GuiGetCurrentGraph(BridgeCFGraphList* graphList); BRIDGE_IMPEXP void GuiShowReferences(); BRIDGE_IMPEXP void GuiSelectInSymbolsTab(duint addr); +BRIDGE_IMPEXP void GuiGotoTrace(duint index); +BRIDGE_IMPEXP void GuiShowTrace(); #ifdef __cplusplus } diff --git a/src/dbg/commands/cmd-gui.cpp b/src/dbg/commands/cmd-gui.cpp index 7c4b3760..e98f270e 100644 --- a/src/dbg/commands/cmd-gui.cpp +++ b/src/dbg/commands/cmd-gui.cpp @@ -327,3 +327,13 @@ bool cbSymbolsFollow(int argc, char* argv[]) GuiFocusView(GUI_SYMMOD); return true; } + +bool cbGotoTrace(int argc, char* argv[]) +{ + duint index = 0; + if(IsArgumentsLessThan(argc, 2) || !valfromstring(argv[1], &index, false)) + return false; + + GuiGotoTrace(index); + GuiShowTrace(); +} \ No newline at end of file diff --git a/src/dbg/commands/cmd-gui.h b/src/dbg/commands/cmd-gui.h index 2c43352e..2db2f2ff 100644 --- a/src/dbg/commands/cmd-gui.h +++ b/src/dbg/commands/cmd-gui.h @@ -22,3 +22,4 @@ bool cbInstrFoldDisassembly(int argc, char* argv[]); bool cbDebugUpdateTitle(int argc, char* argv[]); bool cbShowReferences(int argc, char* argv[]); bool cbSymbolsFollow(int argc, char* argv[]); +bool cbGotoTrace(int argc, char* argv[]); diff --git a/src/dbg/x64dbg.cpp b/src/dbg/x64dbg.cpp index bcf84a8c..ea8752d4 100644 --- a/src/dbg/x64dbg.cpp +++ b/src/dbg/x64dbg.cpp @@ -407,6 +407,7 @@ static void registercommands() dbgcmdnew("guiupdatetitle", cbDebugUpdateTitle, true); // set relevant disassembly title dbgcmdnew("showref", cbShowReferences, false); // show references window dbgcmdnew("symfollow", cbSymbolsFollow, false); // follow address in symbols tab + dbgcmdnew("gototrace,tracegoto", cbGotoTrace, false); // goto index in trace tab //misc dbgcmdnew("chd", cbInstrChd, false); //Change directory diff --git a/src/gui/Src/Bridge/Bridge.cpp b/src/gui/Src/Bridge/Bridge.cpp index bd7c53ee..724bb9e5 100644 --- a/src/gui/Src/Bridge/Bridge.cpp +++ b/src/gui/Src/Bridge/Bridge.cpp @@ -890,6 +890,14 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2) case GUI_SELECT_IN_SYMBOLS_TAB: emit symbolSelectModule(duint(param1)); break; + + case GUI_GOTO_TRACE: + emit gotoTraceIndex(duint(param1)); + break; + + case GUI_SHOW_TRACE: + emit showTraceBrowser(); + break; } return nullptr; diff --git a/src/gui/Src/Bridge/Bridge.h b/src/gui/Src/Bridge/Bridge.h index 5a301eaa..3a9134d8 100644 --- a/src/gui/Src/Bridge/Bridge.h +++ b/src/gui/Src/Bridge/Bridge.h @@ -163,6 +163,8 @@ signals: void symbolSelectModule(duint base); void getCurrentGraph(BridgeCFGraphList* graphList); void showReferences(); + void gotoTraceIndex(duint index); + void showTraceBrowser(); private: CRITICAL_SECTION csBridge; diff --git a/src/gui/Src/Gui/MainWindow.cpp b/src/gui/Src/Gui/MainWindow.cpp index 7b136f08..fc5541a4 100644 --- a/src/gui/Src/Gui/MainWindow.cpp +++ b/src/gui/Src/Gui/MainWindow.cpp @@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget* parent) connect(Bridge::getBridge(), SIGNAL(selectInMemoryMap(duint)), this, SLOT(displayMemMapWidget())); connect(Bridge::getBridge(), SIGNAL(symbolSelectModule(duint)), this, SLOT(displaySymbolWidget())); connect(Bridge::getBridge(), SIGNAL(closeApplication()), this, SLOT(close())); + connect(Bridge::getBridge(), SIGNAL(showTraceBrowser()), this, SLOT(displayTraceWidget())); // Setup menu API initMenuApi(); diff --git a/src/gui/Src/Tracer/TraceBrowser.cpp b/src/gui/Src/Tracer/TraceBrowser.cpp index 0596bb0f..c9b72e25 100644 --- a/src/gui/Src/Tracer/TraceBrowser.cpp +++ b/src/gui/Src/Tracer/TraceBrowser.cpp @@ -50,6 +50,7 @@ TraceBrowser::TraceBrowser(QWidget* parent) : AbstractTableView(parent) connect(Bridge::getBridge(), SIGNAL(updateTraceBrowser()), this, SLOT(updateSlot())); connect(Bridge::getBridge(), SIGNAL(openTraceFile(const QString &)), this, SLOT(openSlot(const QString &))); + connect(Bridge::getBridge(), SIGNAL(gotoTraceIndex(duint)), this, SLOT(gotoIndexSlot(duint))); connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(tokenizerConfigUpdatedSlot())); } @@ -917,7 +918,7 @@ void TraceBrowser::setupRightClickContextMenu() return true; }); MenuBuilder* gotoMenu = new MenuBuilder(this, isValid); - gotoMenu->addAction(makeShortcutAction(DIcon("goto"), tr("Expression"), SLOT(gotoSlot()), "ActionGotoExpression"), isValid); + gotoMenu->addAction(makeShortcutAction(DIcon("goto"), tr("Index"), SLOT(gotoSlot()), "ActionGotoExpression"), isValid); gotoMenu->addAction(makeAction(DIcon("arrow-step-rtr"), tr("Function return"), SLOT(rtrSlot())), isValid); gotoMenu->addAction(makeShortcutAction(DIcon("previous"), tr("Previous"), SLOT(gotoPreviousSlot()), "ActionGotoPrevious"), [this](QMenu*) { @@ -930,7 +931,7 @@ void TraceBrowser::setupRightClickContextMenu() mMenuBuilder->addMenu(makeMenu(DIcon("goto"), tr("Go to")), gotoMenu); MenuBuilder* searchMenu = new MenuBuilder(this, isValid); - searchMenu->addAction(makeAction(DIcon("search_for_constant"), tr("Constant"), SLOT(searchConstantSlot()))); + searchMenu->addAction(makeAction(DIcon("search_for_constant"), tr("Address/Constant"), SLOT(searchConstantSlot()))); searchMenu->addAction(makeAction(DIcon("memory-map"), tr("Memory Reference"), SLOT(searchMemRefSlot()))); mMenuBuilder->addMenu(makeMenu(DIcon("search"), tr("&Search")), searchMenu); @@ -1831,7 +1832,10 @@ void TraceBrowser::enableHighlightingModeSlot() void TraceBrowser::searchConstantSlot() { WordEditDialog constantDlg(this); - constantDlg.setup(tr("Constant"), 0, sizeof(duint)); + duint initialConstant = 0; + if(mTraceFile && mTraceFile->Progress() == 100) + initialConstant = mTraceFile->Registers(getInitialSelection()).regcontext.cip; + constantDlg.setup(tr("Constant"), initialConstant, sizeof(duint)); if(constantDlg.exec() == QDialog::Accepted) { TraceFileSearchConstantRange(mTraceFile, constantDlg.getVal(), constantDlg.getVal()); @@ -1869,3 +1873,8 @@ void TraceBrowser::toggleAutoDisassemblyFollowSelectionSlot() { mAutoDisassemblyFollowSelection = !mAutoDisassemblyFollowSelection; } + +void TraceBrowser::gotoIndexSlot(duint index) +{ + disasm(index, false); +} diff --git a/src/gui/Src/Tracer/TraceBrowser.h b/src/gui/Src/Tracer/TraceBrowser.h index ca75e18a..fc2bf185 100644 --- a/src/gui/Src/Tracer/TraceBrowser.h +++ b/src/gui/Src/Tracer/TraceBrowser.h @@ -185,6 +185,7 @@ public slots: void updateSlot(); void toggleAutoDisassemblyFollowSelectionSlot(); + void gotoIndexSlot(duint index); protected: void disasm(unsigned long long index, bool history = true); diff --git a/src/gui/Src/Tracer/TraceFileSearch.cpp b/src/gui/Src/Tracer/TraceFileSearch.cpp index ee076368..0222fc03 100644 --- a/src/gui/Src/Tracer/TraceFileSearch.cpp +++ b/src/gui/Src/Tracer/TraceFileSearch.cpp @@ -20,8 +20,9 @@ int TraceFileSearchConstantRange(TraceFileReader* file, duint start, duint end) title = QCoreApplication::translate("TraceFileSearch", "Range: %1-%2").arg(ToPtrString(start)).arg(ToPtrString(end)); GuiReferenceInitialize(title.toUtf8().constData()); GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Address").toUtf8().constData()); - GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData()); + GuiReferenceAddColumn(5, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData()); GuiReferenceAddColumn(100, QCoreApplication::translate("TraceFileSearch", "Disassembly").toUtf8().constData()); + GuiReferenceAddCommand(QCoreApplication::translate("TraceFileSearch", "Follow index in trace").toUtf8().constData(), "gototrace 0x$1"); GuiReferenceSetRowCount(0); REGISTERCONTEXT regcontext; @@ -92,8 +93,9 @@ int TraceFileSearchMemReference(TraceFileReader* file, duint address) Zydis zy; GuiReferenceInitialize(QCoreApplication::translate("TraceFileSearch", "Reference").toUtf8().constData()); GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Address").toUtf8().constData()); - GuiReferenceAddColumn(sizeof(duint) * 2, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData()); + GuiReferenceAddColumn(5, QCoreApplication::translate("TraceFileSearch", "Index").toUtf8().constData()); GuiReferenceAddColumn(100, QCoreApplication::translate("TraceFileSearch", "Disassembly").toUtf8().constData()); + GuiReferenceAddCommand(QCoreApplication::translate("TraceFileSearch", "Follow index in trace").toUtf8().constData(), "gototrace 0x$1"); GuiReferenceSetRowCount(0); for(unsigned long long index = 0; index < file->Length(); index++)