From 3d385178da315de72206f3af60707d6e58efe6ab Mon Sep 17 00:00:00 2001 From: mrexodia Date: Fri, 5 Aug 2016 14:48:48 +0200 Subject: [PATCH] initial work on memory breakpoints --- GleeBug/Debugger.Breakpoint.h | 9 +++++++++ GleeBug/Debugger.Global.h | 2 ++ MyDebugger/MyDebugger.h | 6 +++--- MyDebugger/main.cpp | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/GleeBug/Debugger.Breakpoint.h b/GleeBug/Debugger.Breakpoint.h index 669e7b8..6b9b6f3 100644 --- a/GleeBug/Debugger.Breakpoint.h +++ b/GleeBug/Debugger.Breakpoint.h @@ -49,6 +49,14 @@ namespace GleeBug Execute }; + struct MemoryBreakpointInfo + { + struct + { + uint32 offset; + } info[PAGE_SIZE]; + }; + /** \brief Structure describing internal breakpoint info. */ @@ -73,6 +81,7 @@ namespace GleeBug { MemoryType type; ptr size; + MemoryBreakpointInfo* info; } memory; }; }; diff --git a/GleeBug/Debugger.Global.h b/GleeBug/Debugger.Global.h index 7c0e86f..371625b 100644 --- a/GleeBug/Debugger.Global.h +++ b/GleeBug/Debugger.Global.h @@ -5,6 +5,7 @@ //defines #define GLEEBUG_HWBP_COUNT 4 +#define GLEEBUG_PAGE_SIZE 0x1000 namespace GleeBug { @@ -18,6 +19,7 @@ namespace GleeBug //constants const int HWBP_COUNT = GLEEBUG_HWBP_COUNT; + const int PAGE_SIZE = GLEEBUG_PAGE_SIZE; //key typedefs typedef std::pair BreakpointKey; diff --git a/MyDebugger/MyDebugger.h b/MyDebugger/MyDebugger.h index 589e4b9..c7544e0 100644 --- a/MyDebugger/MyDebugger.h +++ b/MyDebugger/MyDebugger.h @@ -12,7 +12,7 @@ protected: { printf("Reached entry breakpoint! GIP: 0x%p\n", mRegisters->Gip()); - if (mProcess->DeleteBreakpoint(info.address)) + /*if (mProcess->DeleteBreakpoint(info.address)) printf("Entry breakpoint deleted!\n"); else printf("Failed to delete entry breakpoint...\n"); @@ -20,7 +20,7 @@ protected: { printf("Step after entry breakpoint! GIP: 0x%p\n", mRegisters->Gip()); - }); + });*/ } void cbEntryHardwareBreakpoint(const BreakpointInfo & info) @@ -61,7 +61,7 @@ protected: else printf("No free hardware breakpoint slot...\n");*/ - if(mProcess->SetBreakpoint(entry, this, &MyDebugger::cbEntryBreakpoint)) + if(mProcess->SetBreakpoint(entry, this, &MyDebugger::cbEntryBreakpoint, true)) printf("Breakpoint set at 0x%p!\n", entry); else printf("Failed to set breakpoint at 0x%p...\b", entry); diff --git a/MyDebugger/main.cpp b/MyDebugger/main.cpp index bde57e2..d7539ea 100644 --- a/MyDebugger/main.cpp +++ b/MyDebugger/main.cpp @@ -7,7 +7,7 @@ static void testDebugger() { #ifdef _WIN64 - wchar_t szFilePath[256] = L"c:\\test64.exe"; + wchar_t szFilePath[256] = L"c:\\MembpTest_x64.exe"; #else //x86 wchar_t szFilePath[256] = L"c:\\test32.exe"; #endif //_WIN64 @@ -161,7 +161,7 @@ static void testCorkami() int main() { - testPeFile(L"C:\\test64.exe"); + testDebugger(); //testCorkami(); //testPeFile(L"c:\\!exclude\\pe\\bin\\appendedhdr.exe"); puts("");