[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.
This commit is contained in:
Hermès Bélusca-Maïto 2025-06-07 22:51:26 +02:00
parent 545f9cebb2
commit 82a57e41e1
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -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;