[NTOSKRNL] In addition to the hard-error port, reference also the process that handles the hard errors so that it doesn't disappear behind our back. On shutdown both the hard-error port and process are dereferenced.

This commit is contained in:
Hermès Bélusca-Maïto 2018-03-31 22:12:44 +02:00
parent 7ca90b50de
commit ed06b843fb
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 36 additions and 3 deletions

View file

@ -707,7 +707,7 @@ NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_UNSUCCESSFUL;
/* Check if we have the Privilege */
/* Check if we have the privileges */
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
{
DPRINT1("NtSetDefaultHardErrorPort: Caller requires "
@ -718,7 +718,7 @@ NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
/* Only called once during bootup, make sure we weren't called yet */
if (!ExReadyForErrors)
{
/* Reference the port */
/* Reference the hard-error port */
Status = ObReferenceObjectByHandle(PortHandle,
0,
LpcPortObjectType,
@ -727,9 +727,11 @@ NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
NULL);
if (NT_SUCCESS(Status))
{
/* Save the data */
/* Keep also a reference to the process handling the hard errors */
ExpDefaultErrorPortProcess = PsGetCurrentProcess();
ObReferenceObject(ExpDefaultErrorPortProcess);
ExReadyForErrors = TRUE;
Status = STATUS_SUCCESS;
}
}