18#define FONT_POINT_SIZE 13
20#define DARK_GREY_COLOR RGB(244, 244, 244)
21#define LIGHT_GREY_COLOR RGB(38, 38, 38)
27#define NUMBER_OF_BUTTONS 4
30#define BUTTON_SHUTDOWN 0
31#define BUTTON_SHUTDOWN_PRESSED (CY_BITMAP + BUTTON_SHUTDOWN)
32#define BUTTON_SHUTDOWN_FOCUSED (CY_BITMAP + BUTTON_SHUTDOWN_PRESSED)
33#define BUTTON_REBOOT (CY_BITMAP + BUTTON_SHUTDOWN_FOCUSED)
34#define BUTTON_REBOOT_PRESSED (CY_BITMAP + BUTTON_REBOOT)
35#define BUTTON_REBOOT_FOCUSED (CY_BITMAP + BUTTON_REBOOT_PRESSED)
36#define BUTTON_SLEEP (CY_BITMAP + BUTTON_REBOOT_FOCUSED)
37#define BUTTON_SLEEP_PRESSED (CY_BITMAP + BUTTON_SLEEP)
38#define BUTTON_SLEEP_FOCUSED (CY_BITMAP + BUTTON_SLEEP_PRESSED)
39#define BUTTON_SLEEP_DISABLED (CY_BITMAP + BUTTON_SLEEP_FOCUSED)
42#define SHUTDOWN_BUTTON_HOT 0
43#define REBOOT_BUTTON_HOT 1
44#define SLEEP_BUTTON_HOT 2
45#define HIBERNATE_BUTTON_HOT 3
132 L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
153 L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
190 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
203 L"EnforceFriendlyShutdown",
234 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
254 return (dwValue != 0);
282 L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
290 L"ShowHibernateButton",
298 return (dwValue != 0);
312 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
329 return (dwValue != 0);
333 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
351 return (dwValue != 0);
523 if (hwndTarget != hButton)
572 HWND hwndTool, hwndTip;
578 tool.
cbSize =
sizeof(tool);
630 HWND hwndDest, hwndTarget;
708 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
769 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
777 switch (ShutdownCode)
803 (
LPBYTE)&dwValue,
sizeof(dwValue));
819 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
820 L"NoLogoff", &dwPolicyValue);
821 if (dwPolicyValue == 0)
827 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
828 L"NoDisconnect", &dwPolicyValue);
829 if (dwPolicyValue == 0)
844 ERR(
"NtPowerInformation(SystemPowerCapabilities) failed (Status 0x%08lx)\n",
Status);
882 if (ShutdownCode !=
CB_ERR)
884 if (ShutdownCode ==
CB_ERR)
887 switch (ShutdownCode)
916 if (pContext->bReasonUI)
940 pContext->hfFont =
CreateFontW(lfHeight, 0, 0, 0,
FW_MEDIUM,
FALSE, 0, 0, 0, 0, 0, 0, 0,
L"MS Shell Dlg");
950 pContext->bIsSleepButtonReplaced =
FALSE;
951 pContext->bTimer =
FALSE;
962 pContext->bIsButtonHot[
i] =
FALSE;
975 pContext->bTimer =
TRUE;
988 WCHAR szBuffer2[256];
990 if (pContext->bFriendlyUI)
1082 if (ShutdownCode !=
CB_ERR)
1085 if (ShutdownCode !=
CB_ERR)
1086 pgContext->nShutdownAction = ShutdownCode;
1230 switch (pdis->
CtlID)
1263 ShutdownOptions &= ~dwExcludeOptions;
1267 if (ShutdownOptions == 0)
1270 Context.pgContext = pgContext;
1271 Context.ShutdownOptions = ShutdownOptions;
1277 if (pgContext->hWlx && pgContext->pWlxFuncs && !
Context.bFriendlyUI)
1279 ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1280 pgContext->hDllInstance,
1338 DWORD ShutdownOptions;
1347 ShutdownOptions &= ~dwExcludeOptions;
1368 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1398 if (dlgValue ==
IDOK)
1428 else if (dlgValue ==
IDHELP)
1430 FIXME(
"Help is not implemented yet.\n");
1433 else if (dlgValue == -1)
1435 ERR(
"Failed to create dialog\n");
OSVERSIONINFOW VersionInfo
static VOID OnTimer(IN HWND hwndDlg, IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
static INT_PTR CALLBACK ShutdownDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
#define RegCloseKey(hKey)
static HINSTANCE hDllInstance
#define NT_SUCCESS(StatCode)
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
#define IDC_BUTTON_HIBERNATE
#define IDS_SHUTDOWN_LOGOFF_DESC
#define IDC_TURN_OFF_STATIC
#define IDS_SHUTDOWN_RESTART_DESC
#define IDD_SHUTDOWN_FANCY
#define IDS_SHUTDOWN_LOGOFF
#define IDS_SHUTDOWN_SHUTDOWN_DESC
#define IDC_SHUTDOWN_STATIC
#define IDS_SHUTDOWN_SLEEP_DESC
#define IDS_SHUTDOWN_SHUTDOWN
#define IDS_SHUTDOWN_HIBERNATE_DESC
#define IDC_REASON_COMMENT
#define IDS_SHUTDOWN_SLEEP
#define IDS_SHUTDOWN_RESTART
#define IDC_BUTTON_REBOOT
#define IDC_REASON_PLANNED
#define IDC_HIBERNATE_STATIC
#define IDC_SHUTDOWN_ACTION
#define IDD_SHUTDOWN_REASON
#define IDC_BUTTON_SHUTDOWN
#define IDC_RESTART_STATIC
#define IDS_SHUTDOWN_HIBERNATE
#define IDC_SHUTDOWN_DESCRIPTION
#define IDD_SHUTDOWN_FANCY_LONG
#define BUTTON_SLEEP_DISABLED
DWORD WINAPI ShellTurnOffDialog(HWND hWnd)
DWORD GetAllowedShutdownOptions(_In_opt_ HKEY hKeyCurrentUser, _In_opt_ HANDLE hUserToken)
static BOOL GetShutdownReasonUI(VOID)
#define BUTTON_REBOOT_PRESSED
#define REBOOT_BUTTON_HOT
static BOOL ForceFriendlyUI(VOID)
#define BUTTON_SLEEP_FOCUSED
static BOOL IsFriendlyUIActive(VOID)
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
DWORD WINAPI ShellShutdownDialog(_In_ HWND hWndParent, _In_opt_ LPCWSTR pUserName, _In_ DWORD dwExcludeOptions)
static BOOL IsShowHibernateButtonActive(VOID)
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
DWORD LoadShutdownSelState(_In_ HKEY hKeyCurrentUser)
static INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
static BOOL IsDomainMember(VOID)
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
#define BUTTON_SHUTDOWN_PRESSED
VOID ChangeRequiredButton(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
#define SHUTDOWN_BUTTON_HOT
VOID SaveShutdownSelState(_In_ HKEY hKeyCurrentUser, _In_ DWORD ShutdownCode)
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
static VOID ShutdownOnOk(_In_ HWND hDlg, _In_ PGINA_CONTEXT pgContext)
LONG GetPolicyDWORDValue(_In_opt_ HKEY hKeyCurrentUser, _In_ PCWSTR pPolicyKey, _In_ PCWSTR ValueName, _Out_ PDWORD pValue)
Looks up a policy value on both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER, under the same policy sub-k...
#define NUMBER_OF_BUTTONS
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
static VOID ShutdownOnFriendlyInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
#define BUTTON_SLEEP_PRESSED
#define BUTTON_REBOOT_FOCUSED
VOID EndFriendlyDialog(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
#define HIBERNATE_BUTTON_HOT
#define BUTTON_SHUTDOWN_FOCUSED
static VOID UpdateShutdownDesc(_In_ HWND hDlg, _In_ PSHUTDOWN_DLG_CONTEXT pContext)
static BOOL IsNetwareActive(VOID)
struct _SHUTDOWN_DLG_CONTEXT SHUTDOWN_DLG_CONTEXT
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
GLuint GLuint GLsizei count
GLint GLint GLint GLint GLint GLint y
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define SE_SHUTDOWN_PRIVILEGE
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define WLX_SHUTDOWN_STATE_REBOOT
"Restart"
BOOL TestTokenPrivilege(_In_opt_ HANDLE hToken, _In_ ULONG Privilege)
Verifies whether the specified token has the given privilege.
#define WLX_SHUTDOWN_STATE_LOGOFF
Shutdown state flags.
#define WLX_SHUTDOWN_STATE_SLEEP
"Stand by"
#define WLX_SHUTDOWN_STATE_POWER_OFF
"Shut down"
#define WLX_SHUTDOWN_STATE_SLEEP2
"Stand by (with wakeup events disabled)"
#define WLX_SHUTDOWN_STATE_HIBERNATE
"Hibernate"
LONG ReadRegDwordValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PDWORD pValue)
#define WLX_SHUTDOWN_STATE_DISCONNECT
"Disconnect" (only available in Terminal Services sessions)
unsigned __int3264 UINT_PTR
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
#define IS_PWR_SUSPEND_ALLOWED(PowerCaps)
#define IS_PWR_HIBERNATE_ALLOWED(PowerCaps)
#define REG_OPTION_NON_VOLATILE
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
@ SystemPowerCapabilities
#define TTM_SETMAXTIPWIDTH
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
ULONG dwOSVersionInfoSize
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
BOOL bIsSleepButtonReplaced
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_USER
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_CTLCOLORSTATIC
#define GetWindowLongPtrW
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HWND WINAPI GetCapture(void)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI SetFocus(_In_opt_ HWND)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
#define MB_ICONEXCLAMATION
HWND WINAPI GetParent(_In_ HWND)
HWND WINAPI WindowFromPoint(_In_ POINT)
int WINAPI GetDlgCtrlID(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP2
#define WLX_SAS_ACTION_LOGOFF