ReactOS  0.4.15-dev-3181-g4acf100
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 OwnerDrawButtonSubclass (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 585 of file shutdown.c.

588 {
589  WCHAR szBuffer[30];
590 
591  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
592  {
593  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE + i, szBuffer, _countof(szBuffer));
594  SetDlgItemTextW(hDlg, IDC_HIBERNATE_STATIC + i, szBuffer);
595  }
596 
597  if (bIsSleepButtonReplaced)
598  {
599  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
600  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
601  }
602 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#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 605 of file shutdown.c.

611 {
612  HWND hwndTool, hwndTip;
613  WCHAR szBuffer[256];
614  TTTOOLINFOW tool;
615 
616  hwndTool = GetDlgItem(hDlg, controlID);
617 
618  tool.cbSize = sizeof(tool);
619  tool.hwnd = hDlg;
621  tool.uId = (UINT_PTR)hwndTool;
622 
623  /* Create the tooltip */
624  hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
628  hDlg, NULL, hInst, NULL);
629 
630  /* Associate the tooltip with the tool. */
631  LoadStringW(hInst, detailID, szBuffer, _countof(szBuffer));
632  tool.lpszText = szBuffer;
633  SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
634  LoadStringW(hInst, titleID, szBuffer, _countof(szBuffer));
635  SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
636  SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
637 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define TTS_BALLOON
Definition: commctrl.h:1761
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:1746
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
#define TTF_IDISHWND
Definition: commctrl.h:1764
#define CW_USEDEFAULT
Definition: winuser.h:225
LONG_PTR LPARAM
Definition: windef.h:208
#define TTM_SETTITLEW
Definition: commctrl.h:1828
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:1779
UINT_PTR uId
Definition: commctrl.h:1743
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1819
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
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:1787
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:1767

Referenced by ShutdownOnInit().

◆ DrawIconOnOwnerDrawnButtons()

static BOOL DrawIconOnOwnerDrawnButtons ( DRAWITEMSTRUCT pdis,
PSHUTDOWN_DLG_CONTEXT  pContext 
)
static

Definition at line 306 of file shutdown.c.

309 {
310  BOOL bRet;
311  HDC hdcMem;
312  HBITMAP hbmOld;
313  int y;
314  RECT rect;
315 
316  hdcMem = CreateCompatibleDC(pdis->hDC);
317  hbmOld = SelectObject(hdcMem, pContext->hImageStrip);
318  rect = pdis->rcItem;
319 
320  /* Check the button ID for revelant bitmap to be used */
321  switch (pdis->CtlID)
322  {
323  case IDC_BUTTON_SHUTDOWN:
324  {
325  switch (pdis->itemAction)
326  {
327  case ODA_DRAWENTIRE:
328  case ODA_FOCUS:
329  case ODA_SELECT:
330  {
331  y = BUTTON_SHUTDOWN;
332  if (pdis->itemState & ODS_SELECTED)
333  {
335  }
336  else if (pContext->bIsButtonHot[0] || (pdis->itemState & ODS_FOCUS))
337  {
339  }
340  break;
341  }
342  }
343  break;
344  }
345 
346  case IDC_BUTTON_REBOOT:
347  {
348  switch (pdis->itemAction)
349  {
350  case ODA_DRAWENTIRE:
351  case ODA_FOCUS:
352  case ODA_SELECT:
353  {
354  y = BUTTON_REBOOT;
355  if (pdis->itemState & ODS_SELECTED)
356  {
358  }
359  else if (pContext->bIsButtonHot[1] || (pdis->itemState & ODS_FOCUS))
360  {
362  }
363  break;
364  }
365  }
366  break;
367  }
368 
370  case IDC_BUTTON_SLEEP:
371  {
372  switch (pdis->itemAction)
373  {
374  case ODA_DRAWENTIRE:
375  case ODA_FOCUS:
376  case ODA_SELECT:
377  {
378  y = BUTTON_SLEEP;
379  if (pdis->itemState & ODS_DISABLED)
380  {
382  }
383  else if (pdis->itemState & ODS_SELECTED)
384  {
386  }
387  else if ((pdis->CtlID == IDC_BUTTON_SLEEP && pContext->bIsButtonHot[2]) ||
388  (pdis->CtlID == IDC_BUTTON_HIBERNATE && pContext->bIsButtonHot[3]) ||
389  (pdis->itemState & ODS_FOCUS))
390  {
392  }
393  break;
394  }
395  }
396  break;
397  }
398  }
399 
400  /* Draw it on the required button */
401  bRet = BitBlt(pdis->hDC,
402  (rect.right - rect.left - CX_BITMAP) / 2,
403  (rect.bottom - rect.top - CY_BITMAP) / 2,
405 
406  SelectObject(hdcMem, hbmOld);
407  DeleteDC(hdcMem);
408 
409  return bRet;
410 }
#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:2525
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define ODA_FOCUS
Definition: winuser.h:2520
#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:2518
#define BUTTON_SHUTDOWN
Definition: shutdown.c:40
#define ODS_DISABLED
Definition: winuser.h:2523
#define BUTTON_SHUTDOWN_FOCUSED
Definition: shutdown.c:42
#define BUTTON_SHUTDOWN_PRESSED
Definition: shutdown.c:41
#define BUTTON_REBOOT_FOCUSED
Definition: shutdown.c:45
BOOL WINAPI DeleteDC(_In_ HDC)
#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:2521
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:332
#define ODA_SELECT
Definition: winuser.h:2519
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 252 of file shutdown.c.

253 {
254  DWORD dwType, dwValue, dwSize;
255  HKEY hKey;
256  LONG lRet;
257 
259  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
260  0,
262  &hKey);
263  if (lRet == ERROR_SUCCESS)
264  {
265  dwValue = 0;
266  dwSize = sizeof(dwValue);
267  lRet = RegQueryValueExW(hKey,
268  L"ForceFriendlyUI",
269  NULL,
270  &dwType,
271  (LPBYTE)&dwValue,
272  &dwSize);
273  RegCloseKey(hKey);
274 
275  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
276  return (dwValue != 0);
277  }
278 
280  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
281  0,
283  &hKey);
284  if (lRet == ERROR_SUCCESS)
285  {
286  dwValue = 0;
287  dwSize = sizeof(dwValue);
288  lRet = RegQueryValueExW(hKey,
289  L"ForceFriendlyUI",
290  NULL,
291  &dwType,
292  (LPBYTE)&dwValue,
293  &dwSize);
294 
295  RegCloseKey(hKey);
296 
297  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
298  return (dwValue != 0);
299  }
300 
301  return FALSE;
302 }
#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:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShellIsFriendlyUIActive().

◆ GetAllowedShutdownOptions()

DWORD GetAllowedShutdownOptions ( VOID  )

Definition at line 770 of file shutdown.c.

771 {
772  DWORD Options = 0;
773 
774  // FIXME: Compute those options accordings to current user's rights!
776 
777  if (IsPwrSuspendAllowed())
779 
780  if (IsPwrHibernateAllowed())
782 
783  return Options;
784 }
#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 764 of file shutdown.c.

765 {
767 }
#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 427 of file shutdown.c.

428 {
430 }
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

Referenced by OnShutDown().

◆ GetShutdownReasonUI()

static BOOL GetShutdownReasonUI ( VOID  )
static

Definition at line 70 of file shutdown.c.

71 {
73  DWORD dwValue, dwSize;
74  HKEY hKey;
75  LONG lRet;
76 
77  /* Query the policy value */
79  L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
80  0,
82  &hKey);
83  if (lRet == ERROR_SUCCESS)
84  {
85  dwValue = 0;
86  dwSize = sizeof(dwValue);
88  L"ShutdownReasonUI",
89  NULL,
90  NULL,
91  (LPBYTE)&dwValue,
92  &dwSize);
94 
95  return (dwValue != 0) ? TRUE : FALSE;
96  }
97 
98  /* Query the machine value */
100  L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
101  0,
103  &hKey);
104  if (lRet == ERROR_SUCCESS)
105  {
106  dwValue = 0;
107  dwSize = sizeof(dwValue);
109  L"ShutdownReasonUI",
110  NULL,
111  NULL,
112  (LPBYTE)&dwValue,
113  &dwSize);
114  RegCloseKey(hKey);
115 
116  return (dwValue != 0) ? TRUE : FALSE;
117  }
118 
119  /* Return the default value */
122  return FALSE;
123 
124  return FALSE;
125 // return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
126 }
#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:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShutdownDialog().

◆ IsDomainMember()

static BOOL IsDomainMember ( VOID  )
static

Definition at line 206 of file shutdown.c.

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

Referenced by ShellIsFriendlyUIActive().

◆ IsFriendlyUIActive()

static BOOL IsFriendlyUIActive ( VOID  )
static

Definition at line 130 of file shutdown.c.

131 {
132  DWORD dwType, dwValue, dwSize;
133  HKEY hKey;
134  LONG lRet;
135 
137  L"SYSTEM\\CurrentControlSet\\Control\\Windows",
138  0,
140  &hKey);
141  if (lRet != ERROR_SUCCESS)
142  return FALSE;
143 
144  /* CORE-17282 First check an optional ReactOS specific override, that Windows does not check.
145  We use this to allow users pairing 'Server'-configuration with FriendlyShutdown.
146  Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
147  dwValue = 0;
148  dwSize = sizeof(dwValue);
149  lRet = RegQueryValueExW(hKey,
150  L"EnforceFriendlyShutdown",
151  NULL,
152  &dwType,
153  (LPBYTE)&dwValue,
154  &dwSize);
155 
156  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue == 0x1)
157  {
158  RegCloseKey(hKey);
159  return TRUE;
160  }
161 
162  /* Check product version number */
163  dwValue = 0;
164  dwSize = sizeof(dwValue);
165  lRet = RegQueryValueExW(hKey,
166  L"CSDVersion",
167  NULL,
168  &dwType,
169  (LPBYTE)&dwValue,
170  &dwSize);
171  RegCloseKey(hKey);
172 
173  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != 0x300)
174  {
175  /* Allow Friendly UI only on Workstation */
176  return FALSE;
177  }
178 
179  /* Check LogonType value */
181  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
182  0,
184  &hKey);
185  if (lRet != ERROR_SUCCESS)
186  return FALSE;
187 
188  dwValue = 0;
189  dwSize = sizeof(dwValue);
190  lRet = RegQueryValueExW(hKey,
191  L"LogonType",
192  NULL,
193  &dwType,
194  (LPBYTE)&dwValue,
195  &dwSize);
196  RegCloseKey(hKey);
197 
198  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
199  return FALSE;
200 
201  return (dwValue != 0);
202 }
#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:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShellIsFriendlyUIActive().

◆ IsNetwareActive()

static BOOL IsNetwareActive ( VOID  )
static

Definition at line 214 of file shutdown.c.

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

Referenced by ShellIsFriendlyUIActive().

◆ IsShowHibernateButtonActive()

static BOOL IsShowHibernateButtonActive ( VOID  )
static

Definition at line 222 of file shutdown.c.

223 {
224  INT_PTR lRet;
225  HKEY hKey;
226  DWORD dwValue, dwSize;
227 
229  L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
230  0, KEY_QUERY_VALUE, &hKey);
231  if (lRet == ERROR_SUCCESS)
232  {
233  dwValue = 0;
234  dwSize = sizeof(dwValue);
235 
236  lRet = RegQueryValueExW(hKey,
237  L"ShowHibernateButton",
238  NULL, NULL,
239  (LPBYTE)&dwValue, &dwSize);
240  RegCloseKey(hKey);
241  if (lRet != ERROR_SUCCESS)
242  {
243  return FALSE;
244  }
245  return (dwValue != 0);
246  }
247  return FALSE;
248 }
#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:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShutdownDialog().

◆ LoadShutdownSelState()

DWORD LoadShutdownSelState ( VOID  )

Definition at line 433 of file shutdown.c.

434 {
435  LONG lRet;
436  HKEY hKeyCurrentUser, hKey;
437  DWORD dwValue, dwTemp, dwSize;
438 
439  /* Default to shutdown */
441 
442  /* Open the current user HKCU key */
443  lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
444  if (lRet == ERROR_SUCCESS)
445  {
446  /* Open the subkey */
447  lRet = RegOpenKeyExW(hKeyCurrentUser,
448  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
449  0, KEY_QUERY_VALUE, &hKey);
450  RegCloseKey(hKeyCurrentUser);
451  }
452  if (lRet != ERROR_SUCCESS)
453  return dwValue;
454 
455  /* Read the value */
456  dwSize = sizeof(dwTemp);
457  lRet = RegQueryValueExW(hKey,
458  L"Shutdown Setting",
459  NULL, NULL,
460  (LPBYTE)&dwTemp, &dwSize);
461  RegCloseKey(hKey);
462 
463  if (lRet == ERROR_SUCCESS)
464  {
465  switch (dwTemp)
466  {
468  dwValue = WLX_SAS_ACTION_LOGOFF;
469  break;
470 
473  break;
474 
477  break;
478 
479  // 0x08
480 
483  break;
484 
485  // 0x20
486 
489  break;
490 
491  // 0x80
492  }
493  }
494 
495  return dwValue;
496 }
#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:56

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

◆ OwnerDrawButtonSubclass()

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

Definition at line 500 of file shutdown.c.

505 {
506  PSHUTDOWN_DLG_CONTEXT pContext;
508 
509  int buttonID = GetDlgCtrlID(hButton);
510 
511  switch (uMsg)
512  {
513  case WM_MOUSEMOVE:
514  {
515  HWND hwndTarget;
517 
518  if (GetCapture() != hButton)
519  {
520  SetCapture(hButton);
521  if (buttonID == IDC_BUTTON_SHUTDOWN)
522  {
523  pContext->bIsButtonHot[0] = TRUE;
524  }
525  else if (buttonID == IDC_BUTTON_REBOOT)
526  {
527  pContext->bIsButtonHot[1] = TRUE;
528  }
529  else if (buttonID == IDC_BUTTON_SLEEP)
530  {
531  pContext->bIsButtonHot[2] = TRUE;
532  }
533  else if (buttonID == IDC_BUTTON_HIBERNATE)
534  {
535  pContext->bIsButtonHot[3] = TRUE;
536  }
538  }
539 
540  ClientToScreen(hButton, &pt);
541  hwndTarget = WindowFromPoint(pt);
542 
543  if (hwndTarget != hButton)
544  {
545  ReleaseCapture();
546  if (buttonID == IDC_BUTTON_SHUTDOWN)
547  {
548  pContext->bIsButtonHot[0] = FALSE;
549  }
550  else if (buttonID == IDC_BUTTON_REBOOT)
551  {
552  pContext->bIsButtonHot[1] = FALSE;
553  }
554  else if (buttonID == IDC_BUTTON_SLEEP)
555  {
556  pContext->bIsButtonHot[2] = FALSE;
557  }
558  else if (buttonID == IDC_BUTTON_HIBERNATE)
559  {
560  pContext->bIsButtonHot[3] = FALSE;
561  }
562  }
563  InvalidateRect(hButton, NULL, FALSE);
564  break;
565  }
566 
567  /* Whenever one of the buttons gets the keyboard focus, set it as default button */
568  case WM_SETFOCUS:
569  {
570  SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
571  break;
572  }
573 
574  /* Otherwise, set IDCANCEL as default button */
575  case WM_KILLFOCUS:
576  {
578  break;
579  }
580  }
581  return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
582 }
#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 DM_SETDEFID
Definition: winuser.h:2082
#define GetWindowLongPtrW
Definition: winuser.h:4805
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
#define WM_KILLFOCUS
Definition: winuser.h:1597
WNDPROC OldButtonProc
Definition: shutdown.c:65
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 GetParent(_In_ HWND)
HWND WINAPI SetCapture(_In_ HWND hWnd)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_BUTTON_REBOOT
Definition: resource.h:64
#define WM_MOUSEMOVE
Definition: winuser.h:1758
#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
#define WM_SETFOCUS
Definition: winuser.h:1596
#define IDCANCEL
Definition: winuser.h:825
LPARAM lParam
Definition: combotst.c:139

Referenced by ShutdownOnInit().

◆ ReplaceRequiredButton()

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

Definition at line 640 of file shutdown.c.

