some small fixes + remove BreakpointInfo.enabled

This commit is contained in:
mrexodia 2017-02-24 18:25:47 +01:00
parent b76d500c42
commit 98ff237193
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
5 changed files with 11 additions and 31 deletions

View File

@ -69,6 +69,7 @@ namespace GleeBug
HardwareSlot slot; HardwareSlot slot;
HardwareType type; HardwareType type;
HardwareSize size; HardwareSize size;
bool enabled;
} hardware; } hardware;
struct struct
{ {
@ -84,7 +85,6 @@ namespace GleeBug
struct BreakpointInfo struct BreakpointInfo
{ {
ptr address; ptr address;
bool enabled;
bool singleshoot; bool singleshoot;
BreakpointType type; BreakpointType type;
BreakpointInternalInfo internal; BreakpointInternalInfo internal;

View File

@ -44,9 +44,6 @@ namespace GleeBug
return; return;
const auto info = foundInfo->second; const auto info = foundInfo->second;
if (!info.enabled)
return; //not a valid software breakpoint
//set continue status //set continue status
mContinueStatus = DBG_CONTINUE; mContinueStatus = DBG_CONTINUE;
@ -142,7 +139,7 @@ namespace GleeBug
if (foundInfo == mProcess->breakpoints.end()) if (foundInfo == mProcess->breakpoints.end())
return; //not a valid hardware breakpoint return; //not a valid hardware breakpoint
const auto info = foundInfo->second; 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 return; //not a valid hardware breakpoint
//set continue status //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 //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. //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; 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]) //TODO: check if the right type is accessed (ExceptionInformation[0])
//FIXED: //FIXED:
@ -434,10 +427,6 @@ namespace GleeBug
//TODO: think about what happens with multiple breakpoints in one page where only one is disabled //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. //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; 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]) //TODO: check if the right type is accessed (ExceptionInformation[0])
//FIXED: //FIXED:
@ -452,8 +441,6 @@ namespace GleeBug
return; return;
} }
/* /*
Access = 1, Access = 1,
Read = 2, Read = 2,

View File

@ -12,7 +12,6 @@ namespace GleeBug
//setup the breakpoint information struct //setup the breakpoint information struct
BreakpointInfo info = {}; BreakpointInfo info = {};
info.address = address; info.address = address;
info.enabled = true;
info.singleshoot = singleshoot; info.singleshoot = singleshoot;
info.type = BreakpointType::Software; info.type = BreakpointType::Software;
@ -64,13 +63,10 @@ namespace GleeBug
return false; return false;
const auto & info = found->second; const auto & info = found->second;
//restore the breakpoint bytes if the breakpoint is enabled //restore the breakpoint bytes
if (info.enabled)
{
if (!MemWriteUnsafe(address, info.internal.software.oldbytes, info.internal.software.size)) if (!MemWriteUnsafe(address, info.internal.software.oldbytes, info.internal.software.size))
return false; return false;
FlushInstructionCache(hProcess, nullptr, 0); FlushInstructionCache(hProcess, nullptr, 0);
}
//remove the breakpoint from the maps //remove the breakpoint from the maps
softwareBreakpointReferences.erase(info.address); softwareBreakpointReferences.erase(info.address);
@ -84,7 +80,7 @@ namespace GleeBug
//find a free hardware breakpoint slot //find a free hardware breakpoint slot
for (int i = 0; i < HWBP_COUNT; i++) for (int i = 0; i < HWBP_COUNT; i++)
{ {
if (!hardwareBreakpoints[i].enabled) if (!hardwareBreakpoints[i].internal.hardware.enabled)
{ {
slot = HardwareSlot(i); slot = HardwareSlot(i);
return true; return true;
@ -122,7 +118,6 @@ namespace GleeBug
//setup the breakpoint information struct //setup the breakpoint information struct
BreakpointInfo info = {}; BreakpointInfo info = {};
info.address = address; info.address = address;
info.enabled = true;
info.singleshoot = singleshoot; info.singleshoot = singleshoot;
info.type = BreakpointType::Hardware; info.type = BreakpointType::Hardware;
info.internal.hardware.slot = slot; info.internal.hardware.slot = slot;
@ -160,7 +155,7 @@ namespace GleeBug
const auto & info = found->second; const auto & info = found->second;
//delete the hardware breakpoint from the internal buffer //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 //delete the hardware breakpoint from the registers
bool success = true; bool success = true;
@ -333,7 +328,6 @@ namespace GleeBug
//setup the breakpoint information struct //setup the breakpoint information struct
BreakpointInfo info = {}; BreakpointInfo info = {};
info.address = address; info.address = address;
info.enabled = true;
info.singleshoot = singleshoot; info.singleshoot = singleshoot;
info.type = BreakpointType::Memory; info.type = BreakpointType::Memory;
info.internal.memory.type = type; info.internal.memory.type = type;

View File

@ -78,7 +78,6 @@ namespace GleeBug
{ {
DWORD dwOldProtect; DWORD dwOldProtect;
auto vps = VirtualProtectEx(hProcess, LPVOID(address), size, newProtect, &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) if (!vps)
return false; return false;
if (oldProtect) if (oldProtect)

View File

@ -12,7 +12,7 @@ namespace GleeBug
permanentDep(false) permanentDep(false)
{ {
for (int i = 0; i < HWBP_COUNT; i++) for (int i = 0; i < HWBP_COUNT; i++)
hardwareBreakpoints[i].enabled = false; hardwareBreakpoints[i].internal.hardware.enabled = false;
} }
void Process::StepOver(const StepCallback & cbStep) void Process::StepOver(const StepCallback & cbStep)