From b3a0b4124a2aaf3e2ad948cd3f120c408f18912f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 29 Aug 2025 18:06:01 +0200 Subject: [PATCH] [MSGINA] Zero out and don't return old user login info on aborted logon attempts - WlxLogoff(): Zero out cached Winlogon buffer pointers and some more user login info. - WlxLoggedOutSAS(): Return the logged-in user token handle *ONLY* if the user is actually logging into the system. If (s)he doesn't log in, but instead cancels the Log-On dialog, or chooses to Shutdown/Reboot the computer from that dialog, do *NOT* return any previous logged-in user token handle. For example, in the case of a previously failed logon attempt due to a wrong or corrupted user profile, shutting down the computer from the Log-On dialog would show the following errors in the debugger: ``` err:(.../winlogon/sas.c:757) ImpersonateLoggedOnUser() failed with error 6 err:(.../winlogon/sas.c:859) Shutdown thread returned failure err:(.../winlogon/sas.c:1182) Failed to start the Shutdown thread, Status 0xc0000001 ``` --- dll/win32/msgina/msgina.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dll/win32/msgina/msgina.c b/dll/win32/msgina/msgina.c index 18760b33f8f..d8b23eeec87 100644 --- a/dll/win32/msgina/msgina.c +++ b/dll/win32/msgina/msgina.c @@ -1045,9 +1045,12 @@ WlxLoggedOutSAS( pgContext->pMprNotifyInfo = pMprNotifyInfo; pgContext->pProfile = pProfile; - res = pGinaUI->LoggedOutSAS(pgContext); - *phToken = pgContext->UserToken; + + /* Return the logon information only if necessary */ + if (res == WLX_SAS_ACTION_LOGON) + *phToken = pgContext->UserToken; + return res; } @@ -1114,6 +1117,20 @@ WlxLogoff( TRACE("WlxLogoff(%p)\n", pWlxContext); + /* Reset the captured Winlogon pointers */ + pgContext->pAuthenticationId = NULL; + pgContext->pdwOptions = NULL; + pgContext->pMprNotifyInfo = NULL; + pgContext->pProfile = NULL; + + /* + * Reset user login information. + * Keep pgContext->UserName and pgContext->DomainName around + * if we want to show them as default (last logged user) in + * the Log-On dialog. + */ + ZeroMemory(&pgContext->LogonTime, sizeof(pgContext->LogonTime)); + /* Delete the password */ SecureZeroMemory(pgContext->Password, sizeof(pgContext->Password));