From 7d45916c9621818a2d405b8adb3c2528fe16be43 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Tue, 5 Jan 2016 04:33:22 +0100 Subject: [PATCH] various small fixes --- GleeBug/Debugger.Thread.HardwareBreakpoint.cpp | 8 ++++---- GleeBug/GleeBug.h | 2 +- GleeBug/Static.BufferFile.cpp | 5 +++++ GleeBug/Static.BufferFile.h | 15 ++++++++------- GleeBug/Static.File.cpp | 2 +- MyDebugger/MyDebugger.h | 8 ++++---- README.md | 2 +- TitanEngineEmulator/Emulator.h | 12 ++++++------ 8 files changed, 30 insertions(+), 24 deletions(-) diff --git a/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp b/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp index 9ff9e63..f260abb 100644 --- a/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp +++ b/GleeBug/Debugger.Thread.HardwareBreakpoint.cpp @@ -37,7 +37,7 @@ namespace GleeBug BYTE DR7_SIZE[HWBP_COUNT]; }; - static inline ptr dr7_ptr(const DR7 & dr7) + static ptr dr7_ptr(const DR7 & dr7) { ptr result = 0; if (BITGET(dr7.DR7_MODE[0], 0)) @@ -91,7 +91,7 @@ namespace GleeBug return result; } - static inline DR7 ptr_dr7(ptr dr7) + static DR7 ptr_dr7(ptr dr7) { DR7 result; memset(&result, 0, sizeof(DR7)); @@ -146,7 +146,7 @@ namespace GleeBug return result; } - static inline DR7_SIZE size_dr7(HardwareSize size) + static DR7_SIZE size_dr7(HardwareSize size) { switch (size) { @@ -165,7 +165,7 @@ namespace GleeBug } } - static inline DR7_TYPE type_dr7(HardwareType type) + static DR7_TYPE type_dr7(HardwareType type) { switch (type) { diff --git a/GleeBug/GleeBug.h b/GleeBug/GleeBug.h index cb0de7f..17e4748 100644 --- a/GleeBug/GleeBug.h +++ b/GleeBug/GleeBug.h @@ -47,7 +47,7 @@ namespace GleeBug \param b Second range. \return True if a comes before b, false otherwise. */ - inline bool operator()(const Range & a, const Range & b) const //a before b? + bool operator()(const Range & a, const Range & b) const //a before b? { return a.second < b.first; } diff --git a/GleeBug/Static.BufferFile.cpp b/GleeBug/Static.BufferFile.cpp index 874937d..e7cdc03 100644 --- a/GleeBug/Static.BufferFile.cpp +++ b/GleeBug/Static.BufferFile.cpp @@ -9,6 +9,11 @@ namespace GleeBug { } + BufferFile::~BufferFile() + { + BufferFile::Close(); + } + bool BufferFile::Open() { return true; diff --git a/GleeBug/Static.BufferFile.h b/GleeBug/Static.BufferFile.h index 4491751..e37f1ec 100644 --- a/GleeBug/Static.BufferFile.h +++ b/GleeBug/Static.BufferFile.h @@ -9,34 +9,35 @@ namespace GleeBug { public: BufferFile(void* data, uint32 size); + ~BufferFile(); /** \brief Opens an existing file. \return true if the file was opened successfully, false otherwise. */ - virtual bool Open() override; + bool Open() override; /** \brief Creates a new file. \param overwrite (Optional) true to overwrite, false to preserve fail if the file already exists. \return true if the file was created, false otherwise. */ - virtual bool Create(bool overwrite = true) override; + bool Create(bool overwrite = true) override; /** \brief Check if there is an open/created file. */ - virtual bool IsOpen() const override; + bool IsOpen() const override; /** \brief Closes the file. */ - virtual void Close() override; + void Close() override; /** \brief Gets the size of the file. */ - virtual uint32 GetSize() const override; + uint32 GetSize() const override; /** \brief Reads from the open file. @@ -46,7 +47,7 @@ namespace GleeBug \param [out] bytesRead (Optional) If set, returns the number of bytes read (even on failure). \return true if the read was fully successful, false otherwise. */ - virtual bool Read(uint32 offset, void* data, uint32 size, uint32* bytesRead = nullptr) const override; + bool Read(uint32 offset, void* data, uint32 size, uint32* bytesRead = nullptr) const override; /** \brief Writes to the open file. @@ -56,7 +57,7 @@ namespace GleeBug \param [out] bytesWritten (Optional) If set, returns the number of bytes written (even on failure) \return true if the write was fully successful, false otherwise. */ - virtual bool Write(uint32 offset, const void* data, uint32 size, uint32* bytesWritten = nullptr) override; + bool Write(uint32 offset, const void* data, uint32 size, uint32* bytesWritten = nullptr) override; private: void* mData; diff --git a/GleeBug/Static.File.cpp b/GleeBug/Static.File.cpp index fd7bd15..dc37953 100644 --- a/GleeBug/Static.File.cpp +++ b/GleeBug/Static.File.cpp @@ -11,7 +11,7 @@ namespace GleeBug File::~File() { - Close(); + File::Close(); } bool File::Open() diff --git a/MyDebugger/MyDebugger.h b/MyDebugger/MyDebugger.h index c2aa363..f97ca90 100644 --- a/MyDebugger/MyDebugger.h +++ b/MyDebugger/MyDebugger.h @@ -16,11 +16,11 @@ protected: printf("Entry breakpoint deleted!\n"); else printf("Failed to delete entry breakpoint...\n"); - mThread->StepInto(std::bind([this]() + mThread->StepInto([this]() { printf("Step after entry breakpoint! GIP: 0x%p\n", mRegisters->Gip()); - })); + }); } void cbEntryHardwareBreakpoint(const BreakpointInfo & info) @@ -31,11 +31,11 @@ protected: printf("Entry hardware breakpoint deleted!\n"); else printf("Failed to delete entry hardware breakpoint...\n"); - mThread->StepInto(std::bind([this]() + mThread->StepInto([this]() { printf("Step after entry hardware breakpoint! GIP: 0x%p\n", mRegisters->Gip()); - })); + }); } void cbStepSystem() diff --git a/README.md b/README.md index 4a58dad..10a0095 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ GleeBug is a **Debugging Framework for Windows** aimed at making debugging enjoyable. It should be complete and easy to use. Feel free to clone and send a pull request or report a bug! -Notice that the project is currently very volatile so for this reason pull requests with new features might be rejected if I feel like they don't fit the future codebase. +Notice that the project is currently very volatile so for this reason pull requests with new features might be rejected if I feel like they don't fit the current codebase. If you plan on adding major features, please consider consulting me (mrexodia) so there isn't any time wasted. diff --git a/TitanEngineEmulator/Emulator.h b/TitanEngineEmulator/Emulator.h index 6c8923d..e682b7a 100644 --- a/TitanEngineEmulator/Emulator.h +++ b/TitanEngineEmulator/Emulator.h @@ -425,7 +425,7 @@ public: bool DeleteHardwareBreakPoint(DWORD IndexOfRegister) { - if (!mProcess || IndexOfRegister < 0 || IndexOfRegister > 3) + if (!mProcess || IndexOfRegister > 3) return false; auto address = mProcess->hardwareBreakpoints[IndexOfRegister].address; return mProcess->DeleteHardwareBreakpoint(address); @@ -524,7 +524,7 @@ protected: } private: //functions - static inline Registers::R registerFromDword(DWORD IndexOfRegister) + static Registers::R registerFromDword(DWORD IndexOfRegister) { switch (IndexOfRegister) { @@ -571,19 +571,19 @@ private: //functions } } - inline ThreadInfo* threadFromHandle(HANDLE hThread) const + ThreadInfo* threadFromHandle(HANDLE hThread) const { //TODO: properly implement this return mThread; } - inline ProcessInfo* processFromHandle(HANDLE hProcess) const + ProcessInfo* processFromHandle(HANDLE hProcess) const { //TODO: properly implement this return mProcess; } - static inline HardwareType hwtypeFromTitan(DWORD type) + static HardwareType hwtypeFromTitan(DWORD type) { switch (type) { @@ -598,7 +598,7 @@ private: //functions } } - static inline HardwareSize hwsizeFromTitan(DWORD size) + static HardwareSize hwsizeFromTitan(DWORD size) { switch (size) {