ReactOS 0.4.15-dev-7931-gfd331f1
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)
 
#define SHUTDOWN_BUTTON_HOT   0
 
#define REBOOT_BUTTON_HOT   1
 
#define SLEEP_BUTTON_HOT   2
 
#define HIBERNATE_BUTTON_HOT   3
 

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 CreateToolTipForButtons (int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
 
VOID EndFriendlyDialog (HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
 
VOID ChangeRequiredButton (HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
 
VOID OnTimer (HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
 
VOID SaveShutdownSelState (IN DWORD ShutdownCode)
 
DWORD GetDefaultShutdownOptions (VOID)
 
DWORD GetAllowedShutdownOptions (VOID)
 
static VOID UpdateShutdownDesc (IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
 
static VOID ShutdownOnFriendlyInit (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.

◆ HIBERNATE_BUTTON_HOT

#define HIBERNATE_BUTTON_HOT   3

Definition at line 55 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.

◆ REBOOT_BUTTON_HOT

#define REBOOT_BUTTON_HOT   1

Definition at line 53 of file shutdown.c.

◆ SHUTDOWN_BUTTON_HOT

#define SHUTDOWN_BUTTON_HOT   0

Definition at line 52 of file shutdown.c.

◆ SLEEP_BUTTON_HOT

#define SLEEP_BUTTON_HOT   2

Definition at line 54 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

◆ ChangeRequiredButton()

VOID ChangeRequiredButton ( HWND  hDlg,
PSHUTDOWN_DLG_CONTEXT  pContext 
)

Definition at line 651 of file shutdown.c.

654{
655 int destID = IDC_BUTTON_SLEEP;
656 int targetedID = IDC_BUTTON_HIBERNATE;
657 HWND hwndDest, hwndTarget;
658 RECT rect;
659 WCHAR szBuffer[30];
660
661 /* If the sleep button has been already replaced earlier, bring sleep button back to its original position */
662 if (pContext->bIsSleepButtonReplaced)
663 {
664 destID = IDC_BUTTON_HIBERNATE;
665 targetedID = IDC_BUTTON_SLEEP;
666 }
667
668 hwndDest = GetDlgItem(hDlg, destID);
669 hwndTarget = GetDlgItem(hDlg, targetedID);
670
671 /* Get the position of the destination button */
672 GetWindowRect(hwndDest, &rect);
673
674 /* Get the corrected translated coordinates which is relative to the client window */
675 MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
676
677 /* Set the position of targeted button and hide the destination button */
678 SetWindowPos(hwndTarget,
679 HWND_TOP,
680 rect.left, rect.top,
681 0, 0,
683
684 EnableWindow(hwndDest, FALSE);
685 ShowWindow(hwndDest, SW_HIDE);
686 EnableWindow(hwndTarget, TRUE);
687 ShowWindow(hwndTarget, SW_SHOW);
688 SetFocus(hwndTarget);
689
690 if (!pContext->bIsSleepButtonReplaced)
691 {
692 LoadStringW(pContext->pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
693 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
694 }
695 else
696 {
697 LoadStringW(pContext->pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
698 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
699 }
700
701 InvalidateRect(hDlg, NULL, FALSE);
702}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:64
#define IDS_SHUTDOWN_SLEEP
Definition: resource.h:117
#define IDC_SLEEP_STATIC
Definition: resource.h:57
#define IDC_BUTTON_SLEEP
Definition: resource.h:63
#define IDS_SHUTDOWN_HIBERNATE
Definition: resource.h:118
#define _countof(array)
Definition: sndvol32.h:68
& rect
Definition: startmenu.cpp:1413
HANDLE hDllInstance
Definition: msgina.h:37
PGINA_CONTEXT pgContext
Definition: shutdown.c:59
BOOL bIsSleepButtonReplaced
Definition: shutdown.c:67
#define SW_HIDE
Definition: winuser.h:768
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define SWP_NOSIZE
Definition: winuser.h:1245
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define HWND_DESKTOP
Definition: winuser.h:1209
#define HWND_TOP
Definition: winuser.h:1207
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SW_SHOW
Definition: winuser.h:775
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1247
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnTimer().

◆ CreateToolTipForButtons()

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

Definition at line 592 of file shutdown.c.

598{
599 HWND hwndTool, hwndTip;
600 WCHAR szBuffer[256];
601 TTTOOLINFOW tool;
602
603 hwndTool = GetDlgItem(hDlg, controlID);
604
605 tool.cbSize = sizeof(tool);
606 tool.hwnd = hDlg;
608 tool.uId = (UINT_PTR)hwndTool;
609
610 /* Create the tooltip */
615 hDlg, NULL, hInst, NULL);
616
617 /* Associate the tooltip with the tool. */
618 LoadStringW(hInst, detailID, szBuffer, _countof(szBuffer));
619 tool.lpszText = szBuffer;
620 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
621 LoadStringW(hInst, titleID, szBuffer, _countof(szBuffer));
622 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
623 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
624}
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_POPUP
Definition: pedump.c:616
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define TTI_NONE
Definition: commctrl.h:1779
#define TTM_SETTITLEW
Definition: commctrl.h:1828
#define TTF_IDISHWND
Definition: commctrl.h:1764
#define TTF_SUBCLASS
Definition: commctrl.h:1767
#define TTM_ADDTOOLW
Definition: commctrl.h:1787
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1819
#define TTS_BALLOON
Definition: commctrl.h:1761
UINT_PTR uId
Definition: commctrl.h:1743
LPWSTR lpszText
Definition: commctrl.h:1746
LONG_PTR LPARAM
Definition: windef.h:208
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)
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ShutdownOnFriendlyInit().

◆ DrawIconOnOwnerDrawnButtons()

static BOOL DrawIconOnOwnerDrawnButtons ( DRAWITEMSTRUCT pdis,
PSHUTDOWN_DLG_CONTEXT  pContext 
)
static

Definition at line 314 of file shutdown.c.

317{
318 BOOL bRet;
319 HDC hdcMem;
320 HBITMAP hbmOld;
321 int y;
322 RECT rect;
323
325 hbmOld = SelectObject(hdcMem, pContext->hImageStrip);
326 rect = pdis->rcItem;
327
328 /* Check the button ID for revelant bitmap to be used */
329 switch (pdis->CtlID)
330 {
332 {
333 switch (pdis->itemAction)
334 {
335 case ODA_DRAWENTIRE:
336 case ODA_FOCUS:
337 case ODA_SELECT:
338 {
340 if (pdis->itemState & ODS_SELECTED)
341 {
343 }
344 else if (pContext->bIsButtonHot[SHUTDOWN_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
345 {
347 }
348 break;
349 }
350 }
351 break;
352 }
353
355 {
356 switch (pdis->itemAction)
357 {
358 case ODA_DRAWENTIRE:
359 case ODA_FOCUS:
360 case ODA_SELECT:
361 {
363 if (pdis->itemState & ODS_SELECTED)
364 {
366 }
367 else if (pContext->bIsButtonHot[REBOOT_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
368 {
370 }
371 break;
372 }
373 }
374 break;
375 }
376
378 case IDC_BUTTON_SLEEP:
379 {
380 switch (pdis->itemAction)
381 {
382 case ODA_DRAWENTIRE:
383 case ODA_FOCUS:
384 case ODA_SELECT:
385 {
386 y = BUTTON_SLEEP;
387 if (pdis->itemState & ODS_DISABLED)
388 {
390 }
391 else if (pdis->itemState & ODS_SELECTED)
392 {
394 }
395 else if ((pdis->CtlID == IDC_BUTTON_SLEEP && pContext->bIsButtonHot[SLEEP_BUTTON_HOT]) ||
397 (pdis->itemState & ODS_FOCUS))
398 {
400 }
401 break;
402 }
403 }
404 break;
405 }
406 }
407
408 /* Draw it on the required button */
409 bRet = BitBlt(pdis->hDC,
410 (rect.right - rect.left - CX_BITMAP) / 2,
411 (rect.bottom - rect.top - CY_BITMAP) / 2,
413
414 SelectObject(hdcMem, hbmOld);
416
417 return bRet;
418}
#define IDC_BUTTON_REBOOT
Definition: resource.h:62
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:61
#define BUTTON_SLEEP_DISABLED
Definition: shutdown.c:49
#define SLEEP_BUTTON_HOT
Definition: shutdown.c:54
#define BUTTON_REBOOT_PRESSED
Definition: shutdown.c:44
#define REBOOT_BUTTON_HOT
Definition: shutdown.c:53
#define BUTTON_SLEEP_FOCUSED
Definition: shutdown.c:48
#define CX_BITMAP
Definition: shutdown.c:34
#define BUTTON_SHUTDOWN_PRESSED
Definition: shutdown.c:41
#define SHUTDOWN_BUTTON_HOT
Definition: shutdown.c:52
#define BUTTON_SHUTDOWN
Definition: shutdown.c:40
#define BUTTON_SLEEP_PRESSED
Definition: shutdown.c:47
#define BUTTON_REBOOT
Definition: shutdown.c:43
#define CY_BITMAP
Definition: shutdown.c:35
#define BUTTON_REBOOT_FOCUSED
Definition: shutdown.c:45
#define HIBERNATE_BUTTON_HOT
Definition: shutdown.c:55
#define BUTTON_SLEEP
Definition: shutdown.c:46
#define BUTTON_SHUTDOWN_FOCUSED
Definition: shutdown.c:42
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
Definition: shutdown.c:70
HDC hdcMem
Definition: welcome.c:104
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
#define ODS_DISABLED
Definition: winuser.h:2547
#define ODS_SELECTED
Definition: winuser.h:2545
#define ODA_DRAWENTIRE
Definition: winuser.h:2542
#define ODA_FOCUS
Definition: winuser.h:2544
#define ODA_SELECT
Definition: winuser.h:2543
#define ODS_FOCUS
Definition: winuser.h:2549

Referenced by ShutdownDialogProc().

◆ EndFriendlyDialog()

VOID EndFriendlyDialog ( HWND  hDlg,
PSHUTDOWN_DLG_CONTEXT  pContext 
)

Definition at line 627 of file shutdown.c.

630{
631 if (pContext->bTimer)
632 {
633 KillTimer(hDlg, pContext->iTimer);
634 }
635
636 DeleteObject(pContext->hBitmap);
637 DeleteObject(pContext->hBrush);
638 DeleteObject(pContext->hImageStrip);
639 DeleteObject(pContext->hfFont);
640
641 /* Remove the subclass from the buttons */
642 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
643 {
646 (LONG_PTR)pContext->OldButtonProc);
647 }
648}
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:37
pKey DeleteObject()
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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WNDPROC OldButtonProc
Definition: shutdown.c:73
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
Definition: winuser.h:5346

Referenced by ShutdownDialogProc().

◆ ForceFriendlyUI()

static BOOL ForceFriendlyUI ( VOID  )
static

Definition at line 260 of file shutdown.c.

261{
262 DWORD dwType, dwValue, dwSize;
263 HKEY hKey;
264 LONG lRet;
265
267 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
268 0,
270 &hKey);
271 if (lRet == ERROR_SUCCESS)
272 {
273 dwValue = 0;
274 dwSize = sizeof(dwValue);
275 lRet = RegQueryValueExW(hKey,
276 L"ForceFriendlyUI",
277 NULL,
278 &dwType,
279 (LPBYTE)&dwValue,
280 &dwSize);
282
283 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
284 return (dwValue != 0);
285 }
286
288 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
289 0,
291 &hKey);
292 if (lRet == ERROR_SUCCESS)
293 {
294 dwValue = 0;
295 dwSize = sizeof(dwValue);
296 lRet = RegQueryValueExW(hKey,
297 L"ForceFriendlyUI",
298 NULL,
299 &dwType,
300 (LPBYTE)&dwValue,
301 &dwSize);
302
304
305 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
306 return (dwValue != 0);
307 }
308
309 return FALSE;
310}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ShellIsFriendlyUIActive().

◆ GetAllowedShutdownOptions()

DWORD GetAllowedShutdownOptions ( VOID  )

Definition at line 783 of file shutdown.c.

784{
785 DWORD Options = 0;
786
787 // FIXME: Compute those options accordings to current user's rights!
789
792
795
796 return Options;
797}
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534

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

◆ GetDefaultShutdownOptions()

DWORD GetDefaultShutdownOptions ( VOID  )

Definition at line 777 of file shutdown.c.

Referenced by OnShutDown().

◆ GetDefaultShutdownSelState()

DWORD GetDefaultShutdownSelState ( VOID  )

Definition at line 435 of file shutdown.c.

436{
438}
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

Referenced by OnShutDown().

◆ GetShutdownReasonUI()

static BOOL GetShutdownReasonUI ( VOID  )
static

Definition at line 78 of file shutdown.c.

79{
81 DWORD dwValue, dwSize;
82 HKEY hKey;
83 LONG lRet;
84
85 /* Query the policy value */
87 L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
88 0,
90 &hKey);
91 if (lRet == ERROR_SUCCESS)
92 {
93 dwValue = 0;
94 dwSize = sizeof(dwValue);
96 L"ShutdownReasonUI",
97 NULL,
98 NULL,
99 (LPBYTE)&dwValue,
100 &dwSize);
102
103 return (dwValue != 0) ? TRUE : FALSE;
104 }
105
106 /* Query the machine value */
108 L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
109 0,
111 &hKey);
112 if (lRet == ERROR_SUCCESS)
113 {
114 dwValue = 0;
115 dwSize = sizeof(dwValue);
117 L"ShutdownReasonUI",
118 NULL,
119 NULL,
120 (LPBYTE)&dwValue,
121 &dwSize);
123
124 return (dwValue != 0) ? TRUE : FALSE;
125 }
126
127 /* Return the default value */
130 return FALSE;
131
132 return FALSE;
133// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
134}
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
#define GetVersionEx
Definition: winbase.h:3852

Referenced by ShutdownDialog().

◆ IsDomainMember()

static BOOL IsDomainMember ( VOID  )
static

Definition at line 214 of file shutdown.c.

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

Referenced by ShellIsFriendlyUIActive().

◆ IsFriendlyUIActive()

static BOOL IsFriendlyUIActive ( VOID  )
static

Definition at line 138 of file shutdown.c.

139{
140 DWORD dwType, dwValue, dwSize;
141 HKEY hKey;
142 LONG lRet;
143
145 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
146 0,
148 &hKey);
149 if (lRet != ERROR_SUCCESS)
150 return FALSE;
151
152 /* CORE-17282 First check an optional ReactOS specific override, that Windows does not check.
153 We use this to allow users pairing 'Server'-configuration with FriendlyShutdown.
154 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
155 dwValue = 0;
156 dwSize = sizeof(dwValue);
157 lRet = RegQueryValueExW(hKey,
158 L"EnforceFriendlyShutdown",
159 NULL,
160 &dwType,
161 (LPBYTE)&dwValue,
162 &dwSize);
163
164 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue == 0x1)
165 {
167 return TRUE;
168 }
169
170 /* Check product version number */
171 dwValue = 0;
172 dwSize = sizeof(dwValue);
173 lRet = RegQueryValueExW(hKey,
174 L"CSDVersion",
175 NULL,
176 &dwType,
177 (LPBYTE)&dwValue,
178 &dwSize);
180
181 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != 0x300)
182 {
183 /* Allow Friendly UI only on Workstation */
184 return FALSE;
185 }
186
187 /* Check LogonType value */
189 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
190 0,
192 &hKey);
193 if (lRet != ERROR_SUCCESS)
194 return FALSE;
195
196 dwValue = 0;
197 dwSize = sizeof(dwValue);
198 lRet = RegQueryValueExW(hKey,
199 L"LogonType",
200 NULL,
201 &dwType,
202 (LPBYTE)&dwValue,
203 &dwSize);
205
206 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
207 return FALSE;
208
209 return (dwValue != 0);
210}

Referenced by ShellIsFriendlyUIActive().

◆ IsNetwareActive()

static BOOL IsNetwareActive ( VOID  )
static

Definition at line 222 of file shutdown.c.

223{
225 return FALSE;
226}

Referenced by ShellIsFriendlyUIActive().

◆ IsShowHibernateButtonActive()

static BOOL IsShowHibernateButtonActive ( VOID  )
static

Definition at line 230 of file shutdown.c.

231{
232 INT_PTR lRet;
233 HKEY hKey;
234 DWORD dwValue, dwSize;
235
237 L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
238 0, KEY_QUERY_VALUE, &hKey);
239 if (lRet == ERROR_SUCCESS)
240 {
241 dwValue = 0;
242 dwSize = sizeof(dwValue);
243
244 lRet = RegQueryValueExW(hKey,
245 L"ShowHibernateButton",
246 NULL, NULL,
247 (LPBYTE)&dwValue, &dwSize);
249 if (lRet != ERROR_SUCCESS)
250 {
251 return FALSE;
252 }
253 return (dwValue != 0);
254 }
255 return FALSE;
256}
int32_t INT_PTR
Definition: typedefs.h:64

Referenced by ShutdownDialog().

◆ LoadShutdownSelState()

DWORD LoadShutdownSelState ( VOID  )

Definition at line 441 of file shutdown.c.

442{
443 LONG lRet;
444 HKEY hKeyCurrentUser, hKey;
445 DWORD dwValue, dwTemp, dwSize;
446
447 /* Default to shutdown */
449
450 /* Open the current user HKCU key */
451 lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
452 if (lRet == ERROR_SUCCESS)
453 {
454 /* Open the subkey */
455 lRet = RegOpenKeyExW(hKeyCurrentUser,
456 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
457 0, KEY_QUERY_VALUE, &hKey);
458 RegCloseKey(hKeyCurrentUser);
459 }
460 if (lRet != ERROR_SUCCESS)
461 return dwValue;
462
463 /* Read the value */
464 dwSize = sizeof(dwTemp);
465 lRet = RegQueryValueExW(hKey,
466 L"Shutdown Setting",
467 NULL, NULL,
468 (LPBYTE)&dwTemp, &dwSize);
470
471 if (lRet == ERROR_SUCCESS)
472 {
473 switch (dwTemp)
474 {
476 dwValue = WLX_SAS_ACTION_LOGOFF;
477 break;
478
481 break;
482
485 break;
486
487 // 0x08
488
491 break;
492
493 // 0x20
494
497 break;
498
499 // 0x80
500 }
501 }
502
503 return dwValue;
504}
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56

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

◆ OnTimer()

VOID OnTimer ( HWND  hDlg,
PSHUTDOWN_DLG_CONTEXT  pContext 
)

Definition at line 704 of file shutdown.c.

707{
708 BOOL ReplaceButton = !!(GetKeyState(VK_SHIFT) & 0x8000);
709
710 if (ReplaceButton && !pContext->bIsSleepButtonReplaced)
711 {
712 ChangeRequiredButton(hDlg, pContext);
713 pContext->bIsSleepButtonReplaced = TRUE;
714 }
715 else if (!ReplaceButton && pContext->bIsSleepButtonReplaced)
716 {
717 ChangeRequiredButton(hDlg, pContext);
718 pContext->bIsSleepButtonReplaced = FALSE;
719 }
720}
VOID ChangeRequiredButton(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:651
#define VK_SHIFT
Definition: winuser.h:2202
SHORT WINAPI GetKeyState(_In_ int)

◆ OwnerDrawButtonSubclass()

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

Definition at line 508 of file shutdown.c.

513{
514 PSHUTDOWN_DLG_CONTEXT pContext;
516 int buttonID = GetDlgCtrlID(hButton);
517
518 switch (uMsg)
519 {
520 case WM_MOUSEMOVE:
521 {
522 HWND hwndTarget;
524
525 if (GetCapture() != hButton)
526 {
527 SetCapture(hButton);
528 if (buttonID == IDC_BUTTON_SHUTDOWN)
529 {
531 }
532 else if (buttonID == IDC_BUTTON_REBOOT)
533 {
535 }
536 else if (buttonID == IDC_BUTTON_SLEEP)
537 {
539 }
540 else if (buttonID == IDC_BUTTON_HIBERNATE)
541 {
543 }
545 }
546
547 ClientToScreen(hButton, &pt);
548 hwndTarget = WindowFromPoint(pt);
549
550 if (hwndTarget != hButton)
551 {
553 if (buttonID == IDC_BUTTON_SHUTDOWN)
554 {
556 }
557 else if (buttonID == IDC_BUTTON_REBOOT)
558 {
560 }
561 else if (buttonID == IDC_BUTTON_SLEEP)
562 {
564 }
565 else if (buttonID == IDC_BUTTON_HIBERNATE)
566 {
568 }
569 }
570 InvalidateRect(hButton, NULL, FALSE);
571 break;
572 }
573
574 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
575 case WM_SETFOCUS:
576 {
577 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
578 break;
579 }
580
581 /* Otherwise, set IDCANCEL as default button */
582 case WM_KILLFOCUS:
583 {
585 break;
586 }
587 }
588 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
589}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
#define pt(x, y)
Definition: drawing.c:79
#define GWLP_USERDATA
Definition: treelist.c:63
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define DM_SETDEFID
Definition: winuser.h:2099
#define GetWindowLongPtrW
Definition: winuser.h:4829
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define IDCANCEL
Definition: winuser.h:831
#define WM_SETFOCUS
Definition: winuser.h:1613
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1775
HWND WINAPI GetCapture(void)
Definition: message.c:2881
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetParent(_In_ HWND)
HWND WINAPI WindowFromPoint(_In_ POINT)
int WINAPI GetDlgCtrlID(_In_ HWND)
#define IDC_HAND
Definition: winuser.h:698
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1614

Referenced by ShutdownOnFriendlyInit().

◆ SaveShutdownSelState()

VOID SaveShutdownSelState ( IN DWORD  ShutdownCode)

Definition at line 723 of file shutdown.c.

725{
726 LONG lRet;
727 HKEY hKeyCurrentUser, hKey;
728 DWORD dwValue = 0;
729
730 /* Open the current user HKCU key */
731 lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
732 if (lRet == ERROR_SUCCESS)
733 {
734 /* Create the subkey */
735 lRet = RegCreateKeyExW(hKeyCurrentUser,
736 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
737 0, NULL,
740 NULL, &hKey, NULL);
741 RegCloseKey(hKeyCurrentUser);
742 }
743 if (lRet != ERROR_SUCCESS)
744 return;
745
746 switch (ShutdownCode)
747 {
750 break;
751
754 break;
755
758 break;
759
761 dwValue = WLX_SHUTDOWN_STATE_SLEEP;
762 break;
763
766 break;
767 }
768
770 L"Shutdown Setting",
771 0, REG_DWORD,
772 (LPBYTE)&dwValue, sizeof(dwValue));
774}
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:1096
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:4882
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_SET_VALUE
Definition: nt_native.h:1017

Referenced by ShellShutdownDialog(), and ShutdownDialog().

◆ ShellIsFriendlyUIActive()

BOOL WINAPI ShellIsFriendlyUIActive ( VOID  )

Definition at line 422 of file shutdown.c.

423{
424 BOOL bActive;
425
426 bActive = IsFriendlyUIActive();
427
429 return FALSE;
430
431 return bActive;
432}
static BOOL ForceFriendlyUI(VOID)
Definition: shutdown.c:260
static BOOL IsFriendlyUIActive(VOID)
Definition: shutdown.c:138
static BOOL IsDomainMember(VOID)
Definition: shutdown.c:214
static BOOL IsNetwareActive(VOID)
Definition: shutdown.c:222

Referenced by ShutdownDialog().

◆ ShellShutdownDialog()

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

Definition at line 1230 of file shutdown.c.

1234{
1235 INT_PTR dlgValue;
1236 DWORD ShutdownOptions;
1237
1238 /*
1239 * As we are called by the shell itself, don't use
1240 * the cached GINA context but use a local copy here.
1241 */
1242 GINA_CONTEXT gContext = { 0 };
1244
1245 UNREFERENCED_PARAMETER(lpUsername);
1246
1247 ShutdownOptions = GetAllowedShutdownOptions();
1248 if (bHideLogoff)
1249 ShutdownOptions &= ~WLX_SHUTDOWN_STATE_LOGOFF;
1250
1251 /* Initialize our local GINA context */
1252 gContext.hDllInstance = hDllInstance;
1253 BufferSize = _countof(gContext.UserName);
1254 // NOTE: Only when this function is called, Win checks inside
1255 // HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1256 // value "Logon User Name", and determines whether it will display
1257 // the user name.
1258 GetUserNameW(gContext.UserName, &BufferSize);
1260
1261 /* Load the shutdown dialog box */
1262 dlgValue = ShutdownDialog(hParent, ShutdownOptions, &gContext);
1263
1264 /* Determine what to do based on user selection */
1265 if (dlgValue == IDOK)
1266 {
1268
1269 switch (gContext.nShutdownAction)
1270 {
1273
1276
1279
1280 // 0x08
1281
1284
1285 // 0x20
1286
1289
1290 // 0x80
1291 }
1292 }
1293 /* Help file is called directly here */
1294 else if (dlgValue == IDHELP)
1295 {
1296 FIXME("Help is not implemented yet.\n");
1297 MessageBoxW(hParent, L"Help is not implemented yet.", L"Message", MB_OK | MB_ICONEXCLAMATION);
1298 }
1299 else if (dlgValue == -1)
1300 {
1301 ERR("Failed to create dialog\n");
1302 }
1303
1304 return 0;
1305}
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
static HINSTANCE hDllInstance
Definition: clb.c:30
#define BufferSize
Definition: mmc.h:75
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:783
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:441
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:1149
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:723
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IDHELP
Definition: resource_2.h:8
WCHAR UserName[256]
Definition: msgina.h:50
ULONG nShutdownAction
Definition: msgina.h:47
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define IDOK
Definition: winuser.h:830
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790

Referenced by ShellTurnOffDialog().

◆ ShellTurnOffDialog()

DWORD WINAPI ShellTurnOffDialog ( HWND  hWnd)

Definition at line 1313 of file shutdown.c.

1314{
1316}
HWND hWnd
Definition: settings.c:17
DWORD WINAPI ShellShutdownDialog(HWND hParent, LPWSTR lpUsername, BOOL bHideLogoff)
Definition: shutdown.c:1230

◆ ShutdownDialog()

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

Definition at line 1149 of file shutdown.c.

1153{
1154 INT_PTR ret;
1156
1157#if 0
1158 DWORD ShutdownOptions;
1159
1160 // FIXME: User impersonation!!
1161 pgContext->nShutdownAction = LoadShutdownSelState();
1162 ShutdownOptions = GetAllowedShutdownOptions();
1163#endif
1164
1165 Context.pgContext = pgContext;
1166 Context.ShutdownOptions = ShutdownOptions;
1167 Context.ShutdownDialogId = IDD_SHUTDOWN;
1168 Context.bCloseDlg = FALSE;
1169 Context.bReasonUI = GetShutdownReasonUI();
1170 Context.bFriendlyUI = ShellIsFriendlyUIActive();
1171
1172 if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1173 {
1174 ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1175 pgContext->hDllInstance,
1177 hwndDlg,
1179 (LPARAM)&Context);
1180 }
1181 else
1182 {
1183 if (Context.bFriendlyUI)
1184 {
1186 {
1187 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1188 }
1189 else
1190 {
1191 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1192 }
1193 }
1194
1195 ret = DialogBoxParamW(pgContext->hDllInstance,
1196 MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : Context.ShutdownDialogId),
1197 hwndDlg,
1199 (LPARAM)&Context);
1200 }
1201
1202#if 0
1203 // FIXME: User impersonation!!
1204 if (ret == IDOK)
1205 SaveShutdownSelState(pgContext->nShutdownAction);
1206#endif
1207
1208 return ret;
1209}
static INT_PTR CALLBACK ShutdownDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: shutdown.c:171
#define IDD_SHUTDOWN_FANCY
Definition: resource.h:44
#define IDD_SHUTDOWN
Definition: resource.h:43
#define IDD_SHUTDOWN_REASON
Definition: resource.h:46
#define IDD_SHUTDOWN_FANCY_LONG
Definition: resource.h:45
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:78
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:230
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
Definition: shutdown.c:422
int ret
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by OnShutDown(), and ShellShutdownDialog().

