workaround for a bug in GetProcessDEPPolicy

This commit is contained in:
mrexodia 2017-02-26 22:41:15 +01:00
parent 98ff237193
commit 1274f2b481
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 5 additions and 2 deletions

View File

@ -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;