645 {
646  int destID = IDC_BUTTON_SLEEP;
647  int targetedID = IDC_BUTTON_HIBERNATE;
648  HWND hwndDest, hwndTarget;
649  RECT rect;
650  WCHAR szBuffer[30];
651 
652  /* If the sleep button has been already replaced earlier, bring sleep button back to its original position */
653  if (bIsSleepButtonReplaced)
654  {
655  destID = IDC_BUTTON_HIBERNATE;
656  targetedID = IDC_BUTTON_SLEEP;
657  }
658 
659  hwndDest = GetDlgItem(hDlg, destID);
660  hwndTarget = GetDlgItem(hDlg, targetedID);
661 
662  /* Get the position of the destination button */
663  GetWindowRect(hwndDest, &rect);
664 
665  /* Get the corrected translated coordinates which is relative to the client window */
666  MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
667 
668  /* Set the position of targeted button and hide the destination button */
669  SetWindowPos(hwndTarget,
670  HWND_TOP,
671  rect.left, rect.top,
672  0, 0,
674 
675  EnableWindow(hwndDest, FALSE);
676  ShowWindow(hwndDest, SW_HIDE);
677  EnableWindow(hwndTarget, TRUE);
678  ShowWindow(hwndTarget, SW_SHOW);
679  SetFocus(hwndTarget);
680 
681  if (bIsAltKeyPressed)
682  {
683  if (!bIsSleepButtonReplaced)
684  {
685  GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
686  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
687  }
688  else
689  {
690  GetDlgItemTextW(hDlg, IDC_BUTTON_SLEEP, szBuffer, _countof(szBuffer));
691  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
692  }
693  }
694  else
695  {
696  if (!bIsSleepButtonReplaced)
697  {
698  LoadStringW(hInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
699  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
700  }
701  else
702  {
703  LoadStringW(hInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
704  SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
705  }
706  }
707 }
#define IDC_BUTTON_SLEEP
Definition: resource.h:62
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
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:1233
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:1228
#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:1231
#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 710 of file shutdown.c.

712 {
713  LONG lRet;
714  HKEY hKeyCurrentUser, hKey;
715  DWORD dwValue = 0;
716 
717  /* Open the current user HKCU key */
718  lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
719  if (lRet == ERROR_SUCCESS)
720  {
721  /* Create the subkey */
722  lRet = RegCreateKeyExW(hKeyCurrentUser,
723  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
724  0, NULL,
727  NULL, &hKey, NULL);
728  RegCloseKey(hKeyCurrentUser);
729  }
730  if (lRet != ERROR_SUCCESS)
731  return;
732 
733  switch (ShutdownCode)
734  {
736  dwValue = WLX_SHUTDOWN_STATE_LOGOFF;
737  break;
738 
741  break;
742 
744  dwValue = WLX_SHUTDOWN_STATE_REBOOT;
745  break;
746 
748  dwValue = WLX_SHUTDOWN_STATE_SLEEP;
749  break;
750 
753  break;
754  }
755 
757  L"Shutdown Setting",
758  0, REG_DWORD,
759  (LPBYTE)&dwValue, sizeof(dwValue));
760  RegCloseKey(hKey);
761 }
#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 414 of file shutdown.c.

415 {
416  BOOL bActive;
417 
418  bActive = IsFriendlyUIActive();
419 
421  return FALSE;
422 
423  return bActive;
424 }
static BOOL IsDomainMember(VOID)
Definition: shutdown.c:206
static BOOL IsNetwareActive(VOID)
Definition: shutdown.c:214
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL IsFriendlyUIActive(VOID)
Definition: shutdown.c:130
static BOOL ForceFriendlyUI(VOID)
Definition: shutdown.c:252

Referenced by ShutdownDialog().

◆ ShellShutdownDialog()

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

Definition at line 1345 of file shutdown.c.

1349 {
1350  INT_PTR dlgValue;
1351  DWORD ShutdownOptions;
1352 
1353  /*
1354  * As we are called by the shell itself, don't use
1355  * the cached GINA context but use a local copy here.
1356  */
1357  GINA_CONTEXT gContext = { 0 };
1358  DWORD BufferSize;
1359 
1360  UNREFERENCED_PARAMETER(lpUsername);
1361 
1362  ShutdownOptions = GetAllowedShutdownOptions();
1363  if (bHideLogoff)
1364  ShutdownOptions &= ~WLX_SHUTDOWN_STATE_LOGOFF;
1365 
1366  /* Initialize our local GINA context */
1367  gContext.hDllInstance = hDllInstance;
1368  BufferSize = _countof(gContext.UserName);
1369  // NOTE: Only when this function is called, Win checks inside
1370  // HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1371  // value "Logon User Name", and determines whether it will display
1372  // the user name.
1373  GetUserNameW(gContext.UserName, &BufferSize);
1375 
1376  /* Load the shutdown dialog box */
1377  dlgValue = ShutdownDialog(hParent, ShutdownOptions, &gContext);
1378 
1379  /* Determine what to do based on user selection */
1380  if (dlgValue == IDOK)
1381  {
1383 
1384  switch (gContext.nShutdownAction)
1385  {
1386  case WLX_SAS_ACTION_LOGOFF:
1388 
1391 
1394 
1395  // 0x08
1396 
1398  return WLX_SHUTDOWN_STATE_SLEEP;
1399 
1400  // 0x20
1401 
1404 
1405  // 0x80
1406  }
1407  }
1408  /* Help file is called directly here */
1409  else if (dlgValue == IDHELP)
1410  {
1411  FIXME("Help is not implemented yet.");
1412  MessageBoxW(hParent, L"Help is not implemented yet.", L"Message", MB_OK | MB_ICONEXCLAMATION);
1413  }
1414  else if (dlgValue == -1)
1415  {
1416  ERR("Failed to create dialog\n");
1417  }
1418 
1419  return 0;
1420 }
#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:433
#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:1189
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:770
#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:710
#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 1428 of file shutdown.c.

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

◆ ShutdownDialog()

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

Definition at line 1189 of file shutdown.c.

1193 {
1194  INT_PTR ret;
1196  BOOL bIsAltKeyPressed = FALSE;
1197  DWORD ShutdownDialogId = IDD_SHUTDOWN;
1198  MSG Msg;
1199  HWND hDlg;
1200 
1201 #if 0
1202  DWORD ShutdownOptions;
1203 
1204  // FIXME: User impersonation!!
1205  pgContext->nShutdownAction = LoadShutdownSelState();
1206  ShutdownOptions = GetAllowedShutdownOptions();
1207 #endif
1208 
1209  Context.pgContext = pgContext;
1210  Context.ShutdownOptions = ShutdownOptions;
1211  Context.bCloseDlg = FALSE;
1212  Context.bReasonUI = GetShutdownReasonUI();
1213  Context.bFriendlyUI = ShellIsFriendlyUIActive();
1214 
1215  if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1216  {
1217  Context.bIsDialogModal = TRUE;
1218  ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1219  pgContext->hDllInstance,
1221  hwndDlg,
1223  (LPARAM)&Context);
1224  }
1225  else
1226  {
1227  if (Context.bFriendlyUI)
1228  {
1230  {
1231  ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1232  }
1233  else
1234  {
1235  ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1236  }
1237  }
1238 
1239  Context.bIsDialogModal = FALSE;
1240  hDlg = CreateDialogParamW(pgContext->hDllInstance,
1241  MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : ShutdownDialogId),
1242  hwndDlg,
1244  (LPARAM)&Context);
1245 
1246  ShowWindow(hDlg, SW_SHOW);
1247 
1248  /* Detect either Alt or Shift key have been pressed or released */
1249  while (GetMessageW(&Msg, NULL, 0, 0))
1250  {
1251  if (!IsDialogMessageW(hDlg, &Msg))
1252  {
1255  }
1256 
1257  switch (Msg.message)
1258  {
1259  case WM_SYSKEYDOWN:
1260  {
1261  /* If the Alt key has been pressed once, add prefix to static controls */
1262  if (Msg.wParam == VK_MENU && !bIsAltKeyPressed)
1263  {
1264  AddPrefixToStaticTexts(hDlg, Context.bIsSleepButtonReplaced);
1265  bIsAltKeyPressed = TRUE;
1266  }
1267  }
1268  break;
1269 
1270  case WM_KEYDOWN:
1271  {
1272  /*
1273  * If the Shift key has been pressed once, and both hibernate button and sleep button are enabled
1274  * replace the sleep button with hibernate button
1275  */
1276  if (Msg.wParam == VK_SHIFT)
1277  {
1278  if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && !Context.bIsSleepButtonReplaced)
1279  {
1281  {
1282  ReplaceRequiredButton(hDlg,
1283  pgContext->hDllInstance,
1284  bIsAltKeyPressed,
1285  Context.bIsSleepButtonReplaced);
1286  Context.bIsSleepButtonReplaced = TRUE;
1287  }
1288  }
1289  }
1290  }
1291  break;
1292 
1293  case WM_KEYUP:
1294  {
1295  /* If the Shift key has been released after being pressed, replace the hibernate button with sleep button again */
1296  if (Msg.wParam == VK_SHIFT)
1297  {
1298  if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && Context.bIsSleepButtonReplaced)
1299  {
1301  {
1302  ReplaceRequiredButton(hDlg,
1303  pgContext->hDllInstance,
1304  bIsAltKeyPressed,
1305  Context.bIsSleepButtonReplaced);
1306  Context.bIsSleepButtonReplaced = FALSE;
1307  }
1308  }
1309  }
1310  }
1311  break;
1312  }
1313  }
1314  ret = Msg.wParam;
1315  }
1316 
1317 #if 0
1318  // FIXME: User impersonation!!
1319  if (ret == IDOK)
1320  SaveShutdownSelState(pgContext->nShutdownAction);
1321 #endif
1322 
1323  return ret;
1324 }
#define IDD_SHUTDOWN
Definition: resource.h:43
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:222
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:433
static INT_PTR CALLBACK ShutdownDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:1012
VOID AddPrefixToStaticTexts(HWND hDlg, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:585
#define TRUE
Definition: types.h:120
VOID ReplaceRequiredButton(HWND hDlg, HINSTANCE hInstance, BOOL bIsAltKeyPressed, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:640
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define VK_MENU
Definition: winuser.h:2180
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:770
#define VK_SHIFT
Definition: winuser.h:2178
#define WM_KEYDOWN
Definition: winuser.h:1698
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:1699
unsigned long DWORD
Definition: ntddk_ex.h:95
struct @1586 Msg[]
int ret
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:70
#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:1702
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:710
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:414

Referenced by OnShutDown(), and ShellShutdownDialog().

◆ ShutdownDialogProc()

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

Definition at line 1012 of file shutdown.c.

1017 {
1018  PSHUTDOWN_DLG_CONTEXT pContext;
1019 
1021 
1022  switch (uMsg)
1023  {
1024  case WM_INITDIALOG:
1025  {
1026  pContext = (PSHUTDOWN_DLG_CONTEXT)lParam;
1027  SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pContext);
1028 
1029  ShutdownOnInit(hDlg, pContext);
1030 
1031  /* Draw the logo bitmap */
1032  pContext->hBitmap =
1034  return TRUE;
1035  }
1036 
1037  case WM_DESTROY:
1038  DeleteObject(pContext->hBitmap);
1039  DeleteObject(pContext->hBrush);
1040  DeleteObject(pContext->hImageStrip);
1041  DeleteObject(pContext->hfFont);
1042 
1043  /* Remove the subclass from the buttons */
1044  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1045  {
1047  }
1048  return TRUE;
1049 
1050  case WM_ACTIVATE:
1051  {
1052  /*
1053  * If the user deactivates the shutdown dialog (it loses its focus
1054  * while the dialog is not being closed), then destroy the dialog
1055  * and cancel shutdown.
1056  */
1057  if (LOWORD(wParam) == WA_INACTIVE)
1058  {
1059  if (!pContext->bCloseDlg)
1060  {
1061  pContext->bCloseDlg = TRUE;
1062 
1063  if (pContext->bIsDialogModal)
1064  {
1065  EndDialog(hDlg, 0);
1066  }
1067  else
1068  {
1069  DestroyWindow(hDlg);
1070  PostQuitMessage(0);
1071  }
1072  }
1073  }
1074  return FALSE;
1075  }
1076 
1077  case WM_PAINT:
1078  {
1079  PAINTSTRUCT ps;
1080  if (pContext->hBitmap)
1081  {
1082  BeginPaint(hDlg, &ps);
1083  DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1084  EndPaint(hDlg, &ps);
1085  }
1086  return TRUE;
1087  }
1088 
1089  case WM_CLOSE:
1090  pContext->bCloseDlg = TRUE;
1091 
1092  if (pContext->bIsDialogModal)
1093  {
1094  EndDialog(hDlg, IDCANCEL);
1095  }
1096  else
1097  {
1098  DestroyWindow(hDlg);
1100  }
1101  break;
1102 
1103  case WM_COMMAND:
1104  switch (LOWORD(wParam))
1105  {
1106  case IDC_BUTTON_SHUTDOWN:
1107  ExitWindowsEx(EWX_SHUTDOWN, SHTDN_REASON_MAJOR_OTHER);
1108  break;
1109 
1110  case IDC_BUTTON_REBOOT:
1111  ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_OTHER);
1112  break;
1113 
1114  case IDC_BUTTON_SLEEP:
1116  break;
1117 
1118  case IDOK:
1119  ShutdownOnOk(hDlg, pContext->pgContext);
1120 
1121  /* Fall back */
1122  case IDCANCEL:
1123  case IDHELP:
1124  pContext->bCloseDlg = TRUE;
1125 
1126  if (pContext->bIsDialogModal)
1127  {
1128  EndDialog(hDlg, LOWORD(wParam));
1129  }
1130  else
1131  {
1132  DestroyWindow(hDlg);
1134  }
1135  break;
1136 
1137  case IDC_SHUTDOWN_ACTION:
1138  UpdateShutdownDesc(hDlg, pContext);
1139  break;
1140  }
1141  break;
1142 
1143  case WM_CTLCOLORSTATIC:
1144  {
1145  /* Either make background transparent or fill it with color for required static controls */
1146  HDC hdcStatic = (HDC)wParam;
1147  UINT StaticID = (UINT)GetWindowLongPtrW((HWND)lParam, GWL_ID);
1148 
1149  switch (StaticID)
1150  {
1151  case IDC_TURN_OFF_STATIC:
1152  SetTextColor(hdcStatic, DARK_GREY_COLOR);
1153  SetBkMode(hdcStatic, TRANSPARENT);
1155 
1156  case IDC_HIBERNATE_STATIC:
1157  case IDC_SHUTDOWN_STATIC:
1158  case IDC_SLEEP_STATIC:
1159  case IDC_RESTART_STATIC:
1160  SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1161  SetBkMode(hdcStatic, TRANSPARENT);
1162  return (LONG_PTR)pContext->hBrush;
1163  }
1164  return FALSE;
1165  }
1166 
1167  case WM_DRAWITEM:
1168  {
1169  /* Draw bitmaps on required buttons */
1171  switch (pdis->CtlID)
1172  {
1173  case IDC_BUTTON_SHUTDOWN:
1174  case IDC_BUTTON_REBOOT:
1175  case IDC_BUTTON_SLEEP:
1176  case IDC_BUTTON_HIBERNATE:
1177  return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1178  }
1179  break;
1180  }
1181 
1182  default:
1183  return FALSE;
1184  }
1185  return TRUE;
1186 }
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:1755
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:839
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:4805
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
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
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:1592
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:306
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_SHUTDOWN_STATIC
Definition: resource.h:58
#define WM_CLOSE
Definition: winuser.h:1604
#define HOLLOW_BRUSH
Definition: wingdi.h:898
WNDPROC OldButtonProc
Definition: shutdown.c:65
#define WM_PAINT
Definition: winuser.h:1603
#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:1723
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define GWLP_WNDPROC
Definition: treelist.c:66
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:898
#define WM_ACTIVATE
Definition: winuser.h:1595
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:1628
#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:988
#define SetWindowLongPtrW
Definition: winuser.h:5322
#define WA_INACTIVE
Definition: winuser.h:2598
#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:1722
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:787

