3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/winlogon/winlogon.c
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
19 #define Unimplemented DbgPrint("WL: %S() at %S:%i unimplemented!\n", __FUNCTION__, __FILE__, __LINE__)
29 WlxSetOption(hWlx
, WLX_OPTION_USE_CTRL_ALT_DEL
, TRUE
, NULL
);
41 WlxSetOption(hWlx
, WLX_OPTION_CONTEXT_POINTER
, (ULONG_PTR
)pWlxContext
, NULL
);
53 DispatchSAS((PWLSESSION
)hWlx
, dwSasType
);
73 WlxAssignShellProtection(
137 WlxDialogBoxIndirect(
140 LPCDLGTEMPLATE hDialogTemplate
,
153 WlxDialogBoxIndirectParam(
156 LPCDLGTEMPLATE hDialogTemplate
,
170 WlxSwitchDesktopToUser(
182 WlxSwitchDesktopToWinlogon(
194 WlxChangePasswordNotify(
196 PWLX_MPR_NOTIFY_INFO pMprInfo
,
210 PWLX_DESKTOP
* ppDesktop
223 PWLX_DESKTOP pDesktop
234 WlxCreateUserDesktop(
238 PWSTR pszDesktopName
,
239 PWLX_DESKTOP
* ppDesktop
250 WlxChangePasswordNotifyEx(
252 PWLX_MPR_NOTIFY_INFO pMprInfo
,
268 PWLX_DESKTOP pDesktop
,
287 PWLSESSION Session
= (PWLSESSION
)hWlx
;
289 if(Session
|| !Value
)
293 case WLX_OPTION_USE_CTRL_ALT_DEL
:
295 case WLX_OPTION_CONTEXT_POINTER
:
297 *OldValue
= (ULONG_PTR
)Session
->MsGina
.Context
;
298 Session
->MsGina
.Context
= (PVOID
)Value
;
301 case WLX_OPTION_USE_SMART_CARD
:
319 PMSGINAINSTANCE Instance
= (PMSGINAINSTANCE
)hWlx
;
321 if(Instance
|| !Value
)
325 case WLX_OPTION_USE_CTRL_ALT_DEL
:
327 case WLX_OPTION_CONTEXT_POINTER
:
329 *Value
= (ULONG_PTR
)Instance
->Context
;
332 case WLX_OPTION_USE_SMART_CARD
:
333 case WLX_OPTION_SMART_CARD_PRESENT
:
334 case WLX_OPTION_SMART_CARD_INFO
:
337 case WLX_OPTION_DISPATCH_TABLE_SIZE
:
339 switch(Instance
->Version
)
341 case WLX_VERSION_1_0
:
342 *Value
= sizeof(WLX_DISPATCH_VERSION_1_0
);
344 case WLX_VERSION_1_1
:
345 *Value
= sizeof(WLX_DISPATCH_VERSION_1_1
);
347 case WLX_VERSION_1_2
:
348 *Value
= sizeof(WLX_DISPATCH_VERSION_1_2
);
350 case WLX_VERSION_1_3
:
351 *Value
= sizeof(WLX_DISPATCH_VERSION_1_3
);
353 case WLX_VERSION_1_4
:
354 *Value
= sizeof(WLX_DISPATCH_VERSION_1_4
);
382 WlxQueryClientCredentials(
383 PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred
394 WlxQueryInetConnectorCredentials(
395 PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred
406 WlxQueryConsoleSwitchCredentials(
407 PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred
418 WlxQueryTsLogonCredentials(
419 PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred
440 WlxQueryTerminalServicesData(
442 PWLX_TERMINAL_SERVICES_DATA pTSData
,
452 WLX_DISPATCH_VERSION_1_4 FunctionTable
= {
454 WlxSetContextPointer
,
457 WlxAssignShellProtection
,
461 WlxDialogBoxIndirect
,
462 WlxDialogBoxIndirectParam
,
463 WlxSwitchDesktopToUser
,
464 WlxSwitchDesktopToWinlogon
,
465 WlxChangePasswordNotify
,
468 WlxCreateUserDesktop
,
469 WlxChangePasswordNotifyEx
,
474 WlxQueryClientCredentials
,
475 WlxQueryInetConnectorCredentials
,
477 WlxQueryTerminalServicesData
,
478 WlxQueryConsoleSwitchCredentials
,
479 WlxQueryTsLogonCredentials
482 /******************************************************************************/
485 GetMsGinaPath(WCHAR
*path
)
487 DWORD Status
, Type
, Size
;
490 Status
= RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
491 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
495 if(Status
!= ERROR_SUCCESS
)
497 wcscpy(path
, L
"msgina.dll");
501 Size
= MAX_PATH
* sizeof(WCHAR
);
502 Status
= RegQueryValueEx(hKey
,
508 if((Status
!= ERROR_SUCCESS
) || (Size
!= REG_SZ
) || (Size
== 0))
510 wcscpy(path
, L
"msgina.dll");
527 switch(LOWORD(wParam
))
530 EndDialog(hwndDlg
, IDOK
);
538 WCHAR str
[MAX_PATH
], str2
[MAX_PATH
];
542 len
= GetDlgItemText(hwndDlg
, IDC_GINALOADFAILED
, str
, MAX_PATH
);
546 wsprintf(str2
, str
, (LPWSTR
)lParam
);
547 SetDlgItemText(hwndDlg
, IDC_GINALOADFAILED
, str2
);
550 SetFocus(GetDlgItem(hwndDlg
, IDOK
));
555 EndDialog(hwndDlg
, IDCANCEL
);
563 LoadGina(PMSGINAFUNCTIONS Functions
, DWORD
*DllVersion
, HMODULE
*GinaInstance
)
566 WCHAR GinaDll
[MAX_PATH
+ 1];
568 GetMsGinaPath(GinaDll
);
570 if(!(hGina
= LoadLibrary(GinaDll
)))
572 DialogBoxParam(hAppInstance
, MAKEINTRESOURCE(IDD_GINALOADFAILED
), 0, GinaLoadFailedProc
, (LPARAM
)&GinaDll
);
575 *GinaInstance
= hGina
;
577 Functions
->WlxNegotiate
= (PFWLXNEGOTIATE
)GetProcAddress(hGina
, "WlxNegotiate");
578 Functions
->WlxInitialize
= (PFWLXINITIALIZE
)GetProcAddress(hGina
, "WlxInitialize");
580 if(Functions
->WlxNegotiate
)
582 if(!Functions
->WlxNegotiate(WLX_VERSION_1_3
, DllVersion
))
587 if(*DllVersion
>= WLX_VERSION_1_0
)
589 Functions
->WlxActivateUserShell
= (PFWLXACTIVATEUSERSHELL
)GetProcAddress(hGina
, "WlxActivateUserShell");
590 Functions
->WlxDisplayLockedNotice
= (PFWLXDISPLAYLOCKEDNOTICE
)GetProcAddress(hGina
, "WlxDisplayLockedNotice");
591 Functions
->WlxDisplaySASNotice
= (PFWLXDISPLAYSASNOTICE
)GetProcAddress(hGina
, "WlxDisplaySASNotice");
592 Functions
->WlxIsLockOk
= (PFWLXISLOCKOK
)GetProcAddress(hGina
, "WlxIsLockOk");
593 Functions
->WlxIsLogoffOk
= (PFWLXISLOGOFFOK
)GetProcAddress(hGina
, "WlxIsLogoffOk");
594 Functions
->WlxLoggedOnSAS
= (PFWLXLOGGEDONSAS
)GetProcAddress(hGina
, "WlxLoggedOnSAS");
595 Functions
->WlxLoggedOutSAS
= (PFWLXLOGGEDOUTSAS
)GetProcAddress(hGina
, "WlxLoggedOutSAS");
596 Functions
->WlxLogoff
= (PFWLXLOGOFF
)GetProcAddress(hGina
, "WlxLogoff");
597 Functions
->WlxShutdown
= (PFWLXSHUTDOWN
)GetProcAddress(hGina
, "WlxShutdown");
598 Functions
->WlxWkstaLockedSAS
= (PFWLXWKSTALOCKEDSAS
)GetProcAddress(hGina
, "WlxWkstaLockedSAS");
601 if(*DllVersion
>= WLX_VERSION_1_1
)
603 Functions
->WlxScreenSaverNotify
= (PFWLXSCREENSAVERNOTIFY
)GetProcAddress(hGina
, "WlxScreenSaverNotify");
604 Functions
->WlxStartApplication
= (PFWLXSTARTAPPLICATION
)GetProcAddress(hGina
, "WlxStartApplication");
607 if(*DllVersion
>= WLX_VERSION_1_3
)
609 Functions
->WlxDisplayStatusMessage
= (PFWLXDISPLAYSTATUSMESSAGE
)GetProcAddress(hGina
, "WlxDisplayStatusMessage");
610 Functions
->WlxGetStatusMessage
= (PFWLXGETSTATUSMESSAGE
)GetProcAddress(hGina
, "WlxGetStatusMessage");
611 Functions
->WlxNetworkProviderLoad
= (PFWLXNETWORKPROVIDERLOAD
)GetProcAddress(hGina
, "WlxNetworkProviderLoad");
612 Functions
->WlxRemoveStatusMessage
= (PFWLXREMOVESTATUSMESSAGE
)GetProcAddress(hGina
, "WlxRemoveStatusMessage");
615 if(*DllVersion
>= WLX_VERSION_1_4
)
621 return (Functions
->WlxNegotiate
!= NULL
) && (Functions
->WlxInitialize
!= NULL
);
627 PWLSESSION WLSession
;
628 DWORD GinaDllVersion
;
630 WLSession
= (PWLSESSION
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WLSESSION
));
636 if(!LoadGina(&WLSession
->MsGina
.Functions
, &GinaDllVersion
, &WLSession
->MsGina
.hDllInstance
))
638 HeapFree(GetProcessHeap(), 0, WLSession
);
642 WLSession
->MsGina
.Context
= NULL
;
643 WLSession
->MsGina
.Version
= GinaDllVersion
;
644 WLSession
->SuppressStatus
= FALSE
;
646 if(!WLSession
->MsGina
.Functions
.WlxInitialize(WLSession
->InteractiveWindowStationName
,
649 (PVOID
)&FunctionTable
,
650 &WLSession
->MsGina
.Context
))
652 HeapFree(GetProcessHeap(), 0, WLSession
);
659 WlxCreateWindowStationAndDesktops(PWLSESSION Session
)
662 * Create the interactive window station
664 Session
->InteractiveWindowStationName
= L
"WinSta0";
665 Session
->InteractiveWindowStation
= CreateWindowStation(Session
->InteractiveWindowStationName
,
666 0, GENERIC_ALL
, NULL
);
667 if(!Session
->InteractiveWindowStation
)
669 DbgPrint("WL: Failed to create window station (0x%X)\n", GetLastError());
672 SetProcessWindowStation(Session
->InteractiveWindowStation
);
675 * Create the application desktop
677 Session
->ApplicationDesktop
= CreateDesktop(L
"Default",
680 0, /* FIXME: Set some flags */
683 if(!Session
->ApplicationDesktop
)
685 DbgPrint("WL: Failed to create Default desktop (0x%X)\n", GetLastError());
690 * Create the winlogon desktop
692 Session
->WinlogonDesktop
= CreateDesktop(WINLOGON_DESKTOP
,
695 0, /* FIXME: Set some flags */
698 if(!Session
->WinlogonDesktop
)
700 DbgPrint("WL: Failed to create Winlogon desktop (0x%X)\n", GetLastError());
705 * Create the screen saver desktop
707 Session
->ScreenSaverDesktop
= CreateDesktop(L
"Screen-Saver",
710 0, /* FIXME: Set some flags */
713 if(!Session
->ScreenSaverDesktop
)
715 DbgPrint("WL: Failed to create Screen-Saver desktop (0x%X)\n", GetLastError());