mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +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;
|
INT ret;
|
||||||
DWORD ShutdownOptions;
|
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();
|
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||||
ShutdownOptions = GetAllowedShutdownOptions();
|
{
|
||||||
RevertToSelf();
|
pgContext->nShutdownAction = LoadShutdownSelState();
|
||||||
}
|
ShutdownOptions = GetAllowedShutdownOptions();
|
||||||
else
|
RevertToSelf();
|
||||||
{
|
}
|
||||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
else
|
||||||
pgContext->nShutdownAction = 0;
|
{
|
||||||
ShutdownOptions = 0;
|
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ShutdownDialog(hwndDlg, ShutdownOptions, pgContext);
|
ret = ShutdownDialog(hwndDlg, ShutdownOptions, pgContext);
|
||||||
|
|
||||||
if (ret == IDOK)
|
if (ret == IDOK)
|
||||||
{
|
{
|
||||||
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
if (pgContext->UserToken != NULL)
|
||||||
{
|
{
|
||||||
SaveShutdownSelState(pgContext->nShutdownAction);
|
if (ImpersonateLoggedOnUser(pgContext->UserToken))
|
||||||
RevertToSelf();
|
{
|
||||||
}
|
SaveShutdownSelState(pgContext->nShutdownAction);
|
||||||
else
|
RevertToSelf();
|
||||||
{
|
}
|
||||||
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
else
|
||||||
|
{
|
||||||
|
ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,12 +132,18 @@ CreateProfile(
|
||||||
|
|
||||||
/* shutdown.c */
|
/* shutdown.c */
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
GetDefaultShutdownSelState(VOID);
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
LoadShutdownSelState(VOID);
|
LoadShutdownSelState(VOID);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
SaveShutdownSelState(DWORD ShutdownCode);
|
SaveShutdownSelState(DWORD ShutdownCode);
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
GetDefaultShutdownOptions(VOID);
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
GetAllowedShutdownOptions(VOID);
|
GetAllowedShutdownOptions(VOID);
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,11 @@ GetShutdownReasonUI(VOID)
|
||||||
// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
|
// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
GetDefaultShutdownSelState(VOID)
|
||||||
|
{
|
||||||
|
return WLX_SAS_ACTION_SHUTDOWN_POWER_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
LoadShutdownSelState(VOID)
|
LoadShutdownSelState(VOID)
|
||||||
|
@ -211,6 +216,12 @@ SaveShutdownSelState(
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
GetDefaultShutdownOptions(VOID)
|
||||||
|
{
|
||||||
|
return WLX_SHUTDOWN_STATE_POWER_OFF | WLX_SHUTDOWN_STATE_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
GetAllowedShutdownOptions(VOID)
|
GetAllowedShutdownOptions(VOID)
|
||||||
{
|
{
|
||||||
|
@ -271,6 +282,13 @@ UpdateShutdownDesc(
|
||||||
|
|
||||||
LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
|
LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
|
||||||
SetDlgItemTextW(hDlg, IDC_SHUTDOWN_DESCRIPTION, 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
|
static VOID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue