diff --git a/GleeBug/Debugger.Breakpoint.h b/GleeBug/Debugger.Breakpoint.h index 745d34d..7bdc553 100644 --- a/GleeBug/Debugger.Breakpoint.h +++ b/GleeBug/Debugger.Breakpoint.h @@ -69,6 +69,7 @@ namespace GleeBug HardwareSlot slot; HardwareType type; HardwareSize size; + bool enabled; } hardware; struct { @@ -84,7 +85,6 @@ namespace GleeBug struct BreakpointInfo { ptr address; - bool enabled; bool singleshoot; BreakpointType type; BreakpointInternalInfo internal; diff --git a/GleeBug/Debugger.Loop.Exception.cpp b/GleeBug/Debugger.Loop.Exception.cpp index 19ea516..767d2f3 100644 --- a/GleeBug/Debugger.Loop.Exception.cpp +++ b/GleeBug/Debugger.Loop.Exception.cpp @@ -44,9 +44,6 @@ namespace GleeBug return; const auto info = foundInfo->second; - if (!info.enabled) - return; //not a valid software breakpoint - //set continue status mContinueStatus = DBG_CONTINUE; @@ -142,7 +139,7 @@ namespace GleeBug if (foundInfo == mProcess->breakpoints.end()) return; //not a valid hardware breakpoint const auto info = foundInfo->second; - if (info.internal.hardware.slot != breakpointSlot || !info.enabled) + if (info.internal.hardware.slot != breakpointSlot) return; //not a valid hardware breakpoint //set continue status @@ -238,10 +235,6 @@ namespace GleeBug //TODO: think about what happens with multiple breakpoints in one page where only one is disabled //There is really no problem about this because enabled is a property of a range and ranges do not overlap. const auto info = foundInfo->second; - if (!info.enabled) - return; - - printf("memory breakpoint: 0x%p (size: %d)\n", info.address, info.internal.memory.size); //TODO: check if the right type is accessed (ExceptionInformation[0]) //FIXED: @@ -434,10 +427,6 @@ namespace GleeBug //TODO: think about what happens with multiple breakpoints in one page where only one is disabled //There is really no problem about this because enabled is a property of a range and ranges do not overlap. const auto info = foundInfo->second; - if (!info.enabled) - return; - - printf("memory breakpoint: 0x%p (size: %d)\n", info.address, info.internal.memory.size); //TODO: check if the right type is accessed (ExceptionInformation[0]) //FIXED: @@ -452,8 +441,6 @@ namespace GleeBug return; } - - /* Access = 1, Read = 2, diff --git a/GleeBug/Debugger.Process.Breakpoint.cpp b/GleeBug/Debugger.Process.Breakpoint.cpp index 7f10ec8..0bab2dc 100644 --- a/GleeBug/Debugger.Process.Breakpoint.cpp +++ b/GleeBug/Debugger.Process.Breakpoint.cpp @@ -12,7 +12,6 @@ namespace GleeBug //setup the breakpoint information struct BreakpointInfo info = {}; info.address = address; - info.enabled = true; info.singleshoot = singleshoot; info.type = BreakpointType::Software; @@ -64,13 +63,10 @@ namespace GleeBug return false; const auto & info = found->second; - //restore the breakpoint bytes if the breakpoint is enabled - if (info.enabled) - { - if (!MemWriteUnsafe(address, info.internal.software.oldbytes, info.internal.software.size)) - return false; - FlushInstructionCache(hProcess, nullptr, 0); - } + //restore the breakpoint bytes + if (!MemWriteUnsafe(address, info.internal.software.oldbytes, info.internal.software.size)) + return false; + FlushInstructionCache(hProcess, nullptr, 0); //remove the breakpoint from the maps softwareBreakpointReferences.erase(info.address); @@ -84,7 +80,7 @@ namespace GleeBug //find a free hardware breakpoint slot for (int i = 0; i < HWBP_COUNT; i++) { - if (!hardwareBreakpoints[i].enabled) + if (!hardwareBreakpoints[i].internal.hardware.enabled) { slot = HardwareSlot(i); return true; @@ -122,7 +118,6 @@ namespace GleeBug //setup the breakpoint information struct BreakpointInfo info = {}; info.address = address; - info.enabled = true; info.singleshoot = singleshoot; info.type = BreakpointType::Hardware; info.internal.hardware.slot = slot; @@ -160,7 +155,7 @@ namespace GleeBug const auto & info = found->second; //delete the hardware breakpoint from the internal buffer - hardwareBreakpoints[int(info.internal.hardware.slot)].enabled = false; + hardwareBreakpoints[int(info.internal.hardware.slot)].internal.hardware.enabled = false; //delete the hardware breakpoint from the registers bool success = true; @@ -333,7 +328,6 @@ namespace GleeBug //setup the breakpoint information struct BreakpointInfo info = {}; info.address = address; - info.enabled = true; info.singleshoot = singleshoot; info.type = BreakpointType::Memory; info.internal.memory.type = type; @@ -386,8 +380,8 @@ namespace GleeBug if (data.Refcount) { //TODO: properly determine the new protection flag - //Are there any other protections left? - //If so add the guard + //Are there any other protections left? + //If so add the guard if (data.Type & ~uint32(info.internal.memory.type)) data.NewProtect = data.OldProtect | PAGE_GUARD; Protect = data.NewProtect; diff --git a/GleeBug/Debugger.Process.Memory.cpp b/GleeBug/Debugger.Process.Memory.cpp index 823dc37..ebf43d2 100644 --- a/GleeBug/Debugger.Process.Memory.cpp +++ b/GleeBug/Debugger.Process.Memory.cpp @@ -78,7 +78,6 @@ namespace GleeBug { DWORD dwOldProtect; auto vps = VirtualProtectEx(hProcess, LPVOID(address), size, newProtect, &dwOldProtect); - printf("MemProtect(0x%p, 0x%X, %08X, %08X) = %d\n", address, size, newProtect, dwOldProtect, vps); if (!vps) return false; if (oldProtect) diff --git a/GleeBug/Debugger.Process.cpp b/GleeBug/Debugger.Process.cpp index 1b0ba6d..0899c22 100644 --- a/GleeBug/Debugger.Process.cpp +++ b/GleeBug/Debugger.Process.cpp @@ -12,7 +12,7 @@ namespace GleeBug permanentDep(false) { for (int i = 0; i < HWBP_COUNT; i++) - hardwareBreakpoints[i].enabled = false; + hardwareBreakpoints[i].internal.hardware.enabled = false; } void Process::StepOver(const StepCallback & cbStep)