mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:21:38 +00:00
[MSGINA] Do not try to impersonate the user on shutdown when we are already logged off
This commit is contained in:
parent
4c4c6e88b3
commit
47567abf27
3 changed files with 50 additions and 17 deletions
|
@ -624,31 +624,40 @@ OnShutDown(
|
|||
INT ret;
|
||||
DWORD ShutdownOptions;
|
||||
|
||||
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||
TRACE("OnShutDown(%p %p)\n", hwndDlg, pgContext);
|
||||
|
||||
pgContext->nShutdownAction = GetDefaultShutdownSelState();
|
||||
ShutdownOptions = GetDefaultShutdownOptions();
|
||||
|
||||
if (pgContext->UserToken != NULL)
|
||||
{
|
||||
pgContext->nShutdownAction = LoadShutdownSelState();
|
||||
ShutdownOptions = GetAllowedShutdownOptions();
|
||||
RevertToSelf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||
pgContext->nShutdownAction = 0;
|
||||
ShutdownOptions = 0;
|
||||
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||
{
|
||||
pgContext->nShutdownAction = LoadShutdownSelState();
|
||||
ShutdownOptions = GetAllowedShutdownOptions();
|
||||
RevertToSelf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
ret = ShutdownDialog(hwndDlg, ShutdownOptions, pgContext);
|
||||
|
||||
if (ret == IDOK)
|
||||
{
|
||||
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||
if (pgContext->UserToken != NULL)
|
||||
{
|
||||
SaveShutdownSelState(pgContext->nShutdownAction);
|
||||
RevertToSelf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||
{
|
||||
SaveShutdownSelState(pgContext->nShutdownAction);
|
||||
RevertToSelf();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,12 +132,18 @@ CreateProfile(
|
|||
|
||||
/* shutdown.c */
|
||||
|
||||
DWORD
|
||||
GetDefaultShutdownSelState(VOID);
|
||||
|
||||
DWORD
|
||||
LoadShutdownSelState(VOID);
|
||||
|
||||
VOID
|
||||
SaveShutdownSelState(DWORD ShutdownCode);
|
||||
|
||||
DWORD
|
||||
GetDefaultShutdownOptions(VOID);
|
||||
|
||||
DWORD
|
||||
GetAllowedShutdownOptions(VOID);
|
||||
|
||||
|
|
|
@ -90,6 +90,11 @@ GetShutdownReasonUI(VOID)
|
|||
// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
DWORD
|
||||
GetDefaultShutdownSelState(VOID)
|
||||
{
|
||||
return WLX_SAS_ACTION_SHUTDOWN_POWER_OFF;
|
||||
}
|
||||
|
||||
DWORD
|
||||
LoadShutdownSelState(VOID)
|
||||
|
@ -211,6 +216,12 @@ SaveShutdownSelState(
|
|||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
DWORD
|
||||
GetDefaultShutdownOptions(VOID)
|
||||
{
|
||||
return WLX_SHUTDOWN_STATE_POWER_OFF | WLX_SHUTDOWN_STATE_REBOOT;
|
||||
}
|
||||
|
||||
DWORD
|
||||
GetAllowedShutdownOptions(VOID)
|
||||
{
|
||||
|
@ -271,6 +282,13 @@ UpdateShutdownDesc(
|
|||
|
||||
LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
|
||||
SetDlgItemTextW(hDlg, IDC_SHUTDOWN_DESCRIPTION, szBuffer);
|
||||
|
||||
if (pContext->bReasonUI)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_REASON_PLANNED), (ShutdownCode != WLX_SAS_ACTION_LOGOFF));
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_REASON_LIST), (ShutdownCode != WLX_SAS_ACTION_LOGOFF));
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_REASON_COMMENT), (ShutdownCode != WLX_SAS_ACTION_LOGOFF));
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue