From 0a80b77e766964e84e38a4559956ffc30d32786b Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Fri, 4 Jan 2019 01:22:44 +0200 Subject: [PATCH] [WINSRV] usersrv: Simplify sanity checks in UserClientShutdown UserClientShutdown will never be called for csrss so we don't need to have a check for that. The existing check was broken and wasn't doing anything anyway. Handle processing winlogon by doing nothing so that consrv won't be bothered about it. --- win32ss/user/winsrv/usersrv/shutdown.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/win32ss/user/winsrv/usersrv/shutdown.c b/win32ss/user/winsrv/usersrv/shutdown.c index c73a535ffb6..539ef2a932d 100644 --- a/win32ss/user/winsrv/usersrv/shutdown.c +++ b/win32ss/user/winsrv/usersrv/shutdown.c @@ -770,15 +770,17 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess, return CsrShutdownNonCsrProcess; } - /* Do not kill Winlogon or CSRSS */ - if (CsrProcess->ClientId.UniqueProcess == NtCurrentProcess() || - CsrProcess->ClientId.UniqueProcess == UlongToHandle(LogonProcessId)) + /* Do not kill Winlogon */ + if (CsrProcess->ClientId.UniqueProcess == UlongToHandle(LogonProcessId)) { DPRINT("Not killing %s; CsrProcess->ShutdownFlags = %lu\n", CsrProcess->ClientId.UniqueProcess == NtCurrentProcess() ? "CSRSS" : "Winlogon", CsrProcess->ShutdownFlags); - return CsrShutdownNonCsrProcess; + /* Returning CsrShutdownCsrProcess means that we handled this process by doing nothing */ + /* This will mark winlogon as processed so consrv won't be notified again for it */ + CsrDereferenceProcess(CsrProcess); + return CsrShutdownCsrProcess; } /* Notify the process for shutdown if needed */