ReactOS 0.4.16-dev-1946-g52006dd
shutdown.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS msgina.dll
4 * FILE: lib/msgina/shutdown.c
5 * PURPOSE: Shutdown Dialog Box (GUI only)
6 * PROGRAMMERS: Lee Schroeder (spaceseel at gmail dot com)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 * Arnav Bhatt (arnavbhatt288 at gmail dot com)
9 */
10
11#include "msgina.h"
12#include <wingdi.h>
13#include <windowsx.h>
14#include <commctrl.h>
15#include <ndk/pofuncs.h>
16
17/* Macros for fancy shutdown dialog */
18#define FONT_POINT_SIZE 13
19
20#define DARK_GREY_COLOR RGB(244, 244, 244)
21#define LIGHT_GREY_COLOR RGB(38, 38, 38)
22
23/* Bitmap's size for buttons */
24#define CX_BITMAP 33
25#define CY_BITMAP 33
26
27#define NUMBER_OF_BUTTONS 4
28
29/* After determining the button as well as its state paint the image strip bitmap using these predefined positions */
30#define BUTTON_SHUTDOWN 0
31#define BUTTON_SHUTDOWN_PRESSED (CY_BITMAP + BUTTON_SHUTDOWN)
32#define BUTTON_SHUTDOWN_FOCUSED (CY_BITMAP + BUTTON_SHUTDOWN_PRESSED)
33#define BUTTON_REBOOT (CY_BITMAP + BUTTON_SHUTDOWN_FOCUSED)
34#define BUTTON_REBOOT_PRESSED (CY_BITMAP + BUTTON_REBOOT)
35#define BUTTON_REBOOT_FOCUSED (CY_BITMAP + BUTTON_REBOOT_PRESSED)
36#define BUTTON_SLEEP (CY_BITMAP + BUTTON_REBOOT_FOCUSED)
37#define BUTTON_SLEEP_PRESSED (CY_BITMAP + BUTTON_SLEEP)
38#define BUTTON_SLEEP_FOCUSED (CY_BITMAP + BUTTON_SLEEP_PRESSED)
39#define BUTTON_SLEEP_DISABLED (CY_BITMAP + BUTTON_SLEEP_FOCUSED)
40
41/* For bIsButtonHot */
42#define SHUTDOWN_BUTTON_HOT 0
43#define REBOOT_BUTTON_HOT 1
44#define SLEEP_BUTTON_HOT 2
45#define HIBERNATE_BUTTON_HOT 3
46
48{
54 HBRUSH hBrush;
65
66
75LONG
77 _In_opt_ HKEY hKeyCurrentUser,
78 _In_ PCWSTR pPolicyKey,
81{
82 HKEY hKey;
83 DWORD dwValue;
84 LONG rc;
85
86 *pValue = 0;
87
88 /* Query the policy value in HKEY_LOCAL_MACHINE */
89 rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, pPolicyKey, 0,
91 if (rc == ERROR_SUCCESS)
92 {
93 rc = ReadRegDwordValue(hKey, ValueName, &dwValue);
95 if (rc == ERROR_SUCCESS)
96 {
97 *pValue = dwValue;
98 return ERROR_SUCCESS;
99 }
100 }
101
102 /* If not found, query the policy value in HKEY_CURRENT_USER */
103 rc = RegOpenKeyExW(hKeyCurrentUser ? hKeyCurrentUser : HKEY_CURRENT_USER,
104 pPolicyKey, 0,
106 if (rc == ERROR_SUCCESS)
107 {
108 rc = ReadRegDwordValue(hKey, ValueName, &dwValue);
110 if (rc == ERROR_SUCCESS)
111 {
112 *pValue = dwValue;
113 return ERROR_SUCCESS;
114 }
115 }
116
117 return ERROR_NOT_FOUND;
118}
119
120
121static
122BOOL
124{
126 DWORD dwValue, dwSize;
127 HKEY hKey;
128 LONG lRet;
129
130 /* Query the policy value */
132 L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
133 0,
135 &hKey);
136 if (lRet == ERROR_SUCCESS)
137 {
138 dwValue = 0;
139 dwSize = sizeof(dwValue);
141 L"ShutdownReasonUI",
142 NULL,
143 NULL,
144 (LPBYTE)&dwValue,
145 &dwSize);
147
148 return (dwValue != 0) ? TRUE : FALSE;
149 }
150
151 /* Query the machine value */
153 L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
154 0,
156 &hKey);
157 if (lRet == ERROR_SUCCESS)
158 {
159 dwValue = 0;
160 dwSize = sizeof(dwValue);
162 L"ShutdownReasonUI",
163 NULL,
164 NULL,
165 (LPBYTE)&dwValue,
166 &dwSize);
168
169 return (dwValue != 0) ? TRUE : FALSE;
170 }
171
172 /* Return the default value */
175 return FALSE;
176
177 return FALSE;
178// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
179}
180
181static
182BOOL
184{
185 DWORD dwType, dwValue, dwSize;
186 HKEY hKey;
187 LONG lRet;
188
190 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
191 0,
193 &hKey);
194 if (lRet != ERROR_SUCCESS)
195 return FALSE;
196
197 /* CORE-17282 First check an optional ReactOS specific override, that Windows does not check.
198 We use this to allow users pairing 'Server'-configuration with FriendlyShutdown.
199 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
200 dwValue = 0;
201 dwSize = sizeof(dwValue);
202 lRet = RegQueryValueExW(hKey,
203 L"EnforceFriendlyShutdown",
204 NULL,
205 &dwType,
206 (LPBYTE)&dwValue,
207 &dwSize);
208
209 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue == 0x1)
210 {
212 return TRUE;
213 }
214
215 /* Check product version number */
216 dwValue = 0;
217 dwSize = sizeof(dwValue);
218 lRet = RegQueryValueExW(hKey,
219 L"CSDVersion",
220 NULL,
221 &dwType,
222 (LPBYTE)&dwValue,
223 &dwSize);
225
226 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != 0x300)
227 {
228 /* Allow Friendly UI only on Workstation */
229 return FALSE;
230 }
231
232 /* Check LogonType value */
234 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
235 0,
237 &hKey);
238 if (lRet != ERROR_SUCCESS)
239 return FALSE;
240
241 dwValue = 0;
242 dwSize = sizeof(dwValue);
243 lRet = RegQueryValueExW(hKey,
244 L"LogonType",
245 NULL,
246 &dwType,
247 (LPBYTE)&dwValue,
248 &dwSize);
250
251 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
252 return FALSE;
253
254 return (dwValue != 0);
255}
256
257static
258BOOL
260{
262 return FALSE;
263}
264
265static
266BOOL
268{
270 return FALSE;
271}
272
273static
274BOOL
276{
277 INT_PTR lRet;
278 HKEY hKey;
279 DWORD dwValue, dwSize;
280
282 L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
283 0, KEY_QUERY_VALUE, &hKey);
284 if (lRet == ERROR_SUCCESS)
285 {
286 dwValue = 0;
287 dwSize = sizeof(dwValue);
288
289 lRet = RegQueryValueExW(hKey,
290 L"ShowHibernateButton",
291 NULL, NULL,
292 (LPBYTE)&dwValue, &dwSize);
294 if (lRet != ERROR_SUCCESS)
295 {
296 return FALSE;
297 }
298 return (dwValue != 0);
299 }
300 return FALSE;
301}
302
303static
304BOOL
306{
307 DWORD dwType, dwValue, dwSize;
308 HKEY hKey;
309 LONG lRet;
310
312 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
313 0,
315 &hKey);
316 if (lRet == ERROR_SUCCESS)
317 {
318 dwValue = 0;
319 dwSize = sizeof(dwValue);
320 lRet = RegQueryValueExW(hKey,
321 L"ForceFriendlyUI",
322 NULL,
323 &dwType,
324 (LPBYTE)&dwValue,
325 &dwSize);
327
328 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
329 return (dwValue != 0);
330 }
331
333 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
334 0,
336 &hKey);
337 if (lRet == ERROR_SUCCESS)
338 {
339 dwValue = 0;
340 dwSize = sizeof(dwValue);
341 lRet = RegQueryValueExW(hKey,
342 L"ForceFriendlyUI",
343 NULL,
344 &dwType,
345 (LPBYTE)&dwValue,
346 &dwSize);
347
349
350 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
351 return (dwValue != 0);
352 }
353
354 return FALSE;
355}
356
357static
358BOOL
360 DRAWITEMSTRUCT* pdis,
361 PSHUTDOWN_DLG_CONTEXT pContext)
362{
363 BOOL bRet;
364 HDC hdcMem;
365 HBITMAP hbmOld;
366 int y;
367 RECT rect;
368
370 hbmOld = SelectObject(hdcMem, pContext->hImageStrip);
371 rect = pdis->rcItem;
372
373 /* Check the button ID for relevant bitmap to be used */
374 switch (pdis->CtlID)
375 {
377 {
378 switch (pdis->itemAction)
379 {
380 case ODA_DRAWENTIRE:
381 case ODA_FOCUS:
382 case ODA_SELECT:
383 {
385 if (pdis->itemState & ODS_SELECTED)
386 {
388 }
389 else if (pContext->bIsButtonHot[SHUTDOWN_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
390 {
392 }
393 break;
394 }
395 }
396 break;
397 }
398
400 {
401 switch (pdis->itemAction)
402 {
403 case ODA_DRAWENTIRE:
404 case ODA_FOCUS:
405 case ODA_SELECT:
406 {
408 if (pdis->itemState & ODS_SELECTED)
409 {
411 }
412 else if (pContext->bIsButtonHot[REBOOT_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
413 {
415 }
416 break;
417 }
418 }
419 break;
420 }
421
423 case IDC_BUTTON_SLEEP:
424 {
425 switch (pdis->itemAction)
426 {
427 case ODA_DRAWENTIRE:
428 case ODA_FOCUS:
429 case ODA_SELECT:
430 {
431 y = BUTTON_SLEEP;
432 if (pdis->itemState & ODS_DISABLED)
433 {
435 }
436 else if (pdis->itemState & ODS_SELECTED)
437 {
439 }
440 else if ((pdis->CtlID == IDC_BUTTON_SLEEP && pContext->bIsButtonHot[SLEEP_BUTTON_HOT]) ||
442 (pdis->itemState & ODS_FOCUS))
443 {
445 }
446 break;
447 }
448 }
449 break;
450 }
451 }
452
453 /* Draw it on the required button */
454 bRet = BitBlt(pdis->hDC,
455 (rect.right - rect.left - CX_BITMAP) / 2,
456 (rect.bottom - rect.top - CY_BITMAP) / 2,
458
459 SelectObject(hdcMem, hbmOld);
461
462 return bRet;
463}
464
465BOOL
466WINAPI
468{
469 BOOL bActive;
470
471 bActive = IsFriendlyUIActive();
472
474 return FALSE;
475
476 return bActive;
477}
478
479static INT_PTR
482 HWND hButton,
483 UINT uMsg,
486{
487 PSHUTDOWN_DLG_CONTEXT pContext;
489 int buttonID = GetDlgCtrlID(hButton);
490
491 switch (uMsg)
492 {
493 case WM_MOUSEMOVE:
494 {
495 HWND hwndTarget;
497
498 if (GetCapture() != hButton)
499 {
500 SetCapture(hButton);
501 if (buttonID == IDC_BUTTON_SHUTDOWN)
502 {
504 }
505 else if (buttonID == IDC_BUTTON_REBOOT)
506 {
508 }
509 else if (buttonID == IDC_BUTTON_SLEEP)
510 {
512 }
513 else if (buttonID == IDC_BUTTON_HIBERNATE)
514 {
516 }
518 }
519
520 ClientToScreen(hButton, &pt);
521 hwndTarget = WindowFromPoint(pt);
522
523 if (hwndTarget != hButton)
524 {
526 if (buttonID == IDC_BUTTON_SHUTDOWN)
527 {
529 }
530 else if (buttonID == IDC_BUTTON_REBOOT)
531 {
533 }
534 else if (buttonID == IDC_BUTTON_SLEEP)
535 {
537 }
538 else if (buttonID == IDC_BUTTON_HIBERNATE)
539 {
541 }
542 }
543 InvalidateRect(hButton, NULL, FALSE);
544 break;
545 }
546
547 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
548 case WM_SETFOCUS:
549 {
550 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
551 break;
552 }
553
554 /* Otherwise, set IDCANCEL as default button */
555 case WM_KILLFOCUS:
556 {
558 break;
559 }
560 }
561 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
562}
563
564VOID
566 int controlID,
567 int detailID,
568 HWND hDlg,
569 int titleID,
571{
572 HWND hwndTool, hwndTip;
573 WCHAR szBuffer[256];
574 TTTOOLINFOW tool;
575
576 hwndTool = GetDlgItem(hDlg, controlID);
577
578 tool.cbSize = sizeof(tool);
579 tool.hwnd = hDlg;
581 tool.uId = (UINT_PTR)hwndTool;
582
583 /* Create the tooltip */
588 hDlg, NULL, hInst, NULL);
589
590 /* Associate the tooltip with the tool */
591 LoadStringW(hInst, detailID, szBuffer, _countof(szBuffer));
592 tool.lpszText = szBuffer;
593 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
594 LoadStringW(hInst, titleID, szBuffer, _countof(szBuffer));
595 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
596 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
597}
598
599VOID
601 HWND hDlg,
602 PSHUTDOWN_DLG_CONTEXT pContext)
603{
604 if (pContext->bTimer)
605 {
606 KillTimer(hDlg, pContext->iTimer);
607 }
608
609 DeleteObject(pContext->hBitmap);
610 DeleteObject(pContext->hBrush);
611 DeleteObject(pContext->hImageStrip);
612 DeleteObject(pContext->hfFont);
613
614 /* Remove the subclass from the buttons */
615 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
616 {
619 (LONG_PTR)pContext->OldButtonProc);
620 }
621}
622
623VOID
625 HWND hDlg,
626 PSHUTDOWN_DLG_CONTEXT pContext)
627{
628 int destID = IDC_BUTTON_SLEEP;
629 int targetedID = IDC_BUTTON_HIBERNATE;
630 HWND hwndDest, hwndTarget;
631 RECT rect;
632 WCHAR szBuffer[30];
633
634 /* If the sleep button has been already replaced earlier, bring sleep button back to its original position */
635 if (pContext->bIsSleepButtonReplaced)
636 {
637 destID = IDC_BUTTON_HIBERNATE;
638 targetedID = IDC_BUTTON_SLEEP;
639 }
640
641 hwndDest = GetDlgItem(hDlg, destID);
642 hwndTarget = GetDlgItem(hDlg, targetedID);
643
644 /* Get the position of the destination button */
645 GetWindowRect(hwndDest, &rect);
646
647 /* Get the corrected translated coordinates which is relative to the client window */
648 MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
649
650 /* Set the position of targeted button and hide the destination button */
651 SetWindowPos(hwndTarget,
652 HWND_TOP,
653 rect.left, rect.top,
654 0, 0,
656
657 EnableWindow(hwndDest, FALSE);
658 ShowWindow(hwndDest, SW_HIDE);
659 EnableWindow(hwndTarget, TRUE);
660 ShowWindow(hwndTarget, SW_SHOW);
661 SetFocus(hwndTarget);
662
663 if (!pContext->bIsSleepButtonReplaced)
664 {
665 LoadStringW(pContext->pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
666 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
667 }
668 else
669 {
670 LoadStringW(pContext->pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
671 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
672 }
673
674 InvalidateRect(hDlg, NULL, FALSE);
675}
676
678 HWND hDlg,
679 PSHUTDOWN_DLG_CONTEXT pContext)
680{
681 BOOL ReplaceButton = !!(GetKeyState(VK_SHIFT) & 0x8000);
682
683 if (ReplaceButton && !pContext->bIsSleepButtonReplaced)
684 {
685 ChangeRequiredButton(hDlg, pContext);
686 pContext->bIsSleepButtonReplaced = TRUE;
687 }
688 else if (!ReplaceButton && pContext->bIsSleepButtonReplaced)
689 {
690 ChangeRequiredButton(hDlg, pContext);
691 pContext->bIsSleepButtonReplaced = FALSE;
692 }
693}
694
695DWORD
697 _In_ HKEY hKeyCurrentUser)
698{
699 HKEY hKey;
700 DWORD dwValue, dwTemp, dwSize;
701 LONG lRet;
702
703 /* Default to first item */
704 dwValue = 0;
705
706 /* Open the subkey */
707 lRet = RegOpenKeyExW(hKeyCurrentUser,
708 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
709 0, KEY_QUERY_VALUE, &hKey);
710 if (lRet != ERROR_SUCCESS)
711 return dwValue;
712
713 /* Read the value */
714 dwSize = sizeof(dwTemp);
715 lRet = RegQueryValueExW(hKey,
716 L"Shutdown Setting",
717 NULL, NULL,
718 (LPBYTE)&dwTemp, &dwSize);
720
721 if (lRet == ERROR_SUCCESS)
722 {
723 switch (dwTemp)
724 {
726 dwValue = WLX_SAS_ACTION_LOGOFF;
727 break;
728
731 break;
732
735 break;
736
737 // 0x08
738
741 break;
742
745 break;
746
749 break;
750
751 // WLX_SHUTDOWN_STATE_DISCONNECT
752 }
753 }
754
755 return dwValue;
756}
757
758VOID
760 _In_ HKEY hKeyCurrentUser,
761 _In_ DWORD ShutdownCode)
762{
763 HKEY hKey;
764 DWORD dwValue = 0;
765 LONG lRet;
766
767 /* Create the subkey */
768 lRet = RegCreateKeyExW(hKeyCurrentUser,
769 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
770 0, NULL,
773 NULL, &hKey, NULL);
774 if (lRet != ERROR_SUCCESS)
775 return;
776
777 switch (ShutdownCode)
778 {
781 break;
782
785 break;
786
789 break;
790
792 dwValue = WLX_SHUTDOWN_STATE_SLEEP;
793 break;
794
797 break;
798 }
799
801 L"Shutdown Setting",
802 0, REG_DWORD,
803 (LPBYTE)&dwValue, sizeof(dwValue));
805}
806
807DWORD
809 _In_opt_ HKEY hKeyCurrentUser,
811{
812 DWORD Options = 0;
813 DWORD dwPolicyValue;
816
817 dwPolicyValue = 0;
818 GetPolicyDWORDValue(hKeyCurrentUser,
819 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
820 L"NoLogoff", &dwPolicyValue);
821 if (dwPolicyValue == 0)
823
824#if 0 // TODO: Enable and lookup on a Terminal Services session
825 dwPolicyValue = 0;
826 GetPolicyDWORDValue(hKeyCurrentUser,
827 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
828 L"NoDisconnect", &dwPolicyValue);
829 if (dwPolicyValue == 0)
831#endif
832
833 /* Add shutdown options only if the user has shutdown privilege */
835 return Options; // The user doesn't have them, bail out.
836
837 /* We can always shutdown and restart */
839
840 /* Determine whether extra power options are available */
841 Status = NtPowerInformation(SystemPowerCapabilities, NULL, 0, &PowerCaps, sizeof(PowerCaps));
842 if (!NT_SUCCESS(Status))
843 {
844 ERR("NtPowerInformation(SystemPowerCapabilities) failed (Status 0x%08lx)\n", Status);
845 }
846 else
847 {
848 if (IS_PWR_SUSPEND_ALLOWED(&PowerCaps))
850
851 // TODO: "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" value "Shutdown"
852 // for sleep options. In particular, if set it tells that wakeup events can be disabled.
853 // This will enable WLX_SHUTDOWN_STATE_SLEEP2 support.
854
855 if (IS_PWR_HIBERNATE_ALLOWED(&PowerCaps))
857 }
858
859 // TODO: Consider Windows 8+ support for:
860 // "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" value "HiberbootEnabled"
861
862 // TODO: Add WLX_SHUTDOWN_AUTOUPDATE if:
863 // - Policy "Software\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU" value "NoAUShutdownOption"
864 // is absent or zero;
865 // - SystemBatteryState detects the computer is on external power;
866 // - wuaueng.dll!ordinal_4 tells there are pending updates.
867
868 return Options;
869}
870
871static VOID
873 _In_ HWND hDlg,
874 _In_ PSHUTDOWN_DLG_CONTEXT pContext) // HINSTANCE hInstance
875{
876 HWND hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
877 DWORD ShutdownCode;
878 UINT DescId = 0;
879 WCHAR szBuffer[256];
880
881 ShutdownCode = SendMessageW(hwndList, CB_GETCURSEL, 0, 0);
882 if (ShutdownCode != CB_ERR)
883 ShutdownCode = SendMessageW(hwndList, CB_GETITEMDATA, ShutdownCode, 0);
884 if (ShutdownCode == CB_ERR) // Invalid selection
885 return;
886
887 switch (ShutdownCode)
888 {
891 break;
892
895 break;
896
899 break;
900
903 break;
904
907 break;
908
909 default:
910 break;
911 }
912
913 LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
915
916 if (pContext->bReasonUI)
917 {
918 BOOL bNotLogoff = (ShutdownCode != WLX_SAS_ACTION_LOGOFF);
919 EnableWindow(GetDlgItem(hDlg, IDC_REASON_PLANNED), bNotLogoff);
920 EnableWindow(GetDlgItem(hDlg, IDC_REASON_LIST), bNotLogoff);
921 EnableWindow(GetDlgItem(hDlg, IDC_REASON_COMMENT), bNotLogoff);
922 }
923}
924
925static VOID
927 IN HWND hDlg,
928 IN PSHUTDOWN_DLG_CONTEXT pContext)
929{
930 PGINA_CONTEXT pgContext = pContext->pgContext;
931 HDC hdc;
932 LONG lfHeight;
933 BOOLEAN bCanSuspend = !!(pContext->ShutdownOptions & (WLX_SHUTDOWN_STATE_SLEEP | WLX_SHUTDOWN_STATE_SLEEP2));
934 BOOLEAN bCanHibernate = !!(pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE);
935
936 /* Create font for the IDC_TURN_OFF_STATIC static control */
937 hdc = GetDC(hDlg);
939 ReleaseDC(hDlg, hdc);
940 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
942
943 /* Create a brush for static controls for fancy shutdown dialog */
944 pContext->hBrush = CreateSolidBrush(DARK_GREY_COLOR);
945
946 /* Gather image strip */
947 pContext->hImageStrip = LoadBitmapW(pgContext->hDllInstance, MAKEINTRESOURCEW(IDB_IMAGE_STRIP));
948
949 /* Set the boolean flags to false */
950 pContext->bIsSleepButtonReplaced = FALSE;
951 pContext->bTimer = FALSE;
952
953 EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), bCanHibernate);
954 EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_SLEEP), bCanSuspend);
955
956 /* Gather old button function */
957 pContext->OldButtonProc = (WNDPROC)GetWindowLongPtrW(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), GWLP_WNDPROC);
958
959 /* Set bIsButtonHot to false, create tooltips for each buttons, make buttons to remember pContext and subclass the buttons */
960 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
961 {
962 pContext->bIsButtonHot[i] = FALSE;
968 hDlg, IDS_SHUTDOWN_SHUTDOWN + i,
969 pgContext->hDllInstance);
970 }
971
972 if ((pContext->ShutdownDialogId == IDD_SHUTDOWN_FANCY) && bCanSuspend)
973 {
974 pContext->iTimer = SetTimer(hDlg, 0, 50, NULL);
975 pContext->bTimer = TRUE;
976 }
977}
978
979static VOID
981 IN HWND hDlg,
982 IN PSHUTDOWN_DLG_CONTEXT pContext)
983{
984 PGINA_CONTEXT pgContext = pContext->pgContext;
985 HWND hwndList;
986 INT idx, count, i;
987 WCHAR szBuffer[256];
988 WCHAR szBuffer2[256];
989
990 if (pContext->bFriendlyUI)
991 {
992 ShutdownOnFriendlyInit(hDlg, pContext);
993 return;
994 }
995
996 hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
997
998 /* Clear the content before it's used */
999 SendMessageW(hwndList, CB_RESETCONTENT, 0, 0);
1000
1001 /* Log off */
1002 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_LOGOFF)
1003 {
1004 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_LOGOFF, szBuffer, _countof(szBuffer));
1005 StringCchPrintfW(szBuffer2, _countof(szBuffer2), szBuffer, pgContext->UserName);
1006 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer2);
1007 if (idx != CB_ERR)
1009 }
1010
1011 /* Shut down */
1012 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_POWER_OFF)
1013 {
1014 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SHUTDOWN, szBuffer, _countof(szBuffer));
1015 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
1016 if (idx != CB_ERR)
1018 }
1019
1020 /* Restart */
1021 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_REBOOT)
1022 {
1023 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_RESTART, szBuffer, _countof(szBuffer));
1024 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
1025 if (idx != CB_ERR)
1027 }
1028
1029 // if (pContext->ShutdownOptions & 0x08) {}
1030
1031 /* Sleep */
1032 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP)
1033 {
1034 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
1035 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
1036 if (idx != CB_ERR)
1038 }
1039
1040 // if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP2) {}
1041
1042 /* Hibernate */
1043 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE)
1044 {
1045 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
1046 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
1047 if (idx != CB_ERR)
1049 }
1050
1051 // if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_DISCONNECT) {}
1052
1053 // if (pContext->ShutdownOptions & WLX_SHUTDOWN_AUTOUPDATE) {}
1054
1055 /* Set the default selection */
1056 count = SendMessageW(hwndList, CB_GETCOUNT, 0, 0);
1057 for (i = 0; i < count; i++)
1058 {
1059 if (SendMessageW(hwndList, CB_GETITEMDATA, i, 0) == pgContext->nShutdownAction)
1060 {
1061 SendMessageW(hwndList, CB_SETCURSEL, i, 0);
1062 break;
1063 }
1064 }
1065 /* If no item was selected (nShutdownAction with value 0 or invalid,
1066 * or an action that is currently unavailable), set the selection to
1067 * the first list item. */
1068 if (count && (SendMessageW(hwndList, CB_GETCURSEL, 0, 0) == CB_ERR))
1069 SendMessageW(hwndList, CB_SETCURSEL, 0, 0);
1070
1071 /* Update the choice description based on the current selection */
1072 UpdateShutdownDesc(hDlg, pContext);
1073}
1074
1075static VOID
1077 _In_ HWND hDlg,
1078 _In_ PGINA_CONTEXT pgContext)
1079{
1080 HWND hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
1081 DWORD ShutdownCode = SendMessageW(hwndList, CB_GETCURSEL, 0, 0);
1082 if (ShutdownCode != CB_ERR)
1083 {
1084 ShutdownCode = SendMessageW(hwndList, CB_GETITEMDATA, ShutdownCode, 0);
1085 if (ShutdownCode != CB_ERR)
1086 pgContext->nShutdownAction = ShutdownCode;
1087 }
1088}
1089
1090static INT_PTR
1093 HWND hDlg,
1094 UINT uMsg,
1095 WPARAM wParam,
1096 LPARAM lParam)
1097{
1098 PSHUTDOWN_DLG_CONTEXT pContext;
1099
1101
1102 switch (uMsg)
1103 {
1104 case WM_INITDIALOG:
1105 {
1106 pContext = (PSHUTDOWN_DLG_CONTEXT)lParam;
1107 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pContext);
1108 ShutdownOnInit(hDlg, pContext);
1109 return TRUE;
1110 }
1111
1112 case WM_DESTROY:
1113 if (pContext->bFriendlyUI)
1114 EndFriendlyDialog(hDlg, pContext);
1115 return TRUE;
1116
1117 case WM_ACTIVATE:
1118 {
1119 /*
1120 * If the user deactivates the shutdown dialog (it loses its focus
1121 * while the dialog is not being closed), then destroy the dialog
1122 * and cancel shutdown.
1123 */
1124 if (LOWORD(wParam) == WA_INACTIVE)
1125 {
1126 if (!pContext->bCloseDlg)
1127 {
1128 pContext->bCloseDlg = TRUE;
1129 EndDialog(hDlg, IDCANCEL);
1130 }
1131 }
1132 return FALSE;
1133 }
1134
1135 case WM_CLOSE:
1136 pContext->bCloseDlg = TRUE;
1137 EndDialog(hDlg, IDCANCEL);
1138 break;
1139
1140 case WM_COMMAND:
1141 switch (LOWORD(wParam))
1142 {
1143 /* Check for fancy shutdown dialog buttons */
1146 {
1148 PGINA_CONTEXT pgContext = pContext->pgContext;
1149 pgContext->nShutdownAction = 0;
1151 {
1154 }
1155 else if (Button == IDC_BUTTON_REBOOT)
1156 {
1159 }
1160 else if (Button == IDC_BUTTON_SLEEP)
1161 {
1163 {
1164 /* Choose "Sleep with wakeup events disabled" if
1165 * available, otherwise use the regular sleep mode */
1168 else
1170 }
1171 }
1172 else if (Button == IDC_BUTTON_HIBERNATE)
1173 {
1176 }
1177 if (pgContext->nShutdownAction == 0)
1178 break;
1179
1180 pContext->bCloseDlg = TRUE;
1181 EndDialog(hDlg, IDOK);
1182 break;
1183 }
1184
1185 /* Classic shutdown dialog buttons */
1186 case IDOK:
1187 ShutdownOnOk(hDlg, pContext->pgContext);
1188
1189 /* Fall back */
1190 case IDCANCEL:
1191 case IDHELP:
1192 pContext->bCloseDlg = TRUE;
1193 EndDialog(hDlg, LOWORD(wParam));
1194 break;
1195
1197 UpdateShutdownDesc(hDlg, pContext);
1198 break;
1199 }
1200 break;
1201
1202 case WM_CTLCOLORSTATIC:
1203 {
1204 /* Either make background transparent or fill it with color for required static controls */
1205 HDC hdcStatic = (HDC)wParam;
1207
1208 switch (StaticID)
1209 {
1211 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1212 SetBkMode(hdcStatic, TRANSPARENT);
1214
1217 case IDC_SLEEP_STATIC:
1218 case IDC_RESTART_STATIC:
1219 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1220 SetBkMode(hdcStatic, TRANSPARENT);
1221 return (LONG_PTR)pContext->hBrush;
1222 }
1223 return FALSE;
1224 }
1225
1226 case WM_DRAWITEM:
1227 {
1228 /* Draw bitmaps on required buttons */
1230 switch (pdis->CtlID)
1231 {
1233 case IDC_BUTTON_REBOOT:
1234 case IDC_BUTTON_SLEEP:
1236 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1237 }
1238 break;
1239 }
1240
1241 case WM_TIMER:
1242 OnTimer(hDlg, pContext);
1243 return TRUE;
1244
1245 default:
1246 return FALSE;
1247 }
1248 return TRUE;
1249}
1250
1251INT_PTR
1253 IN HWND hwndDlg,
1254 IN DWORD ShutdownOptions,
1255 IN PGINA_CONTEXT pgContext)
1256{
1257 INT_PTR ret;
1259
1260#if 0
1261 ShutdownOptions = GetAllowedShutdownOptions(hKeyCurrentUser, pgContext->UserToken);
1262 pgContext->nShutdownAction = LoadShutdownSelState(hKeyCurrentUser);
1263 ShutdownOptions &= ~dwExcludeOptions;
1264#endif
1265
1266 /* Bail out early if no shutdown options are available */
1267 if (ShutdownOptions == 0)
1268 return IDCANCEL;
1269
1270 Context.pgContext = pgContext;
1271 Context.ShutdownOptions = ShutdownOptions;
1272 Context.ShutdownDialogId = IDD_SHUTDOWN;
1273 Context.bCloseDlg = FALSE;
1274 Context.bReasonUI = GetShutdownReasonUI();
1275 Context.bFriendlyUI = ShellIsFriendlyUIActive();
1276
1277 if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1278 {
1279 ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1280 pgContext->hDllInstance,
1282 hwndDlg,
1284 (LPARAM)&Context);
1285 }
1286 else
1287 {
1288 if (Context.bFriendlyUI)
1289 {
1291 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1292 else
1293 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1294 }
1295
1296 ret = DialogBoxParamW(pgContext->hDllInstance,
1297 MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : Context.ShutdownDialogId),
1298 hwndDlg,
1300 (LPARAM)&Context);
1301 }
1302
1303 // TODO: Handle shutdown reasons.
1304
1305#if 0
1306 if (ret == IDOK)
1307 SaveShutdownSelState(hKeyCurrentUser, pgContext->nShutdownAction);
1308#endif
1309
1310 return ret;
1311}
1312
1313
1314/*
1315 * NOTES:
1316 * - Based upon observations on the ShellShutdownDialog() function, the function doesn't actually
1317 * do anything except show a dialog box and returning a value based upon the value chosen. That
1318 * means that any code that calls the function has to execute the chosen action (shut down,
1319 * restart, etc.).
1320 * - When this function is called in Windows XP, it shows the classic dialog box regardless if
1321 * SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType is enabled or not.
1322 * - When the Help button is pushed, it sends the same return value as IDCANCEL (0x00), but
1323 * at the same time, it calls the help file directly from the dialog box.
1324 * - When the dialog is created, it doesn't disable all other input from the other windows.
1325 * This is done elsewhere. When running the function ShellShutdownDialog() from XP/2K3, if the user
1326 * clicks out of the window, it automatically closes itself.
1327 * - The parameter pUserName, never seems to be used when calling the function from Windows XP. Either
1328 * it was a parameter that was never used in the final version before release, or it has a use that
1329 * is currently not known.
1330 */
1335 _In_ DWORD dwExcludeOptions)
1336{
1337 INT_PTR dlgValue;
1338 DWORD ShutdownOptions;
1339
1340 /*
1341 * As we are called by the shell itself, don't use
1342 * the cached GINA context but use a local copy here.
1343 */
1344 GINA_CONTEXT gContext = {0};
1345
1347 ShutdownOptions &= ~dwExcludeOptions;
1348
1349 /* Initialize our local GINA context */
1350 gContext.hDllInstance = hDllInstance;
1352 if (gContext.nShutdownAction == 0)
1354
1355 if (pUserName)
1356 {
1357 /* Use the caller-given user name */
1358 StringCbCopyW(gContext.UserName, sizeof(gContext.UserName), pUserName);
1359 }
1360 else
1361 {
1362 /* Use either the convenience "Logon User Name" registered by
1363 * WlxActivateUserShell(), or if not found, retrieve a user name
1364 * via GetUserNameW() */
1365 HKEY hKey;
1366 LONG lRet;
1368 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1369 0,
1371 if (lRet == ERROR_SUCCESS)
1372 {
1373 DWORD dwType, cbData = sizeof(gContext.UserName);
1374 lRet = RegQueryValueExW(hKey,
1375 L"Logon User Name",
1376 NULL,
1377 &dwType,
1378 (PBYTE)gContext.UserName,
1379 &cbData);
1381
1382 /* NULL-terminate the string */
1383 if (lRet != ERROR_SUCCESS)
1384 cbData = 0;
1385 gContext.UserName[cbData / sizeof(WCHAR)] = UNICODE_NULL;
1386 }
1387 else
1388 {
1389 DWORD BufferSize = _countof(gContext.UserName);
1390 GetUserNameW(gContext.UserName, &BufferSize);
1391 }
1392 }
1393
1394 /* Load the shutdown dialog box */
1395 dlgValue = ShutdownDialog(hWndParent, ShutdownOptions, &gContext);
1396
1397 /* Determine what to do based on user selection */
1398 if (dlgValue == IDOK)
1399 {
1401
1402 switch (gContext.nShutdownAction)
1403 {
1406
1409
1412
1413 // 0x08
1414
1417
1420
1423
1424 // WLX_SHUTDOWN_STATE_DISCONNECT
1425 }
1426 }
1427 /* Help file is called directly here */
1428 else if (dlgValue == IDHELP)
1429 {
1430 FIXME("Help is not implemented yet.\n");
1431 MessageBoxW(hWndParent, L"Help is not implemented yet.", L"Message", MB_OK | MB_ICONEXCLAMATION);
1432 }
1433 else if (dlgValue == -1)
1434 {
1435 ERR("Failed to create dialog\n");
1436 }
1437
1438 return 0;
1439}
1440
1441/*
1442 * NOTES:
1443 * - Undocumented, called from MS shell32.dll to show the turn off dialog.
1444 * - Seems to have the same purpose as ShellShutdownDialog.
1445 */
1448{
1449 return ShellShutdownDialog(hWnd, NULL, 0);
1450}
static LPWSTR pUserName
unsigned char BOOLEAN
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
HANDLE hUserToken
Definition: install.c:39
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
static VOID OnTimer(IN HWND hwndDlg, IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
Definition: shutdown.c:72
static INT_PTR CALLBACK ShutdownDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: shutdown.c:171
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define RegCloseKey(hKey)
Definition: registry.h:49
static HINSTANCE hDllInstance
Definition: clb.c:9
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
unsigned int idx
Definition: utils.c:41
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 RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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
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
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define CALLBACK
Definition: compat.h:35
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:64
#define IDS_SHUTDOWN_LOGOFF_DESC
Definition: resource.h:120
#define IDC_TURN_OFF_STATIC
Definition: resource.h:55
#define IDS_SHUTDOWN_RESTART_DESC
Definition: resource.h:122
#define IDD_SHUTDOWN_FANCY
Definition: resource.h:44
#define IDS_SHUTDOWN_LOGOFF
Definition: resource.h:114
#define IDS_SHUTDOWN_SHUTDOWN_DESC
Definition: resource.h:121
#define IDC_SHUTDOWN_STATIC
Definition: resource.h:58
#define IDS_SHUTDOWN_SLEEP_DESC
Definition: resource.h:123
#define IDS_SHUTDOWN_SHUTDOWN
Definition: resource.h:115
#define IDS_SHUTDOWN_HIBERNATE_DESC
Definition: resource.h:124
#define IDC_REASON_COMMENT
Definition: resource.h:53
#define IDS_SHUTDOWN_SLEEP
Definition: resource.h:117
#define IDS_SHUTDOWN_RESTART
Definition: resource.h:116
#define IDC_BUTTON_REBOOT
Definition: resource.h:62
#define IDB_IMAGE_STRIP
Definition: resource.h:79
#define IDC_REASON_PLANNED
Definition: resource.h:50
#define IDD_SHUTDOWN
Definition: resource.h:43
#define IDC_SLEEP_STATIC
Definition: resource.h:57
#define IDC_HIBERNATE_STATIC
Definition: resource.h:56
#define IDC_SHUTDOWN_ACTION
Definition: resource.h:48
#define IDC_REASON_LIST
Definition: resource.h:51
#define IDC_BUTTON_SLEEP
Definition: resource.h:63
#define IDD_SHUTDOWN_REASON
Definition: resource.h:46
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:61
#define IDC_RESTART_STATIC
Definition: resource.h:59
#define IDS_SHUTDOWN_HIBERNATE
Definition: resource.h:118
#define IDC_SHUTDOWN_DESCRIPTION
Definition: resource.h:49
#define IDD_SHUTDOWN_FANCY_LONG
Definition: resource.h:45
#define BUTTON_SLEEP_DISABLED
Definition: shutdown.c:39
DWORD WINAPI ShellTurnOffDialog(HWND hWnd)
Definition: shutdown.c:1447
#define DARK_GREY_COLOR
Definition: shutdown.c:20
DWORD GetAllowedShutdownOptions(_In_opt_ HKEY hKeyCurrentUser, _In_opt_ HANDLE hUserToken)
Definition: shutdown.c:808
#define SLEEP_BUTTON_HOT
Definition: shutdown.c:44
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:123
#define BUTTON_REBOOT_PRESSED
Definition: shutdown.c:34
#define REBOOT_BUTTON_HOT
Definition: shutdown.c:43
static BOOL ForceFriendlyUI(VOID)
Definition: shutdown.c:305
#define BUTTON_SLEEP_FOCUSED
Definition: shutdown.c:38
static BOOL IsFriendlyUIActive(VOID)
Definition: shutdown.c:183
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
Definition: shutdown.c:565
DWORD WINAPI ShellShutdownDialog(_In_ HWND hWndParent, _In_opt_ LPCWSTR pUserName, _In_ DWORD dwExcludeOptions)
Definition: shutdown.c:1332
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:275
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:980
DWORD LoadShutdownSelState(_In_ HKEY hKeyCurrentUser)
Definition: shutdown.c:696
#define CX_BITMAP
Definition: shutdown.c:24
static INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:481
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
static BOOL IsDomainMember(VOID)
Definition: shutdown.c:259
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:359
#define BUTTON_SHUTDOWN_PRESSED
Definition: shutdown.c:31
VOID ChangeRequiredButton(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:624
#define SHUTDOWN_BUTTON_HOT
Definition: shutdown.c:42
VOID SaveShutdownSelState(_In_ HKEY hKeyCurrentUser, _In_ DWORD ShutdownCode)
Definition: shutdown.c:759
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
Definition: shutdown.c:467
static VOID ShutdownOnOk(_In_ HWND hDlg, _In_ PGINA_CONTEXT pgContext)
Definition: shutdown.c:1076
LONG GetPolicyDWORDValue(_In_opt_ HKEY hKeyCurrentUser, _In_ PCWSTR pPolicyKey, _In_ PCWSTR ValueName, _Out_ PDWORD pValue)
Looks up a policy value on both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER, under the same policy sub-k...
Definition: shutdown.c:76
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:27
#define FONT_POINT_SIZE
Definition: shutdown.c:18
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:1252
static VOID ShutdownOnFriendlyInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:926
#define BUTTON_SHUTDOWN
Definition: shutdown.c:30
#define BUTTON_SLEEP_PRESSED
Definition: shutdown.c:37
#define BUTTON_REBOOT
Definition: shutdown.c:33
#define CY_BITMAP
Definition: shutdown.c:25
#define BUTTON_REBOOT_FOCUSED
Definition: shutdown.c:35
VOID EndFriendlyDialog(HWND hDlg, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:600
#define HIBERNATE_BUTTON_HOT
Definition: shutdown.c:45
#define LIGHT_GREY_COLOR
Definition: shutdown.c:21
#define BUTTON_SLEEP
Definition: shutdown.c:36
#define BUTTON_SHUTDOWN_FOCUSED
Definition: shutdown.c:32
static VOID UpdateShutdownDesc(_In_ HWND hDlg, _In_ PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:872
static BOOL IsNetwareActive(VOID)
Definition: shutdown.c:267
struct _SHUTDOWN_DLG_CONTEXT SHUTDOWN_DLG_CONTEXT
#define pt(x, y)
Definition: drawing.c:79
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
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
PWCHAR pValue
pKey DeleteObject()
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HDC hdc
Definition: main.c:9
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define WLX_SHUTDOWN_STATE_REBOOT
"Restart"
Definition: msgina.h:135
BOOL TestTokenPrivilege(_In_opt_ HANDLE hToken, _In_ ULONG Privilege)
Verifies whether the specified token has the given privilege.
Definition: utils.c:140
#define WLX_SHUTDOWN_STATE_LOGOFF
Shutdown state flags.
Definition: msgina.h:133
#define WLX_SHUTDOWN_STATE_SLEEP
"Stand by"
Definition: msgina.h:137
#define WLX_SHUTDOWN_STATE_POWER_OFF
"Shut down"
Definition: msgina.h:134
#define WLX_SHUTDOWN_STATE_SLEEP2
"Stand by (with wakeup events disabled)"
Definition: msgina.h:138
#define WLX_SHUTDOWN_STATE_HIBERNATE
"Hibernate"
Definition: msgina.h:139
LONG ReadRegDwordValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PDWORD pValue)
Definition: utils.c:90
#define WLX_SHUTDOWN_STATE_DISCONNECT
"Disconnect" (only available in Terminal Services sessions)
Definition: msgina.h:140
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned int UINT
Definition: ndis.h:50
#define IS_PWR_SUSPEND_ALLOWED(PowerCaps)
Definition: potypes.h:63
#define IS_PWR_HIBERNATE_ALLOWED(PowerCaps)
Definition: potypes.h:70
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_SET_VALUE
Definition: nt_native.h:1020
#define UNICODE_NULL
NTSTATUS NTAPI NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength)
Definition: power.c:901
@ SystemPowerCapabilities
Definition: ntpoapi.h:71
#define LOWORD(l)
Definition: pedump.c:82
BYTE * PBYTE
Definition: pedump.c:66
#define WS_POPUP
Definition: pedump.c:616
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define TTI_NONE
Definition: commctrl.h:1779
#define TTM_SETTITLEW
Definition: commctrl.h:1833
#define TTF_IDISHWND
Definition: commctrl.h:1764
#define TTF_SUBCLASS
Definition: commctrl.h:1767
#define TTM_ADDTOOLW
Definition: commctrl.h:1792
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1824
#define TTS_BALLOON
Definition: commctrl.h:1761
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
#define IDHELP
Definition: resource_2.h:8
#define REG_DWORD
Definition: sdbapi.c:615
#define _countof(array)
Definition: sndvol32.h:70
& rect
Definition: startmenu.cpp:1413
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
Definition: window.h:573
WCHAR UserName[256]
Definition: msgina.h:51
ULONG nShutdownAction
Definition: msgina.h:48
HANDLE hDllInstance
Definition: msgina.h:38
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
PGINA_CONTEXT pgContext
Definition: shutdown.c:49
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
Definition: shutdown.c:60
WNDPROC OldButtonProc
Definition: shutdown.c:63
BOOL bIsSleepButtonReplaced
Definition: shutdown.c:57
Definition: windef.h:99
UINT_PTR uId
Definition: commctrl.h:1743
LPWSTR lpszText
Definition: commctrl.h:1746
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
HDC hdcMem
Definition: welcome.c:104
#define GetVersionEx
Definition: winbase.h:3601
#define WINAPI
Definition: msvc.h:6
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define ERROR_NOT_FOUND
Definition: winerror.h:1014
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
#define HOLLOW_BRUSH
Definition: wingdi.h:899
#define SRCCOPY
Definition: wingdi.h:333
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
#define FW_MEDIUM
Definition: wingdi.h:375
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ODS_DISABLED
Definition: winuser.h:2583
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CB_SETITEMDATA
Definition: winuser.h:1995
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define ODS_SELECTED
Definition: winuser.h:2581
#define SW_HIDE
Definition: winuser.h:779
#define WM_CLOSE
Definition: winuser.h:1649
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define DM_SETDEFID
Definition: winuser.h:2135
#define GetWindowLongPtrW
Definition: winuser.h:4931
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define GWL_ID
Definition: winuser.h:870
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_COMMAND
Definition: winuser.h:1768
#define ODA_FOCUS
Definition: winuser.h:2580
#define CB_ERR
Definition: winuser.h:2471
#define CB_SETCURSEL
Definition: winuser.h:1990
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_SETFOCUS
Definition: winuser.h:1641
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_MOUSEMOVE
Definition: winuser.h:1803
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WA_INACTIVE
Definition: winuser.h:2664
#define CB_RESETCONTENT
Definition: winuser.h:1988
#define WM_INITDIALOG
Definition: winuser.h:1767
#define CB_GETCOUNT
Definition: winuser.h:1971
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define WM_DRAWITEM
Definition: winuser.h:1673
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define HWND_DESKTOP
Definition: winuser.h:1220
#define WM_ACTIVATE
Definition: winuser.h:1640
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HWND_TOP
Definition: winuser.h:1218
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_SETFONT
Definition: winuser.h:1678
#define WM_TIMER
Definition: winuser.h:1770
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 CB_ADDSTRING
Definition: winuser.h:1965
#define CB_GETITEMDATA
Definition: winuser.h:1979
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
#define MB_ICONEXCLAMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:801
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
#define ODA_SELECT
Definition: winuser.h:2579
HWND WINAPI WindowFromPoint(_In_ POINT)
int WINAPI GetDlgCtrlID(_In_ HWND)
#define VK_SHIFT
Definition: winuser.h:2238
#define IDC_HAND
Definition: winuser.h:706
#define SW_SHOW
Definition: winuser.h:786
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2515
#define SWP_NOZORDER
Definition: winuser.h:1258
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define CB_GETCURSEL
Definition: winuser.h:1972
#define SetWindowLongPtrW
Definition: winuser.h:5457
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define ODS_FOCUS
Definition: winuser.h:2585
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
#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_SHUTDOWN_SLEEP2
Definition: winwlx.h:65
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180