mirror of https://github.com/x64dbg/GleeBug
Merge pull request #69 from gmh5225/Branch_fix_dep
Solving DEP problem when attaching process
This commit is contained in:
commit
f6896bc22e
|
|
@ -15,28 +15,6 @@ namespace GleeBug
|
|||
mProcess->systemBreakpoint = true;
|
||||
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
|
||||
cbSystemBreakpoint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,28 @@ namespace GleeBug
|
|||
});
|
||||
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
|
||||
cbCreateProcessEvent(createProcess, *mProcess);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue