From 82a57e41e18320d3b6579c07a87527262ee84eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 7 Jun 2025 22:51:26 +0200 Subject: [PATCH] [WINLOGON] Correctly reset LogonState in case logon or shutdown fails (#8133) CORE-18351 CORE-18237 CORE-17137 CORE-16567 CORE-15360 CORE-5071 CORE-3804 Reset `LogonState` back to `STATE_LOGGED_OFF` before invoking `WlxDisplaySASNotice()` when: - in `STATE_LOGGED_OFF_SAS` state, `HandleLogon()` failed; - or when an attempted shutdown operation failed. This fixes the resulting inconsistent `LogonState` that happened if any of these operations failed due to legitimate reasons. For example, a corrupted user profile that caused the login attempt to abort, or, an ongoing shutdown attempt being aborted as well. One of the user-visible effects of this inconsistency, was the inability to access the familiar Logged-Out SAS dialog by pressing Ctrl-Alt-Del at the invite (SAS notice) dialog, because the `LogonState` was incorrectly left into the `STATE_LOGGED_OFF_SAS` state, instead of being reset to `STATE_LOGGED_OFF`. ---- Typical scenario: The "Administrator" user, who is auto-logged-in by default after the installation, gets a corrupted ntuser.dat profile registry hive if the 2nd-stage installation is aborted at the end by force-restarting ReactOS. After reboot, ReactOS tries to log into the account, but fails, and goes back to the Ctrl-Alt-Del invite dialog. Before this fix, the user couldn't go into the Logged-Out SAS dialog to enter new login credentials and attempt login to another account. This is now fixed. --- base/system/winlogon/sas.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/system/winlogon/sas.c b/base/system/winlogon/sas.c index 1b30616b4cd..e1570d0b8ad 100644 --- a/base/system/winlogon/sas.c +++ b/base/system/winlogon/sas.c @@ -1071,6 +1071,7 @@ DoGenericAction( { if (!HandleLogon(Session)) { + Session->LogonState = STATE_LOGGED_OFF; Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); CallNotificationDlls(Session, LogonHandler); } @@ -1132,12 +1133,14 @@ DoGenericAction( if (!NT_SUCCESS(HandleShutdown(Session, wlxAction))) { RemoveStatusMessage(Session); + Session->LogonState = STATE_LOGGED_OFF; Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); } } else { RemoveStatusMessage(Session); + Session->LogonState = STATE_LOGGED_OFF; Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context); } break;