From cc9bd15013ad92be1075ed319854e74e0f5fe93c Mon Sep 17 00:00:00 2001 From: "mr.exodia" Date: Sat, 14 Dec 2013 14:56:49 +0100 Subject: [PATCH] BRIDGE: added GuiUpdateWindowTitle & GuiUpdateCPUTitle DBG: changed memory map modname (now with extension) DBG: change the window title to the currently debugged file + modname in CPU window for currently disassembled module GUI: added update window title + cpu title --- x64_dbg_bridge/bridgemain.cpp | 10 +++++ x64_dbg_bridge/bridgemain.h | 6 ++- x64_dbg_dbg/_exports.cpp | 2 +- x64_dbg_dbg/debugger.cpp | 21 +++++++++++ .../Project/Src/BasicView/MemoryMapView.cpp | 12 +++--- x64_dbg_gui/Project/Src/Bridge/Bridge.cpp | 23 +++++++++++- x64_dbg_gui/Project/Src/Bridge/Bridge.h | 4 ++ .../Project/Src/Gui/BreakpointsView.cpp | 24 ++++++------ x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 37 ++++++++++++++----- x64_dbg_gui/Project/Src/Gui/MainWindow.h | 5 +++ x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp | 2 + 11 files changed, 116 insertions(+), 30 deletions(-) diff --git a/x64_dbg_bridge/bridgemain.cpp b/x64_dbg_bridge/bridgemain.cpp index 1e892d79..a8b6cc6c 100644 --- a/x64_dbg_bridge/bridgemain.cpp +++ b/x64_dbg_bridge/bridgemain.cpp @@ -408,6 +408,16 @@ BRIDGE_IMPEXP void GuiUpdateBreakpointsView() _gui_sendmessage(GUI_UPDATE_BREAKPOINTS_VIEW, 0, 0); } +BRIDGE_IMPEXP void GuiUpdateWindowTitle(const char* filename) +{ + _gui_sendmessage(GUI_UPDATE_WINDOW_TITLE, (void*)filename, 0); +} + +BRIDGE_IMPEXP void GuiUpdateCPUTitle(const char* modname) +{ + _gui_sendmessage(GUI_UPDATE_CPU_TITLE, (void*)modname, 0); +} + //Main BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { diff --git a/x64_dbg_bridge/bridgemain.h b/x64_dbg_bridge/bridgemain.h index 407a616e..3c21cd3c 100644 --- a/x64_dbg_bridge/bridgemain.h +++ b/x64_dbg_bridge/bridgemain.h @@ -52,7 +52,9 @@ enum MSGTYPE GUI_CLEAR_LOG, // param1=unused, param2=unused GUI_UPDATE_REGISTER_VIEW, // param1=unused, param2=unused GUI_UPDATE_DISASSEMBLY_VIEW, // param1=unused, param2=unused - GUI_UPDATE_BREAKPOINTS_VIEW // param1=unused, param2=unused + GUI_UPDATE_BREAKPOINTS_VIEW, // param1=unused, param2=unused + GUI_UPDATE_WINDOW_TITLE, // param1=(const char*)file, param2=unused + GUI_UPDATE_CPU_TITLE // param1=(const char*)mod, param2=unused }; //Debugger enums @@ -215,6 +217,8 @@ BRIDGE_IMPEXP void GuiUpdateAllViews(); BRIDGE_IMPEXP void GuiUpdateRegisterView(); BRIDGE_IMPEXP void GuiUpdateDisassemblyView(); BRIDGE_IMPEXP void GuiUpdateBreakpointsView(); +BRIDGE_IMPEXP void GuiUpdateWindowTitle(const char* filename); +BRIDGE_IMPEXP void GuiUpdateCPUTitle(const char* modname); #ifdef __cplusplus } diff --git a/x64_dbg_dbg/_exports.cpp b/x64_dbg_dbg/_exports.cpp index 9db24c72..000a2dd5 100644 --- a/x64_dbg_dbg/_exports.cpp +++ b/x64_dbg_dbg/_exports.cpp @@ -37,7 +37,7 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap) { MEMPAGE curPage; *curPage.mod=0; - modnamefromaddr(MyAddress, curPage.mod, false); + modnamefromaddr(MyAddress, curPage.mod, true); memcpy(&curPage.mbi, &mbi, sizeof(mbi)); pageVector.push_back(curPage); memmap->count++; diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 522fd36f..36eabdb2 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -13,6 +13,7 @@ static PROCESS_INFORMATION g_pi= {0,0,0,0}; static char szFileName[MAX_PATH]=""; +static char szBaseFileName[MAX_PATH]=""; static bool bFileIsDll=false; static uint pDebuggedBase=0; static uint pDebuggedEntry=0; @@ -64,6 +65,10 @@ void DebugUpdateGui(uint disasm_addr) { GuiUpdateAllViews(); GuiDisasmAt(disasm_addr, (duint)GetContextData(UE_CIP)); + char modname[MAX_MODULE_SIZE]=""; + if(!modnamefromaddr(disasm_addr, modname, true)) + *modname=0; + GuiUpdateCPUTitle(modname); } static void cbUserBreakpoint() @@ -565,6 +570,14 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter) SetCustomHandler(UE_CH_UNHANDLEDEXCEPTION, (void*)cbException); //inform GUI start we started without problems GuiSetDebugState(initialized); + //set GUI title + strcpy(szBaseFileName, szFileName); + int len=strlen(szBaseFileName); + while(szBaseFileName[len]!='\\' and len) + len--; + if(len) + strcpy(szBaseFileName, szBaseFileName+len+1); + GuiUpdateWindowTitle(szBaseFileName); //call plugin callback PLUG_CB_INITDEBUG initInfo; initInfo.szFileName=szFileName; @@ -1457,6 +1470,14 @@ static DWORD WINAPI threadAttachLoop(void* lpParameter) SetCustomHandler(UE_CH_UNHANDLEDEXCEPTION, (void*)cbException); //inform GUI start we started without problems GuiSetDebugState(initialized); + //set GUI title + strcpy(szBaseFileName, szFileName); + int len=strlen(szBaseFileName); + while(szBaseFileName[len]!='\\' and len) + len--; + if(len) + strcpy(szBaseFileName, szBaseFileName+len+1); + GuiUpdateWindowTitle(szBaseFileName); //call plugin callback PLUG_CB_INITDEBUG initInfo; initInfo.szFileName=szFileName; diff --git a/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp index c6f0f6c9..462d7682 100644 --- a/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp @@ -6,12 +6,12 @@ MemoryMapView::MemoryMapView(StdTable *parent) : StdTable(parent) int charwidth=QFontMetrics(this->font()).width(QChar(' ')); - addColumnAt(8+charwidth*2*sizeof(uint_t), "", false); //addr - addColumnAt(8+charwidth*2*sizeof(uint_t), "", false); //size - addColumnAt(8+charwidth*32, "", false); //module - addColumnAt(8+charwidth*3, "", false); - addColumnAt(8+charwidth*5, "", false); - addColumnAt(8+charwidth*5, "", false); + addColumnAt(8+charwidth*2*sizeof(uint_t), "ADDR", false); //addr + addColumnAt(8+charwidth*2*sizeof(uint_t), "SIZE", false); //size + addColumnAt(8+charwidth*32, "MOD", false); //module + addColumnAt(8+charwidth*3, "TYP", false); + addColumnAt(8+charwidth*5, "CPROT", false); + addColumnAt(8+charwidth*5, "APROT", false); addColumnAt(100, "", false); diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp index 4e536e75..2ec2001e 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp @@ -52,6 +52,16 @@ void Bridge::emitUpdateBreakpoints() emit updateBreakpoints(); } +void Bridge::emitUpdateWindowTitle(QString filename) +{ + emit updateWindowTitle(filename); +} + +void Bridge::emitUpdateCPUTitle(QString modname) +{ + emit updateCPUTitle(modname); +} + /************************************************************************************ Static Functions @@ -121,9 +131,20 @@ __declspec(dllexport) void _gui_sendmessage(MSGTYPE type, void* param1, void* pa } break; + case GUI_UPDATE_WINDOW_TITLE: + { + Bridge::getBridge()->emitUpdateWindowTitle(QString(reinterpret_cast(param1))); + } + break; + + case GUI_UPDATE_CPU_TITLE: + { + Bridge::getBridge()->emitUpdateCPUTitle(QString(reinterpret_cast(param1))); + } + break; + default: { - } break; } diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.h b/x64_dbg_gui/Project/Src/Bridge/Bridge.h index d8620b0a..51cebae7 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.h +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.h @@ -29,6 +29,8 @@ public: void emitClearLog(); void emitUpdateRegisters(); void emitUpdateBreakpoints(); + void emitUpdateWindowTitle(QString filename); + void emitUpdateCPUTitle(QString modname); signals: void disassembleAt(int_t va, int_t eip); @@ -38,6 +40,8 @@ signals: void clearLog(); void updateRegisters(); void updateBreakpoints(); + void updateWindowTitle(QString filename); + void updateCPUTitle(QString modname); public slots: diff --git a/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp b/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp index fd80520b..dd7dfdc6 100644 --- a/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp +++ b/x64_dbg_gui/Project/Src/Gui/BreakpointsView.cpp @@ -6,28 +6,28 @@ BreakpointsView::BreakpointsView(QWidget *parent) :QWidget(parent) mHardBPTable = new StdTable(this); int wCharWidth = QFontMetrics(mHardBPTable->font()).width(QChar(' ')); mHardBPTable->setContextMenuPolicy(Qt::CustomContextMenu); - mHardBPTable->addColumnAt(wCharWidth*10, "Hardware", false); - mHardBPTable->addColumnAt(wCharWidth*10, "Name", false); - mHardBPTable->addColumnAt(wCharWidth*10, "Module", false); - mHardBPTable->addColumnAt(wCharWidth*10, "State", false); + mHardBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Hardware", false); + mHardBPTable->addColumnAt(8+wCharWidth*32, "Name", false); + mHardBPTable->addColumnAt(8+wCharWidth*32, "Module", false); + mHardBPTable->addColumnAt(8+wCharWidth*8, "State", false); mHardBPTable->addColumnAt(wCharWidth*10, "Comment", false); // Software mSoftBPTable = new StdTable(this); mSoftBPTable->setContextMenuPolicy(Qt::CustomContextMenu); - mSoftBPTable->addColumnAt(wCharWidth*10, "Software", false); - mSoftBPTable->addColumnAt(wCharWidth*10, "Name", false); - mSoftBPTable->addColumnAt(wCharWidth*10, "Module", false); - mSoftBPTable->addColumnAt(wCharWidth*10, "State", false); + mSoftBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Software", false); + mSoftBPTable->addColumnAt(8+wCharWidth*32, "Name", false); + mSoftBPTable->addColumnAt(8+wCharWidth*32, "Module", false); + mSoftBPTable->addColumnAt(8+wCharWidth*8, "State", false); mSoftBPTable->addColumnAt(wCharWidth*10, "Comment", false); // Memory mMemBPTable = new StdTable(this); mMemBPTable->setContextMenuPolicy(Qt::CustomContextMenu); - mMemBPTable->addColumnAt(wCharWidth*10, "Memory", false); - mMemBPTable->addColumnAt(wCharWidth*10, "Name", false); - mMemBPTable->addColumnAt(wCharWidth*10, "Module", false); - mMemBPTable->addColumnAt(wCharWidth*10, "State", false); + mMemBPTable->addColumnAt(8+wCharWidth*2*sizeof(uint_t), "Memory", false); + mMemBPTable->addColumnAt(8+wCharWidth*32, "Name", false); + mMemBPTable->addColumnAt(8+wCharWidth*32, "Module", false); + mMemBPTable->addColumnAt(8+wCharWidth*8, "State", false); mMemBPTable->addColumnAt(wCharWidth*10, "Comment", false); // Splitter diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 7635bd23..02565b16 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -7,13 +7,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi this->showMaximized(); - //Set window title #ifdef _WIN64 - setWindowTitle("x64_dbg"); + mWindowMainTitle="x64_dbg"; #else - setWindowTitle("x32_dbg"); + mWindowMainTitle="x32_dbg"; #endif + //Set window title + setWindowTitle(QString(mWindowMainTitle)); + //Load application icon HICON hIcon=LoadIcon(GetModuleHandleA(0), MAKEINTRESOURCE(100)); SendMessageA((HWND)MainWindow::winId(), WM_SETICON, ICON_BIG, (LPARAM)hIcon); @@ -51,17 +53,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); //Create QMdiSubWindow - QMdiSubWindow* subWindow = new QMdiSubWindow(); - subWindow->setWindowTitle("CPU"); - subWindow->showMaximized(); + mSubWindow = new QMdiSubWindow(); + mSubWindow->setWindowTitle("CPU"); + mSubWindow->showMaximized(); mCpuWin = new CPUWidget(); mCpuWin->setWindowIcon(QIcon(":/icons/images/processor-cpu.png")); - subWindow->setWidget(mCpuWin); + mSubWindow->setWidget(mCpuWin); //Add subWindow to Main QMdiArea here - mdiArea->addSubWindow(subWindow); + mdiArea->addSubWindow(mSubWindow); mdiArea->addSubWindow(mMemMapView); mdiArea->addSubWindow(mLogView); mdiArea->addSubWindow(mBreakpointsView); @@ -81,7 +83,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->statusBar->addPermanentWidget(mLastLogLabel, 1); // Setup Signals/Slots - connect(ui->actionStepOver, SIGNAL(triggered()), mCpuWin, SLOT(stepOverSlot())); connect(mCmdLineEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand())); connect(ui->actionStepOver,SIGNAL(triggered()),this,SLOT(execStepOver())); connect(ui->actionStepInto,SIGNAL(triggered()),this,SLOT(execStepInto())); @@ -97,6 +98,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->actionScylla,SIGNAL(triggered()),this,SLOT(startScylla())); connect(ui->actionRestart,SIGNAL(triggered()),this,SLOT(restartDebugging())); connect(ui->actionBreakpoints,SIGNAL(triggered()),this,SLOT(displayBreakpointWidget())); + connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString))); + connect(Bridge::getBridge(), SIGNAL(updateCPUTitle(QString)), this, SLOT(updateCPUTitleSlot(QString))); const char* errormsg=DbgInit(); if(errormsg) @@ -253,3 +256,19 @@ void MainWindow::dropEvent(QDropEvent* pEvent) pEvent->acceptProposedAction(); } } + +void MainWindow::updateWindowTitleSlot(QString filename) +{ + if(filename.length()) + setWindowTitle(QString(mWindowMainTitle)+QString(" - ")+filename); + else + setWindowTitle(QString(mWindowMainTitle)); +} + +void MainWindow::updateCPUTitleSlot(QString modname) +{ + if(modname.length()) + mSubWindow->setWindowTitle(QString("CPU - ")+modname); + else + mSubWindow->setWindowTitle(QString("CPU")); +} diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.h b/x64_dbg_gui/Project/Src/Gui/MainWindow.h index e8dcd604..c3551932 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.h +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.h @@ -42,6 +42,8 @@ public slots: void startScylla(); void restartDebugging(); void displayBreakpointWidget(); + void updateWindowTitleSlot(QString filename); + void updateCPUTitleSlot(QString modname); private slots: void on_actionGoto_triggered(); @@ -53,6 +55,7 @@ private: CommandLineEdit* mCmdLineEdit; + QMdiSubWindow* mSubWindow; QMdiSubWindow* mMemMapView; QMdiSubWindow* mLogView; QMdiSubWindow* mBreakpointsView; @@ -60,6 +63,8 @@ private: StatusLabel* mStatusLabel; StatusLabel* mLastLogLabel; + const char* mWindowMainTitle; + protected: void dragEnterEvent(QDragEnterEvent* pEvent); void dropEvent(QDropEvent* pEvent); diff --git a/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp b/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp index fde433e7..4a48a27a 100644 --- a/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp +++ b/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp @@ -32,6 +32,8 @@ void StatusLabel::debugStateChangedSlot(DBGSTATE state) case stopped: this->setText("Terminated"); this->setStyleSheet("QLabel { background-color : #c0c0c0; }"); + GuiUpdateWindowTitle(""); + GuiUpdateCPUTitle(""); break; default: break;