[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
  ```
This commit is contained in:
Hermès Bélusca-Maïto
2025-08-29 18:23:55 +02:00
parent 8ce870d87b
commit b3a0b4124a
+19 -2
View File
@@ -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));