From 1274f2b481f5c2361d0b3d14d1d93a039a8d2698 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Sun, 26 Feb 2017 22:41:15 +0100 Subject: [PATCH] workaround for a bug in GetProcessDEPPolicy --- GleeBug/Debugger.Loop.Exception.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GleeBug/Debugger.Loop.Exception.cpp b/GleeBug/Debugger.Loop.Exception.cpp index 767d2f3..25423ea 100644 --- a/GleeBug/Debugger.Loop.Exception.cpp +++ b/GleeBug/Debugger.Loop.Exception.cpp @@ -20,10 +20,13 @@ namespace GleeBug 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(mProcess->hProcess, &lpFlags, &bPermanent)) - mProcess->permanentDep = lpFlags && bPermanent; + if (GPDP(hProcess, &lpFlags, &bPermanent)) + mProcess->permanentDep = lpFlags != 0 && bPermanent; + CloseHandle(hProcess); } #else mProcess->permanentDep = true;