[WINLOGON][MSGINA] Add emergency restart and log off features (#5629)

CORE-18958

Introduce an emergency log-off and restart feature, available when holding
down the control key and selecting "Log Off" or "Shut down" in the MSGINA
Ctrl-Alt-Del security dialog, similar to Windows Server 2003 and newer
Windows versions.
This commit is contained in:
Carl J. Bialorucki 2023-08-31 03:51:54 -06:00 committed by GitHub
parent 58770200e7
commit 2263547985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 141 additions and 3 deletions

View file

@ -1060,13 +1060,17 @@ DoGenericAction(
break;
case WLX_SAS_ACTION_LOGOFF: /* 0x04 */
case WLX_SAS_ACTION_SHUTDOWN: /* 0x05 */
case WLX_SAS_ACTION_FORCE_LOGOFF: /* 0x09 */
case WLX_SAS_ACTION_SHUTDOWN_POWER_OFF: /* 0x0a */
case WLX_SAS_ACTION_SHUTDOWN_REBOOT: /* 0x0b */
if (Session->LogonState != STATE_LOGGED_OFF)
{
UINT LogOffFlags = EWX_LOGOFF;
if (wlxAction == WLX_SAS_ACTION_FORCE_LOGOFF)
LogOffFlags |= EWX_FORCE;
if (!Session->Gina.Functions.WlxIsLogoffOk(Session->Gina.Context))
break;
if (!NT_SUCCESS(HandleLogoff(Session, EWX_LOGOFF)))
if (!NT_SUCCESS(HandleLogoff(Session, LogOffFlags)))
{
RemoveStatusMessage(Session);
break;

View file

@ -11,6 +11,8 @@
#include <wingdi.h>
#include <winnls.h>
#include <winreg.h>
#include <ndk/exfuncs.h>
#include <ndk/setypes.h>
typedef struct _DISPLAYSTATUSMSG
{
@ -31,6 +33,8 @@ typedef struct _LEGALNOTICEDATA
// Timer ID for the animated dialog bar.
#define IDT_BAR 1
#define ISKEYDOWN(x) (GetKeyState(x) & 0x8000)
typedef struct _DLG_DATA
{
PGINA_CONTEXT pgContext;
@ -985,12 +989,44 @@ SecurityDialogProc(
EndDialog(hwndDlg, WLX_SAS_ACTION_LOCK_WKSTA);
return TRUE;
case IDC_SECURITY_LOGOFF:
if (OnLogOff(hwndDlg, pgContext) == IDYES)
if (ISKEYDOWN(VK_CONTROL))
{
if (ResourceMessageBox(pgContext,
hwndDlg,
MB_OKCANCEL | MB_ICONSTOP,
IDS_EMERGENCYLOGOFFTITLE,
IDS_EMERGENCYLOGOFF) == IDOK)
{
EndDialog(hwndDlg, WLX_SAS_ACTION_FORCE_LOGOFF);
}
}
else if (OnLogOff(hwndDlg, pgContext) == IDYES)
{
EndDialog(hwndDlg, WLX_SAS_ACTION_LOGOFF);
}
return TRUE;
case IDC_SECURITY_SHUTDOWN:
if (OnShutDown(hwndDlg, pgContext) == IDOK)
/* Emergency restart feature */
if (ISKEYDOWN(VK_CONTROL))
{
if (ResourceMessageBox(pgContext,
hwndDlg,
MB_OKCANCEL | MB_ICONSTOP,
IDS_EMERGENCYRESTARTTITLE,
IDS_EMERGENCYRESTART) == IDOK)
{
BOOLEAN Old;
ERR("Emergency restarting NT...\n");
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &Old);
NtShutdownSystem(ShutdownReboot);
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, Old, FALSE, &Old);
}
}
else if (OnShutDown(hwndDlg, pgContext) == IDOK)
{
EndDialog(hwndDlg, pgContext->nShutdownAction);
}
return TRUE;
case IDC_SECURITY_CHANGEPWD:
if (OnChangePassword(hwndDlg, pgContext))

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Вашия акаунт е временно ограничен в момента. Моля опитайте по-късно."
IDS_INVALIDWORKSTATION "Акаунта ви е ограничен на този компютър. Моля използвайте друг компютър."
IDS_ACCOUNTRESTRICTION "Не можете да влезете поради ограничение на акаунта."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -239,6 +239,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Ihr Konto sieht es nicht vor, dass Sie sich zu dieser Zeit anmelden. Bitte versuchen Sie es später noch einmal."
IDS_INVALIDWORKSTATION "Ihr Konto sieht es nicht vor, dass Sie sich an diesem Computer anmelden. Bitte melden Sie sich an einem anderen Computer an."
IDS_ACCOUNTRESTRICTION "Wegen einer Kontenbeschränkung dürfen Sie sich nicht anmelden."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -235,6 +235,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -243,6 +243,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "En este momento, tu cuenta tiene restricciones horarias para acceder. Inténtelo de nuevo más tarde."
IDS_INVALIDWORKSTATION "Su cuenta está configurada para no permitirte usar este equipo. Inténtelo en otro equipo."
IDS_ACCOUNTRESTRICTION "Es imposible acceder porque tu cuenta tiene restricciones."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Votre compte a des restrictions temporelles qui vous empêchent de vous connecter à cette heure-ci. Veuillez réessayer ultérieurement."
IDS_INVALIDWORKSTATION "Votre compte a été configuré pour que vous n'utilisiez pas cet ordinateur. Veuillez réessayer depuis un autre ordinateur."
IDS_ACCOUNTRESTRICTION "Impossible de vous connecter en raison d'une restriction sur votre compte."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -235,6 +235,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "A fiókján olyan időkorlátozás van, amely miatt jelenleg nem tud belépni. Kérjük próbálja újra később."
IDS_INVALIDWORKSTATION "A fiókja úgy van beállítva hogy nem használhatja ezt a számítógépet. Kérjük próbálkozzon egy másik számítógéppel."
IDS_ACCOUNTRESTRICTION "Fiókkorlátozás miatt nem sikerült a bejelentkezés."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Akun anda memiliki pembatasan waktu sehingga mencegah untuk masuk saat ini. Mohon coba lagi nanti."
IDS_INVALIDWORKSTATION "Akun anda disetel untuk mencegah masuk di komputer ini. Mohon coba gunakan komputer lain."
IDS_ACCOUNTRESTRICTION "Tidak bisa masuk karena pembatasan akun."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -243,6 +243,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -239,6 +239,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "あなたのアカウントはこの時間のログオンを妨げる時間制限があります。あとでやり直して下さい。"
IDS_INVALIDWORKSTATION "あなたのアカウントはこのコンピュータで使えないように設定されています。他のコンピュータをお使い下さい。"
IDS_ACCOUNTRESTRICTION "アカウント制限のため、あなたはログオンできません。"
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -234,6 +234,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -245,6 +245,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Twoje konto ma ograniczenia czasowe, które uniemożliwiają zalogowanie się w tej chwili. Spróbuj ponownie później."
IDS_INVALIDWORKSTATION "Twoje konto zostało skonfigurowane w sposób nie zezwalający na używanie tego komputera. Spróbuj na innym komputerze."
IDS_ACCOUNTRESTRICTION "Nie możesz się zalogować z powodu ograniczeń konta."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -235,6 +235,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "A sua conta tem restrições de horário que impedem o início de sessão no momento. Por favor, tente novamente mais tarde."
IDS_INVALIDWORKSTATION "A sua conta está configurada para impedir que use este computador. Por favor, tente outro computador."
IDS_ACCOUNTRESTRICTION "Não é possível iniciar sessão devido a uma restrição de conta."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -243,6 +243,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Contul dumneavoastră are restricții de timp care vă împiedică să vă conectați în acest moment. Încercați mai târziu."
IDS_INVALIDWORKSTATION "Contul dumneavoastră este configurat pentru a vă preveni în a folosi acest calculator. Încercați la alt calculator."
IDS_ACCOUNTRESTRICTION "Eșec în conectarea dumneavoastră din cauza unei restricții a contului."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -236,6 +236,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -239,6 +239,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -238,6 +238,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you from logging on at this time. Please try again later."
IDS_INVALIDWORKSTATION "Your account is configured to prevent you from using this computer. Please try another computer."
IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account restriction."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -236,6 +236,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Hesabınızda şu anda oturum açmanızı engelleyen zaman kısıtlamaları var. Lütfen daha sonra tekrar deneyiniz."
IDS_INVALIDWORKSTATION "Hesabınız, bu bilgisayarı kullanmanızı engelleyecek şekilde yapılandırıldı. Lütfen başka bir bilgisayar deneyiniz."
IDS_ACCOUNTRESTRICTION "Hesap kısıtlaması nedeniyle oturum açılamıyor."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -242,6 +242,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "Ваш профіль має обмеження часу, через що ви не можете зайти зараз. Будь-ласка, спробуйте пізніше."
IDS_INVALIDWORKSTATION "Ваш профіль налаштовано так, що ви не можете користуватись цим комп'ютером. Спробуйте інший комп'ютер."
IDS_ACCOUNTRESTRICTION "Не вдалось ввійти через обмеження профілю."
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -243,6 +243,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "您的账户具有的时间限制阻止您现在登录。请稍后再试。"
IDS_INVALIDWORKSTATION "您的账户设置阻止了您在这台计算机登录。请在另一台计算机尝试登录。"
IDS_ACCOUNTRESTRICTION "您的账户由于账户限制而不能登录。"
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -242,6 +242,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "由於您的帳户有時間限制,因此目前無法讓您登入。請稍候再試一次。"
IDS_INVALIDWORKSTATION "您的帳户已設定為不能使用這個電腦登入。請使用其他電腦登入。"
IDS_ACCOUNTRESTRICTION "由於您的帳户的限制,因此無法讓您登入。"
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -242,6 +242,10 @@ BEGIN
IDS_INVALIDLOGONHOURS "由於您的帳戶有時間限制,因此目前無法讓您登入。請稍候再試一次。"
IDS_INVALIDWORKSTATION "您的帳戶已設定為不能使用這個電腦登入。請使用其他電腦登入。"
IDS_ACCOUNTRESTRICTION "由於您的帳戶的限制,因此無法讓您登入。"
IDS_EMERGENCYLOGOFFTITLE "Log Off ReactOS"
IDS_EMERGENCYLOGOFF "Click OK to immediately log off. Any unsaved data will be lost. Use this only as a last resort."
IDS_EMERGENCYRESTARTTITLE "Emergency restart"
IDS_EMERGENCYRESTART "Click OK to immediately restart. Any unsaved data will be lost. Use this only as a last resort."
END
/* Shutdown Dialog Strings */

View file

@ -122,3 +122,9 @@
#define IDS_SHUTDOWN_RESTART_DESC 50007
#define IDS_SHUTDOWN_SLEEP_DESC 50008
#define IDS_SHUTDOWN_HIBERNATE_DESC 50009
/* Emergency log off and restart */
#define IDS_EMERGENCYLOGOFFTITLE 50010
#define IDS_EMERGENCYLOGOFF 50011
#define IDS_EMERGENCYRESTARTTITLE 50012
#define IDS_EMERGENCYRESTART 50013