ReactOS 0.4.15-dev-5863-g1fe3ab7
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 <powrprof.h>
13#include <wingdi.h>
14#include <windowsx.h>
15#include <commctrl.h>
16
17/* Shutdown state flags */
18#define WLX_SHUTDOWN_STATE_LOGOFF 0x01
19#define WLX_SHUTDOWN_STATE_POWER_OFF 0x02
20#define WLX_SHUTDOWN_STATE_REBOOT 0x04
21// 0x08
22#define WLX_SHUTDOWN_STATE_SLEEP 0x10
23// 0x20
24#define WLX_SHUTDOWN_STATE_HIBERNATE 0x40
25// 0x80
26
27/* Macros for fancy shut down dialog */
28#define FONT_POINT_SIZE 13
29
30#define DARK_GREY_COLOR RGB(244, 244, 244)
31#define LIGHT_GREY_COLOR RGB(38, 38, 38)
32
33/* Bitmap's size for buttons */
34#define CX_BITMAP 33
35#define CY_BITMAP 33
36
37#define NUMBER_OF_BUTTONS 4
38
39/* After determining the button as well as its state paint the image strip bitmap using these predefined positions */
40#define BUTTON_SHUTDOWN 0
41#define BUTTON_SHUTDOWN_PRESSED (CY_BITMAP + BUTTON_SHUTDOWN)
42#define BUTTON_SHUTDOWN_FOCUSED (CY_BITMAP + BUTTON_SHUTDOWN_PRESSED)
43#define BUTTON_REBOOT (CY_BITMAP + BUTTON_SHUTDOWN_FOCUSED)
44#define BUTTON_REBOOT_PRESSED (CY_BITMAP + BUTTON_REBOOT)
45#define BUTTON_REBOOT_FOCUSED (CY_BITMAP + BUTTON_REBOOT_PRESSED)
46#define BUTTON_SLEEP (CY_BITMAP + BUTTON_REBOOT_FOCUSED)
47#define BUTTON_SLEEP_PRESSED (CY_BITMAP + BUTTON_SLEEP)
48#define BUTTON_SLEEP_FOCUSED (CY_BITMAP + BUTTON_SLEEP_PRESSED)
49#define BUTTON_SLEEP_DISABLED (CY_BITMAP + BUTTON_SLEEP_FOCUSED)
50
52{
57 HBRUSH hBrush;
67
68static
69BOOL
71{
73 DWORD dwValue, dwSize;
74 HKEY hKey;
75 LONG lRet;
76
77 /* Query the policy value */
79 L"Software\\Policies\\Microsoft\\Windows NT\\Reliability",
80 0,
82 &hKey);
83 if (lRet == ERROR_SUCCESS)
84 {
85 dwValue = 0;
86 dwSize = sizeof(dwValue);
88 L"ShutdownReasonUI",
89 NULL,
90 NULL,
91 (LPBYTE)&dwValue,
92 &dwSize);
94
95 return (dwValue != 0) ? TRUE : FALSE;
96 }
97
98 /* Query the machine value */
100 L"Software\\Microsoft\\Windows\\CurrentVersion\\Reliability",
101 0,
103 &hKey);
104 if (lRet == ERROR_SUCCESS)
105 {
106 dwValue = 0;
107 dwSize = sizeof(dwValue);
109 L"ShutdownReasonUI",
110 NULL,
111 NULL,
112 (LPBYTE)&dwValue,
113 &dwSize);
115
116 return (dwValue != 0) ? TRUE : FALSE;
117 }
118
119 /* Return the default value */
122 return FALSE;
123
124 return FALSE;
125// return (VersionInfo.wProductType == VER_NT_WORKSTATION) ? FALSE : TRUE;
126}
127
128static
129BOOL
131{
132 DWORD dwType, dwValue, dwSize;
133 HKEY hKey;
134 LONG lRet;
135
137 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
138 0,
140 &hKey);
141 if (lRet != ERROR_SUCCESS)
142 return FALSE;
143
144 /* CORE-17282 First check an optional ReactOS specific override, that Windows does not check.
145 We use this to allow users pairing 'Server'-configuration with FriendlyShutdown.
146 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
147 dwValue = 0;
148 dwSize = sizeof(dwValue);
149 lRet = RegQueryValueExW(hKey,
150 L"EnforceFriendlyShutdown",
151 NULL,
152 &dwType,
153 (LPBYTE)&dwValue,
154 &dwSize);
155
156 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue == 0x1)
157 {
159 return TRUE;
160 }
161
162 /* Check product version number */
163 dwValue = 0;
164 dwSize = sizeof(dwValue);
165 lRet = RegQueryValueExW(hKey,
166 L"CSDVersion",
167 NULL,
168 &dwType,
169 (LPBYTE)&dwValue,
170 &dwSize);
172
173 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != 0x300)
174 {
175 /* Allow Friendly UI only on Workstation */
176 return FALSE;
177 }
178
179 /* Check LogonType value */
181 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
182 0,
184 &hKey);
185 if (lRet != ERROR_SUCCESS)
186 return FALSE;
187
188 dwValue = 0;
189 dwSize = sizeof(dwValue);
190 lRet = RegQueryValueExW(hKey,
191 L"LogonType",
192 NULL,
193 &dwType,
194 (LPBYTE)&dwValue,
195 &dwSize);
197
198 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
199 return FALSE;
200
201 return (dwValue != 0);
202}
203
204static
205BOOL
207{
209 return FALSE;
210}
211
212static
213BOOL
215{
217 return FALSE;
218}
219
220static
221BOOL
223{
224 INT_PTR lRet;
225 HKEY hKey;
226 DWORD dwValue, dwSize;
227
229 L"SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Shutdown",
230 0, KEY_QUERY_VALUE, &hKey);
231 if (lRet == ERROR_SUCCESS)
232 {
233 dwValue = 0;
234 dwSize = sizeof(dwValue);
235
236 lRet = RegQueryValueExW(hKey,
237 L"ShowHibernateButton",
238 NULL, NULL,
239 (LPBYTE)&dwValue, &dwSize);
241 if (lRet != ERROR_SUCCESS)
242 {
243 return FALSE;
244 }
245 return (dwValue != 0);
246 }
247 return FALSE;
248}
249
250static
251BOOL
253{
254 DWORD dwType, dwValue, dwSize;
255 HKEY hKey;
256 LONG lRet;
257
259 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
260 0,
262 &hKey);
263 if (lRet == ERROR_SUCCESS)
264 {
265 dwValue = 0;
266 dwSize = sizeof(dwValue);
267 lRet = RegQueryValueExW(hKey,
268 L"ForceFriendlyUI",
269 NULL,
270 &dwType,
271 (LPBYTE)&dwValue,
272 &dwSize);
274
275 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
276 return (dwValue != 0);
277 }
278
280 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
281 0,
283 &hKey);
284 if (lRet == ERROR_SUCCESS)
285 {
286 dwValue = 0;
287 dwSize = sizeof(dwValue);
288 lRet = RegQueryValueExW(hKey,
289 L"ForceFriendlyUI",
290 NULL,
291 &dwType,
292 (LPBYTE)&dwValue,
293 &dwSize);
294
296
297 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD)
298 return (dwValue != 0);
299 }
300
301 return FALSE;
302}
303
304static
305BOOL
307 DRAWITEMSTRUCT* pdis,
308 PSHUTDOWN_DLG_CONTEXT pContext)
309{
310 BOOL bRet;
311 HDC hdcMem;
312 HBITMAP hbmOld;
313 int y;
314 RECT rect;
315
317 hbmOld = SelectObject(hdcMem, pContext->hImageStrip);
318 rect = pdis->rcItem;
319
320 /* Check the button ID for revelant bitmap to be used */
321 switch (pdis->CtlID)
322 {
324 {
325 switch (pdis->itemAction)
326 {
327 case ODA_DRAWENTIRE:
328 case ODA_FOCUS:
329 case ODA_SELECT:
330 {
332 if (pdis->itemState & ODS_SELECTED)
333 {
335 }
336 else if (pContext->bIsButtonHot[0] || (pdis->itemState & ODS_FOCUS))
337 {
339 }
340 break;
341 }
342 }
343 break;
344 }
345
347 {
348 switch (pdis->itemAction)
349 {
350 case ODA_DRAWENTIRE:
351 case ODA_FOCUS:
352 case ODA_SELECT:
353 {
355 if (pdis->itemState & ODS_SELECTED)
356 {
358 }
359 else if (pContext->bIsButtonHot[1] || (pdis->itemState & ODS_FOCUS))
360 {
362 }
363 break;
364 }
365 }
366 break;
367 }
368
370 case IDC_BUTTON_SLEEP:
371 {
372 switch (pdis->itemAction)
373 {
374 case ODA_DRAWENTIRE:
375 case ODA_FOCUS:
376 case ODA_SELECT:
377 {
378 y = BUTTON_SLEEP;
379 if (pdis->itemState & ODS_DISABLED)
380 {
382 }
383 else if (pdis->itemState & ODS_SELECTED)
384 {
386 }
387 else if ((pdis->CtlID == IDC_BUTTON_SLEEP && pContext->bIsButtonHot[2]) ||
388 (pdis->CtlID == IDC_BUTTON_HIBERNATE && pContext->bIsButtonHot[3]) ||
389 (pdis->itemState & ODS_FOCUS))
390 {
392 }
393 break;
394 }
395 }
396 break;
397 }
398 }
399
400 /* Draw it on the required button */
401 bRet = BitBlt(pdis->hDC,
402 (rect.right - rect.left - CX_BITMAP) / 2,
403 (rect.bottom - rect.top - CY_BITMAP) / 2,
405
406 SelectObject(hdcMem, hbmOld);
408
409 return bRet;
410}
411
412BOOL
413WINAPI
415{
416 BOOL bActive;
417
418 bActive = IsFriendlyUIActive();
419
421 return FALSE;
422
423 return bActive;
424}
425
426DWORD
428{
430}
431
432DWORD
434{
435 LONG lRet;
436 HKEY hKeyCurrentUser, hKey;
437 DWORD dwValue, dwTemp, dwSize;
438
439 /* Default to shutdown */
441
442 /* Open the current user HKCU key */
443 lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
444 if (lRet == ERROR_SUCCESS)
445 {
446 /* Open the subkey */
447 lRet = RegOpenKeyExW(hKeyCurrentUser,
448 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
449 0, KEY_QUERY_VALUE, &hKey);
450 RegCloseKey(hKeyCurrentUser);
451 }
452 if (lRet != ERROR_SUCCESS)
453 return dwValue;
454
455 /* Read the value */
456 dwSize = sizeof(dwTemp);
457 lRet = RegQueryValueExW(hKey,
458 L"Shutdown Setting",
459 NULL, NULL,
460 (LPBYTE)&dwTemp, &dwSize);
462
463 if (lRet == ERROR_SUCCESS)
464 {
465 switch (dwTemp)
466 {
468 dwValue = WLX_SAS_ACTION_LOGOFF;
469 break;
470
473 break;
474
477 break;
478
479 // 0x08
480
483 break;
484
485 // 0x20
486
489 break;
490
491 // 0x80
492 }
493 }
494
495 return dwValue;
496}
497
498static INT_PTR
501 HWND hButton,
502 UINT uMsg,
505{
506 PSHUTDOWN_DLG_CONTEXT pContext;
508
509 int buttonID = GetDlgCtrlID(hButton);
510
511 switch (uMsg)
512 {
513 case WM_MOUSEMOVE:
514 {
515 HWND hwndTarget;
517
518 if (GetCapture() != hButton)
519 {
520 SetCapture(hButton);
521 if (buttonID == IDC_BUTTON_SHUTDOWN)
522 {
523 pContext->bIsButtonHot[0] = TRUE;
524 }
525 else if (buttonID == IDC_BUTTON_REBOOT)
526 {
527 pContext->bIsButtonHot[1] = TRUE;
528 }
529 else if (buttonID == IDC_BUTTON_SLEEP)
530 {
531 pContext->bIsButtonHot[2] = TRUE;
532 }
533 else if (buttonID == IDC_BUTTON_HIBERNATE)
534 {
535 pContext->bIsButtonHot[3] = TRUE;
536 }
538 }
539
540 ClientToScreen(hButton, &pt);
541 hwndTarget = WindowFromPoint(pt);
542
543 if (hwndTarget != hButton)
544 {
546 if (buttonID == IDC_BUTTON_SHUTDOWN)
547 {
548 pContext->bIsButtonHot[0] = FALSE;
549 }
550 else if (buttonID == IDC_BUTTON_REBOOT)
551 {
552 pContext->bIsButtonHot[1] = FALSE;
553 }
554 else if (buttonID == IDC_BUTTON_SLEEP)
555 {
556 pContext->bIsButtonHot[2] = FALSE;
557 }
558 else if (buttonID == IDC_BUTTON_HIBERNATE)
559 {
560 pContext->bIsButtonHot[3] = FALSE;
561 }
562 }
563 InvalidateRect(hButton, NULL, FALSE);
564 break;
565 }
566
567 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
568 case WM_SETFOCUS:
569 {
570 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
571 break;
572 }
573
574 /* Otherwise, set IDCANCEL as default button */
575 case WM_KILLFOCUS:
576 {
578 break;
579 }
580 }
581 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
582}
583
584VOID
586 HWND hDlg,
587 BOOL bIsSleepButtonReplaced)
588{
589 WCHAR szBuffer[30];
590
591 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
592 {
593 GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE + i, szBuffer, _countof(szBuffer));
594 SetDlgItemTextW(hDlg, IDC_HIBERNATE_STATIC + i, szBuffer);
595 }
596
597 if (bIsSleepButtonReplaced)
598 {
599 GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
600 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
601 }
602}
603
604VOID
606 int controlID,
607 int detailID,
608 HWND hDlg,
609 int titleID,
611{
612 HWND hwndTool, hwndTip;
613 WCHAR szBuffer[256];
614 TTTOOLINFOW tool;
615
616 hwndTool = GetDlgItem(hDlg, controlID);
617
618 tool.cbSize = sizeof(tool);
619 tool.hwnd = hDlg;
621 tool.uId = (UINT_PTR)hwndTool;
622
623 /* Create the tooltip */
628 hDlg, NULL, hInst, NULL);
629
630 /* Associate the tooltip with the tool. */
631 LoadStringW(hInst, detailID, szBuffer, _countof(szBuffer));
632 tool.lpszText = szBuffer;
633 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
634 LoadStringW(hInst, titleID, szBuffer, _countof(szBuffer));
635 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
636 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
637}
638
639VOID
641 HWND hDlg,
643 BOOL bIsAltKeyPressed,
644 BOOL bIsSleepButtonReplaced)
645{
646 int destID = IDC_BUTTON_SLEEP;
647 int targetedID = IDC_BUTTON_HIBERNATE;
648 HWND hwndDest, hwndTarget;
649 RECT rect;
650 WCHAR szBuffer[30];
651
652 /* If the sleep button has been already replaced earlier, bring sleep button back to its original position */
653 if (bIsSleepButtonReplaced)
654 {
655 destID = IDC_BUTTON_HIBERNATE;
656 targetedID = IDC_BUTTON_SLEEP;
657 }
658
659 hwndDest = GetDlgItem(hDlg, destID);
660 hwndTarget = GetDlgItem(hDlg, targetedID);
661
662 /* Get the position of the destination button */
663 GetWindowRect(hwndDest, &rect);
664
665 /* Get the corrected translated coordinates which is relative to the client window */
666 MapWindowPoints(HWND_DESKTOP, hDlg, (LPPOINT)&rect, sizeof(RECT)/sizeof(POINT));
667
668 /* Set the position of targeted button and hide the destination button */
669 SetWindowPos(hwndTarget,
670 HWND_TOP,
671 rect.left, rect.top,
672 0, 0,
674
675 EnableWindow(hwndDest, FALSE);
676 ShowWindow(hwndDest, SW_HIDE);
677 EnableWindow(hwndTarget, TRUE);
678 ShowWindow(hwndTarget, SW_SHOW);
679 SetFocus(hwndTarget);
680
681 if (bIsAltKeyPressed)
682 {
683 if (!bIsSleepButtonReplaced)
684 {
685 GetDlgItemTextW(hDlg, IDC_BUTTON_HIBERNATE, szBuffer, _countof(szBuffer));
686 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
687 }
688 else
689 {
690 GetDlgItemTextW(hDlg, IDC_BUTTON_SLEEP, szBuffer, _countof(szBuffer));
691 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
692 }
693 }
694 else
695 {
696 if (!bIsSleepButtonReplaced)
697 {
699 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
700 }
701 else
702 {
703 LoadStringW(hInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
704 SetDlgItemTextW(hDlg, IDC_SLEEP_STATIC, szBuffer);
705 }
706 }
707}
708
709VOID
711 IN DWORD ShutdownCode)
712{
713 LONG lRet;
714 HKEY hKeyCurrentUser, hKey;
715 DWORD dwValue = 0;
716
717 /* Open the current user HKCU key */
718 lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
719 if (lRet == ERROR_SUCCESS)
720 {
721 /* Create the subkey */
722 lRet = RegCreateKeyExW(hKeyCurrentUser,
723 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
724 0, NULL,
727 NULL, &hKey, NULL);
728 RegCloseKey(hKeyCurrentUser);
729 }
730 if (lRet != ERROR_SUCCESS)
731 return;
732
733 switch (ShutdownCode)
734 {
737 break;
738
741 break;
742
745 break;
746
748 dwValue = WLX_SHUTDOWN_STATE_SLEEP;
749 break;
750
753 break;
754 }
755
757 L"Shutdown Setting",
758 0, REG_DWORD,
759 (LPBYTE)&dwValue, sizeof(dwValue));
761}
762
763DWORD
765{
767}
768
769DWORD
771{
772 DWORD Options = 0;
773
774 // FIXME: Compute those options accordings to current user's rights!
776
779
782
783 return Options;
784}
785
786static VOID
788 IN HWND hDlg,
789 IN PSHUTDOWN_DLG_CONTEXT pContext) // HINSTANCE hInstance
790{
791 UINT DescId = 0;
792 DWORD ShutdownCode;
793 WCHAR szBuffer[256];
794
795 ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETCURSEL, 0, 0);
796 if (ShutdownCode == CB_ERR) // Invalid selection
797 return;
798
799 ShutdownCode = SendDlgItemMessageW(hDlg, IDC_SHUTDOWN_ACTION, CB_GETITEMDATA, ShutdownCode, 0);
800
801 switch (ShutdownCode)
802 {
805 break;
806
809 break;
810
813 break;
814
817 break;
818
821 break;
822
823 default:
824 break;
825 }
826
827 LoadStringW(pContext->pgContext->hDllInstance, DescId, szBuffer, _countof(szBuffer));
829
830 if (pContext->bReasonUI)
831 {
835 }
836}
837
838static VOID
840 IN HWND hDlg,
841 IN PSHUTDOWN_DLG_CONTEXT pContext)
842{
843 PGINA_CONTEXT pgContext = pContext->pgContext;
844 HWND hwndList;
845 INT idx, count, i;
846 WCHAR szBuffer[256];
847 WCHAR szBuffer2[256];
848 HDC hdc;
849 LONG lfHeight;
850
851 /* Create font for the IDC_TURN_OFF_STATIC static control */
852 hdc = GetDC(hDlg);
854 ReleaseDC(hDlg, hdc);
855 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
857
858 /* Create a brush for static controls for fancy shut down dialog */
859 pContext->hBrush = CreateSolidBrush(DARK_GREY_COLOR);
860
861 pContext->hImageStrip = LoadBitmapW(pgContext->hDllInstance, MAKEINTRESOURCEW(IDB_IMAGE_STRIP));
862
863 hwndList = GetDlgItem(hDlg, IDC_SHUTDOWN_ACTION);
864
865 /* Clear the content before it's used */
866 SendMessageW(hwndList, CB_RESETCONTENT, 0, 0);
867
868 /* Set the boolean flags to false */
869 pContext->bIsSleepButtonReplaced = FALSE;
870
871 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
872 {
873 pContext->bIsButtonHot[i] = FALSE;
874 }
875
876 /* Log off */
877 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_LOGOFF)
878 {
879 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_LOGOFF, szBuffer, _countof(szBuffer));
880 StringCchPrintfW(szBuffer2, _countof(szBuffer2), szBuffer, pgContext->UserName);
881 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer2);
882 if (idx != CB_ERR)
884 }
885
886 /* Shut down - DEFAULT */
887 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_POWER_OFF)
888 {
889 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SHUTDOWN, szBuffer, _countof(szBuffer));
890 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
891 if (idx != CB_ERR)
893 }
894 else if (pContext->bFriendlyUI)
895 {
897 }
898
899 /* Restart */
900 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_REBOOT)
901 {
902 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_RESTART, szBuffer, _countof(szBuffer));
903 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
904 if (idx != CB_ERR)
906 }
907 else if (pContext->bFriendlyUI)
908 {
910 }
911
912 // if (pContext->ShutdownOptions & 0x08) {}
913
914 /* Sleep */
915 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_SLEEP)
916 {
917 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_SLEEP, szBuffer, _countof(szBuffer));
918 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
919 if (idx != CB_ERR)
921 }
922 else if (pContext->bFriendlyUI)
923 {
925 }
926
927 // if (pContext->ShutdownOptions & 0x20) {}
928
929 /* Hibernate */
930 if (pContext->ShutdownOptions & WLX_SHUTDOWN_STATE_HIBERNATE)
931 {
932 LoadStringW(pgContext->hDllInstance, IDS_SHUTDOWN_HIBERNATE, szBuffer, _countof(szBuffer));
933 idx = SendMessageW(hwndList, CB_ADDSTRING, 0, (LPARAM)szBuffer);
934 if (idx != CB_ERR)
936 }
937 else if (pContext->bFriendlyUI)
938 {
940 }
941
942 // if (pContext->ShutdownOptions & 0x80) {}
943
944 /* Set the default shut down selection */
945 count = SendMessageW(hwndList, CB_GETCOUNT, 0, 0);
946 for (i = 0; i < count; i++)
947 {
948 if (SendMessageW(hwndList, CB_GETITEMDATA, i, 0) == pgContext->nShutdownAction)
949 {
950 SendMessageW(hwndList, CB_SETCURSEL, i, 0);
951 break;
952 }
953 }
954
955 /* Create tool tips for the buttons of fancy log off dialog */
959 pContext->pgContext->hDllInstance);
963 pContext->pgContext->hDllInstance);
967 pContext->pgContext->hDllInstance);
970 hDlg, IDS_SHUTDOWN_SLEEP,
971 pContext->pgContext->hDllInstance);
972
973 /* Gather old button func */
974 pContext->OldButtonProc = (WNDPROC)GetWindowLongPtrW(GetDlgItem(hDlg, IDC_BUTTON_HIBERNATE), GWLP_WNDPROC);
975
976 /* Make buttons to remember pContext and subclass the buttons */
977 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
978 {
981 }
982
983 /* Update the choice description based on the current selection */
984 UpdateShutdownDesc(hDlg, pContext);
985}
986
987static VOID
989 IN HWND hDlg,
990 IN PGINA_CONTEXT pgContext)
991{
992 INT idx;
993
997 0,
998 0);
999 if (idx != CB_ERR)
1000 {
1001 pgContext->nShutdownAction =
1005 idx,
1006 0);
1007 }
1008}
1009
1010static INT_PTR
1013 HWND hDlg,
1014 UINT uMsg,
1015 WPARAM wParam,
1016 LPARAM lParam)
1017{
1018 PSHUTDOWN_DLG_CONTEXT pContext;
1019
1021
1022 switch (uMsg)
1023 {
1024 case WM_INITDIALOG:
1025 {
1026 pContext = (PSHUTDOWN_DLG_CONTEXT)lParam;
1027 SetWindowLongPtrW(hDlg, GWLP_USERDATA, (LONG_PTR)pContext);
1028
1029 ShutdownOnInit(hDlg, pContext);
1030
1031 /* Draw the logo bitmap */
1032 pContext->hBitmap =
1033 LoadImageW(pContext->pgContext->hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
1034 return TRUE;
1035 }
1036
1037 case WM_DESTROY:
1038 DeleteObject(pContext->hBitmap);
1039 DeleteObject(pContext->hBrush);
1040 DeleteObject(pContext->hImageStrip);
1041 DeleteObject(pContext->hfFont);
1042
1043 /* Remove the subclass from the buttons */
1044 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1045 {
1047 }
1048 return TRUE;
1049
1050 case WM_ACTIVATE:
1051 {
1052 /*
1053 * If the user deactivates the shutdown dialog (it loses its focus
1054 * while the dialog is not being closed), then destroy the dialog
1055 * and cancel shutdown.
1056 */
1057 if (LOWORD(wParam) == WA_INACTIVE)
1058 {
1059 if (!pContext->bCloseDlg)
1060 {
1061 pContext->bCloseDlg = TRUE;
1062
1063 if (pContext->bIsDialogModal)
1064 {
1065 EndDialog(hDlg, 0);
1066 }
1067 else
1068 {
1069 DestroyWindow(hDlg);
1070 PostQuitMessage(0);
1071 }
1072 }
1073 }
1074 return FALSE;
1075 }
1076
1077 case WM_PAINT:
1078 {
1079 PAINTSTRUCT ps;
1080 if (pContext->hBitmap)
1081 {
1082 BeginPaint(hDlg, &ps);
1083 DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
1084 EndPaint(hDlg, &ps);
1085 }
1086 return TRUE;
1087 }
1088
1089 case WM_CLOSE:
1090 pContext->bCloseDlg = TRUE;
1091
1092 if (pContext->bIsDialogModal)
1093 {
1094 EndDialog(hDlg, IDCANCEL);
1095 }
1096 else
1097 {
1098 DestroyWindow(hDlg);
1100 }
1101 break;
1102
1103 case WM_COMMAND:
1104 switch (LOWORD(wParam))
1105 {
1107 ExitWindowsEx(EWX_SHUTDOWN, SHTDN_REASON_MAJOR_OTHER);
1108 break;
1109
1110 case IDC_BUTTON_REBOOT:
1111 ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_OTHER);
1112 break;
1113
1114 case IDC_BUTTON_SLEEP:
1116 break;
1117
1118 case IDOK:
1119 ShutdownOnOk(hDlg, pContext->pgContext);
1120
1121 /* Fall back */
1122 case IDCANCEL:
1123 case IDHELP:
1124 pContext->bCloseDlg = TRUE;
1125
1126 if (pContext->bIsDialogModal)
1127 {
1128 EndDialog(hDlg, LOWORD(wParam));
1129 }
1130 else
1131 {
1132 DestroyWindow(hDlg);
1134 }
1135 break;
1136
1138 UpdateShutdownDesc(hDlg, pContext);
1139 break;
1140 }
1141 break;
1142
1143 case WM_CTLCOLORSTATIC:
1144 {
1145 /* Either make background transparent or fill it with color for required static controls */
1146 HDC hdcStatic = (HDC)wParam;
1148
1149 switch (StaticID)
1150 {
1152 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1153 SetBkMode(hdcStatic, TRANSPARENT);
1155
1158 case IDC_SLEEP_STATIC:
1159 case IDC_RESTART_STATIC:
1160 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1161 SetBkMode(hdcStatic, TRANSPARENT);
1162 return (LONG_PTR)pContext->hBrush;
1163 }
1164 return FALSE;
1165 }
1166
1167 case WM_DRAWITEM:
1168 {
1169 /* Draw bitmaps on required buttons */
1171 switch (pdis->CtlID)
1172 {
1174 case IDC_BUTTON_REBOOT:
1175 case IDC_BUTTON_SLEEP:
1177 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1178 }
1179 break;
1180 }
1181
1182 default:
1183 return FALSE;
1184 }
1185 return TRUE;
1186}
1187
1188INT_PTR
1190 IN HWND hwndDlg,
1191 IN DWORD ShutdownOptions,
1192 IN PGINA_CONTEXT pgContext)
1193{
1194 INT_PTR ret;
1196 BOOL bIsAltKeyPressed = FALSE;
1197 DWORD ShutdownDialogId = IDD_SHUTDOWN;
1198 MSG Msg;
1199 HWND hDlg;
1200
1201#if 0
1202 DWORD ShutdownOptions;
1203
1204 // FIXME: User impersonation!!
1205 pgContext->nShutdownAction = LoadShutdownSelState();
1206 ShutdownOptions = GetAllowedShutdownOptions();
1207#endif
1208
1209 Context.pgContext = pgContext;
1210 Context.ShutdownOptions = ShutdownOptions;
1211 Context.bCloseDlg = FALSE;
1212 Context.bReasonUI = GetShutdownReasonUI();
1213 Context.bFriendlyUI = ShellIsFriendlyUIActive();
1214
1215 if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1216 {
1217 Context.bIsDialogModal = TRUE;
1218 ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1219 pgContext->hDllInstance,
1221 hwndDlg,
1223 (LPARAM)&Context);
1224 }
1225 else
1226 {
1227 if (Context.bFriendlyUI)
1228 {
1230 {
1231 ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1232 }
1233 else
1234 {
1235 ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1236 }
1237 }
1238
1239 Context.bIsDialogModal = FALSE;
1240 hDlg = CreateDialogParamW(pgContext->hDllInstance,
1241 MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : ShutdownDialogId),
1242 hwndDlg,
1244 (LPARAM)&Context);
1245
1246 ShowWindow(hDlg, SW_SHOW);
1247
1248 /* Detect either Alt or Shift key have been pressed or released */
1249 while (GetMessageW(&Msg, NULL, 0, 0))
1250 {
1251 if (!IsDialogMessageW(hDlg, &Msg))
1252 {
1255 }
1256
1257 switch (Msg.message)
1258 {
1259 case WM_SYSKEYDOWN:
1260 {
1261 /* If the Alt key has been pressed once, add prefix to static controls */
1262 if (Msg.wParam == VK_MENU && !bIsAltKeyPressed)
1263 {
1264 AddPrefixToStaticTexts(hDlg, Context.bIsSleepButtonReplaced);
1265 bIsAltKeyPressed = TRUE;
1266 }
1267 }
1268 break;
1269
1270 case WM_KEYDOWN:
1271 {
1272 /*
1273 * If the Shift key has been pressed once, and both hibernate button and sleep button are enabled
1274 * replace the sleep button with hibernate button
1275 */
1276 if (Msg.wParam == VK_SHIFT)
1277 {
1278 if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && !Context.bIsSleepButtonReplaced)
1279 {
1281 {
1283 pgContext->hDllInstance,
1284 bIsAltKeyPressed,
1285 Context.bIsSleepButtonReplaced);
1286 Context.bIsSleepButtonReplaced = TRUE;
1287 }
1288 }
1289 }
1290 }
1291 break;
1292
1293 case WM_KEYUP:
1294 {
1295 /* If the Shift key has been released after being pressed, replace the hibernate button with sleep button again */
1296 if (Msg.wParam == VK_SHIFT)
1297 {
1298 if (ShutdownDialogId == IDD_SHUTDOWN_FANCY && Context.bIsSleepButtonReplaced)
1299 {
1301 {
1303 pgContext->hDllInstance,
1304 bIsAltKeyPressed,
1305 Context.bIsSleepButtonReplaced);
1306 Context.bIsSleepButtonReplaced = FALSE;
1307 }
1308 }
1309 }
1310 }
1311 break;
1312 }
1313 }
1314 ret = Msg.wParam;
1315 }
1316
1317#if 0
1318 // FIXME: User impersonation!!
1319 if (ret == IDOK)
1320 SaveShutdownSelState(pgContext->nShutdownAction);
1321#endif
1322
1323 return ret;
1324}
1325
1326
1327/*
1328 * NOTES:
1329 * - Based upon observations on the ShellShutdownDialog() function, the function doesn't actually
1330 * do anything except show a dialog box and returning a value based upon the value chosen. That
1331 * means that any code that calls the function has to execute the chosen action (shut down,
1332 * restart, etc.).
1333 * - When this function is called in Windows XP, it shows the classic dialog box regardless if
1334 * SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType is enabled or not.
1335 * - When the Help button is pushed, it sends the same return value as IDCANCEL (0x00), but
1336 * at the same time, it calls the help file directly from the dialog box.
1337 * - When the dialog is created, it doesn't disable all other input from the other windows.
1338 * This is done elsewhere. When running the function ShellShutdownDialog() from XP/2K3, if the user clicks
1339 * out of the window, it automatically closes itself.
1340 * - The parameter, lpUsername never seems to be used when calling the function from Windows XP. Either
1341 * it was a parameter that was never used in the final version before release, or it has a use that
1342 * is currently not known.
1343 */
1346 HWND hParent,
1347 LPWSTR lpUsername,
1348 BOOL bHideLogoff)
1349{
1350 INT_PTR dlgValue;
1351 DWORD ShutdownOptions;
1352
1353 /*
1354 * As we are called by the shell itself, don't use
1355 * the cached GINA context but use a local copy here.
1356 */
1357 GINA_CONTEXT gContext = { 0 };
1359
1360 UNREFERENCED_PARAMETER(lpUsername);
1361
1362 ShutdownOptions = GetAllowedShutdownOptions();
1363 if (bHideLogoff)
1364 ShutdownOptions &= ~WLX_SHUTDOWN_STATE_LOGOFF;
1365
1366 /* Initialize our local GINA context */
1367 gContext.hDllInstance = hDllInstance;
1368 BufferSize = _countof(gContext.UserName);
1369 // NOTE: Only when this function is called, Win checks inside
1370 // HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1371 // value "Logon User Name", and determines whether it will display
1372 // the user name.
1373 GetUserNameW(gContext.UserName, &BufferSize);
1375
1376 /* Load the shutdown dialog box */
1377 dlgValue = ShutdownDialog(hParent, ShutdownOptions, &gContext);
1378
1379 /* Determine what to do based on user selection */
1380 if (dlgValue == IDOK)
1381 {
1383
1384 switch (gContext.nShutdownAction)
1385 {
1388
1391
1394
1395 // 0x08
1396
1399
1400 // 0x20
1401
1404
1405 // 0x80
1406 }
1407 }
1408 /* Help file is called directly here */
1409 else if (dlgValue == IDHELP)
1410 {
1411 FIXME("Help is not implemented yet.\n");
1412 MessageBoxW(hParent, L"Help is not implemented yet.", L"Message", MB_OK | MB_ICONEXCLAMATION);
1413 }
1414 else if (dlgValue == -1)
1415 {
1416 ERR("Failed to create dialog\n");
1417 }
1418
1419 return 0;
1420}
1421
1422/*
1423 * NOTES:
1424 * - Undocumented, called from MS shell32.dll to show the turn off dialog.
1425 * - Seems to have the same purpose as ShellShutdownDialog.
1426 */
1429{
1431}
HWND hWnd
Definition: settings.c:17
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define IDI_ROSLOGO
Definition: resource.h:42
static INT_PTR CALLBACK ShutdownDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: shutdown.c:171
#define FIXME(fmt,...)
Definition: debug.h:111
#define UNIMPLEMENTED
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:110
#define RegCloseKey(hKey)
Definition: registry.h:47
HINSTANCE hInstance
Definition: charmap.c:19
static HINSTANCE hDllInstance
Definition: clb.c:30
WPARAM wParam
Definition: combotst.c:138
struct @1609 Msg[]
LPARAM lParam
Definition: combotst.c:139
#define BufferSize
Definition: mmc.h:75
#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
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:1091
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3232
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:4900
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define CALLBACK
Definition: compat.h:35
#define IDC_BUTTON_HIBERNATE
Definition: resource.h:61
#define IDS_SHUTDOWN_LOGOFF_DESC
Definition: resource.h:121
#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:115
#define IDS_SHUTDOWN_SHUTDOWN_DESC
Definition: resource.h:120
#define IDC_SHUTDOWN_STATIC
Definition: resource.h:58
#define IDS_SHUTDOWN_SLEEP_DESC
Definition: resource.h:123
#define IDS_SHUTDOWN_SHUTDOWN
Definition: resource.h:114
#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:64
#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:62
#define IDD_SHUTDOWN_REASON
Definition: resource.h:46
#define IDC_BUTTON_SHUTDOWN
Definition: resource.h:63
#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:49
static VOID ShutdownOnOk(IN HWND hDlg, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:988
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:770
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
DWORD WINAPI ShellTurnOffDialog(HWND hWnd)
Definition: shutdown.c:1428
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:433
#define DARK_GREY_COLOR
Definition: shutdown.c:30
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:70
#define BUTTON_REBOOT_PRESSED
Definition: shutdown.c:44
static BOOL ForceFriendlyUI(VOID)
Definition: shutdown.c:252
#define BUTTON_SLEEP_FOCUSED
Definition: shutdown.c:48
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
static BOOL IsFriendlyUIActive(VOID)
Definition: shutdown.c:130
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID, HINSTANCE hInst)
Definition: shutdown.c:605
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:222
static VOID ShutdownOnInit(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:839
#define CX_BITMAP
Definition: shutdown.c:34
static INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:500
VOID AddPrefixToStaticTexts(HWND hDlg, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:585
struct _SHUTDOWN_DLG_CONTEXT * PSHUTDOWN_DLG_CONTEXT
static BOOL IsDomainMember(VOID)
Definition: shutdown.c:206
static BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:306
#define BUTTON_SHUTDOWN_PRESSED
Definition: shutdown.c:41
DWORD WINAPI ShellShutdownDialog(HWND hParent, LPWSTR lpUsername, BOOL bHideLogoff)
Definition: shutdown.c:1345
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
Definition: shutdown.c:414
DWORD GetDefaultShutdownSelState(VOID)
Definition: shutdown.c:427
#define NUMBER_OF_BUTTONS
Definition: shutdown.c:37
#define FONT_POINT_SIZE
Definition: shutdown.c:28
INT_PTR ShutdownDialog(IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
Definition: shutdown.c:1189
#define BUTTON_SHUTDOWN
Definition: shutdown.c:40
static VOID UpdateShutdownDesc(IN HWND hDlg, IN PSHUTDOWN_DLG_CONTEXT pContext)
Definition: shutdown.c:787
#define BUTTON_SLEEP_PRESSED
Definition: shutdown.c:47
#define BUTTON_REBOOT
Definition: shutdown.c:43
VOID ReplaceRequiredButton(HWND hDlg, HINSTANCE hInstance, BOOL bIsAltKeyPressed, BOOL bIsSleepButtonReplaced)
Definition: shutdown.c:640
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define CY_BITMAP
Definition: shutdown.c:35
#define BUTTON_REBOOT_FOCUSED
Definition: shutdown.c:45
#define LIGHT_GREY_COLOR
Definition: shutdown.c:31
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
DWORD GetDefaultShutdownOptions(VOID)
Definition: shutdown.c:764
#define BUTTON_SLEEP
Definition: shutdown.c:46
#define BUTTON_SHUTDOWN_FOCUSED
Definition: shutdown.c:42
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:710
static BOOL IsNetwareActive(VOID)
Definition: shutdown.c:214
struct _SHUTDOWN_DLG_CONTEXT SHUTDOWN_DLG_CONTEXT
#define pt(x, y)
Definition: drawing.c:79
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
pKey DeleteObject()
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
__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 REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_POPUP
Definition: pedump.c:616
long LONG
Definition: pedump.c:60
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:681
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#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
#define IDHELP
Definition: resource_2.h:8
#define REG_DWORD
Definition: sdbapi.c:596
#define _countof(array)
Definition: sndvol32.h:68
& rect
Definition: startmenu.cpp:1413
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR UserName[256]
Definition: msgina.h:50
ULONG nShutdownAction
Definition: msgina.h:47
HANDLE hDllInstance
Definition: msgina.h:37
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
PGINA_CONTEXT pgContext
Definition: shutdown.c:53
BOOL bIsButtonHot[NUMBER_OF_BUTTONS]
Definition: shutdown.c:63
WNDPROC OldButtonProc
Definition: shutdown.c:65
BOOL bIsSleepButtonReplaced
Definition: shutdown.c:60
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
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
int ret
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
HDC hdcMem
Definition: welcome.c:104
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define GetVersionEx
Definition: winbase.h:3723
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
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:1539
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:918
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 WM_PAINT
Definition: winuser.h:1610
#define ODS_DISABLED
Definition: winuser.h:2537
HWND WINAPI SetCapture(_In_ HWND hWnd)
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CB_SETITEMDATA
Definition: winuser.h:1956
#define EWX_SHUTDOWN
Definition: winuser.h:634
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1762
#define ODS_SELECTED
Definition: winuser.h:2535
#define SW_HIDE
Definition: winuser.h:762
#define WM_CLOSE
Definition: winuser.h:1611
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define DM_SETDEFID
Definition: winuser.h:2089
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4819
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define WM_KEYUP
Definition: winuser.h:1706
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define ODA_DRAWENTIRE
Definition: winuser.h:2532
BOOL WINAPI IsDialogMessageW(_In_ HWND, _In_ LPMSG)
#define IDCANCEL
Definition: winuser.h:825
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define GWL_ID
Definition: winuser.h:853
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)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1730
#define ODA_FOCUS
Definition: winuser.h:2534
#define CB_ERR
Definition: winuser.h:2425
#define CB_SETCURSEL
Definition: winuser.h:1951
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_SETFOCUS
Definition: winuser.h:1603
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SWP_NOSIZE
Definition: winuser.h:1235
#define WM_MOUSEMOVE
Definition: winuser.h:1765
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WA_INACTIVE
Definition: winuser.h:2612
#define CB_RESETCONTENT
Definition: winuser.h:1949
#define WM_INITDIALOG
Definition: winuser.h:1729
#define CB_GETCOUNT
Definition: winuser.h:1932
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
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:824
#define WM_DRAWITEM
Definition: winuser.h:1635
#define HWND_DESKTOP
Definition: winuser.h:1199
#define WM_ACTIVATE
Definition: winuser.h:1602
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EWX_REBOOT
Definition: winuser.h:633
#define HWND_TOP
Definition: winuser.h:1197
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_SETFONT
Definition: winuser.h:1640
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DST_BITMAP
Definition: winuser.h:516
#define CB_ADDSTRING
Definition: winuser.h:1926
#define CB_GETITEMDATA
Definition: winuser.h:1940
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define MB_OK
Definition: winuser.h:784
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
#define ODA_SELECT
Definition: winuser.h:2533
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
HWND WINAPI WindowFromPoint(_In_ POINT)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1081
int WINAPI GetDlgCtrlID(_In_ HWND)
#define VK_SHIFT
Definition: winuser.h:2192
#define IDC_HAND
Definition: winuser.h:693
#define SW_SHOW
Definition: winuser.h:769
#define WM_DESTROY
Definition: winuser.h:1599
#define WM_KEYDOWN
Definition: winuser.h:1705
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:2896
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2132
#define SWP_NOZORDER
Definition: winuser.h:1237
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define CB_GETCURSEL
Definition: winuser.h:1933
#define SetWindowLongPtrW
Definition: winuser.h:5336
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WM_KILLFOCUS
Definition: winuser.h:1604
#define ODS_FOCUS
Definition: winuser.h:2539
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_MENU
Definition: winuser.h:2194
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_LOGOFF
Definition: winwlx.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184