[WIN32K] Use KeStackAttachProcess

This commit is contained in:
Mark Jansen 2019-06-12 18:52:14 +02:00
parent 97d1590914
commit 04712d418c
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -1040,7 +1040,6 @@ IntRemoveHook(PVOID Object)
PTHREADINFO ptiHook, pti; PTHREADINFO ptiHook, pti;
PDESKTOP pdo; PDESKTOP pdo;
PHOOK Hook = Object; PHOOK Hook = Object;
BOOL bOtherProcess;
NT_ASSERT(UserIsEnteredExclusive()); NT_ASSERT(UserIsEnteredExclusive());
@ -1055,11 +1054,14 @@ IntRemoveHook(PVOID Object)
if (IsListEmpty(&ptiHook->aphkStart[HOOKID_TO_INDEX(HookId)])) if (IsListEmpty(&ptiHook->aphkStart[HOOKID_TO_INDEX(HookId)]))
{ {
BOOL bOtherProcess;
KAPC_STATE ApcState;
ptiHook->fsHooks &= ~HOOKID_TO_FLAG(HookId); ptiHook->fsHooks &= ~HOOKID_TO_FLAG(HookId);
bOtherProcess = (ptiHook->ppi != pti->ppi); bOtherProcess = (ptiHook->ppi != pti->ppi);
if (bOtherProcess) if (bOtherProcess)
KeAttachProcess(&ptiHook->ppi->peProcess->Pcb); KeStackAttachProcess(&ptiHook->ppi->peProcess->Pcb, &ApcState);
_SEH2_TRY _SEH2_TRY
{ {
@ -1073,7 +1075,7 @@ IntRemoveHook(PVOID Object)
_SEH2_END; _SEH2_END;
if (bOtherProcess) if (bOtherProcess)
KeDetachProcess(); KeUnstackDetachProcess(&ApcState);
} }
} }
else // Global else // Global
@ -1601,7 +1603,9 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
} }
else else
{ {
KeAttachProcess(&ptiHook->ppi->peProcess->Pcb); KAPC_STATE ApcState;
KeStackAttachProcess(&ptiHook->ppi->peProcess->Pcb, &ApcState);
_SEH2_TRY _SEH2_TRY
{ {
ptiHook->pClientInfo->fsHooks = ptiHook->fsHooks; ptiHook->pClientInfo->fsHooks = ptiHook->fsHooks;
@ -1612,7 +1616,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
ERR("Problem writing to Remote ClientInfo!\n"); ERR("Problem writing to Remote ClientInfo!\n");
} }
_SEH2_END; _SEH2_END;
KeDetachProcess(); KeUnstackDetachProcess(&ApcState);
} }
} }
} }