◆ ShutdownDialogProc()

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

Definition at line 1017 of file shutdown.c.

1022{
1023 PSHUTDOWN_DLG_CONTEXT pContext;
1024
1026
1027 switch (uMsg)
1028 {
1029 case WM_INITDIALOG:
1030 {
1031 pContext = (PSHUTDOWN_DLG_CONTEXT)lParam;
1032 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pContext);
1033
1034 ShutdownOnInit(hDlg, pContext);
1035 return TRUE;
1036 }
1037
1038 case WM_DESTROY:
1039 if (pContext->bFriendlyUI)
1040 {
1041 EndFriendlyDialog(hDlg, pContext);
1042 }
1043 return TRUE;
1044
1045 case WM_ACTIVATE:
1046 {
1047 /*
1048 * If the user deactivates the shutdown dialog (it loses its focus
1049 * while the dialog is not being closed), then destroy the dialog
1050 * and cancel shutdown.
1051 */
1052 if (LOWORD(wParam) == WA_INACTIVE)
1053 {
1054 if (!pContext->bCloseDlg)
1055 {
1056 pContext->bCloseDlg = TRUE;
1057 EndDialog(hDlg, IDCANCEL);
1058 }
1059 }
1060 return FALSE;
1061 }
1062
1063 case WM_CLOSE:
1064 pContext->bCloseDlg = TRUE;
1065 EndDialog(hDlg, IDCANCEL);
1066 break;
1067
1068 case WM_COMMAND:
1069 switch (LOWORD(wParam))
1070 {
1072 ExitWindowsEx(EWX_SHUTDOWN, SHTDN_REASON_MAJOR_OTHER);
1073 break;
1074
1075 case IDC_BUTTON_REBOOT:
1076 ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_OTHER);
1077 break;
1078
1079 case IDC_BUTTON_SLEEP:
1081 break;
1082
1083 case IDOK:
1084 ShutdownOnOk(hDlg, pContext->pgContext);
1085
1086 /* Fall back */
1087 case IDCANCEL:
1088 case IDHELP:
1089 pContext->bCloseDlg = TRUE;
1090 EndDialog(hDlg, LOWORD(wParam));
1091 break;
1092
1094 UpdateShutdownDesc(hDlg, pContext);
1095 break;
1096 }
1097 break;
1098
1099 case WM_CTLCOLORSTATIC:
1100 {
1101 /* Either make background transparent or fill it with color for required static controls */
1102 HDC hdcStatic = (HDC)wParam;
1104
1105 switch (StaticID)
1106 {
1108 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1109 SetBkMode(hdcStatic, TRANSPARENT);
1111
1114 case IDC_SLEEP_STATIC:
1115 case IDC_RESTART_STATIC:
1116 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1117 SetBkMode(hdcStatic, TRANSPARENT);
1118 return (LONG_PTR)pContext->hBrush;
1119 }
1120 return FALSE;
1121 }
1122
1123 case WM_DRAWITEM:
1124 {
1125 /* Draw bitmaps on required buttons */
1127 switch (pdis->CtlID)
1128 {
1130 case IDC_BUTTON_REBOOT:
1131 case IDC_BUTTON_SLEEP:
1133 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1134 }
1135 break;
1136 }
1137
1138 case WM_TIMER:
1139 OnTimer(hDlg, pContext);
1140 return TRUE;
1141
1142 default:
1143 return FALSE;
1144 }
1145 return TRUE;
1146}
static VOID OnTimer(IN HWND hwndDlg, IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
Definition: shutdown.c:72
#define IDC_TURN_OFF_STATIC
Definition: resource.h:55
#define IDC_SHUTDOWN_STATIC
Definition: resource.h:58
#define IDC_HIBERNATE_STATIC
Definition: resource.h:56
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
#define IDC_RESTART_STATIC
Definition: resource.h:59
static VOID ShutdownOnOk(IN HWND hDlg, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:993
#define DARK_GREY_COLOR
Definition: shutdown.c:30
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:904
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:314
static VOID UpdateShutdownDesc(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:800
VOID EndFriendlyDialog(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:627
#define LIGHT_GREY_COLOR
Definition: shutdown.c:31
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:681
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
#define HOLLOW_BRUSH
Definition: wingdi.h:899
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define EWX_SHUTDOWN
Definition: winuser.h:639
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define WM_CLOSE
Definition: winuser.h:1621
#define GWL_ID
Definition: winuser.h:859
#define WM_COMMAND
Definition: winuser.h:1740
#define WA_INACTIVE
Definition: winuser.h:2622
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_ACTIVATE
Definition: winuser.h:1612
#define EWX_REBOOT
Definition: winuser.h:638
#define WM_TIMER
Definition: winuser.h:1742
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

◆ ShutdownOnFriendlyInit()

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

Definition at line 852 of file shutdown.c.

855{
856 PGINA_CONTEXT pgContext = pContext->pgContext;
857 HDC hdc;
858 LONG lfHeight;
859
860 /* Create font for the IDC_TURN_OFF_STATIC static control */
861 hdc = GetDC(hDlg);
863 ReleaseDC(hDlg, hdc);
864 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
866
867 /* Create a brush for static controls for fancy shut down dialog */
868 pContext->hBrush = CreateSolidBrush(DARK_GREY_COLOR);
869
870 /* Gather image strip */
871 pContext->hImageStrip = LoadBitmapW(pgContext->hDllInstance, MAKEINTRESOURCEW(IDB_IMAGE_STRIP));
872
873 /* Set the boolean flags to false */
874 pContext->bIsSleepButtonReplaced = FALSE;
875 pContext->bTimer = FALSE;
876
879
880 /* Gather old button func */
881 pContext->OldButtonProc = (WNDPROC)GetWindowLongPtrW(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), GWLP_WNDPROC);
882
883 /* Set bIsButtonHot to false, create tooltips for each buttons, make buttons to remember pContext and subclass the buttons */
884 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
885 {
886 pContext->bIsButtonHot[i] = FALSE;
892 hDlg, IDS_SHUTDOWN_SHUTDOWN + i,
893 pContext->pgContext->hDllInstance);
894 }
895
896 if (pContext->ShutdownDialogId == IDD_SHUTDOWN_FANCY && IsPwrSuspendAllowed())
897 {
898 pContext->iTimer = SetTimer(hDlg, 0, 50, NULL);
899 pContext->bTimer = TRUE;
900 }
901}
#define IDS_SHUTDOWN_SHUTDOWN_DESC
Definition: resource.h:121
#define IDS_SHUTDOWN_SHUTDOWN
Definition: resource.h:115
#define IDB_IMAGE_STRIP
Definition: resource.h:79
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
Definition: shutdown.c:592
static INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:508
#define FONT_POINT_SIZE
Definition: shutdown.c:28
HDC hdc
Definition: main.c:9
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
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)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define FW_MEDIUM
Definition: wingdi.h:375
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETFONT
Definition: winuser.h:1650
HDC WINAPI GetDC(_In_opt_ HWND)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2163

Referenced by ShutdownOnInit().

◆ ShutdownOnInit()

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

Definition at line 904 of file shutdown.c.

907{
908 PGINA_CONTEXT pgContext = pContext->pgContext;
909 HWND hwndList;
910 INT idx, count, i;
911 WCHAR szBuffer[256];
912 WCHAR szBuffer2[256];
913
914 if (pContext->bFriendlyUI)
915 {
916 ShutdownOnFriendlyInit(hDlg, pContext);
917 return;
918 }
919
920 hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
921
922 /* Clear the content before it's used */
923 SendMessageW(hwndList, CB_RESETCONTENT, 0, 0);
924
925 /* Log off */
926 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_LOGOFF)
927 {
928 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_LOGOFF, szBuffer, _countof(szBuffer));
929 StringCchPrintfW(szBuffer2, _countof(szBuffer2), szBuffer, pgContext->UserName);
930 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer2);
931 if (idx != CB_ERR)
933 }
934
935 /* Shut down - DEFAULT */
936 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_POWER_OFF)
937 {
938 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SHUTDOWN, szBuffer, _countof(szBuffer));
939 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
940 if (idx != CB_ERR)
942 }
943
944 /* Restart */
945 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_REBOOT)
946 {
947 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_RESTART, szBuffer, _countof(szBuffer));
948 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
949 if (idx != CB_ERR)
951 }
952
953 // if (pContext->ShutdownOptions & 0x08) {}
954
955 /* Sleep */
956 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP)
957 {
958 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
959 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
960 if (idx != CB_ERR)
962 }
963
964 // if (pContext->ShutdownOptions & 0x20) {}
965
966 /* Hibernate */
967 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE)
968 {
969 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
970 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
971 if (idx != CB_ERR)
973 }
974
975 // if (pContext->ShutdownOptions & 0x80) {}
976
977 /* Set the default shut down selection */
978 count = SendMessageW(hwndList, CB_GETCOUNT, 0, 0);
979 for (i = 0; i < count; i++)
980 {
981 if (SendMessageW(hwndList, CB_GETITEMDATA, i, 0) == pgContext->nShutdownAction)
982 {
983 SendMessageW(hwndList, CB_SETCURSEL, i, 0);
984 break;
985 }
986 }
987
988 /* Update the choice description based on the current selection */
989 UpdateShutdownDesc(hDlg, pContext);
990}
unsigned int idx
Definition: utils.c:41
#define IDS_SHUTDOWN_LOGOFF
Definition: resource.h:114
#define IDS_SHUTDOWN_RESTART
Definition: resource.h:116
static VOID ShutdownOnFriendlyInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:852
GLuint GLuint GLsizei count
Definition: gl.h:1545
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
int32_t INT
Definition: typedefs.h:58
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define CB_ERR
Definition: winuser.h:2435
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define CB_GETCOUNT
Definition: winuser.h:1942
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETITEMDATA
Definition: winuser.h:1950

Referenced by ShutdownDialogProc().

◆ ShutdownOnOk()

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

Definition at line 993 of file shutdown.c.

996{
997 INT idx;
998
1002 0,
1003 0);
1004 if (idx != CB_ERR)
1005 {
1006 pgContext->nShutdownAction =
1010 idx,
1011 0);
1012 }
1013}
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by ShutdownDialogProc().

◆ UpdateShutdownDesc()

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

Definition at line 800 of file shutdown.c.

803{
804 UINT DescId = 0;
805 DWORD ShutdownCode;
806 WCHAR szBuffer[256];
807
808 ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETCURSEL, 0, 0);
809 if (ShutdownCode == CB_ERR) // Invalid selection
810 return;
811
812 ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETITEMDATA, ShutdownCode, 0);
813
814 switch (ShutdownCode)
815 {
818 break;
819
822 break;
823
826 break;
827
830 break;
831
834 break;
835
836 default:
837 break;
838 }
839
840 LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
842
843 if (pContext->bReasonUI)
844 {
848 }
849}
#define IDS_SHUTDOWN_LOGOFF_DESC
Definition: resource.h:120
#define IDS_SHUTDOWN_RESTART_DESC
Definition: resource.h:122
#define IDS_SHUTDOWN_SLEEP_DESC
Definition: resource.h:123
#define IDS_SHUTDOWN_HIBERNATE_DESC
Definition: resource.h:124
#define IDC_REASON_COMMENT
Definition: resource.h:53
#define IDC_REASON_PLANNED
Definition: resource.h:50
#define IDC_REASON_LIST
Definition: resource.h:51
#define IDC_SHUTDOWN_DESCRIPTION
Definition: resource.h:49

Referenced by ShutdownDialogProc(), and ShutdownOnInit().