fixed DEP policy query (documentation of GetProcessDEPPolicy is total bullshit for x64)

This commit is contained in:
mrexodia 2016-08-19 16:02:06 +02:00
parent f422383d70
commit bff2775e7a
2 changed files with 20 additions and 20 deletions

View File

@ -10,6 +10,25 @@ namespace GleeBug
mProcess->systemBreakpoint = true;
mContinueStatus = DBG_CONTINUE;
//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)
{
DWORD lpFlags;
BOOL bPermanent;
if (GPDP(mProcess->hProcess, &lpFlags, &bPermanent))
mProcess->permanentDep = lpFlags && bPermanent;
}
#else
mProcess->permanentDep = true;
#endif //_WIN64
//call the callback
cbSystemBreakpoint();
}
@ -155,7 +174,7 @@ namespace GleeBug
//call the debug event callback
cbExceptionEvent(exceptionInfo);
//dispatch the exception
//dispatch the exception (https://msdn.microsoft.com/en-us/library/windows/desktop/aa363082(v=vs.85).aspx)
switch (exceptionInfo.ExceptionRecord.ExceptionCode)
{
case STATUS_BREAKPOINT:

View File

@ -13,25 +13,6 @@ namespace GleeBug
{
for (int i = 0; i < HWBP_COUNT; i++)
hardwareBreakpoints[i].enabled = false;
// DEP is disabled if lpFlagsDep == 0
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)
{
DWORD lpFlags;
BOOL bPermanent;
if (GPDP(hProcess, &lpFlags, &bPermanent))
permanentDep = lpFlags && bPermanent;
#ifdef _WIN64
else if (GetLastError() == ERROR_NOT_SUPPORTED)
permanentDep = true;
#endif
}
}
void Process::StepOver(const StepCallback & cbStep)