ReactOS 0.4.15-dev-7131-ge4d03f4
wlx.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Winlogon
4 * FILE: base/system/winlogon/wlx.c
5 * PURPOSE: Logon
6 * PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
7 * Ge van Geldorp (gvg@reactos.com)
8 * Hervé Poussineau (hpoussin@reactos.org)
9 */
10
11/* INCLUDES *****************************************************************/
12
13#include "winlogon.h"
14
15typedef struct _DIALOG_LIST_ENTRY
16{
22
23/* GLOBALS ******************************************************************/
24
25//static UINT_PTR IdTimer;
27
28/* FUNCTIONS ****************************************************************/
29
30VOID
32{
34}
35
36
37static
40{
41 PDIALOG_LIST_ENTRY ListEntry;
42
43 ListEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DIALOG_LIST_ENTRY));
44 if (ListEntry == NULL)
45 return NULL;
46
47 TRACE("Add entry %p\n", ListEntry);
48
50 &ListEntry->Entry);
51
52 return ListEntry;
53}
54
55
56static
57VOID
59{
60 TRACE("Remove entry %p\n", ListEntry);
61
62 RemoveEntryList(&ListEntry->Entry);
63 RtlFreeHeap(RtlGetProcessHeap(), 0, ListEntry);
64}
65
66
67static
70{
71 PDIALOG_LIST_ENTRY Current;
72 PLIST_ENTRY ListEntry;
73
74 ListEntry = DialogListHead.Flink;
75 while (ListEntry != &DialogListHead)
76 {
77 Current = CONTAINING_RECORD(ListEntry,
79 Entry);
80 if (Current->hWnd == hwndDlg)
81 {
82 TRACE("Found entry: %p\n", Current);
83 return Current;
84 }
85
86 ListEntry = ListEntry->Flink;
87 }
88
89 TRACE("Found no entry!\n");
90 return NULL;
91}
92
93
94VOID
96{
97 PDIALOG_LIST_ENTRY Current;
98 PLIST_ENTRY ListEntry;
99
100 ListEntry = DialogListHead.Flink;
101 while (ListEntry != &DialogListHead)
102 {
103 Current = CONTAINING_RECORD(ListEntry,
105 Entry);
106
107 PostMessage(Current->hWnd, WLX_WM_SAS, 0, 0);
108
109 ListEntry = ListEntry->Flink;
110 }
111}
112
113
114static
118 IN HWND hwndDlg,
119 IN UINT uMsg,
122{
123 PDIALOG_LIST_ENTRY ListEntry;
124 INT_PTR ret;
125
126 if (uMsg == WM_INITDIALOG)
127 {
128 ListEntry = (PDIALOG_LIST_ENTRY)lParam;
129
130 TRACE("Set dialog handle: %p\n", hwndDlg);
131 ListEntry->hWnd = hwndDlg;
132 lParam = ListEntry->lParam;
133// SetTopTimeout(hWnd);
134 }
135 else
136 {
137 ListEntry = GetDialogListEntry(hwndDlg);
138 if (ListEntry == NULL)
139 return FALSE;
140 }
141
142 if (uMsg == WLX_WM_SAS)
143 {
144 EndDialog(hwndDlg, WLX_DLG_SAS);
145 return 0;
146 }
147
148 ret = ListEntry->DlgProc(hwndDlg, uMsg, wParam, lParam);
149
150 return ret;
151
152/*
153 if (uMsg == WM_TIMER && (UINT_PTR)wParam == IdTimer)
154 {
155 EndDialog(hwndDlg, -1);
156 KillTimer(hwndDlg, IdTimer);
157 return TRUE;
158 }
159 else if (uMsg == WM_INITDIALOG)
160 {
161 IdTimer = SetTimer(hwndDlg, 0, WLSession->DialogTimeout * 1000, NULL);
162 return PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
163 }
164 else if (uMsg == WM_NCDESTROY)
165 {
166 BOOL ret;
167 ret = PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
168 PreviousWindowProc = NULL;
169 return ret;
170 }
171 else
172 {
173 return PreviousWindowProc(hwndDlg, uMsg, wParam, lParam);
174 }
175*/
176}
177
178/*
179 * @implemented
180 */
181VOID
182WINAPI
184 HANDLE hWlx)
185{
186 ULONG_PTR OldValue;
187
188 TRACE("WlxUseCtrlAltDel()\n");
189
191}
192
193/*
194 * @implemented
195 */
196VOID
197WINAPI
199 HANDLE hWlx,
200 PVOID pWlxContext)
201{
202 ULONG_PTR OldValue;
203
204 TRACE("WlxSetContextPointer(%p)\n", pWlxContext);
205
206 WlxSetOption(hWlx, WLX_OPTION_CONTEXT_POINTER, (ULONG_PTR)pWlxContext, &OldValue);
207}
208
209/*
210 * @implemented
211 */
212VOID
213WINAPI
215 HANDLE hWlx,
216 DWORD dwSasType)
217{
218 PWLSESSION Session = (PWLSESSION)hWlx;
219
220 TRACE("WlxSasNotify(0x%lx)\n", dwSasType);
221
222 if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL || dwSasType > WLX_SAS_TYPE_MAX_MSFT_VALUE)
223 PostMessageW(Session->SASWindow, WLX_WM_SAS, dwSasType, 0);
224}
225
226/*
227 * @implemented
228 */
229BOOL
230WINAPI
232 HANDLE hWlx,
234{
235 PWLSESSION Session = (PWLSESSION)hWlx;
236
237 TRACE("WlxSetTimeout(%lu)\n", Timeout);
238
239 Session->DialogTimeout = Timeout;
240 return TRUE;
241}
242
243/*
244 * @unimplemented
245 */
246int
247WINAPI
249 HANDLE hWlx,
250 HANDLE hToken,
253{
258
260 return 0;
261}
262
263/*
264 * @implemented
265 */
266int
267WINAPI
269 HANDLE hWlx,
270 HWND hwndOwner,
271 LPWSTR lpszText,
272 LPWSTR lpszTitle,
273 UINT fuStyle)
274{
276
277 TRACE("WlxMessageBox()\n");
278 /* FIXME: Provide a custom window proc to be able to handle timeout */
279 return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle);
280}
281
282/*
283 * @implemented
284 */
285int
286WINAPI
288 HANDLE hWlx,
290 LPWSTR lpszTemplate,
291 HWND hwndOwner,
292 DLGPROC dlgprc)
293{
295
296 TRACE("WlxDialogBox()\n");
297
298 return (int)WlxDialogBoxParam(hWlx, hInst, lpszTemplate, hwndOwner, dlgprc, 0);
299}
300
301/*
302 * @implemented
303 */
304int
305WINAPI
307 HANDLE hWlx,
309 LPWSTR lpszTemplate,
310 HWND hwndOwner,
311 DLGPROC dlgprc,
312 LPARAM dwInitParam)
313{
314 PDIALOG_LIST_ENTRY ListEntry;
315 int ret;
316
318
319 TRACE("WlxDialogBoxParam()\n");
320
321 ListEntry = AddDialogListEntry();
322 if (ListEntry == NULL)
323 return -1;
324
325 ListEntry->DlgProc = dlgprc;
326 ListEntry->lParam = dwInitParam;
327
328 ret = (int)DialogBoxParamW(hInst, lpszTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
329
330 RemoveDialogListEntry(ListEntry);
331
332 return ret;
333}
334
335/*
336 * @implemented
337 */
338int
339WINAPI
341 HANDLE hWlx,
343 LPCDLGTEMPLATE hDialogTemplate,
344 HWND hwndOwner,
345 DLGPROC dlgprc)
346{
348
349 TRACE("WlxDialogBoxIndirect()\n");
350
351 return (int)WlxDialogBoxIndirectParam(hWlx, hInst, hDialogTemplate, hwndOwner, dlgprc, 0);
352}
353
354/*
355 * @implemented
356 */
357int
358WINAPI
360 HANDLE hWlx,
362 LPCDLGTEMPLATE hDialogTemplate,
363 HWND hwndOwner,
364 DLGPROC dlgprc,
365 LPARAM dwInitParam)
366{
367 PDIALOG_LIST_ENTRY ListEntry;
368 int ret;
369
371
372 TRACE("WlxDialogBoxIndirectParam()\n");
373
374 ListEntry = AddDialogListEntry();
375 if (ListEntry == NULL)
376 return -1;
377
378 ListEntry->DlgProc = dlgprc;
379 ListEntry->lParam = dwInitParam;
380
381 ret = (int)DialogBoxIndirectParamW(hInst, hDialogTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
382
383 RemoveDialogListEntry(ListEntry);
384
385 return ret;
386}
387
388/*
389 * @implemented
390 */
391int
392WINAPI
394 HANDLE hWlx)
395{
396 PWLSESSION Session = (PWLSESSION)hWlx;
397
398 TRACE("WlxSwitchDesktopToUser()\n");
399
400 return (int)SwitchDesktop(Session->ApplicationDesktop);
401}
402
403/*
404 * @implemented
405 */
406int
407WINAPI
409 HANDLE hWlx)
410{
411 PWLSESSION Session = (PWLSESSION)hWlx;
412
413 TRACE("WlxSwitchDesktopToWinlogon()\n");
414
415 return (int)SwitchDesktop(Session->WinlogonDesktop);
416}
417
418/*
419 * @unimplemented
420 */
421int
422WINAPI
424 HANDLE hWlx,
425 PWLX_MPR_NOTIFY_INFO pMprInfo,
426 DWORD dwChangeInfo)
427{
429 UNREFERENCED_PARAMETER(pMprInfo);
430 UNREFERENCED_PARAMETER(dwChangeInfo);
431
433 return 0;
434}
435
436/*
437 * @unimplemented
438 */
439BOOL
440WINAPI
442 HANDLE hWlx,
443 PWLX_DESKTOP* ppDesktop)
444{
446 UNREFERENCED_PARAMETER(ppDesktop);
447
449 return FALSE;
450}
451
452/*
453 * @unimplemented
454 */
455BOOL
456WINAPI
458 HANDLE hWlx,
459 PWLX_DESKTOP pDesktop)
460{
462 UNREFERENCED_PARAMETER(pDesktop);
463
465 return FALSE;
466}
467
468/*
469 * @unimplemented
470 */
471BOOL
472WINAPI
474 HANDLE hWlx,
475 HANDLE hToken,
476 DWORD Flags,
477 PWSTR pszDesktopName,
478 PWLX_DESKTOP* ppDesktop)
479{
483 UNREFERENCED_PARAMETER(pszDesktopName);
484 UNREFERENCED_PARAMETER(ppDesktop);
485
487 return FALSE;
488}
489
490/*
491 * @unimplemented
492 */
493int
494WINAPI
496 HANDLE hWlx,
497 PWLX_MPR_NOTIFY_INFO pMprInfo,
498 DWORD dwChangeInfo,
499 PWSTR ProviderName,
501{
503 UNREFERENCED_PARAMETER(pMprInfo);
504 UNREFERENCED_PARAMETER(dwChangeInfo);
505 UNREFERENCED_PARAMETER(ProviderName);
507
509 return 0;
510}
511
512/*
513 * @unimplemented
514 */
515BOOL
516WINAPI
518 HANDLE hWlx,
519 PWLX_DESKTOP pDesktop,
520 HANDLE hToken)
521{
523 UNREFERENCED_PARAMETER(pDesktop);
525
527 return FALSE;
528}
529
530/*
531 * @implemented
532 */
533BOOL
534WINAPI
536 HANDLE hWlx,
537 DWORD Option,
539 ULONG_PTR* OldValue)
540{
541 PWLSESSION Session = (PWLSESSION)hWlx;
542
543 TRACE("WlxSetOption(%lu)\n", Option);
544
545 switch (Option)
546 {
548 *OldValue = (ULONG_PTR)Session->Gina.UseCtrlAltDelete;
549 Session->Gina.UseCtrlAltDelete = (BOOL)Value;
550 return TRUE;
552 *OldValue = (ULONG_PTR)Session->Gina.Context;
553 Session->Gina.Context = (PVOID)Value;
554 return TRUE;
557 return FALSE;
558 }
559
560 return FALSE;
561}
562
563/*
564 * @implemented
565 */
566BOOL
567WINAPI
569 HANDLE hWlx,
570 DWORD Option,
572{
573 PWLSESSION Session = (PWLSESSION)hWlx;
574
575 TRACE("WlxGetOption(%lu)\n", Option);
576
577 switch (Option)
578 {
581 return TRUE;
583 {
584 *Value = (ULONG_PTR)Session->Gina.Context;
585 return TRUE;
586 }
591 return FALSE;
593 {
594 switch (Session->Gina.Version)
595 {
596 case WLX_VERSION_1_0:
598 break;
599 case WLX_VERSION_1_1:
601 break;
602 case WLX_VERSION_1_2:
604 break;
605 case WLX_VERSION_1_3:
607 break;
608 case WLX_VERSION_1_4:
610 break;
611 default:
612 return FALSE;
613 }
614 return TRUE;
615 }
616 }
617
618 return FALSE;
619}
620
621/*
622 * @unimplemented
623 */
624VOID
625WINAPI
627 HANDLE hWlx)
628{
630
632}
633
634/*
635 * @unimplemented
636 */
637BOOL
638WINAPI
641{
643
645 return FALSE;
646}
647
648/*
649 * @unimplemented
650 */
651BOOL
652WINAPI
655{
657
659 return FALSE;
660}
661
662/*
663 * @unimplemented
664 */
665BOOL
666WINAPI
668{
670 return FALSE;
671}
672
673/*
674 * @unimplemented
675 */
676DWORD
677WINAPI
679 HANDLE hWlx,
681 WCHAR* UserName,
682 WCHAR* Domain)
683{
685 UNREFERENCED_PARAMETER(pTSData);
686 UNREFERENCED_PARAMETER(UserName);
688
690 return 0;
691}
692
693/*
694 * @unimplemented
695 */
696DWORD
697WINAPI
700{
702
704 return 0;
705}
706
707/*
708 * @unimplemented
709 */
710BOOL
711WINAPI
714{
716
718 return FALSE;
719}
720
721static
750};
751
752/******************************************************************************/
753
754static
755BOOL
758 IN DWORD Len)
759{
760 LONG Status;
761 DWORD Type, Size;
762 HKEY hKey;
763
766 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
767 0,
769 &hKey);
770 if (Status != ERROR_SUCCESS)
771 {
772 /* Default value */
773 wcsncpy(Path, L"msgina.dll", Len);
774 return TRUE;
775 }
776
777 Size = Len * sizeof(WCHAR);
779 hKey,
780 L"GinaDLL",
781 NULL,
782 &Type,
783 (LPBYTE)Path,
784 &Size);
785 if (Status != ERROR_SUCCESS || Type != REG_SZ || Size == 0)
786 wcsncpy(Path, L"msgina.dll", Len);
788 return TRUE;
789}
790
791static
792BOOL
793WINAPI
795 IN PVOID pWlxContext,
796 IN OUT BOOL *pSecure)
797{
798 if (*pSecure)
799 *pSecure = WLSession->Gina.Functions.WlxIsLogoffOk(pWlxContext);
800 return TRUE;
801}
802
803static
804BOOL
806 IN OUT PGINAFUNCTIONS Functions,
807 OUT DWORD *DllVersion,
808 OUT HMODULE *GinaInstance)
809{
810 HMODULE hGina = NULL;
811 WCHAR GinaDll[MAX_PATH + 1];
812 BOOL ret = FALSE;
813
814 GinaDll[0] = '\0';
815 if (!GetGinaPath(GinaDll, MAX_PATH))
816 goto cleanup;
817 /* Terminate string */
818 GinaDll[MAX_PATH] = '\0';
819
820 hGina = LoadLibraryW(GinaDll);
821 if (!hGina)
822 goto cleanup;
823
824 Functions->WlxNegotiate = (PFWLXNEGOTIATE)GetProcAddress(hGina, "WlxNegotiate");
825 Functions->WlxInitialize = (PFWLXINITIALIZE)GetProcAddress(hGina, "WlxInitialize");
826
827 if (!Functions->WlxInitialize)
828 goto cleanup;
829
830 if (!Functions->WlxNegotiate)
831 {
832 /* Assume current version */
833 *DllVersion = WLX_CURRENT_VERSION;
834 }
835 else
836 {
837 TRACE("About to negotiate with Gina %S. Winlogon uses version %x\n",
838 GinaDll, WLX_CURRENT_VERSION);
839 if (!Functions->WlxNegotiate(WLX_CURRENT_VERSION, DllVersion))
840 goto cleanup;
841 }
842
843 TRACE("Gina uses WLX_VERSION %lx\n", *DllVersion);
844
845 if (*DllVersion >= WLX_VERSION_1_0)
846 {
847 Functions->WlxActivateUserShell = (PFWLXACTIVATEUSERSHELL)GetProcAddress(hGina, "WlxActivateUserShell");
848 if (!Functions->WlxActivateUserShell) goto cleanup;
849 Functions->WlxDisplayLockedNotice = (PFWLXDISPLAYLOCKEDNOTICE)GetProcAddress(hGina, "WlxDisplayLockedNotice");
850 if (!Functions->WlxDisplayLockedNotice) goto cleanup;
851 Functions->WlxDisplaySASNotice = (PFWLXDISPLAYSASNOTICE)GetProcAddress(hGina, "WlxDisplaySASNotice");
852 if (!Functions->WlxDisplaySASNotice) goto cleanup;
853 Functions->WlxIsLockOk = (PFWLXISLOCKOK)GetProcAddress(hGina, "WlxIsLockOk");
854 if (!Functions->WlxIsLockOk) goto cleanup;
855 Functions->WlxIsLogoffOk = (PFWLXISLOGOFFOK)GetProcAddress(hGina, "WlxIsLogoffOk");
856 if (!Functions->WlxIsLogoffOk) goto cleanup;
857 Functions->WlxLoggedOnSAS = (PFWLXLOGGEDONSAS)GetProcAddress(hGina, "WlxLoggedOnSAS");
858 if (!Functions->WlxLoggedOnSAS) goto cleanup;
859 Functions->WlxLoggedOutSAS = (PFWLXLOGGEDOUTSAS)GetProcAddress(hGina, "WlxLoggedOutSAS");
860 if (!Functions->WlxLoggedOutSAS) goto cleanup;
861 Functions->WlxLogoff = (PFWLXLOGOFF)GetProcAddress(hGina, "WlxLogoff");
862 if (!Functions->WlxLogoff) goto cleanup;
863 Functions->WlxShutdown = (PFWLXSHUTDOWN)GetProcAddress(hGina, "WlxShutdown");
864 if (!Functions->WlxShutdown) goto cleanup;
865 Functions->WlxWkstaLockedSAS = (PFWLXWKSTALOCKEDSAS)GetProcAddress(hGina, "WlxWkstaLockedSAS");
866 if (!Functions->WlxWkstaLockedSAS) goto cleanup;
867 }
868
869 if (*DllVersion >= WLX_VERSION_1_1)
870 {
871 Functions->WlxScreenSaverNotify = (PFWLXSCREENSAVERNOTIFY)GetProcAddress(hGina, "WlxScreenSaverNotify");
872 Functions->WlxStartApplication = (PFWLXSTARTAPPLICATION)GetProcAddress(hGina, "WlxStartApplication");
873 }
874
875 if (*DllVersion >= WLX_VERSION_1_3)
876 {
877 Functions->WlxDisplayStatusMessage = (PFWLXDISPLAYSTATUSMESSAGE)GetProcAddress(hGina, "WlxDisplayStatusMessage");
878 if (!Functions->WlxDisplayStatusMessage) goto cleanup;
879 Functions->WlxGetStatusMessage = (PFWLXGETSTATUSMESSAGE)GetProcAddress(hGina, "WlxGetStatusMessage");
880 if (!Functions->WlxGetStatusMessage) goto cleanup;
881 Functions->WlxNetworkProviderLoad = (PFWLXNETWORKPROVIDERLOAD)GetProcAddress(hGina, "WlxNetworkProviderLoad");
882 if (!Functions->WlxNetworkProviderLoad) goto cleanup;
883 Functions->WlxRemoveStatusMessage = (PFWLXREMOVESTATUSMESSAGE)GetProcAddress(hGina, "WlxRemoveStatusMessage");
884 if (!Functions->WlxRemoveStatusMessage) goto cleanup;
885 }
886
887 /* Provide some default functions */
888 if (!Functions->WlxScreenSaverNotify)
889 Functions->WlxScreenSaverNotify = DefaultWlxScreenSaverNotify;
890
891 ret = TRUE;
892
893cleanup:
894 if (!ret)
895 {
896 if (hGina)
897 FreeLibrary(hGina);
898 }
899 else
900 *GinaInstance = hGina;
901 return ret;
902}
903
904BOOL
906 IN OUT PWLSESSION Session)
907{
908 DWORD GinaDllVersion;
909
910 if (!LoadGina(&Session->Gina.Functions, &GinaDllVersion, &Session->Gina.hDllInstance))
911 return FALSE;
912
913 Session->Gina.Context = NULL;
914 Session->Gina.Version = GinaDllVersion;
915 Session->Gina.UseCtrlAltDelete = FALSE;
916 Session->SuppressStatus = FALSE;
917
918 TRACE("Calling WlxInitialize(\"%S\")\n", Session->InteractiveWindowStationName);
919 return Session->Gina.Functions.WlxInitialize(
920 Session->InteractiveWindowStationName,
921 (HANDLE)Session,
922 NULL,
924 &Session->Gina.Context);
925}
926
927BOOL
929 _Inout_ PWLSESSION Session)
930{
931 SECURITY_ATTRIBUTES WinstaSecurity;
932 SECURITY_ATTRIBUTES ApplicationDesktopSecurity;
933 SECURITY_ATTRIBUTES WinlogonDesktopSecurity;
934 SECURITY_ATTRIBUTES ScreenSaverDesktopSecurity;
935 PSECURITY_DESCRIPTOR WlWinstaSecurityDescriptor;
936 PSECURITY_DESCRIPTOR WlApplicationDesktopSecurityDescriptor;
937 PSECURITY_DESCRIPTOR WlWinlogonDesktopSecurityDescriptor;
938 PSECURITY_DESCRIPTOR WlScreenSaverDesktopSecurityDescriptor;
939 BOOL ret = FALSE;
940
941 if (!CreateWinstaSecurity(&WlWinstaSecurityDescriptor))
942 {
943 ERR("WL: Failed to create winsta security!\n");
944 return ret;
945 }
946
947 WinstaSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
948 WinstaSecurity.lpSecurityDescriptor = WlWinstaSecurityDescriptor;
949 WinstaSecurity.bInheritHandle = TRUE;
950
951 if (!CreateApplicationDesktopSecurity(&WlApplicationDesktopSecurityDescriptor))
952 {
953 ERR("WL: Failed to create application desktop security!\n");
954 goto cleanup;
955 }
956
957 ApplicationDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
958 ApplicationDesktopSecurity.lpSecurityDescriptor = WlApplicationDesktopSecurityDescriptor;
959 ApplicationDesktopSecurity.bInheritHandle = TRUE;
960
961 if (!CreateWinlogonDesktopSecurity(&WlWinlogonDesktopSecurityDescriptor))
962 {
963 ERR("WL: Failed to create winlogon desktop security!\n");
964 goto cleanup;
965 }
966
967 WinlogonDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
968 WinlogonDesktopSecurity.lpSecurityDescriptor = WlWinlogonDesktopSecurityDescriptor;
969 WinlogonDesktopSecurity.bInheritHandle = FALSE;
970
971 if (!CreateScreenSaverSecurity(&WlScreenSaverDesktopSecurityDescriptor))
972 {
973 ERR("WL: Failed to create winlogon desktop security!\n");
974 goto cleanup;
975 }
976
977 ScreenSaverDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
978 ScreenSaverDesktopSecurity.lpSecurityDescriptor = WlScreenSaverDesktopSecurityDescriptor;
979 ScreenSaverDesktopSecurity.bInheritHandle = TRUE;
980
981 /*
982 * Create the interactive window station
983 */
984 Session->InteractiveWindowStationName = L"WinSta0";
985 Session->InteractiveWindowStation = CreateWindowStationW(
986 Session->InteractiveWindowStationName,
987 0,
989 &WinstaSecurity);
990 if (!Session->InteractiveWindowStation)
991 {
992 ERR("WL: Failed to create window station (%lu)\n", GetLastError());
993 goto cleanup;
994 }
995
996 if (!SetProcessWindowStation(Session->InteractiveWindowStation))
997 {
998 ERR("WL: SetProcessWindowStation() failed (error %lu)\n", GetLastError());
999 goto cleanup;
1000 }
1001
1002 /*
1003 * Create the application desktop
1004 */
1005 Session->ApplicationDesktop = CreateDesktopW(
1006 L"Default",
1007 NULL,
1008 NULL,
1009 0, /* FIXME: Add DF_ALLOWOTHERACCOUNTHOOK flag? */
1011 &ApplicationDesktopSecurity);
1012 if (!Session->ApplicationDesktop)
1013 {
1014 ERR("WL: Failed to create Default desktop (%lu)\n", GetLastError());
1015 goto cleanup;
1016 }
1017
1018 /*
1019 * Create the winlogon desktop
1020 */
1021 Session->WinlogonDesktop = CreateDesktopW(
1022 L"Winlogon",
1023 NULL,
1024 NULL,
1025 0,
1027 &WinlogonDesktopSecurity);
1028 if (!Session->WinlogonDesktop)
1029 {
1030 ERR("WL: Failed to create Winlogon desktop (%lu)\n", GetLastError());
1031 goto cleanup;
1032 }
1033
1034 /*
1035 * Create the screen saver desktop
1036 */
1037 Session->ScreenSaverDesktop = CreateDesktopW(
1038 L"Screen-Saver",
1039 NULL,
1040 NULL,
1041 0,
1043 &ScreenSaverDesktopSecurity);
1044 if(!Session->ScreenSaverDesktop)
1045 {
1046 ERR("WL: Failed to create Screen-Saver desktop (%lu)\n", GetLastError());
1047 goto cleanup;
1048 }
1049
1050 /*
1051 * Switch to winlogon desktop
1052 */
1053 if (!SetThreadDesktop(Session->WinlogonDesktop) ||
1054 !SwitchDesktop(Session->WinlogonDesktop))
1055 {
1056 ERR("WL: Cannot switch to Winlogon desktop (%lu)\n", GetLastError());
1057 goto cleanup;
1058 }
1059
1060 SetWindowStationUser(Session->InteractiveWindowStation,
1061 &LuidNone, NULL, 0);
1062
1063 ret = TRUE;
1064
1065cleanup:
1066 if (!ret)
1067 {
1068 if (Session->ApplicationDesktop)
1069 {
1070 CloseDesktop(Session->ApplicationDesktop);
1071 Session->ApplicationDesktop = NULL;
1072 }
1073 if (Session->WinlogonDesktop)
1074 {
1075 CloseDesktop(Session->WinlogonDesktop);
1076 Session->WinlogonDesktop = NULL;
1077 }
1078 if (Session->ScreenSaverDesktop)
1079 {
1080 CloseDesktop(Session->ScreenSaverDesktop);
1081 Session->ScreenSaverDesktop = NULL;
1082 }
1083 if (Session->InteractiveWindowStation)
1084 {
1085 CloseWindowStation(Session->InteractiveWindowStation);
1086 Session->InteractiveWindowStation = NULL;
1087 }
1088 if (WlWinstaSecurityDescriptor)
1089 {
1090 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinstaSecurityDescriptor);
1091 }
1092 if (WlApplicationDesktopSecurityDescriptor)
1093 {
1094 RtlFreeHeap(RtlGetProcessHeap(), 0, WlApplicationDesktopSecurityDescriptor);
1095 }
1096 if (WlWinlogonDesktopSecurityDescriptor)
1097 {
1098 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinlogonDesktopSecurityDescriptor);
1099 }
1100 if (WlScreenSaverDesktopSecurityDescriptor)
1101 {
1102 RtlFreeHeap(RtlGetProcessHeap(), 0, WlScreenSaverDesktopSecurityDescriptor);
1103 }
1104 }
1105
1106 return ret;
1107}
PRTL_UNICODE_STRING_BUFFER Path
Type
Definition: Type.h:7
BOOL CreateApplicationDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *ApplicationDesktopSd)
Creates a security descriptor for the default application desktop upon its creation.
Definition: security.c:359
BOOL CreateWinstaSecurity(_Out_ PSECURITY_DESCRIPTOR *WinstaSd)
Creates a security descriptor for the default window station upon its creation.
Definition: security.c:112
BOOL CreateWinlogonDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *WinlogonDesktopSd)
Creates a security descriptor for the default Winlogon desktop. This descriptor serves as a security ...
Definition: security.c:541
BOOL CreateScreenSaverSecurity(_Out_ PSECURITY_DESCRIPTOR *ScreenSaverDesktopSd)
Creates a security descriptor for the screen saver desktop.
Definition: security.c:690
#define UNIMPLEMENTED
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:110
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define Len
Definition: deflate.h:82
#define DLGPROC
Definition: maze.c:62
#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
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3353
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4123
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define LoadLibraryW(x)
Definition: compat.h:747
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static void cleanup(void)
Definition: main.c:1335
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define ULONG_PTR
Definition: config.h:101
HINSTANCE hInst
Definition: dxdiag.c:13
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
#define REG_SZ
Definition: layer.c:22
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define _Inout_
Definition: ms_sal.h:378
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
static ULONG Timeout
Definition: ping.c:61
LUID LuidNone
Definition: sas.c:47
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define TRACE(s)
Definition: solgame.cpp:4
base of all file and directory entries
Definition: entries.h:83
Definition: wlx.c:16
HWND hWnd
Definition: wlx.c:18
LIST_ENTRY Entry
Definition: wlx.c:17
DLGPROC DlgProc
Definition: wlx.c:19
LPARAM lParam
Definition: wlx.c:20
PFWLXISLOGOFFOK WlxIsLogoffOk
Definition: winlogon.h:106
PVOID Context
Definition: winlogon.h:129
GINAFUNCTIONS Functions
Definition: winlogon.h:128
BOOL UseCtrlAltDelete
Definition: winlogon.h:131
DWORD Version
Definition: winlogon.h:130
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LPVOID lpSecurityDescriptor
Definition: compat.h:193
DWORD DialogTimeout
Definition: winlogon.h:235
HDESK WinlogonDesktop
Definition: winlogon.h:229
HWND SASWindow
Definition: winlogon.h:225
GINAINSTANCE Gina
Definition: winlogon.h:221
HDESK ApplicationDesktop
Definition: winlogon.h:228
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define OUT
Definition: typedefs.h:40
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
HDESK WINAPI CreateDesktopW(LPCWSTR lpszDesktop, LPCWSTR lpszDevice, LPDEVMODEW pDevmode, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
Definition: desktop.c:473
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
PWLSESSION WLSession
Definition: winlogon.c:20
int(WINAPI * PFWLXWKSTALOCKEDSAS)(PVOID, DWORD)
Definition: winlogon.h:74
VOID(WINAPI * PFWLXDISPLAYLOCKEDNOTICE)(PVOID)
Definition: winlogon.h:73
int(WINAPI * PFWLXLOGGEDOUTSAS)(PVOID, DWORD, PLUID, PSID, PDWORD, PHANDLE, PWLX_MPR_NOTIFY_INFO, PVOID *)
Definition: winlogon.h:68
BOOL(WINAPI * PFWLXNEGOTIATE)(DWORD, DWORD *)
Definition: winlogon.h:65
VOID(WINAPI * PFWLXSHUTDOWN)(PVOID, DWORD)
Definition: winlogon.h:78
BOOL WINAPI SetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:419
BOOL(WINAPI * PFWLXISLOGOFFOK)(PVOID)
Definition: winlogon.h:76
VOID(WINAPI * PFWLXLOGOFF)(PVOID)
Definition: winlogon.h:77
BOOL(WINAPI * PFWLXREMOVESTATUSMESSAGE)(PVOID)
Definition: winlogon.h:90
BOOL(WINAPI * PFWLXSTARTAPPLICATION)(PVOID, PWSTR, PVOID, PWSTR)
Definition: winlogon.h:83
BOOL(WINAPI * PFWLXINITIALIZE)(LPWSTR, HANDLE, PVOID, PVOID, PVOID *)
Definition: winlogon.h:66
BOOL(WINAPI * PFWLXSCREENSAVERNOTIFY)(PVOID, BOOL *)
Definition: winlogon.h:82
struct _WLSESSION * PWLSESSION
BOOL(WINAPI * PFWLXNETWORKPROVIDERLOAD)(PVOID, PWLX_MPR_NOTIFY_INFO)
Definition: winlogon.h:87
BOOL(WINAPI * PFWLXGETSTATUSMESSAGE)(PVOID, DWORD *, PWSTR, DWORD)
Definition: winlogon.h:89
BOOL(WINAPI * PFWLXISLOCKOK)(PVOID)
Definition: winlogon.h:75
BOOL(WINAPI * PFWLXDISPLAYSTATUSMESSAGE)(PVOID, HDESK, DWORD, PWSTR, PWSTR)
Definition: winlogon.h:88
VOID(WINAPI * PFWLXDISPLAYSASNOTICE)(PVOID)
Definition: winlogon.h:67
int(WINAPI * PFWLXLOGGEDONSAS)(PVOID, DWORD, PVOID)
Definition: winlogon.h:72
BOOL(WINAPI * PFWLXACTIVATEUSERSHELL)(PVOID, PWSTR, PWSTR, PVOID)
Definition: winlogon.h:71
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI SwitchDesktop(_In_ HDESK)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
HWINSTA WINAPI CreateWindowStationW(_In_opt_ LPCWSTR lpwinsta, _In_ DWORD dwFlags, _In_ ACCESS_MASK dwDesiredAccess, _In_opt_ LPSECURITY_ATTRIBUTES lpsa)
BOOL WINAPI CloseWindowStation(_In_ HWINSTA)
#define WM_INITDIALOG
Definition: winuser.h:1738
BOOL WINAPI SetProcessWindowStation(_In_ HWINSTA)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define PostMessage
Definition: winuser.h:5831
BOOL WINAPI CloseDesktop(_In_ HDESK)
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_OPTION_USE_CTRL_ALT_DEL
Definition: winwlx.h:322
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WLX_DLG_SAS
Definition: winwlx.h:73
#define WLX_VERSION_1_1
Definition: winwlx.h:29
#define WLX_WM_SAS
Definition: winwlx.h:71
#define WLX_CURRENT_VERSION
Definition: winwlx.h:33
#define WLX_VERSION_1_3
Definition: winwlx.h:31
struct _WLX_DISPATCH_VERSION_1_3 WLX_DISPATCH_VERSION_1_3
#define WLX_OPTION_USE_SMART_CARD
Definition: winwlx.h:324
#define WLX_VERSION_1_4
Definition: winwlx.h:32
#define WLX_OPTION_SMART_CARD_PRESENT
Definition: winwlx.h:329
#define WLX_OPTION_DISPATCH_TABLE_SIZE
Definition: winwlx.h:331
#define WLX_VERSION_1_2
Definition: winwlx.h:30
struct _WLX_DISPATCH_VERSION_1_0 WLX_DISPATCH_VERSION_1_0
struct _WLX_DISPATCH_VERSION_1_1 WLX_DISPATCH_VERSION_1_1
struct _WLX_DISPATCH_VERSION_1_2 WLX_DISPATCH_VERSION_1_2
#define WLX_OPTION_CONTEXT_POINTER
Definition: winwlx.h:323
#define WLX_VERSION_1_0
Definition: winwlx.h:28
#define WLX_OPTION_SMART_CARD_INFO
Definition: winwlx.h:330
struct _WLX_DISPATCH_VERSION_1_4 WLX_DISPATCH_VERSION_1_4
#define WLX_SAS_TYPE_MAX_MSFT_VALUE
Definition: winwlx.h:46
static VOID RemoveDialogListEntry(PDIALOG_LIST_ENTRY ListEntry)
Definition: wlx.c:58
BOOL WINAPI WlxCloseUserDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop, HANDLE hToken)
Definition: wlx.c:517
DWORD WINAPI WlxQueryConsoleSwitchCredentials(PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred)
Definition: wlx.c:698
int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:306
BOOL WINAPI WlxCreateUserDesktop(HANDLE hWlx, HANDLE hToken, DWORD Flags, PWSTR pszDesktopName, PWLX_DESKTOP *ppDesktop)
Definition: wlx.c:473
int WINAPI WlxAssignShellProtection(HANDLE hWlx, HANDLE hToken, HANDLE hProcess, HANDLE hThread)
Definition: wlx.c:248
static PDIALOG_LIST_ENTRY AddDialogListEntry(VOID)
Definition: wlx.c:39
int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:359
struct _DIALOG_LIST_ENTRY * PDIALOG_LIST_ENTRY
BOOL WINAPI WlxSetTimeout(HANDLE hWlx, DWORD Timeout)
Definition: wlx.c:231
BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR *OldValue)
Definition: wlx.c:535
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:722
DWORD WINAPI WlxQueryTerminalServicesData(HANDLE hWlx, PWLX_TERMINAL_SERVICES_DATA pTSData, WCHAR *UserName, WCHAR *Domain)
Definition: wlx.c:678
struct _DIALOG_LIST_ENTRY DIALOG_LIST_ENTRY
int WINAPI WlxSwitchDesktopToUser(HANDLE hWlx)
Definition: wlx.c:393
BOOL WINAPI WlxQueryClientCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred)
Definition: wlx.c:639
static PDIALOG_LIST_ENTRY GetDialogListEntry(HWND hwndDlg)
Definition: wlx.c:69
int WINAPI WlxChangePasswordNotifyEx(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo, PWSTR ProviderName, PVOID Reserved)
Definition: wlx.c:495
VOID WINAPI WlxSasNotify(HANDLE hWlx, DWORD dwSasType)
Definition: wlx.c:214
static BOOL LoadGina(IN OUT PGINAFUNCTIONS Functions, OUT DWORD *DllVersion, OUT HMODULE *GinaInstance)
Definition: wlx.c:805
int WINAPI WlxDialogBoxIndirect(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc)
Definition: wlx.c:340
BOOL GinaInit(IN OUT PWLSESSION Session)
Definition: wlx.c:905
VOID WINAPI WlxWin31Migrate(HANDLE hWlx)
Definition: wlx.c:626
VOID WINAPI WlxUseCtrlAltDel(HANDLE hWlx)
Definition: wlx.c:183
int WINAPI WlxChangePasswordNotify(HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo)
Definition: wlx.c:423
BOOL WINAPI WlxQueryTsLogonCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred)
Definition: wlx.c:712
BOOL WINAPI WlxDisconnect(VOID)
Definition: wlx.c:667
BOOL WINAPI WlxGetOption(HANDLE hWlx, DWORD Option, ULONG_PTR *Value)
Definition: wlx.c:568
VOID WINAPI WlxSetContextPointer(HANDLE hWlx, PVOID pWlxContext)
Definition: wlx.c:198
static LIST_ENTRY DialogListHead
Definition: wlx.c:26
static BOOL GetGinaPath(OUT LPWSTR Path, IN DWORD Len)
Definition: wlx.c:756
static BOOL WINAPI DefaultWlxScreenSaverNotify(IN PVOID pWlxContext, IN OUT BOOL *pSecure)
Definition: wlx.c:794
VOID InitDialogListHead(VOID)
Definition: wlx.c:31
int WINAPI WlxSwitchDesktopToWinlogon(HANDLE hWlx)
Definition: wlx.c:408
int WINAPI WlxDialogBox(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc)
Definition: wlx.c:287
static INT_PTR CALLBACK DefaultWlxWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: wlx.c:117
BOOL WINAPI WlxGetSourceDesktop(HANDLE hWlx, PWLX_DESKTOP *ppDesktop)
Definition: wlx.c:441
BOOL CreateWindowStationAndDesktops(_Inout_ PWLSESSION Session)
Definition: wlx.c:928
VOID CloseAllDialogWindows(VOID)
Definition: wlx.c:95
int WINAPI WlxMessageBox(HANDLE hWlx, HWND hwndOwner, LPWSTR lpszText, LPWSTR lpszTitle, UINT fuStyle)
Definition: wlx.c:268
BOOL WINAPI WlxQueryInetConnectorCredentials(PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred)
Definition: wlx.c:653
BOOL WINAPI WlxSetReturnDesktop(HANDLE hWlx, PWLX_DESKTOP pDesktop)
Definition: wlx.c:457
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184