mirror of https://github.com/x64dbg/GleeBug
memory breakpoints now throw the desired exceptions
This commit is contained in:
parent
bff2775e7a
commit
aecc172ecb
|
|
@ -259,7 +259,11 @@ namespace GleeBug
|
||||||
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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
DWORD oldProtect;
|
||||||
|
auto vps = !!VirtualProtectEx(hProcess, LPVOID(page), PAGE_SIZE, data.NewProtect, &oldProtect);
|
||||||
|
printf("VirtualProtect(0x%p, 0x%X, %08X, %08X) = %d\n", page, PAGE_SIZE, data.NewProtect, oldProtect, vps);
|
||||||
|
return vps;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process::SetMemoryBreakpoint(ptr address, ptr size, MemoryType type, bool singleshoot)
|
bool Process::SetMemoryBreakpoint(ptr address, ptr size, MemoryType type, bool singleshoot)
|
||||||
|
|
@ -317,7 +321,8 @@ namespace GleeBug
|
||||||
for (const auto & page : breakpointData)
|
for (const auto & page : breakpointData)
|
||||||
{
|
{
|
||||||
DWORD oldProtect;
|
DWORD oldProtect;
|
||||||
VirtualProtectEx(hProcess, LPVOID(page.addr), PAGE_SIZE, page.OldProtect, &oldProtect);
|
auto vps = !!VirtualProtectEx(hProcess, LPVOID(page.addr), PAGE_SIZE, page.OldProtect, &oldProtect);
|
||||||
|
printf("VirtualProtect(0x%p, 0x%X, %08X, %08X) = %d\n", page, PAGE_SIZE, page.OldProtect, oldProtect, vps);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -384,7 +389,9 @@ namespace GleeBug
|
||||||
else
|
else
|
||||||
Protect = data.OldProtect;
|
Protect = data.OldProtect;
|
||||||
DWORD oldProtect;
|
DWORD oldProtect;
|
||||||
if (!VirtualProtectEx(hProcess, LPVOID(page), PAGE_SIZE, Protect, &oldProtect))
|
auto vps = !!VirtualProtectEx(hProcess, LPVOID(page), PAGE_SIZE, Protect, &oldProtect);
|
||||||
|
printf("VirtualProtect(0x%p, 0x%X, %08X, %08X) = %d\n", page, PAGE_SIZE, Protect, oldProtect, vps);
|
||||||
|
if (!vps)
|
||||||
success = false;
|
success = false;
|
||||||
if (!data.Refcount)
|
if (!data.Refcount)
|
||||||
memoryBreakpointPages.erase(foundData);
|
memoryBreakpointPages.erase(foundData);
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,25 @@ using namespace GleeBug;
|
||||||
class MyDebugger : public Debugger
|
class MyDebugger : public Debugger
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
void cbMemoryBreakpoint(const BreakpointInfo & info)
|
||||||
|
{
|
||||||
|
printf("Reached memory breakpoint! GIP: 0x%p\n",
|
||||||
|
mRegisters->Gip());
|
||||||
|
}
|
||||||
|
|
||||||
void cbEntryBreakpoint(const BreakpointInfo & info)
|
void cbEntryBreakpoint(const BreakpointInfo & info)
|
||||||
{
|
{
|
||||||
printf("Reached entry breakpoint! GIP: 0x%p\n",
|
printf("Reached entry breakpoint! GIP: 0x%p\n",
|
||||||
mRegisters->Gip());
|
mRegisters->Gip());
|
||||||
|
#ifdef _WIN64
|
||||||
|
printf("RBX: 0x%p\n", mRegisters->Rbx());
|
||||||
|
if (mProcess->SetMemoryBreakpoint(mRegisters->Rbx(), 0x1000, this, &MyDebugger::cbMemoryBreakpoint, MemoryType::Execute))
|
||||||
|
puts("Memory breakpoint set!");
|
||||||
|
else
|
||||||
|
puts("Failed to set memory breakpoint...");
|
||||||
|
#endif
|
||||||
|
//system("pause");
|
||||||
|
|
||||||
/*if (mProcess->DeleteBreakpoint(info.address))
|
/*if (mProcess->DeleteBreakpoint(info.address))
|
||||||
printf("Entry breakpoint deleted!\n");
|
printf("Entry breakpoint deleted!\n");
|
||||||
else
|
else
|
||||||
|
|
@ -61,6 +76,7 @@ protected:
|
||||||
else
|
else
|
||||||
printf("No free hardware breakpoint slot...\n");*/
|
printf("No free hardware breakpoint slot...\n");*/
|
||||||
|
|
||||||
|
entry = ptr(createProcess.lpBaseOfImage) + 0x1060;
|
||||||
if(mProcess->SetBreakpoint(entry, this, &MyDebugger::cbEntryBreakpoint, true))
|
if(mProcess->SetBreakpoint(entry, this, &MyDebugger::cbEntryBreakpoint, true))
|
||||||
printf("Breakpoint set at 0x%p!\n", entry);
|
printf("Breakpoint set at 0x%p!\n", entry);
|
||||||
else
|
else
|
||||||
|
|
@ -119,6 +135,8 @@ protected:
|
||||||
exceptionType,
|
exceptionType,
|
||||||
exceptionInfo.ExceptionRecord.ExceptionCode,
|
exceptionInfo.ExceptionRecord.ExceptionCode,
|
||||||
exceptionInfo.ExceptionRecord.ExceptionAddress);
|
exceptionInfo.ExceptionRecord.ExceptionAddress);
|
||||||
|
for (DWORD i = 0; i < exceptionInfo.ExceptionRecord.NumberParameters; i++)
|
||||||
|
printf(" ExceptionInformation[%d] = 0x%p\n", i, exceptionInfo.ExceptionRecord.ExceptionInformation[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbDebugStringEvent(const OUTPUT_DEBUG_STRING_INFO & debugString) override
|
void cbDebugStringEvent(const OUTPUT_DEBUG_STRING_INFO & debugString) override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue