ReactOS  0.4.15-dev-2153-g62b4c61
shutdown.c File Reference
#include "msgina.h"
#include <powrprof.h>
#include <wingdi.h>
#include <windowsx.h>
#include <commctrl.h>
Include dependency graph for shutdown.c:

Go to the source code of this file.

Classes

struct  _SHUTDOWN_DLG_CONTEXT
 

Macros

#define WLX_SHUTDOWN_STATE_LOGOFF   0x01
 
#define WLX_SHUTDOWN_STATE_POWER_OFF   0x02
 
#define WLX_SHUTDOWN_STATE_REBOOT   0x04
 
#define WLX_SHUTDOWN_STATE_SLEEP   0x10
 
#define WLX_SHUTDOWN_STATE_HIBERNATE   0x40
 
#define FONT_POINT_SIZE   13
 
#define DARK_GREY_COLOR   RGB(244, 244, 244)
 
#define LIGHT_GREY_COLOR   RGB(38, 38, 38)
 
#define CX_BITMAP   33
 
#define CY_BITMAP   33
 
#define NUMBER_OF_BUTTONS   4
 
#define BUTTON_SHUTDOWN   0
 
#define BUTTON_SHUTDOWN_PRESSED   (CY_BITMAP + BUTTON_SHUTDOWN)
 
#define BUTTON_SHUTDOWN_FOCUSED   (CY_BITMAP + BUTTON_SHUTDOWN_PRESSED)
 
#define BUTTON_REBOOT   (CY_BITMAP + BUTTON_SHUTDOWN_FOCUSED)
 
#define BUTTON_REBOOT_PRESSED   (CY_BITMAP + BUTTON_REBOOT)
 
#define BUTTON_REBOOT_FOCUSED   (CY_BITMAP + BUTTON_REBOOT_PRESSED)
 
#define BUTTON_SLEEP   (CY_BITMAP + BUTTON_REBOOT_FOCUSED)
 
#define BUTTON_SLEEP_PRESSED   (CY_BITMAP + BUTTON_SLEEP)
 
#define BUTTON_SLEEP_FOCUSED   (CY_BITMAP + BUTTON_SLEEP_PRESSED)
 
#define BUTTON_SLEEP_DISABLED   (CY_BITMAP + BUTTON_SLEEP_FOCUSED)
 

Typedefs

typedef struct _SHUTDOWN_DLG_CONTEXT SHUTDOWN_DLG_CONTEXT
 
typedef struct _SHUTDOWN_DLG_CONTEXTPSHUTDOWN_DLG_CONTEXT
 

Functions

static BOOL GetShutdownReasonUI (VOID)
 
static BOOL IsFriendlyUIActive (VOID)
 
static BOOL IsDomainMember (VOID)
 
static BOOL IsNetwareActive (VOID)
 
static BOOL IsShowHibernateButtonActive (VOID)
 
static BOOL ForceFriendlyUI (VOID)
 
static BOOL DrawIconOnOwnerDrawnButtons (DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
 
BOOL WINAPI ShellIsFriendlyUIActive (VOID)
 
DWORD GetDefaultShutdownSelState (VOID)
 
DWORD LoadShutdownSelState (VOID)
 
static INT_PTR CALLBACK HotButtonSubclass (HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID AddPrefixToStaticTexts (HWND hDlg, BOOL bIsSleepButtonReplaced)
 
VOID CreateToolTipForButtons (int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
 
VOID ReplaceRequiredButton (HWND hDlg, HINSTANCE hInstance, BOOL bIsAltKeyPressed, BOOL bIsSleepButtonReplaced)
 
VOID SaveShutdownSelState (IN DWORD ShutdownCode)
 
DWORD GetDefaultShutdownOptions (VOID)
 
DWORD GetAllowedShutdownOptions (VOID)
 
static VOID UpdateShutdownDesc (IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
 
static VOID ShutdownOnInit (IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
 
static VOID ShutdownOnOk (IN HWND hDlg, IN PGINA_CONTEXT pgContext)
 
static INT_PTR CALLBACK ShutdownDialogProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR ShutdownDialog (IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
 
DWORD WINAPI ShellShutdownDialog (HWND hParent, LPWSTR lpUsername, BOOL bHideLogoff)
 
DWORD WINAPI ShellTurnOffDialog (HWND hWnd)
 

Macro Definition Documentation

◆ BUTTON_REBOOT

#define BUTTON_REBOOT   (CY_BITMAP + BUTTON_SHUTDOWN_FOCUSED)

Definition at line 43 of file shutdown.c.

◆ BUTTON_REBOOT_FOCUSED

#define BUTTON_REBOOT_FOCUSED   (CY_BITMAP + BUTTON_REBOOT_PRESSED)

Definition at line 45 of file shutdown.c.

◆ BUTTON_REBOOT_PRESSED

#define BUTTON_REBOOT_PRESSED   (CY_BITMAP + BUTTON_REBOOT)

Definition at line 44 of file shutdown.c.

◆ BUTTON_SHUTDOWN

#define BUTTON_SHUTDOWN   0

Definition at line 40 of file shutdown.c.

◆ BUTTON_SHUTDOWN_FOCUSED

#define BUTTON_SHUTDOWN_FOCUSED   (CY_BITMAP + BUTTON_SHUTDOWN_PRESSED)

Definition at line 42 of file shutdown.c.

◆ BUTTON_SHUTDOWN_PRESSED

#define BUTTON_SHUTDOWN_PRESSED   (CY_BITMAP + BUTTON_SHUTDOWN)

Definition at line 41 of file shutdown.c.

◆ BUTTON_SLEEP

#define BUTTON_SLEEP   (CY_BITMAP + BUTTON_REBOOT_FOCUSED)

Definition at line 46 of file shutdown.c.

◆ BUTTON_SLEEP_DISABLED

#define BUTTON_SLEEP_DISABLED   (CY_BITMAP + BUTTON_SLEEP_FOCUSED)

Definition at line 49 of file shutdown.c.

◆ BUTTON_SLEEP_FOCUSED

#define BUTTON_SLEEP_FOCUSED   (CY_BITMAP + BUTTON_SLEEP_PRESSED)

Definition at line 48 of file shutdown.c.

◆ BUTTON_SLEEP_PRESSED

#define BUTTON_SLEEP_PRESSED   (CY_BITMAP + BUTTON_SLEEP)

Definition at line 47 of file shutdown.c.

◆ CX_BITMAP

#define CX_BITMAP   33

Definition at line 34 of file shutdown.c.

◆ CY_BITMAP

#define CY_BITMAP   33

Definition at line 35 of file shutdown.c.

◆ DARK_GREY_COLOR

#define DARK_GREY_COLOR   RGB(244, 244, 244)

Definition at line 30 of file shutdown.c.

◆ FONT_POINT_SIZE

#define FONT_POINT_SIZE   13

Definition at line 28 of file shutdown.c.

◆ LIGHT_GREY_COLOR

#define LIGHT_GREY_COLOR   RGB(38, 38, 38)

Definition at line 31 of file shutdown.c.

◆ NUMBER_OF_BUTTONS

#define NUMBER_OF_BUTTONS   4

Definition at line 37 of file shutdown.c.

◆ WLX_SHUTDOWN_STATE_HIBERNATE

#define WLX_SHUTDOWN_STATE_HIBERNATE   0x40

Definition at line 24 of file shutdown.c.

◆ WLX_SHUTDOWN_STATE_LOGOFF

#define WLX_SHUTDOWN_STATE_LOGOFF   0x01

Definition at line 18 of file shutdown.c.

◆ WLX_SHUTDOWN_STATE_POWER_OFF

#define WLX_SHUTDOWN_STATE_POWER_OFF   0x02

Definition at line 19 of file shutdown.c.

◆ WLX_SHUTDOWN_STATE_REBOOT

#define WLX_SHUTDOWN_STATE_REBOOT   0x04

Definition at line 20 of file shutdown.c.

◆ WLX_SHUTDOWN_STATE_SLEEP

#define WLX_SHUTDOWN_STATE_SLEEP   0x10

Definition at line 22 of file shutdown.c.

Typedef Documentation

◆ PSHUTDOWN_DLG_CONTEXT

◆ SHUTDOWN_DLG_CONTEXT

Function Documentation

◆ AddPrefixToStaticTexts()

VOID AddPrefixToStaticTexts ( HWND  hDlg,
BOOL  bIsSleepButtonReplaced 
)

Definition at line 576 of file shutdown.c.

579 {
580  WCHAR szBuffer[30];
581 
582  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
583  {
584  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE + i, szBuffer, _countof(szBuffer));
585  SetDlgItemTextW(hDlg, IDC_HIBERNATE_STATIC + i, szBuffer);
586  }
587 
588  if (bIsSleepButtonReplaced)
589  {
590  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
591  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
592  }
593 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define IDC_HIBERNATE_STATIC
Definition: resource.h:56
#define IDC_SLEEP_STATIC
Definition: resource.h:57
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:37
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
Definition: glfuncs.h:248
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61

Referenced by ShutdownDialog().

◆ CreateToolTipForButtons()

VOID CreateToolTipForButtons ( int  controlID,
int  detailID,
HWND  hDlg,
int  titleID,
HINSTANCE  hInst 
)

Definition at line 596 of file shutdown.c.

602 {
603  HWND hwndTool, hwndTip;
604  WCHAR szBuffer[256];
605  TTTOOLINFOW tool;
606 
607  hwndTool = GetDlgItem(hDlg, controlID);
608 
609  tool.cbSize = sizeof(tool);
610  tool.hwnd = hDlg;
612  tool.uId = (UINT_PTR)hwndTool;
613 
614  /* Create the tooltip */
615  hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
619  hDlg, NULL, hInst, NULL);
620 
621  /* Associate the tooltip with the tool. */
622  LoadStringW(hInst, detailID, szBuffer, _countof(szBuffer));
623  tool.lpszText = szBuffer;
624  SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
625  LoadStringW(hInst, titleID, szBuffer, _countof(szBuffer));
626  SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
627  SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
628 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define TTS_BALLOON
Definition: commctrl.h:1757
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LPWSTR lpszText
Definition: commctrl.h:1742
#define TTS_ALWAYSTIP
Definition: commctrl.h:1753
#define TTF_IDISHWND
Definition: commctrl.h:1760
#define CW_USEDEFAULT
Definition: winuser.h:225
LONG_PTR LPARAM
Definition: windef.h:208
#define TTM_SETTITLEW
Definition: commctrl.h:1824
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define TTI_NONE
Definition: commctrl.h:1775
UINT_PTR uId
Definition: commctrl.h:1739
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1815
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1703
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)
HINSTANCE hInst
Definition: dxdiag.c:13
#define TTM_ADDTOOLW
Definition: commctrl.h:1783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define TTF_SUBCLASS
Definition: commctrl.h:1763

Referenced by ShutdownOnInit().

◆ DrawIconOnOwnerDrawnButtons()

static BOOL DrawIconOnOwnerDrawnButtons ( DRAWITEMSTRUCT pdis,
PSHUTDOWN_DLG_CONTEXT  pContext 
)
static

Definition at line 305 of file shutdown.c.

308 {
309  BOOL bRet;
310  HDC hdcMem;
311  HBITMAP hbmOld;
312  int y;
313  RECT rect;
314 
315  hdcMem = CreateCompatibleDC(pdis->hDC);
316  hbmOld = SelectObject(hdcMem, pContext->hImageStrip);
317  rect = pdis->rcItem;
318 
319  /* Check the button ID for revelant bitmap to be used */
320  switch (pdis->CtlID)
321  {
322  case IDC_BUTTON_SHUTDOWN:
323  {
324  switch (pdis->itemAction)
325  {
326  case ODA_DRAWENTIRE:
327  case ODA_FOCUS:
328  case ODA_SELECT:
329  {
330  y = BUTTON_SHUTDOWN;
331  if (pdis->itemState & ODS_SELECTED)
332  {
334  }
335  else if (pContext->bIsButtonHot[0] || (pdis->itemState & ODS_FOCUS))
336  {
338  }
339  break;
340  }
341  }
342  break;
343  }
344 
345  case IDC_BUTTON_REBOOT:
346  {
347  switch (pdis->itemAction)
348  {
349  case ODA_DRAWENTIRE:
350  case ODA_FOCUS:
351  case ODA_SELECT:
352  {
353  y = BUTTON_REBOOT;
354  if (pdis->itemState & ODS_SELECTED)
355  {
357  }
358  else if (pContext->bIsButtonHot[1] || (pdis->itemState & ODS_FOCUS))
359  {
361  }
362  break;
363  }
364  }
365  break;
366  }
367 
369  case IDC_BUTTON_SLEEP:
370  {
371  switch (pdis->itemAction)
372  {
373  case ODA_DRAWENTIRE:
374  case ODA_FOCUS:
375  case ODA_SELECT:
376  {
377  y = BUTTON_SLEEP;
378  if (pdis->itemState & ODS_DISABLED)
379  {
381  }
382  else if (pdis->itemState & ODS_SELECTED)
383  {
385  }
386  else if ((pdis->CtlID == IDC_BUTTON_SLEEP && pContext->bIsButtonHot[2]) ||
387  (pdis->CtlID == IDC_BUTTON_HIBERNATE && pContext->bIsButtonHot[3]) ||
388  (pdis->itemState & ODS_FOCUS))
389  {
391  }
392  break;
393  }
394  }
395  break;
396  }
397  }
398 
399  /* If the owner draw button has keyboard focus make it the default button */
400  if (pdis->itemState & ODS_FOCUS)
401  {
402  SendMessageW(GetParent(pdis->hwndItem), DM_SETDEFID, pdis->CtlID, 0);
403  }
404 
405  /* Draw it on the required button */
406  bRet = BitBlt(pdis->hDC,
407  (rect.right - rect.left - CX_BITMAP) / 2,
408  (rect.bottom - rect.top - CY_BITMAP) / 2,
410 
411  SelectObject(hdcMem, hbmOld);
412  DeleteDC(hdcMem);
413 
414  return bRet;
415 }
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
#define CX_BITMAP
Definition: shutdown.c:34
#define BUTTON_SLEEP_FOCUSED
Definition: shutdown.c:48
#define BUTTON_REBOOT_PRESSED
Definition: shutdown.c:44
#define CY_BITMAP
Definition: shutdown.c:35
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ODS_FOCUS
Definition: winuser.h:2524
#define DM_SETDEFID
Definition: winuser.h:2081
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define ODA_FOCUS
Definition: winuser.h:2519
#define BUTTON_SLEEP_DISABLED
Definition: shutdown.c:49
& rect
Definition: startmenu.cpp:1413
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:63
#define BUTTON_REBOOT
Definition: shutdown.c:43
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
#define BUTTON_SHUTDOWN
Definition: shutdown.c:40
#define ODS_DISABLED
Definition: winuser.h:2522
#define BUTTON_SHUTDOWN_FOCUSED
Definition: shutdown.c:42
#define BUTTON_SHUTDOWN_PRESSED
Definition: shutdown.c:41
#define BUTTON_REBOOT_FOCUSED
Definition: shutdown.c:45
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI DeleteDC(_In_ HDC)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BUTTON_SLEEP
Definition: shutdown.c:46
#define IDC_BUTTON_REBOOT
Definition: resource.h:64
#define BUTTON_SLEEP_PRESSED
Definition: shutdown.c:47
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
Definition: shutdown.c:63
#define ODS_SELECTED
Definition: winuser.h:2520
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:332
#define ODA_SELECT
Definition: winuser.h:2518
HDC hdcMem
Definition: welcome.c:104
static VOID NTAPI 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)
Definition: common.c:49

Referenced by ShutdownDialogProc().

◆ ForceFriendlyUI()

static BOOL ForceFriendlyUI ( VOID  )
static

Definition at line 251 of file shutdown.c.

252 {
253  DWORD dwType, dwValue, dwSize;
254  HKEY hKey;
255  LONG lRet;
256 
258  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
259  0,
261  &hKey);
262  if (lRet == ERROR_SUCCESS)
263  {
264  dwValue = 0;
265  dwSize = sizeof(dwValue);
266  lRet = RegQueryValueExW(hKey,
267  L"ForceFriendlyUI",
268  NULL,
269  &dwType,
270  (LPBYTE)&dwValue,
271  &dwSize);
272  RegCloseKey(hKey);
273 
274  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
275  return (dwValue != 0);
276  }
277 
279  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
280  0,
282  &hKey);
283  if (lRet == ERROR_SUCCESS)
284  {
285  dwValue = 0;
286  dwSize = sizeof(dwValue);
287  lRet = RegQueryValueExW(hKey,
288  L"ForceFriendlyUI",
289  NULL,
290  &dwType,
291  (LPBYTE)&dwValue,
292  &dwSize);
293 
294  RegCloseKey(hKey);
295 
296  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
297  return (dwValue != 0);
298  }
299 
300  return FALSE;
301 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShellIsFriendlyUIActive().

◆ GetAllowedShutdownOptions()

DWORD GetAllowedShutdownOptions ( VOID  )

Definition at line 761 of file shutdown.c.

762 {
763  DWORD Options = 0;
764 
765  // FIXME: Compute those options accordings to current user's rights!
767 
768  if (IsPwrSuspendAllowed())
770 
771  if (IsPwrHibernateAllowed())
773 
774  return Options;
775 }
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3531
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450

Referenced by OnShutDown(), ShellShutdownDialog(), and ShutdownDialog().

◆ GetDefaultShutdownOptions()

DWORD GetDefaultShutdownOptions ( VOID  )

Definition at line 755 of file shutdown.c.

756 {
758 }
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20

Referenced by OnShutDown().

◆ GetDefaultShutdownSelState()

DWORD GetDefaultShutdownSelState ( VOID  )

Definition at line 432 of file shutdown.c.

433 {
435 }
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

Referenced by OnShutDown().

◆ GetShutdownReasonUI()

static BOOL GetShutdownReasonUI ( VOID  )
static

Definition at line 69 of file shutdown.c.

70 {
72  DWORD dwValue, dwSize;
73  HKEY hKey;
74  LONG lRet;
75 
76  /* Query the policy value */
78  L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
79  0,
81  &hKey);
82  if (lRet == ERROR_SUCCESS)
83  {
84  dwValue = 0;
85  dwSize = sizeof(dwValue);
87  L"ShutdownReasonUI",
88  NULL,
89  NULL,
90  (LPBYTE)&dwValue,
91  &dwSize);
93 
94  return (dwValue != 0) ? TRUE : FALSE;
95  }
96 
97  /* Query the machine value */
99  L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
100  0,
102  &hKey);
103  if (lRet == ERROR_SUCCESS)
104  {
105  dwValue = 0;
106  dwSize = sizeof(dwValue);
108  L"ShutdownReasonUI",
109  NULL,
110  NULL,
111  (LPBYTE)&dwValue,
112  &dwSize);
113  RegCloseKey(hKey);
114 
115  return (dwValue != 0) ? TRUE : FALSE;
116  }
117 
118  /* Return the default value */
121  return FALSE;
122 
123  return FALSE;
124 // return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
125 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define GetVersionEx
Definition: winbase.h:3708
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShutdownDialog().

◆ HotButtonSubclass()

static INT_PTR CALLBACK HotButtonSubclass ( HWND  hButton,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 505 of file shutdown.c.

510 {
511  PSHUTDOWN_DLG_CONTEXT pContext;
513 
514  int buttonID = GetDlgCtrlID(hButton);
515 
516  switch (uMsg)
517  {
518  case WM_MOUSEMOVE:
519  {
520  HWND hwndTarget;
522 
523  if (GetCapture() != hButton)
524  {
525  SetCapture(hButton);
526  if (buttonID == IDC_BUTTON_SHUTDOWN)
527  {
528  pContext->bIsButtonHot[0] = TRUE;
529  }
530  else if (buttonID == IDC_BUTTON_REBOOT)
531  {
532  pContext->bIsButtonHot[1] = TRUE;
533  }
534  else if (buttonID == IDC_BUTTON_SLEEP)
535  {
536  pContext->bIsButtonHot[2] = TRUE;
537  }
538  else if (buttonID == IDC_BUTTON_HIBERNATE)
539  {
540  pContext->bIsButtonHot[3] = TRUE;
541  }
543  }
544 
545  ClientToScreen(hButton, &pt);
546  hwndTarget = WindowFromPoint(pt);
547 
548  if (hwndTarget != hButton)
549  {
550  ReleaseCapture();
551  if (buttonID == IDC_BUTTON_SHUTDOWN)
552  {
553  pContext->bIsButtonHot[0] = FALSE;
554  }
555  else if (buttonID == IDC_BUTTON_REBOOT)
556  {
557  pContext->bIsButtonHot[1] = FALSE;
558  }
559  else if (buttonID == IDC_BUTTON_SLEEP)
560  {
561  pContext->bIsButtonHot[2] = FALSE;
562  }
563  else if (buttonID == IDC_BUTTON_HIBERNATE)
564  {
565  pContext->bIsButtonHot[3] = FALSE;
566  }
567  }
568  InvalidateRect(hButton, NULL, FALSE);
569  break;
570  }
571  }
572  return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
573 }
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define GetWindowLongPtrW
Definition: winuser.h:4804
WPARAM wParam
Definition: combotst.c:138
int WINAPI GetDlgCtrlID(_In_ HWND)
#define FALSE
Definition: types.h:117
HWND WINAPI GetCapture(void)
Definition: message.c:2880
#define GWLP_USERDATA
Definition: treelist.c:63
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:63
#define IDC_HAND
Definition: winuser.h:693
WNDPROC OldButtonProc
Definition: shutdown.c:64
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
HWND WINAPI SetCapture(_In_ HWND hWnd)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define IDC_BUTTON_REBOOT
Definition: resource.h:64
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define NULL
Definition: types.h:112
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
HWND WINAPI WindowFromPoint(_In_ POINT)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
Definition: shutdown.c:63
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPARAM lParam
Definition: combotst.c:139

Referenced by ShutdownOnInit().

◆ IsDomainMember()

static BOOL IsDomainMember ( VOID  )
static

Definition at line 205 of file shutdown.c.

206 {
208  return FALSE;
209 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by ShellIsFriendlyUIActive().

◆ IsFriendlyUIActive()

static BOOL IsFriendlyUIActive ( VOID  )
static

Definition at line 129 of file shutdown.c.

130 {
131  DWORD dwType, dwValue, dwSize;
132  HKEY hKey;
133  LONG lRet;
134 
136  L"SYSTEM\\CurrentControlSet\\Control\\Windows",
137  0,
139  &hKey);
140  if (lRet != ERROR_SUCCESS)
141  return FALSE;
142 
143  /* CORE-17282 First check an optional ReactOS specific override, that Windows does not check.
144  We use this to allow users pairing 'Server'-configuration with FriendlyShutdown.
145  Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
146  dwValue = 0;
147  dwSize = sizeof(dwValue);
148  lRet = RegQueryValueExW(hKey,
149  L"EnforceFriendlyShutdown",
150  NULL,
151  &dwType,
152  (LPBYTE)&dwValue,
153  &dwSize);
154 
155  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue == 0x1)
156  {
157  RegCloseKey(hKey);
158  return TRUE;
159  }
160 
161  /* Check product version number */
162  dwValue = 0;
163  dwSize = sizeof(dwValue);
164  lRet = RegQueryValueExW(hKey,
165  L"CSDVersion",
166  NULL,
167  &dwType,
168  (LPBYTE)&dwValue,
169  &dwSize);
170  RegCloseKey(hKey);
171 
172  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != 0x300)
173  {
174  /* Allow Friendly UI only on Workstation */
175  return FALSE;
176  }
177 
178  /* Check LogonType value */
180  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
181  0,
183  &hKey);
184  if (lRet != ERROR_SUCCESS)
185  return FALSE;
186 
187  dwValue = 0;
188  dwSize = sizeof(dwValue);
189  lRet = RegQueryValueExW(hKey,
190  L"LogonType",
191  NULL,
192  &dwType,
193  (LPBYTE)&dwValue,
194  &dwSize);
195  RegCloseKey(hKey);
196 
197  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
198  return FALSE;
199 
200  return (dwValue != 0);
201 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShellIsFriendlyUIActive().

◆ IsNetwareActive()

static BOOL IsNetwareActive ( VOID  )
static

Definition at line 213 of file shutdown.c.

214 {
216  return FALSE;
217 }
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by ShellIsFriendlyUIActive().

◆ IsShowHibernateButtonActive()

static BOOL IsShowHibernateButtonActive ( VOID  )
static

Definition at line 221 of file shutdown.c.

222 {
223  INT_PTR lRet;
224  HKEY hKey;
225  DWORD dwValue, dwSize;
226 
228  L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
229  0, KEY_QUERY_VALUE, &hKey);
230  if (lRet == ERROR_SUCCESS)
231  {
232  dwValue = 0;
233  dwSize = sizeof(dwValue);
234 
235  lRet = RegQueryValueExW(hKey,
236  L"ShowHibernateButton",
237  NULL, NULL,
238  (LPBYTE)&dwValue, &dwSize);
239  RegCloseKey(hKey);
240  if (lRet != ERROR_SUCCESS)
241  {
242  return FALSE;
243  }
244  return (dwValue != 0);
245  }
246  return FALSE;
247 }
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT_PTR
Definition: typedefs.h:64
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShutdownDialog().

◆ LoadShutdownSelState()

DWORD LoadShutdownSelState ( VOID  )

Definition at line 438 of file shutdown.c.

439 {
440  LONG lRet;
441  HKEY hKeyCurrentUser, hKey;
442  DWORD dwValue, dwTemp, dwSize;
443 
444  /* Default to shutdown */
446 
447  /* Open the current user HKCU key */
448  lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
449  if (lRet == ERROR_SUCCESS)
450  {
451  /* Open the subkey */
452  lRet = RegOpenKeyExW(hKeyCurrentUser,
453  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
454  0, KEY_QUERY_VALUE, &hKey);
455  RegCloseKey(hKeyCurrentUser);
456  }
457  if (lRet != ERROR_SUCCESS)
458  return dwValue;
459 
460  /* Read the value */
461  dwSize = sizeof(dwTemp);
462  lRet = RegQueryValueExW(hKey,
463  L"Shutdown Setting",
464  NULL, NULL,
465  (LPBYTE)&dwTemp, &dwSize);
466  RegCloseKey(hKey);
467 
468  if (lRet == ERROR_SUCCESS)
469  {
470  switch (dwTemp)
471  {
473  dwValue = WLX_SAS_ACTION_LOGOFF;
474  break;
475 
478  break;
479 
482  break;
483 
484  // 0x08
485 
488  break;
489 
490  // 0x20
491 
494  break;
495 
496  // 0x80
497  }
498  }
499 
500  return dwValue;
501 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3232
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by OnShutDown(), ShellShutdownDialog(), and ShutdownDialog().

◆ ReplaceRequiredButton()

VOID ReplaceRequiredButton ( HWND  hDlg,
HINSTANCE  hInstance,
BOOL  bIsAltKeyPressed,
BOOL  bIsSleepButtonReplaced 
)

Definition at line 631 of file shutdown.c.

636 {
637  int destID = IDC_BUTTON_SLEEP;
638  int targetedID = IDC_BUTTON_HIBERNATE;
639  HWND hwndDest, hwndTarget;
640  RECT rect;
641  WCHAR szBuffer[30];
642 
643  /* If the sleep button has been already replaced earlier, bring sleep button back to its original position */
644  if (bIsSleepButtonReplaced)
645  {
646  destID = IDC_BUTTON_HIBERNATE;
647  targetedID = IDC_BUTTON_SLEEP;
648  }
649 
650  hwndDest = GetDlgItem(hDlg, destID);
651  hwndTarget = GetDlgItem(hDlg, targetedID);
652 
653  /* Get the position of the destination button */
654  GetWindowRect(hwndDest, &rect);
655 
656  /* Get the corrected translated coordinates which is relative to the client window */
657  MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
658 
659  /* Set the position of targeted button and hide the destination button */
660  SetWindowPos(hwndTarget,
661  HWND_TOP,
662  rect.left, rect.top,
663  0, 0,
665 
666  EnableWindow(hwndDest, FALSE);
667  ShowWindow(hwndDest, SW_HIDE);
668  EnableWindow(hwndTarget, TRUE);
669  ShowWindow(hwndTarget, SW_SHOW);
670  SetFocus(hwndTarget);
671 
672  if (bIsAltKeyPressed)
673  {
674  if (!bIsSleepButtonReplaced)
675  {
676  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
677  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
678  }
679  else
680  {
681  GetDlgItemTextW(hDlg, IDC_BUTTON_SLEEP, szBuffer, _countof(szBuffer));
682  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
683  }
684  }
685  else
686  {
687  if (!bIsSleepButtonReplaced)
688  {
689  LoadStringW(hInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
690  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
691  }
692  else
693  {
694  LoadStringW(hInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
695  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
696  }
697  }
698 }
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
#define HWND_TOP
Definition: winuser.h:1193
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDC_SLEEP_STATIC
Definition: resource.h:57
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
#define SW_SHOW
Definition: winuser.h:769
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define _countof(array)
Definition: sndvol32.h:68
#define IDS_SHUTDOWN_HIBERNATE
Definition: resource.h:118
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SWP_NOSIZE
Definition: winuser.h:1230
#define IDS_SHUTDOWN_SLEEP
Definition: resource.h:117
#define HWND_DESKTOP
Definition: winuser.h:1195
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
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)

Referenced by ShutdownDialog().

◆ SaveShutdownSelState()

VOID SaveShutdownSelState ( IN DWORD  ShutdownCode)

Definition at line 701 of file shutdown.c.

703 {
704  LONG lRet;
705  HKEY hKeyCurrentUser, hKey;
706  DWORD dwValue = 0;
707 
708  /* Open the current user HKCU key */
709  lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
710  if (lRet == ERROR_SUCCESS)
711  {
712  /* Create the subkey */
713  lRet = RegCreateKeyExW(hKeyCurrentUser,
714  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
715  0, NULL,
718  NULL, &hKey, NULL);
719  RegCloseKey(hKeyCurrentUser);
720  }
721  if (lRet != ERROR_SUCCESS)
722  return;
723 
724  switch (ShutdownCode)
725  {
727  dwValue = WLX_SHUTDOWN_STATE_LOGOFF;
728  break;
729 
732  break;
733 
735  dwValue = WLX_SHUTDOWN_STATE_REBOOT;
736  break;
737 
739  dwValue = WLX_SHUTDOWN_STATE_SLEEP;
740  break;
741 
744  break;
745  }
746 
748  L"Shutdown Setting",
749  0, REG_DWORD,
750  (LPBYTE)&dwValue, sizeof(dwValue));
751  RegCloseKey(hKey);
752 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
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)
Definition: reg.c:1091
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
FxAutoRegKey hKey
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3232
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by ShellShutdownDialog(), and ShutdownDialog().

◆ ShellIsFriendlyUIActive()

BOOL WINAPI ShellIsFriendlyUIActive ( VOID  )

Definition at line 419 of file shutdown.c.

420 {
421  BOOL bActive;
422 
423  bActive = IsFriendlyUIActive();
424 
426  return FALSE;
427 
428  return bActive;
429 }
static BOOL IsDomainMember(VOID)
Definition: shutdown.c:205
static BOOL IsNetwareActive(VOID)
Definition: shutdown.c:213
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL IsFriendlyUIActive(VOID)
Definition: shutdown.c:129
static BOOL ForceFriendlyUI(VOID)
Definition: shutdown.c:251

Referenced by ShutdownDialog().

◆ ShellShutdownDialog()

DWORD WINAPI ShellShutdownDialog ( HWND  hParent,
LPWSTR  lpUsername,
BOOL  bHideLogoff 
)

Definition at line 1310 of file shutdown.c.

1314 {
1315  INT_PTR dlgValue;
1316  DWORD ShutdownOptions;
1317 
1318  /*
1319  * As we are called by the shell itself, don't use
1320  * the cached GINA context but use a local copy here.
1321  */
1322  GINA_CONTEXT gContext = { 0 };
1323  DWORD BufferSize;
1324 
1325  UNREFERENCED_PARAMETER(lpUsername);
1326 
1327  ShutdownOptions = GetAllowedShutdownOptions();
1328  if (bHideLogoff)
1329  ShutdownOptions &= ~WLX_SHUTDOWN_STATE_LOGOFF;
1330 
1331  /* Initialize our local GINA context */
1332  gContext.hDllInstance = hDllInstance;
1333  BufferSize = _countof(gContext.UserName);
1334  // NOTE: Only when this function is called, Win checks inside
1335  // HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1336  // value "Logon User Name", and determines whether it will display
1337  // the user name.
1338  GetUserNameW(gContext.UserName, &BufferSize);
1340 
1341  /* Load the shutdown dialog box */
1342  dlgValue = ShutdownDialog(hParent, ShutdownOptions, &gContext);
1343 
1344  /* Determine what to do based on user selection */
1345  if (dlgValue == IDOK)
1346  {
1348 
1349  switch (gContext.nShutdownAction)
1350  {
1351  case WLX_SAS_ACTION_LOGOFF:
1353 
1356 
1359 
1360  // 0x08
1361 
1363  return WLX_SHUTDOWN_STATE_SLEEP;
1364 
1365  // 0x20
1366 
1369 
1370  // 0x80
1371  }
1372  }
1373  /* Help file is called directly here */
1374  else if (dlgValue == IDHELP)
1375  {
1376  FIXME("Help is not implemented yet.");
1377  MessageBoxW(hParent, L"Help is not implemented yet.", L"Message", MB_OK | MB_ICONEXCLAMATION);
1378  }
1379  else if (dlgValue == -1)
1380  {
1381  ERR("Failed to create dialog\n");
1382  }
1383 
1384  return 0;
1385 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define IDOK
Definition: winuser.h:824
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:438
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:1156
int32_t INT_PTR
Definition: typedefs.h:64
HANDLE hDllInstance
Definition: msgina.h:37
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define IDHELP
Definition: resource_2.h:8
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
ULONG nShutdownAction
Definition: msgina.h:47
#define FIXME(fmt,...)
Definition: debug.h:111
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:761
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
WCHAR UserName[256]
Definition: msgina.h:50
static HINSTANCE hDllInstance
Definition: clb.c:30
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define ERR(fmt,...)
Definition: debug.h:110
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
#define MB_OK
Definition: winuser.h:784
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:701
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by ShellTurnOffDialog().

◆ ShellTurnOffDialog()

DWORD WINAPI ShellTurnOffDialog ( HWND  hWnd)

Definition at line 1393 of file shutdown.c.

1394 {
1395  return ShellShutdownDialog(hWnd, NULL, FALSE);
1396 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
DWORD WINAPI ShellShutdownDialog(HWND hParent, LPWSTR lpUsername, BOOL bHideLogoff)
Definition: shutdown.c:1310
#define NULL
Definition: types.h:112

◆ ShutdownDialog()

INT_PTR ShutdownDialog ( IN HWND  hwndDlg,
IN DWORD  ShutdownOptions,
IN PGINA_CONTEXT  pgContext 
)

Definition at line 1156 of file shutdown.c.

1160 {
1161  INT_PTR ret;
1163  BOOL bIsAltKeyPressed = FALSE;
1164  DWORD ShutdownDialogId = IDD_SHUTDOWN;
1165  MSG Msg;
1166  HWND hDlg;
1167 
1168 #if 0
1169  DWORD ShutdownOptions;
1170 
1171  // FIXME: User impersonation!!
1172  pgContext->nShutdownAction = LoadShutdownSelState();
1173  ShutdownOptions = GetAllowedShutdownOptions();
1174 #endif
1175 
1176  Context.pgContext = pgContext;
1177  Context.ShutdownOptions = ShutdownOptions;
1178  Context.bCloseDlg = FALSE;
1179  Context.bReasonUI = GetShutdownReasonUI();
1180  Context.bFriendlyUI = ShellIsFriendlyUIActive();
1181 
1182  if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1183  {
1184  ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1185  pgContext->hDllInstance,
1187  hwndDlg,
1189  (LPARAM)&Context);
1190  }
1191  else
1192  {
1193  if (Context.bFriendlyUI)
1194  {
1196  {
1197  ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1198  }
1199  else
1200  {
1201  ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1202  }
1203  }
1204 
1205  hDlg = CreateDialogParamW(pgContext->hDllInstance,
1206  MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : ShutdownDialogId),
1207  hwndDlg,
1209  (LPARAM)&Context);
1210 
1211  ShowWindow(hDlg, SW_SHOW);
1212 
1213  /* Detect either Alt or Shift key have been pressed or released */
1214  while (GetMessageW(&Msg, NULL, 0, 0))
1215  {
1216  if (!IsDialogMessageW(hDlg, &Msg))
1217  {
1220  }
1221 
1222  switch (Msg.message)
1223  {
1224  case WM_SYSKEYDOWN:
1225  {
1226  /* If the Alt key has been pressed once, add prefix to static controls */
1227  if (Msg.wParam == VK_MENU && !bIsAltKeyPressed)
1228  {
1229  AddPrefixToStaticTexts(hDlg, Context.bIsSleepButtonReplaced);
1230  bIsAltKeyPressed = TRUE;
1231  }
1232  }
1233  break;
1234 
1235  case WM_KEYDOWN:
1236  {
1237  /*
1238  * If the Shift key has been pressed once, and both hibernate button and sleep button are enabled
1239  * replace the sleep button with hibernate button
1240  */
1241  if (Msg.wParam == VK_SHIFT)
1242  {
1243  if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && !Context.bIsSleepButtonReplaced)
1244  {
1246  {
1247  ReplaceRequiredButton(hDlg,
1248  pgContext->hDllInstance,
1249  bIsAltKeyPressed,
1250  Context.bIsSleepButtonReplaced);
1251  Context.bIsSleepButtonReplaced = TRUE;
1252  }
1253  }
1254  }
1255  }
1256  break;
1257 
1258  case WM_KEYUP:
1259  {
1260  /* If the Shift key has been released after being pressed, replace the hibernate button with sleep button again */
1261  if (Msg.wParam == VK_SHIFT)
1262  {
1263  if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && Context.bIsSleepButtonReplaced)
1264  {
1266  {
1267  ReplaceRequiredButton(hDlg,
1268  pgContext->hDllInstance,
1269  bIsAltKeyPressed,
1270  Context.bIsSleepButtonReplaced);
1271  Context.bIsSleepButtonReplaced = FALSE;
1272  }
1273  }
1274  }
1275  }
1276  break;
1277  }
1278  }
1279  ret = Msg.wParam;
1280  }
1281 
1282 #if 0
1283  // FIXME: User impersonation!!
1284  if (ret == IDOK)
1285  SaveShutdownSelState(pgContext->nShutdownAction);
1286 #endif
1287 
1288  return ret;
1289 }
#define IDD_SHUTDOWN
Definition: resource.h:43
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:221
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define IDOK
Definition: winuser.h:824
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:438
static INT_PTR CALLBACK ShutdownDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:1003
VOID AddPrefixToStaticTexts(HWND hDlg, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:576
#define TRUE
Definition: types.h:120
VOID ReplaceRequiredButton(HWND hDlg, HINSTANCE hInstance, BOOL bIsAltKeyPressed, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:631
struct @1616 Msg[]
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define VK_MENU
Definition: winuser.h:2179
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:64
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:761
#define VK_SHIFT
Definition: winuser.h:2177
#define WM_KEYDOWN
Definition: winuser.h:1697
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOW
Definition: winuser.h:769
#define IDD_SHUTDOWN_FANCY_LONG
Definition: resource.h:45
#define WM_KEYUP
Definition: winuser.h:1698
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:69
#define NULL
Definition: types.h:112
#define IDD_SHUTDOWN_REASON
Definition: resource.h:46
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
struct tagContext Context
Definition: acpixf.h:1034
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:701
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
#define IDD_SHUTDOWN_FANCY
Definition: resource.h:44
BOOL WINAPI IsDialogMessageW(_In_ HWND, _In_ LPMSG)
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
Definition: shutdown.c:419

Referenced by OnShutDown(), and ShellShutdownDialog().

◆ ShutdownDialogProc()

static INT_PTR CALLBACK ShutdownDialogProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1003 of file shutdown.c.

1008 {
1009  PSHUTDOWN_DLG_CONTEXT pContext;
1010 
1012 
1013  switch (uMsg)
1014  {
1015  case WM_INITDIALOG:
1016  {
1017  pContext = (PSHUTDOWN_DLG_CONTEXT)lParam;
1018  SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pContext);
1019 
1020  ShutdownOnInit(hDlg, pContext);
1021 
1022  /* Draw the logo bitmap */
1023  pContext->hBitmap =
1025  return TRUE;
1026  }
1027 
1028  case WM_DESTROY:
1029  DeleteObject(pContext->hBitmap);
1030  DeleteObject(pContext->hBrush);
1031  DeleteObject(pContext->hImageStrip);
1032  DeleteObject(pContext->hfFont);
1033 
1034  /* Remove the subclass from the buttons */
1035  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1036  {
1038  }
1039  return TRUE;
1040 
1041  case WM_ACTIVATE:
1042  {
1043  /*
1044  * If the user deactivates the shutdown dialog (it loses its focus
1045  * while the dialog is not being closed), then destroy the dialog
1046  * and cancel shutdown.
1047  */
1048  if (LOWORD(wParam) == WA_INACTIVE)
1049  {
1050  if (!pContext->bCloseDlg)
1051  {
1052  pContext->bCloseDlg = TRUE;
1053  DestroyWindow(hDlg);
1054  PostQuitMessage(0);
1055  }
1056  }
1057  return FALSE;
1058  }
1059 
1060  case WM_PAINT:
1061  {
1062  PAINTSTRUCT ps;
1063  if (pContext->hBitmap)
1064  {
1065  BeginPaint(hDlg, &ps);
1066  DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1067  EndPaint(hDlg, &ps);
1068  }
1069  return TRUE;
1070  }
1071 
1072  case WM_CLOSE:
1073  pContext->bCloseDlg = TRUE;
1074  DestroyWindow(hDlg);
1076  break;
1077 
1078  case WM_COMMAND:
1079  switch (LOWORD(wParam))
1080  {
1081  case IDC_BUTTON_SHUTDOWN:
1082  ExitWindowsEx(EWX_SHUTDOWN, SHTDN_REASON_MAJOR_OTHER);
1083  break;
1084 
1085  case IDC_BUTTON_REBOOT:
1086  ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_OTHER);
1087  break;
1088 
1089  case IDC_BUTTON_SLEEP:
1091  break;
1092 
1093  case IDOK:
1094  ShutdownOnOk(hDlg, pContext->pgContext);
1095 
1096  /* Fall back */
1097  case IDCANCEL:
1098  case IDHELP:
1099  pContext->bCloseDlg = TRUE;
1100  DestroyWindow(hDlg);
1102  break;
1103 
1104  case IDC_SHUTDOWN_ACTION:
1105  UpdateShutdownDesc(hDlg, pContext);
1106  break;
1107  }
1108  break;
1109 
1110  case WM_CTLCOLORSTATIC:
1111  {
1112  /* Either make background transparent or fill it with color for required static controls */
1113  HDC hdcStatic = (HDC)wParam;
1114  UINT StaticID = (UINT)GetWindowLongPtrW((HWND)lParam, GWL_ID);
1115 
1116  switch (StaticID)
1117  {
1118  case IDC_TURN_OFF_STATIC:
1119  SetTextColor(hdcStatic, DARK_GREY_COLOR);
1120  SetBkMode(hdcStatic, TRANSPARENT);
1122 
1123  case IDC_HIBERNATE_STATIC:
1124  case IDC_SHUTDOWN_STATIC:
1125  case IDC_SLEEP_STATIC:
1126  case IDC_RESTART_STATIC:
1127  SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1128  SetBkMode(hdcStatic, TRANSPARENT);
1129  return (LONG_PTR)pContext->hBrush;
1130  }
1131  return FALSE;
1132  }
1133 
1134  case WM_DRAWITEM:
1135  {
1136  /* Draw bitmaps on required buttons */
1138  switch (pdis->CtlID)
1139  {
1140  case IDC_BUTTON_SHUTDOWN:
1141  case IDC_BUTTON_REBOOT:
1142  case IDC_BUTTON_SLEEP:
1143  case IDC_BUTTON_HIBERNATE:
1144  return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1145  }
1146  break;
1147  }
1148 
1149  default:
1150  return FALSE;
1151  }
1152  return TRUE;
1153 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:681
#define IDI_ROSLOGO
Definition: resource.h:42
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
#define IDC_TURN_OFF_STATIC
Definition: resource.h:55
#define IDOK
Definition: winuser.h:824
#define TRUE
Definition: types.h:120
#define GWL_ID
Definition: winuser.h:853
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:830
static HDC
Definition: imagelist.c:92
#define DARK_GREY_COLOR
Definition: shutdown.c:30
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define IDC_HIBERNATE_STATIC
Definition: resource.h:56
#define IDC_SLEEP_STATIC
Definition: resource.h:57
UINT_PTR WPARAM
Definition: windef.h:207
#define LIGHT_GREY_COLOR
Definition: shutdown.c:31
#define GetWindowLongPtrW
Definition: winuser.h:4804
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
int32_t INT_PTR
Definition: typedefs.h:64
#define EWX_REBOOT
Definition: winuser.h:633
BOOL WINAPI DestroyWindow(_In_ HWND)
HANDLE hDllInstance
Definition: msgina.h:37
WPARAM wParam
Definition: combotst.c:138
#define IDHELP
Definition: resource_2.h:8
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
#define FALSE
Definition: types.h:117
#define EWX_SHUTDOWN
Definition: winuser.h:634
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define TRANSPARENT
Definition: wingdi.h:949
#define GWLP_USERDATA
Definition: treelist.c:63
LONG_PTR LPARAM
Definition: windef.h:208
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:63
PGINA_CONTEXT pgContext
Definition: shutdown.c:53
#define WM_DESTROY
Definition: winuser.h:1591
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:305
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_SHUTDOWN_STATIC
Definition: resource.h:58
#define WM_CLOSE
Definition: winuser.h:1603
#define HOLLOW_BRUSH
Definition: wingdi.h:898
WNDPROC OldButtonProc
Definition: shutdown.c:64
#define WM_PAINT
Definition: winuser.h:1602
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:37
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_COMMAND
Definition: winuser.h:1722
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define GWLP_WNDPROC
Definition: treelist.c:66
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define WM_ACTIVATE
Definition: winuser.h:1594
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
Definition: glfuncs.h:248
#define IDC_BUTTON_REBOOT
Definition: resource.h:64
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
#define WM_DRAWITEM
Definition: winuser.h:1627
#define DST_BITMAP
Definition: winuser.h:516
#define IDC_RESTART_STATIC
Definition: resource.h:59
static VOID ShutdownOnOk(IN HWND hDlg, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:979
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define WA_INACTIVE
Definition: winuser.h:2597
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDCANCEL
Definition: winuser.h:825
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static VOID UpdateShutdownDesc(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:778

Referenced by ShutdownDialog().

◆ ShutdownOnInit()

static VOID ShutdownOnInit ( IN HWND  hDlg,
IN PSHUTDOWN_DLG_CONTEXT  pContext 
)
static

Definition at line 830 of file shutdown.c.

833 {
834  PGINA_CONTEXT pgContext = pContext->pgContext;
835  HWND hwndList;
836  INT idx, count, i;
837  WCHAR szBuffer[256];
838  WCHAR szBuffer2[256];
839  HDC hdc;
840  LONG lfHeight;
841 
842  /* Create font for the IDC_TURN_OFF_STATIC static control */
843  hdc = GetDC(hDlg);
844  lfHeight = -MulDiv(FONT_POINT_SIZE, GetDeviceCaps(hdc, LOGPIXELSY), 72);
845  ReleaseDC(hDlg, hdc);
846  pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
847  SendDlgItemMessageW(hDlg, IDC_TURN_OFF_STATIC, WM_SETFONT, (WPARAM)pContext->hfFont, TRUE);
848 
849  /* Create a brush for static controls for fancy shut down dialog */
850  pContext->hBrush = CreateSolidBrush(DARK_GREY_COLOR);
851 
852  pContext->hImageStrip = LoadBitmapW(pgContext->hDllInstance, MAKEINTRESOURCEW(IDB_IMAGE_STRIP));
853 
854  hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
855 
856  /* Clear the content before it's used */
857  SendMessageW(hwndList, CB_RESETCONTENT, 0, 0);
858 
859  /* Set the boolean flags to false */
860  pContext->bIsSleepButtonReplaced = FALSE;
861 
862  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
863  {
864  pContext->bIsButtonHot[i] = FALSE;
865  }
866 
867  /* Log off */
868  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_LOGOFF)
869  {
870  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_LOGOFF, szBuffer, _countof(szBuffer));
871  StringCchPrintfW(szBuffer2, _countof(szBuffer2), szBuffer, pgContext->UserName);
872  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer2);
873  if (idx != CB_ERR)
875  }
876 
877  /* Shut down - DEFAULT */
878  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_POWER_OFF)
879  {
880  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SHUTDOWN, szBuffer, _countof(szBuffer));
881  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
882  if (idx != CB_ERR)
884  }
885  else if (pContext->bFriendlyUI)
886  {
888  }
889 
890  /* Restart */
891  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_REBOOT)
892  {
893  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_RESTART, szBuffer, _countof(szBuffer));
894  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
895  if (idx != CB_ERR)
897  }
898  else if (pContext->bFriendlyUI)
899  {
901  }
902 
903  // if (pContext->ShutdownOptions & 0x08) {}
904 
905  /* Sleep */
906  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP)
907  {
908  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
909  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
910  if (idx != CB_ERR)
912  }
913  else if (pContext->bFriendlyUI)
914  {
916  }
917 
918  // if (pContext->ShutdownOptions & 0x20) {}
919 
920  /* Hibernate */
921  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE)
922  {
923  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
924  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
925  if (idx != CB_ERR)
927  }
928  else if (pContext->bFriendlyUI)
929  {
931  }
932 
933  // if (pContext->ShutdownOptions & 0x80) {}
934 
935  /* Set the default shut down selection */
936  count = SendMessageW(hwndList, CB_GETCOUNT, 0, 0);
937  for (i = 0; i < count; i++)
938  {
939  if (SendMessageW(hwndList, CB_GETITEMDATA, i, 0) == pgContext->nShutdownAction)
940  {
941  SendMessageW(hwndList, CB_SETCURSEL, i, 0);
942  break;
943  }
944  }
945 
946  /* Create tool tips for the buttons of fancy log off dialog */
950  pContext->pgContext->hDllInstance);
953  hDlg, IDS_SHUTDOWN_SHUTDOWN,
954  pContext->pgContext->hDllInstance);
957  hDlg, IDS_SHUTDOWN_RESTART,
958  pContext->pgContext->hDllInstance);
961  hDlg, IDS_SHUTDOWN_SLEEP,
962  pContext->pgContext->hDllInstance);
963 
964  /* Gather old button func */
965  pContext->OldButtonProc = (WNDPROC)GetWindowLongPtrW(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), GWLP_WNDPROC);
966 
967  /* Make buttons to remember pContext and subclass the buttons */
968  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
969  {
972  }
973 
974  /* Update the choice description based on the current selection */
975  UpdateShutdownDesc(hDlg, pContext);
976 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define CB_SETITEMDATA
Definition: winuser.h:1948
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define IDC_TURN_OFF_STATIC
Definition: resource.h:55
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)
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#define IDS_SHUTDOWN_RESTART_DESC
Definition: resource.h:122
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define CB_GETITEMDATA
Definition: winuser.h:1932
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
static HDC
Definition: imagelist.c:92
#define DARK_GREY_COLOR
Definition: shutdown.c:30
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define IDS_SHUTDOWN_SLEEP_DESC
Definition: resource.h:123
HANDLE hDllInstance
Definition: msgina.h:37
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
ULONG nShutdownAction
Definition: msgina.h:47
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static INT_PTR CALLBACK HotButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:505
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define IDS_SHUTDOWN_RESTART
Definition: resource.h:116
unsigned int idx
Definition: utils.c:41
#define GWLP_USERDATA
Definition: treelist.c:63
#define CB_ADDSTRING
Definition: winuser.h:1918
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
#define IDS_SHUTDOWN_SHUTDOWN
Definition: resource.h:114
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR UserName[256]
Definition: msgina.h:50
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:63
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CB_ERR
Definition: winuser.h:2410
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
#define FW_MEDIUM
Definition: wingdi.h:374
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define IDS_SHUTDOWN_LOGOFF
Definition: resource.h:115
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:37
#define IDS_SHUTDOWN_HIBERNATE
Definition: resource.h:118
static const WCHAR L[]
Definition: oid.c:1250
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define CB_SETCURSEL
Definition: winuser.h:1943
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define IDS_SHUTDOWN_SLEEP
Definition: resource.h:117
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
Definition: glfuncs.h:248
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2132
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define IDC_BUTTON_REBOOT
Definition: resource.h:64
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
#define IDB_IMAGE_STRIP
Definition: resource.h:79
#define IDS_SHUTDOWN_HIBERNATE_DESC
Definition: resource.h:124
#define WM_SETFONT
Definition: winuser.h:1632
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define IDS_SHUTDOWN_SHUTDOWN_DESC
Definition: resource.h:120
#define LOGPIXELSY
Definition: wingdi.h:718
#define CB_GETCOUNT
Definition: winuser.h:1924
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define FONT_POINT_SIZE
Definition: shutdown.c:28
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
Definition: shutdown.c:596
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
static VOID UpdateShutdownDesc(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:778

Referenced by ShutdownDialogProc().

◆ ShutdownOnOk()

static VOID ShutdownOnOk ( IN HWND  hDlg,
IN PGINA_CONTEXT  pgContext 
)
static

Definition at line 979 of file shutdown.c.

982 {
983  INT idx;
984 
985  idx = SendDlgItemMessageW(hDlg,
987  CB_GETCURSEL,
988  0,
989  0);
990  if (idx != CB_ERR)
991  {
992  pgContext->nShutdownAction =
993  SendDlgItemMessageW(hDlg,
996  idx,
997  0);
998  }
999 }
#define CB_GETITEMDATA
Definition: winuser.h:1932
int32_t INT
Definition: typedefs.h:58
#define CB_GETCURSEL
Definition: winuser.h:1925
unsigned int idx
Definition: utils.c:41
#define CB_ERR
Definition: winuser.h:2410
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ShutdownDialogProc().

◆ UpdateShutdownDesc()

static VOID UpdateShutdownDesc ( IN HWND  hDlg,
IN PSHUTDOWN_DLG_CONTEXT  pContext 
)
static

Definition at line 778 of file shutdown.c.

781 {
782  UINT DescId = 0;
783  DWORD ShutdownCode;
784  WCHAR szBuffer[256];
785 
786  ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETCURSEL, 0, 0);
787  if (ShutdownCode == CB_ERR) // Invalid selection
788  return;
789 
790  ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETITEMDATA, ShutdownCode, 0);
791 
792  switch (ShutdownCode)
793  {
795  DescId = IDS_SHUTDOWN_LOGOFF_DESC;
796  break;
797 
800  break;
801 
803  DescId = IDS_SHUTDOWN_RESTART_DESC;
804  break;
805 
807  DescId = IDS_SHUTDOWN_SLEEP_DESC;
808  break;
809 
812  break;
813 
814  default:
815  break;
816  }
817 
818  LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
819  SetDlgItemTextW(hDlg, IDC_SHUTDOWN_DESCRIPTION, szBuffer);
820 
821  if (pContext->bReasonUI)
822  {
826  }
827 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define IDS_SHUTDOWN_RESTART_DESC
Definition: resource.h:122
#define CB_GETITEMDATA
Definition: winuser.h:1932
#define IDS_SHUTDOWN_LOGOFF_DESC
Definition: resource.h:121
#define IDC_SHUTDOWN_DESCRIPTION
Definition: resource.h:49
#define IDS_SHUTDOWN_SLEEP_DESC
Definition: resource.h:123
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
#define IDC_REASON_PLANNED
Definition: resource.h:50
#define CB_ERR
Definition: winuser.h:2410
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
#define IDC_REASON_COMMENT
Definition: resource.h:53
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
unsigned int UINT
Definition: ndis.h:50
#define IDS_SHUTDOWN_HIBERNATE_DESC
Definition: resource.h:124
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define IDS_SHUTDOWN_SHUTDOWN_DESC
Definition: resource.h:120
#define IDC_REASON_LIST
Definition: resource.h:51

Referenced by ShutdownDialogProc(), and ShutdownOnInit().