mirror of https://github.com/x64dbg/GleeBug
Solving "What happens if you hit a breakpoint before a system breakpoint"
This commit is contained in:
parent
69be313fac
commit
9bd5c380e5
|
|
@ -15,28 +15,6 @@ namespace GleeBug
|
||||||
mProcess->systemBreakpoint = true;
|
mProcess->systemBreakpoint = true;
|
||||||
mContinueStatus = DBG_CONTINUE;
|
mContinueStatus = DBG_CONTINUE;
|
||||||
|
|
||||||
//get process DEP policy (TODO: what happens if a breakpoint is hit before the system breakpoint?)
|
|
||||||
#ifndef _WIN64
|
|
||||||
typedef BOOL(WINAPI * GETPROCESSDEPPOLICY)(
|
|
||||||
_In_ HANDLE /*hProcess*/,
|
|
||||||
_Out_ LPDWORD /*lpFlags*/,
|
|
||||||
_Out_ PBOOL /*lpPermanent*/
|
|
||||||
);
|
|
||||||
static auto GPDP = GETPROCESSDEPPOLICY(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetProcessDEPPolicy"));
|
|
||||||
if(GPDP)
|
|
||||||
{
|
|
||||||
//If you use mProcess->hProcess GetProcessDEPPolicy will put garbage in bPermanent.
|
|
||||||
auto hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, mProcess->dwProcessId);
|
|
||||||
DWORD lpFlags;
|
|
||||||
BOOL bPermanent;
|
|
||||||
if(GPDP(hProcess, &lpFlags, &bPermanent))
|
|
||||||
mProcess->permanentDep = lpFlags != 0 && bPermanent;
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
mProcess->permanentDep = true;
|
|
||||||
#endif //_WIN64
|
|
||||||
|
|
||||||
//call the callback
|
//call the callback
|
||||||
cbSystemBreakpoint();
|
cbSystemBreakpoint();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,28 @@ namespace GleeBug
|
||||||
});
|
});
|
||||||
mThread = mProcess->thread = mProcess->threads.find(mDebugEvent.dwThreadId)->second.get();
|
mThread = mProcess->thread = mProcess->threads.find(mDebugEvent.dwThreadId)->second.get();
|
||||||
|
|
||||||
|
//get process DEP policy
|
||||||
|
#ifndef _WIN64
|
||||||
|
typedef BOOL(WINAPI * GETPROCESSDEPPOLICY)(
|
||||||
|
_In_ HANDLE /*hProcess*/,
|
||||||
|
_Out_ LPDWORD /*lpFlags*/,
|
||||||
|
_Out_ PBOOL /*lpPermanent*/
|
||||||
|
);
|
||||||
|
static auto GPDP = GETPROCESSDEPPOLICY(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetProcessDEPPolicy"));
|
||||||
|
if(GPDP)
|
||||||
|
{
|
||||||
|
//If you use mProcess->hProcess GetProcessDEPPolicy will put garbage in bPermanent.
|
||||||
|
auto hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, mProcess->dwProcessId);
|
||||||
|
DWORD lpFlags;
|
||||||
|
BOOL bPermanent;
|
||||||
|
if(GPDP(hProcess, &lpFlags, &bPermanent))
|
||||||
|
mProcess->permanentDep = lpFlags != 0 && bPermanent;
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
mProcess->permanentDep = true;
|
||||||
|
#endif //_WIN64
|
||||||
|
|
||||||
//call the debug event callback
|
//call the debug event callback
|
||||||
cbCreateProcessEvent(createProcess, *mProcess);
|
cbCreateProcessEvent(createProcess, *mProcess);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue