added MemoryType::Read

This commit is contained in:
mrexodia 2016-08-19 16:23:21 +02:00
parent aecc172ecb
commit 94060f3d99
3 changed files with 8 additions and 6 deletions

View File

@ -45,8 +45,9 @@ namespace GleeBug
enum class MemoryType enum class MemoryType
{ {
Access = 1, Access = 1,
Write = 2, Read = 2,
Execute = 4 Write = 4,
Execute = 8
}; };
/** /**

View File

@ -238,6 +238,7 @@ namespace GleeBug
switch (type) switch (type)
{ {
case MemoryType::Access: case MemoryType::Access:
case MemoryType::Read:
data.NewProtect = data.OldProtect | PAGE_GUARD; data.NewProtect = data.OldProtect | PAGE_GUARD;
break; break;
case MemoryType::Write: case MemoryType::Write:
@ -254,7 +255,7 @@ namespace GleeBug
data.Type = oldData.Type | uint32(type); data.Type = oldData.Type | uint32(type);
data.OldProtect = oldData.OldProtect; data.OldProtect = oldData.OldProtect;
data.Refcount = oldData.Refcount + 1; 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; 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 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; data.NewProtect = permanentDep ? RemoveExecuteAccess(RemoveWriteAccess(data.OldProtect)) : data.OldProtect | PAGE_GUARD;

View File

@ -320,7 +320,7 @@ namespace GleeBug
\param singleshoot (Optional) True to remove the breakpoint after the first hit. \param singleshoot (Optional) True to remove the breakpoint after the first hit.
\return true if the memory breakpoint was set, false otherwise. \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. \brief Sets a memory breakpoint.
@ -331,7 +331,7 @@ namespace GleeBug
\param singleshoot (Optional) True to remove the breakpoint after the first hit. \param singleshoot (Optional) True to remove the breakpoint after the first hit.
\return true if the memory breakpoint was set, false otherwise. \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. \brief Sets a hardware breakpoint.
@ -345,7 +345,7 @@ namespace GleeBug
\return true if the memory breakpoint was set, false otherwise. \return true if the memory breakpoint was set, false otherwise.
*/ */
template <typename T> template <typename T>
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<void>(static_cast<Debugger*>(debugger)); static_cast<void>(static_cast<Debugger*>(debugger));
return SetMemoryBreakpoint(address, size, std::bind(callback, debugger, std::placeholders::_1), type, singleshoot); return SetMemoryBreakpoint(address, size, std::bind(callback, debugger, std::placeholders::_1), type, singleshoot);