From 94060f3d99ebe6404188c67b188977a4891a080c Mon Sep 17 00:00:00 2001 From: mrexodia Date: Fri, 19 Aug 2016 16:23:21 +0200 Subject: [PATCH] added MemoryType::Read --- GleeBug/Debugger.Breakpoint.h | 5 +++-- GleeBug/Debugger.Process.Breakpoint.cpp | 3 ++- GleeBug/Debugger.Process.h | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GleeBug/Debugger.Breakpoint.h b/GleeBug/Debugger.Breakpoint.h index a6aeb6a..745d34d 100644 --- a/GleeBug/Debugger.Breakpoint.h +++ b/GleeBug/Debugger.Breakpoint.h @@ -45,8 +45,9 @@ namespace GleeBug enum class MemoryType { Access = 1, - Write = 2, - Execute = 4 + Read = 2, + Write = 4, + Execute = 8 }; /** diff --git a/GleeBug/Debugger.Process.Breakpoint.cpp b/GleeBug/Debugger.Process.Breakpoint.cpp index 26cab49..ce9285f 100644 --- a/GleeBug/Debugger.Process.Breakpoint.cpp +++ b/GleeBug/Debugger.Process.Breakpoint.cpp @@ -238,6 +238,7 @@ namespace GleeBug switch (type) { case MemoryType::Access: + case MemoryType::Read: data.NewProtect = data.OldProtect | PAGE_GUARD; break; case MemoryType::Write: @@ -254,7 +255,7 @@ namespace GleeBug data.Type = oldData.Type | uint32(type); data.OldProtect = oldData.OldProtect; data.Refcount = oldData.Refcount + 1; - if (data.Type & uint32(MemoryType::Access)) //Access always becomes PAGE_GUARD + if (data.Type & uint32(MemoryType::Access) || data.Type & uint32(MemoryType::Read)) //Access/Read always becomes PAGE_GUARD data.NewProtect = data.OldProtect | PAGE_GUARD; else if (data.Type & (uint32(MemoryType::Write) | uint32(MemoryType::Execute))) //Write + Execute becomes either PAGE_GUARD or both write and execute flags removed data.NewProtect = permanentDep ? RemoveExecuteAccess(RemoveWriteAccess(data.OldProtect)) : data.OldProtect | PAGE_GUARD; diff --git a/GleeBug/Debugger.Process.h b/GleeBug/Debugger.Process.h index 79eba6a..20733f8 100644 --- a/GleeBug/Debugger.Process.h +++ b/GleeBug/Debugger.Process.h @@ -320,7 +320,7 @@ namespace GleeBug \param singleshoot (Optional) True to remove the breakpoint after the first hit. \return true if the memory breakpoint was set, false otherwise. */ - bool SetMemoryBreakpoint(ptr address, ptr size, MemoryType type = MemoryType::Access, bool singleshoot = false); + bool SetMemoryBreakpoint(ptr address, ptr size, MemoryType type = MemoryType::Access, bool singleshoot = true); /** \brief Sets a memory breakpoint. @@ -331,7 +331,7 @@ namespace GleeBug \param singleshoot (Optional) True to remove the breakpoint after the first hit. \return true if the memory breakpoint was set, false otherwise. */ - bool SetMemoryBreakpoint(ptr address, ptr size, const BreakpointCallback & cbBreakpoint, MemoryType type = MemoryType::Access, bool singleshoot = false); + bool SetMemoryBreakpoint(ptr address, ptr size, const BreakpointCallback & cbBreakpoint, MemoryType type = MemoryType::Access, bool singleshoot = true); /** \brief Sets a hardware breakpoint. @@ -345,7 +345,7 @@ namespace GleeBug \return true if the memory breakpoint was set, false otherwise. */ template - bool SetMemoryBreakpoint(ptr address, ptr size, T* debugger, void(T::*callback)(const BreakpointInfo & info), MemoryType type = MemoryType::Access, bool singleshoot = false) + bool SetMemoryBreakpoint(ptr address, ptr size, T* debugger, void(T::*callback)(const BreakpointInfo & info), MemoryType type = MemoryType::Access, bool singleshoot = true) { static_cast(static_cast(debugger)); return SetMemoryBreakpoint(address, size, std::bind(callback, debugger, std::placeholders::_1), type, singleshoot);