From 04c772720f1b55ee6a2746ffbbc554820a7e9ff0 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Sat, 2 Aug 2014 00:28:20 +0200 Subject: [PATCH] DBG: fixed a bug in cbDebugInit + differentiate between system breakpoint and "attach breakpoint" GUI: resolved issue #139 (Break on system breakpoint only when attaching option) --- x64_dbg_dbg/debugger.cpp | 10 ++++++---- x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp | 12 ++++++++++++ x64_dbg_gui/Project/Src/Gui/SettingsDialog.h | 2 ++ x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui | 13 +++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/debugger.cpp b/x64_dbg_dbg/debugger.cpp index 55085d27..96108f9f 100644 --- a/x64_dbg_dbg/debugger.cpp +++ b/x64_dbg_dbg/debugger.cpp @@ -778,7 +778,10 @@ static void cbSystemBreakpoint(void* ExceptionData) { hActiveThread=threadgethandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId); //log message - dputs("system breakpoint reached!"); + if(bIsAttached) + dputs("attach breakpoint reached!"); + else + dputs("system breakpoint reached!"); bSkipExceptions=false; //we are not skipping first-chance exceptions uint cip=GetContextDataEx(hActiveThread, UE_CIP); GuiDumpAt(memfindbaseaddr(cip, 0, true)); //dump somewhere @@ -788,7 +791,7 @@ static void cbSystemBreakpoint(void* ExceptionData) callbackInfo.reserved=0; plugincbcall(CB_SYSTEMBREAKPOINT, &callbackInfo); - if(settingboolget("Events", "SystemBreakpoint")) + if(bIsAttached ? settingboolget("Events", "AttachBreakpoint") : settingboolget("Events", "SystemBreakpoint")) { //update GUI DebugUpdateGui(cip, true); @@ -1249,7 +1252,6 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) switch(GetFileArchitecture(arg1)) { case invalid: - case notfound: dputs("invalid PE file!"); return STATUS_ERROR; #ifdef _WIN64 @@ -1261,7 +1263,7 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) #endif //_WIN64 return STATUS_ERROR; default: - return STATUS_ERROR; + break; } static char arg2[deflen]=""; diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp index b4cba480..e117302b 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.cpp @@ -46,6 +46,7 @@ void SettingsDialog::LoadSettings() settings.eventSystemBreakpoint=true; settings.eventTlsCallbacks=true; settings.eventEntryBreakpoint=true; + settings.eventAttachBreakpoint=true; settings.engineCalcType=calc_unsigned; settings.engineBreakpointType=break_int3short; settings.engineUndecorateSymbolNames=true; @@ -61,6 +62,7 @@ void SettingsDialog::LoadSettings() GetSettingBool("Events", "EntryBreakpoint", &settings.eventEntryBreakpoint); GetSettingBool("Events", "DllEntry", &settings.eventDllEntry); GetSettingBool("Events", "ThreadEntry", &settings.eventThreadEntry); + GetSettingBool("Events", "AttachBreakpoint", &settings.eventAttachBreakpoint); GetSettingBool("Events", "DllLoad", &settings.eventDllLoad); GetSettingBool("Events", "DllUnload", &settings.eventDllUnload); GetSettingBool("Events", "ThreadStart", &settings.eventThreadStart); @@ -71,6 +73,7 @@ void SettingsDialog::LoadSettings() ui->chkEntryBreakpoint->setCheckState(bool2check(settings.eventEntryBreakpoint)); ui->chkDllEntry->setCheckState(bool2check(settings.eventDllEntry)); ui->chkThreadEntry->setCheckState(bool2check(settings.eventThreadEntry)); + ui->chkAttachBreakpoint->setCheckState(bool2check(settings.eventAttachBreakpoint)); ui->chkDllLoad->setCheckState(bool2check(settings.eventDllLoad)); ui->chkDllUnload->setCheckState(bool2check(settings.eventDllUnload)); ui->chkThreadStart->setCheckState(bool2check(settings.eventThreadStart)); @@ -164,6 +167,7 @@ void SettingsDialog::SaveSettings() BridgeSettingSetUint("Events", "EntryBreakpoint", settings.eventEntryBreakpoint); BridgeSettingSetUint("Events", "DllEntry", settings.eventDllEntry); BridgeSettingSetUint("Events", "ThreadEntry", settings.eventThreadEntry); + BridgeSettingSetUint("Events", "AttachBreakpoint", settings.eventAttachBreakpoint); BridgeSettingSetUint("Events", "DllLoad", settings.eventDllLoad); BridgeSettingSetUint("Events", "DllUnload", settings.eventDllUnload); BridgeSettingSetUint("Events", "ThreadStart", settings.eventThreadStart); @@ -280,6 +284,14 @@ void SettingsDialog::on_chkThreadEntry_stateChanged(int arg1) settings.eventThreadEntry=true; } +void SettingsDialog::on_chkAttachBreakpoint_stateChanged(int arg1) +{ + if(arg1==Qt::Unchecked) + settings.eventAttachBreakpoint=false; + else + settings.eventAttachBreakpoint=true; +} + void SettingsDialog::on_chkDllLoad_stateChanged(int arg1) { if(arg1==Qt::Unchecked) diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h index ba927157..d5c8ee59 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h @@ -32,6 +32,7 @@ private slots: void on_chkEntryBreakpoint_stateChanged(int arg1); void on_chkDllEntry_stateChanged(int arg1); void on_chkThreadEntry_stateChanged(int arg1); + void on_chkAttachBreakpoint_stateChanged(int arg1); void on_chkDllLoad_stateChanged(int arg1); void on_chkDllUnload_stateChanged(int arg1); void on_chkThreadStart_stateChanged(int arg1); @@ -93,6 +94,7 @@ private: bool eventEntryBreakpoint; bool eventDllEntry; bool eventThreadEntry; + bool eventAttachBreakpoint; bool eventDllLoad; bool eventDllUnload; bool eventThreadStart; diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui index 3703219c..f83e5ed9 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.ui @@ -197,6 +197,19 @@ Thread Entry + + + + 20 + 130 + 121 + 17 + + + + Attach Breakpoint + +