From a71b10b697d46c2b151eb593424f081889665ab4 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Fri, 20 Nov 2015 00:30:36 +0100 Subject: [PATCH] fixed various warnings --- GleeBug/Debugger.Global.h | 6 ++++++ GleeBug/Debugger.Process.Breakpoint.cpp | 4 ++-- GleeBug/Debugger.Process.cpp | 2 +- GleeBug/Debugger.Process.h | 2 +- GleeBug/Debugger.Thread.HardwareBreakpoint.cpp | 6 +++--- GleeBug/Debugger.cpp | 6 +++--- GleeBug/Debugger.h | 16 ++++++++-------- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/GleeBug/Debugger.Global.h b/GleeBug/Debugger.Global.h index a3e3cb8..7cb5b05 100644 --- a/GleeBug/Debugger.Global.h +++ b/GleeBug/Debugger.Global.h @@ -3,6 +3,9 @@ #include "GleeBug.h" +//defines +#define GLEEBUG_HWBP_COUNT 4 + namespace GleeBug { //forward declarations @@ -13,6 +16,9 @@ namespace GleeBug enum class BreakpointType; struct BreakpointInfo; + //constants + const int HWBP_COUNT = GLEEBUG_HWBP_COUNT; + //key typedefs typedef std::pair BreakpointKey; diff --git a/GleeBug/Debugger.Process.Breakpoint.cpp b/GleeBug/Debugger.Process.Breakpoint.cpp index 1f5332d..7b57568 100644 --- a/GleeBug/Debugger.Process.Breakpoint.cpp +++ b/GleeBug/Debugger.Process.Breakpoint.cpp @@ -55,10 +55,10 @@ namespace GleeBug return true; } - bool ProcessInfo::GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) + bool ProcessInfo::GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) const { //find a free hardware breakpoint slot - for (int i = 0; i < 4;i++) + for (int i = 0; i < HWBP_COUNT; i++) { if (!hardwareBreakpoints[i].enabled) { diff --git a/GleeBug/Debugger.Process.cpp b/GleeBug/Debugger.Process.cpp index 3e37ce7..b93b04b 100644 --- a/GleeBug/Debugger.Process.cpp +++ b/GleeBug/Debugger.Process.cpp @@ -9,7 +9,7 @@ namespace GleeBug thread(nullptr), systemBreakpoint(false) { - for (int i = 0; i < 4; i++) + for (int i = 0; i < HWBP_COUNT; i++) hardwareBreakpoints[i].enabled = false; } }; \ No newline at end of file diff --git a/GleeBug/Debugger.Process.h b/GleeBug/Debugger.Process.h index 22f5188..5861b8b 100644 --- a/GleeBug/Debugger.Process.h +++ b/GleeBug/Debugger.Process.h @@ -101,7 +101,7 @@ namespace GleeBug \param [out] slot First free slot found, has no meaning when the function fails. \return true if a free slot was found, false otherwise. */ - bool GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot); + bool GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) const; /** \brief Sets a hardware breakpoint. diff --git a/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp b/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp index f25938c..3b7dabc 100644 --- a/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp +++ b/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp @@ -32,9 +32,9 @@ namespace GleeBug #pragma pack(1) struct DR7 { - BYTE DR7_MODE[4]; - BYTE DR7_TYPE[4]; - BYTE DR7_SIZE[4]; + BYTE DR7_MODE[HWBP_COUNT]; + BYTE DR7_TYPE[HWBP_COUNT]; + BYTE DR7_SIZE[HWBP_COUNT]; }; static inline ptr dr7_ptr(const DR7 & dr7) diff --git a/GleeBug/Debugger.cpp b/GleeBug/Debugger.cpp index 033da4e..80c3ffd 100644 --- a/GleeBug/Debugger.cpp +++ b/GleeBug/Debugger.cpp @@ -18,7 +18,7 @@ namespace GleeBug STARTUPINFOW si; memset(&si, 0, sizeof(si)); const wchar_t* szFileNameCreateProcess; - wchar_t* szCommandLineCreateProcess = nullptr; + wchar_t* szCommandLineCreateProcess; wchar_t* szCreateWithCmdLine = nullptr; if (szCommandLine == nullptr || !wcslen(szCommandLine)) { @@ -50,12 +50,12 @@ namespace GleeBug return result; } - bool Debugger::Stop() + bool Debugger::Stop() const { return !!TerminateProcess(_mainProcess.hProcess, 0); } - bool Debugger::Detach() + bool Debugger::Detach() const { return !!DebugActiveProcessStop(_mainProcess.dwProcessId); } diff --git a/GleeBug/Debugger.h b/GleeBug/Debugger.h index 317679c..b88c0c9 100644 --- a/GleeBug/Debugger.h +++ b/GleeBug/Debugger.h @@ -38,13 +38,13 @@ namespace GleeBug \brief Stops the debuggee (terminate the process) \return true if the debuggee was stopped correctly, false otherwise. */ - bool Stop(); + bool Stop() const; /** \brief Detaches the debuggee. \return true if the debuggee was detached correctly, false otherwise. */ - bool Detach(); + bool Detach() const; /** \brief Run the debug loop (does not return until the debuggee is detached or terminated). @@ -226,26 +226,26 @@ namespace GleeBug protected: //variables PROCESS_INFORMATION _mainProcess; - uint32 _continueStatus; - bool _breakDebugger; + uint32 _continueStatus = DBG_EXCEPTION_NOT_HANDLED; + bool _breakDebugger = false; DEBUG_EVENT _debugEvent; ProcessMap _processes; - bool _isRunning; + bool _isRunning = false; /** \brief The current process (can be null in some cases). */ - ProcessInfo* _process; + ProcessInfo* _process = nullptr; /** \brief The current thread (can be null in some cases). Should be a copy of _process->thread. */ - ThreadInfo* _thread; + ThreadInfo* _thread = nullptr; /** \brief The current thread registers (can be null in some cases). Should be a copy of _thread->registers. */ - Registers* _registers; + Registers* _registers = nullptr; }; };