Referenced by ShutdownDialog().

◆ ShutdownOnInit()

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

Definition at line 839 of file shutdown.c.

842 {
843  PGINA_CONTEXT pgContext = pContext->pgContext;
844  HWND hwndList;
845  INT idx, count, i;
846  WCHAR szBuffer[256];
847  WCHAR szBuffer2[256];
848  HDC hdc;
849  LONG lfHeight;
850 
851  /* Create font for the IDC_TURN_OFF_STATIC static control */
852  hdc = GetDC(hDlg);
853  lfHeight = -MulDiv(FONT_POINT_SIZE, GetDeviceCaps(hdc, LOGPIXELSY), 72);
854  ReleaseDC(hDlg, hdc);
855  pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
856  SendDlgItemMessageW(hDlg, IDC_TURN_OFF_STATIC, WM_SETFONT, (WPARAM)pContext->hfFont, TRUE);
857 
858  /* Create a brush for static controls for fancy shut down dialog */
859  pContext->hBrush = CreateSolidBrush(DARK_GREY_COLOR);
860 
861  pContext->hImageStrip = LoadBitmapW(pgContext->hDllInstance, MAKEINTRESOURCEW(IDB_IMAGE_STRIP));
862 
863  hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
864 
865  /* Clear the content before it's used */
866  SendMessageW(hwndList, CB_RESETCONTENT, 0, 0);
867 
868  /* Set the boolean flags to false */
869  pContext->bIsSleepButtonReplaced = FALSE;
870 
871  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
872  {
873  pContext->bIsButtonHot[i] = FALSE;
874  }
875 
876  /* Log off */
877  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_LOGOFF)
878  {
879  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_LOGOFF, szBuffer, _countof(szBuffer));
880  StringCchPrintfW(szBuffer2, _countof(szBuffer2), szBuffer, pgContext->UserName);
881  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer2);
882  if (idx != CB_ERR)
884  }
885 
886  /* Shut down - DEFAULT */
887  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_POWER_OFF)
888  {
889  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SHUTDOWN, szBuffer, _countof(szBuffer));
890  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
891  if (idx != CB_ERR)
893  }
894  else if (pContext->bFriendlyUI)
895  {
897  }
898 
899  /* Restart */
900  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_REBOOT)
901  {
902  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_RESTART, szBuffer, _countof(szBuffer));
903  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
904  if (idx != CB_ERR)
906  }
907  else if (pContext->bFriendlyUI)
908  {
910  }
911 
912  // if (pContext->ShutdownOptions & 0x08) {}
913 
914  /* Sleep */
915  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP)
916  {
917  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
918  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
919  if (idx != CB_ERR)
921  }
922  else if (pContext->bFriendlyUI)
923  {
925  }
926 
927  // if (pContext->ShutdownOptions & 0x20) {}
928 
929  /* Hibernate */
930  if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE)
931  {
932  LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
933  idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
934  if (idx != CB_ERR)
936  }
937  else if (pContext->bFriendlyUI)
938  {
940  }
941 
942  // if (pContext->ShutdownOptions & 0x80) {}
943 
944  /* Set the default shut down selection */
945  count = SendMessageW(hwndList, CB_GETCOUNT, 0, 0);
946  for (i = 0; i < count; i++)
947  {
948  if (SendMessageW(hwndList, CB_GETITEMDATA, i, 0) == pgContext->nShutdownAction)
949  {
950  SendMessageW(hwndList, CB_SETCURSEL, i, 0);
951  break;
952  }
953  }
954 
955  /* Create tool tips for the buttons of fancy log off dialog */
959  pContext->pgContext->hDllInstance);
962  hDlg, IDS_SHUTDOWN_SHUTDOWN,
963  pContext->pgContext->hDllInstance);
966  hDlg, IDS_SHUTDOWN_RESTART,
967  pContext->pgContext->hDllInstance);
970  hDlg, IDS_SHUTDOWN_SLEEP,
971  pContext->pgContext->hDllInstance);
972 
973  /* Gather old button func */
974  pContext->OldButtonProc = (WNDPROC)GetWindowLongPtrW(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), GWLP_WNDPROC);
975 
976  /* Make buttons to remember pContext and subclass the buttons */
977  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
978  {
981  }
982 
983  /* Update the choice description based on the current selection */
984  UpdateShutdownDesc(hDlg, pContext);
985 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define CB_SETITEMDATA
Definition: winuser.h:1949
#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
static INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:500
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define CB_GETITEMDATA
Definition: winuser.h:1933
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:4805
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#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
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:1919
#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:1942
#define CB_ERR
Definition: winuser.h:2411
#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:1944
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2882
#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:1633
#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:1925
#define SetWindowLongPtrW
Definition: winuser.h:5322
#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:605
static VOID UpdateShutdownDesc(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:787

Referenced by ShutdownDialogProc().

◆ ShutdownOnOk()

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

Definition at line 988 of file shutdown.c.

991 {
992  INT idx;
993 
994  idx = SendDlgItemMessageW(hDlg,
996  CB_GETCURSEL,
997  0,
998  0);
999  if (idx != CB_ERR)
1000  {
1001  pgContext->nShutdownAction =
1002  SendDlgItemMessageW(hDlg,
1005  idx,
1006  0);
1007  }
1008 }
#define CB_GETITEMDATA
Definition: winuser.h:1933
int32_t INT
Definition: typedefs.h:58
#define CB_GETCURSEL
Definition: winuser.h:1926
unsigned int idx
Definition: utils.c:41
#define CB_ERR
Definition: winuser.h:2411
#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 787 of file shutdown.c.

790 {
791  UINT DescId = 0;
792  DWORD ShutdownCode;
793  WCHAR szBuffer[256];
794 
795  ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETCURSEL, 0, 0);
796  if (ShutdownCode == CB_ERR) // Invalid selection
797  return;
798 
799  ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETITEMDATA, ShutdownCode, 0);
800 
801  switch (ShutdownCode)
802  {
804  DescId = IDS_SHUTDOWN_LOGOFF_DESC;
805  break;
806 
809  break;
810 
812  DescId = IDS_SHUTDOWN_RESTART_DESC;
813  break;
814 
816  DescId = IDS_SHUTDOWN_SLEEP_DESC;
817  break;
818 
821  break;
822 
823  default:
824  break;
825  }
826 
827  LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
828  SetDlgItemTextW(hDlg, IDC_SHUTDOWN_DESCRIPTION, szBuffer);
829 
830  if (pContext->bReasonUI)
831  {
835  }
836 }
#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:1933
#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:1926
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:2411
#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().