mirror of https://github.com/x64dbg/GleeBug
Merge pull request #75 from 3rdit/fix/hwbp-thread-suspension
Fix hardware breakpoint register index mismatch
This commit is contained in:
commit
6e282f0091
|
|
@ -143,7 +143,10 @@ namespace GleeBug
|
||||||
|
|
||||||
//if the breakpoint was deleted during callback, clear internal stepping to prevent thread suspension
|
//if the breakpoint was deleted during callback, clear internal stepping to prevent thread suspension
|
||||||
if(mProcess->breakpoints.find({ BreakpointType::Hardware, info.address }) == mProcess->breakpoints.end())
|
if(mProcess->breakpoints.find({ BreakpointType::Hardware, info.address }) == mProcess->breakpoints.end())
|
||||||
|
{
|
||||||
mThread->isInternalStepping = false;
|
mThread->isInternalStepping = false;
|
||||||
|
Registers(mThread->hThread, CONTEXT_CONTROL).TrapFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
//delete the breakpoint if it is singleshoot
|
//delete the breakpoint if it is singleshoot
|
||||||
if(info.singleshoot)
|
if(info.singleshoot)
|
||||||
|
|
|
||||||
|
|
@ -821,6 +821,10 @@ public:
|
||||||
{
|
{
|
||||||
if(!mProcess)
|
if(!mProcess)
|
||||||
return false;
|
return false;
|
||||||
|
//convert from UE_DRx (11-14) to slot index (0-3)
|
||||||
|
auto slot = (HardwareSlot)(IndexOfRegister - UE_DR0);
|
||||||
|
if((DWORD)slot > 3)
|
||||||
|
return false;
|
||||||
auto running = mIsRunning;
|
auto running = mIsRunning;
|
||||||
if(running)
|
if(running)
|
||||||
{
|
{
|
||||||
|
|
@ -828,7 +832,7 @@ public:
|
||||||
thread.second->Suspend();
|
thread.second->Suspend();
|
||||||
}
|
}
|
||||||
if(!mProcess->SetHardwareBreakpoint(bpxAddress,
|
if(!mProcess->SetHardwareBreakpoint(bpxAddress,
|
||||||
(HardwareSlot)IndexOfRegister, [bpxCallBack](const BreakpointInfo & info)
|
slot, [bpxCallBack](const BreakpointInfo & info)
|
||||||
{
|
{
|
||||||
(HWBPCALLBACK(bpxCallBack))((const void*)info.address);
|
(HWBPCALLBACK(bpxCallBack))((const void*)info.address);
|
||||||
}, hwtypeFromTitan(bpxType), hwsizeFromTitan(bpxSize)))
|
}, hwtypeFromTitan(bpxType), hwsizeFromTitan(bpxSize)))
|
||||||
|
|
@ -843,9 +847,11 @@ public:
|
||||||
|
|
||||||
bool DeleteHardwareBreakPoint(DWORD IndexOfRegister)
|
bool DeleteHardwareBreakPoint(DWORD IndexOfRegister)
|
||||||
{
|
{
|
||||||
if(!mProcess || IndexOfRegister > 3)
|
//convert from UE_DRx (11-14) to slot index (0-3)
|
||||||
|
auto slot = IndexOfRegister - UE_DR0;
|
||||||
|
if(!mProcess || slot > 3)
|
||||||
return false;
|
return false;
|
||||||
auto address = mProcess->hardwareBreakpoints[IndexOfRegister].address;
|
auto address = mProcess->hardwareBreakpoints[slot].address;
|
||||||
return mProcess->DeleteHardwareBreakpoint(address);
|
return mProcess->DeleteHardwareBreakpoint(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -856,7 +862,7 @@ public:
|
||||||
HardwareSlot slot;
|
HardwareSlot slot;
|
||||||
bool result = mProcess->GetFreeHardwareBreakpointSlot(slot);
|
bool result = mProcess->GetFreeHardwareBreakpointSlot(slot);
|
||||||
if(result)
|
if(result)
|
||||||
*RegisterIndex = (DWORD)slot;
|
*RegisterIndex = UE_DR0 + (DWORD)slot; //UE_DR0-UE_DR3 (11-14), not 0-3
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue