3 * Copyright (C) 2003-2004, 2006 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * PROJECT: ReactOS msgina.dll
21 * FILE: dll/win32/msgina/msgina.c
22 * PURPOSE: ReactOS Logon GINA DLL
23 * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
24 * Hervé Poussineau (hpoussin@reactos.org)
31 #include <ndk/sefuncs.h>
33 HINSTANCE hDllInstance
;
35 extern GINA_UI GinaGraphicalUI
;
36 extern GINA_UI GinaTextUI
;
37 static PGINA_UI pGinaUI
;
38 static SID_IDENTIFIER_AUTHORITY SystemAuthority
= {SECURITY_NT_AUTHORITY
};
46 IN DWORD dwWinlogonVersion
,
47 OUT PDWORD pdwDllVersion
)
49 TRACE("WlxNegotiate(%lx, %p)\n", dwWinlogonVersion
, pdwDllVersion
);
51 if(!pdwDllVersion
|| (dwWinlogonVersion
< WLX_VERSION_1_3
))
54 *pdwDllVersion
= WLX_VERSION_1_3
;
71 return ERROR_INVALID_PARAMETER
;
74 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, &dwType
, NULL
, &cbData
);
75 if (rc
!= ERROR_SUCCESS
)
78 return ERROR_FILE_NOT_FOUND
;
79 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
81 return ERROR_NOT_ENOUGH_MEMORY
;
82 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
83 if (rc
!= ERROR_SUCCESS
)
85 HeapFree(GetProcessHeap(), 0, Value
);
88 /* NULL-terminate the string */
89 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
107 return ERROR_INVALID_PARAMETER
;
109 cbData
= sizeof(DWORD
);
110 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, &dwType
, (LPBYTE
)&dwValue
, &cbData
);
111 if (rc
== ERROR_SUCCESS
&& dwType
== REG_DWORD
)
114 return ERROR_SUCCESS
;
120 HKEY ControlKey
= NULL
;
121 LPWSTR SystemStartOptions
= NULL
;
122 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
123 BOOL ConsoleBoot
= FALSE
;
128 L
"SYSTEM\\CurrentControlSet\\Control",
133 rc
= ReadRegSzValue(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
134 if (rc
!= ERROR_SUCCESS
)
137 /* Check for CONSOLE switch in SystemStartOptions */
138 CurrentOption
= SystemStartOptions
;
139 while (CurrentOption
)
141 NextOption
= wcschr(CurrentOption
, L
' ');
144 if (wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
146 TRACE("Found %S. Switching to console boot\n", CurrentOption
);
150 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
155 pGinaUI
= &GinaTextUI
;
157 pGinaUI
= &GinaGraphicalUI
;
159 if (ControlKey
!= NULL
)
160 RegCloseKey(ControlKey
);
161 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
167 GetRegistrySettings(PGINA_CONTEXT pgContext
)
170 LPWSTR lpAutoAdminLogon
= NULL
;
171 LPWSTR lpDontDisplayLastUserName
= NULL
;
172 LPWSTR lpShutdownWithoutLogon
= NULL
;
173 DWORD dwDisableCAD
= 0;
177 rc
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
178 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
182 if (rc
!= ERROR_SUCCESS
)
184 WARN("RegOpenKeyExW() failed with error %lu\n", rc
);
188 rc
= ReadRegSzValue(hKey
,
191 if (rc
== ERROR_SUCCESS
)
193 if (wcscmp(lpAutoAdminLogon
, L
"1") == 0)
194 pgContext
->bAutoAdminLogon
= TRUE
;
197 TRACE("bAutoAdminLogon: %s\n", pgContext
->bAutoAdminLogon
? "TRUE" : "FALSE");
199 rc
= ReadRegDwordValue(hKey
,
202 if (rc
== ERROR_SUCCESS
)
204 if (dwDisableCAD
!= 0)
205 pgContext
->bDisableCAD
= TRUE
;
208 TRACE("bDisableCAD: %s\n", pgContext
->bDisableCAD
? "TRUE" : "FALSE");
210 pgContext
->bShutdownWithoutLogon
= TRUE
;
211 rc
= ReadRegSzValue(hKey
,
212 L
"ShutdownWithoutLogon",
213 &lpShutdownWithoutLogon
);
214 if (rc
== ERROR_SUCCESS
)
216 if (wcscmp(lpShutdownWithoutLogon
, L
"0") == 0)
217 pgContext
->bShutdownWithoutLogon
= FALSE
;
220 rc
= ReadRegSzValue(hKey
,
221 L
"DontDisplayLastUserName",
222 &lpDontDisplayLastUserName
);
223 if (rc
== ERROR_SUCCESS
)
225 if (wcscmp(lpDontDisplayLastUserName
, L
"1") == 0)
226 pgContext
->bDontDisplayLastUserName
= TRUE
;
229 dwSize
= sizeof(pgContext
->UserName
);
230 rc
= RegQueryValueExW(hKey
,
234 (LPBYTE
)&pgContext
->UserName
,
237 dwSize
= sizeof(pgContext
->Domain
);
238 rc
= RegQueryValueExW(hKey
,
242 (LPBYTE
)&pgContext
->Domain
,
245 if (lpShutdownWithoutLogon
!= NULL
)
246 HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon
);
248 if (lpDontDisplayLastUserName
!= NULL
)
249 HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName
);
251 if (lpAutoAdminLogon
!= NULL
)
252 HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon
);
260 typedef DWORD (WINAPI
*pThemeWait
)(DWORD dwTimeout
);
261 typedef BOOL (WINAPI
*pThemeWatch
)(void);
264 InitThemeSupport(VOID
)
266 HMODULE hDll
= LoadLibraryW(L
"shsvcs.dll");
267 pThemeWait themeWait
;
268 pThemeWatch themeWatch
;
273 themeWait
= (pThemeWait
) GetProcAddress(hDll
, (LPCSTR
)2);
274 themeWatch
= (pThemeWatch
) GetProcAddress(hDll
, (LPCSTR
)1);
276 if(themeWait
&& themeWatch
)
291 PVOID pWinlogonFunctions
,
294 PGINA_CONTEXT pgContext
;
296 UNREFERENCED_PARAMETER(pvReserved
);
300 pgContext
= (PGINA_CONTEXT
)LocalAlloc(LMEM_FIXED
| LMEM_ZEROINIT
, sizeof(GINA_CONTEXT
));
303 WARN("LocalAlloc() failed\n");
307 if (!GetRegistrySettings(pgContext
))
309 WARN("GetRegistrySettings() failed\n");
310 LocalFree(pgContext
);
314 /* Return the context to winlogon */
315 *pWlxContext
= (PVOID
)pgContext
;
316 pgContext
->hDllInstance
= hDllInstance
;
318 /* Save pointer to dispatch table */
319 pgContext
->pWlxFuncs
= (PWLX_DISPATCH_VERSION_1_3
)pWinlogonFunctions
;
321 /* Save the winlogon handle used to call the dispatch functions */
322 pgContext
->hWlx
= hWlx
;
324 /* Save window station */
325 pgContext
->station
= lpWinsta
;
327 /* Clear status window handle */
328 pgContext
->hStatusWindow
= NULL
;
330 /* Notify winlogon that we will use the default SAS */
331 pgContext
->pWlxFuncs
->WlxUseCtrlAltDel(hWlx
);
333 /* Locates the authentication package */
334 //LsaRegisterLogonProcess(...);
336 /* Check autologon settings the first time */
337 pgContext
->AutoLogonState
= AUTOLOGON_CHECK_REGISTRY
;
339 pgContext
->nShutdownAction
= WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
;
342 return pGinaUI
->Initialize(pgContext
);
350 WlxScreenSaverNotify(
355 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
357 HKEY hKeyCurrentUser
, hKey
;
358 DWORD bufferSize
= sizeof(szBuffer
);
359 DWORD varType
= REG_SZ
;
362 TRACE("(%p %p)\n", pWlxContext
, pSecure
);
368 * HKLM\Software\Policies\Microsoft\Windows\Control Panel\Desktop : ScreenSaverIsSecure
370 * HKCU\Control Panel\Desktop : ScreenSaverIsSecure
373 if (!ImpersonateLoggedOnUser(pgContext
->UserToken
))
375 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
380 /* Open the current user HKCU key */
381 rc
= RegOpenCurrentUser(MAXIMUM_ALLOWED
, &hKeyCurrentUser
);
382 TRACE("RegOpenCurrentUser: %ld\n", rc
);
383 if (rc
== ERROR_SUCCESS
)
385 /* Open the subkey */
386 rc
= RegOpenKeyExW(hKeyCurrentUser
,
387 L
"Control Panel\\Desktop",
391 TRACE("RegOpenKeyExW: %ld\n", rc
);
392 RegCloseKey(hKeyCurrentUser
);
396 if (rc
== ERROR_SUCCESS
)
398 rc
= RegQueryValueExW(hKey
,
399 L
"ScreenSaverIsSecure",
405 TRACE("RegQueryValueExW: %ld\n", rc
);
407 if (rc
== ERROR_SUCCESS
)
409 TRACE("szBuffer: \"%S\"\n", szBuffer
);
410 *pSecure
= _wtoi(szBuffer
);
416 /* Revert the impersonation */
419 TRACE("*pSecure: %ld\n", *pSecure
);
433 PWSTR pszDesktopName
,
437 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
438 STARTUPINFOW StartupInfo
;
439 PROCESS_INFORMATION ProcessInformation
;
440 WCHAR CurrentDirectory
[MAX_PATH
];
445 len
= GetWindowsDirectoryW(CurrentDirectory
, MAX_PATH
);
446 if (len
== 0 || len
> MAX_PATH
)
448 ERR("GetWindowsDirectoryW() failed\n");
452 ret
= DuplicateTokenEx(pgContext
->UserToken
, MAXIMUM_ALLOWED
, NULL
, SecurityImpersonation
, TokenPrimary
, &hAppToken
);
455 ERR("DuplicateTokenEx() failed with error %lu\n", GetLastError());
459 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
460 ZeroMemory(&ProcessInformation
, sizeof(ProcessInformation
));
461 StartupInfo
.cb
= sizeof(StartupInfo
);
462 StartupInfo
.lpTitle
= pszCmdLine
;
463 StartupInfo
.dwFlags
= STARTF_USESHOWWINDOW
;
464 StartupInfo
.wShowWindow
= SW_SHOW
;
465 StartupInfo
.lpDesktop
= pszDesktopName
;
467 len
= GetWindowsDirectoryW(CurrentDirectory
, MAX_PATH
);
468 if (len
== 0 || len
> MAX_PATH
)
470 ERR("GetWindowsDirectoryW() failed\n");
473 ret
= CreateProcessAsUserW(
480 CREATE_UNICODE_ENVIRONMENT
,
484 &ProcessInformation
);
485 CloseHandle(ProcessInformation
.hProcess
);
486 CloseHandle(ProcessInformation
.hThread
);
487 CloseHandle(hAppToken
);
489 ERR("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
497 WlxActivateUserShell(
499 PWSTR pszDesktopName
,
500 PWSTR pszMprLogonScript
,
504 DWORD BufSize
, ValueType
;
505 WCHAR pszUserInitApp
[MAX_PATH
+ 1];
506 WCHAR pszExpUserInitApp
[MAX_PATH
];
510 TRACE("WlxActivateUserShell()\n");
512 UNREFERENCED_PARAMETER(pszMprLogonScript
);
514 /* Get the path of userinit */
517 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
521 if (rc
!= ERROR_SUCCESS
)
523 WARN("RegOpenKeyExW() failed with error %lu\n", rc
);
527 /* Query userinit application */
528 BufSize
= sizeof(pszUserInitApp
) - sizeof(UNICODE_NULL
);
529 rc
= RegQueryValueExW(
534 (LPBYTE
)pszUserInitApp
,
537 if (rc
!= ERROR_SUCCESS
|| (ValueType
!= REG_SZ
&& ValueType
!= REG_EXPAND_SZ
))
539 WARN("RegQueryValueExW() failed with error %lu\n", rc
);
542 pszUserInitApp
[MAX_PATH
] = UNICODE_NULL
;
544 len
= ExpandEnvironmentStringsW(pszUserInitApp
, pszExpUserInitApp
, MAX_PATH
);
547 WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len
);
551 /* Start userinit app */
552 return WlxStartApplication(pWlxContext
, pszDesktopName
, pEnvironment
, pszExpUserInitApp
);
564 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
565 INT SasAction
= WLX_SAS_ACTION_NONE
;
567 TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType
);
569 UNREFERENCED_PARAMETER(pReserved
);
573 case WLX_SAS_TYPE_CTRL_ALT_DEL
:
574 case WLX_SAS_TYPE_TIMEOUT
:
576 SasAction
= pGinaUI
->LoggedOnSAS(pgContext
, dwSasType
);
579 case WLX_SAS_TYPE_SC_INSERT
:
581 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
584 case WLX_SAS_TYPE_SC_REMOVE
:
586 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
591 WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType
);
603 WlxDisplayStatusMessage(
604 IN PVOID pWlxContext
,
610 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
612 TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage
);
614 return pGinaUI
->DisplayStatusMessage(pgContext
, hDesktop
, dwOptions
, pTitle
, pMessage
);
621 WlxRemoveStatusMessage(
622 IN PVOID pWlxContext
)
624 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
626 TRACE("WlxRemoveStatusMessage()\n");
628 return pGinaUI
->RemoveStatusMessage(pgContext
);
632 DuplicationString(PWSTR Str
)
637 if (Str
== NULL
) return NULL
;
639 cb
= (wcslen(Str
) + 1) * sizeof(WCHAR
);
640 if ((NewStr
= LocalAlloc(LMEM_FIXED
, cb
)))
641 memcpy(NewStr
, Str
, cb
);
648 IN PGINA_CONTEXT pgContext
,
653 HANDLE hToken
= NULL
;
654 PTOKEN_GROUPS Groups
= NULL
;
655 BOOL bIsAdmin
= FALSE
;
659 NTSTATUS SubStatus
= STATUS_SUCCESS
;
661 TRACE("(%S %S %S)\n", UserName
, Domain
, Password
);
663 Status
= ConnectToLsa(pgContext
);
664 if (!NT_SUCCESS(Status
))
666 WARN("ConnectToLsa() failed\n");
670 Status
= MyLogonUser(pgContext
->LsaHandle
,
671 pgContext
->AuthenticationPackage
,
675 &pgContext
->UserToken
,
677 if (!NT_SUCCESS(Status
))
679 WARN("MyLogonUser() failed\n");
683 Status
= NtQueryInformationToken(hToken
,
688 if ((Status
!= STATUS_SUCCESS
) && (Status
!= STATUS_BUFFER_TOO_SMALL
))
690 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status
);
694 Groups
= HeapAlloc(GetProcessHeap(), 0, Size
);
697 TRACE("HeapAlloc() failed\n");
701 Status
= NtQueryInformationToken(hToken
,
706 if (!NT_SUCCESS(Status
))
708 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status
);
712 for (i
= 0; i
< Groups
->GroupCount
; i
++)
714 if (RtlEqualSid(Groups
->Groups
[i
].Sid
, AdminSid
))
716 TRACE("Member of Admins group\n");
724 HeapFree(GetProcessHeap(), 0, Groups
);
735 IN OUT PGINA_CONTEXT pgContext
,
739 OUT PNTSTATUS SubStatus
)
743 Status
= ConnectToLsa(pgContext
);
744 if (!NT_SUCCESS(Status
))
746 WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status
);
750 Status
= MyLogonUser(pgContext
->LsaHandle
,
751 pgContext
->AuthenticationPackage
,
755 &pgContext
->UserToken
,
757 if (!NT_SUCCESS(Status
))
759 WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status
);
768 IN OUT PGINA_CONTEXT pgContext
,
773 LPWSTR ProfilePath
= NULL
;
774 LPWSTR lpEnvironment
= NULL
;
775 TOKEN_STATISTICS Stats
;
776 PWLX_PROFILE_V2_0 pProfile
= NULL
;
777 DWORD cbStats
, cbSize
;
781 /* Store the logon time in the context */
782 GetLocalTime(&pgContext
->LogonTime
);
784 /* Store user and domain in the context */
785 wcscpy(pgContext
->UserName
, UserName
);
786 if (Domain
== NULL
|| wcslen(Domain
) == 0)
788 dwLength
= _countof(pgContext
->Domain
);
789 GetComputerNameW(pgContext
->Domain
, &dwLength
);
793 wcscpy(pgContext
->Domain
, Domain
);
796 /* Get profile path */
798 bResult
= GetProfilesDirectoryW(NULL
, &cbSize
);
799 if (!bResult
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
801 ProfilePath
= HeapAlloc(GetProcessHeap(), 0, cbSize
* sizeof(WCHAR
));
804 WARN("HeapAlloc() failed\n");
807 bResult
= GetProfilesDirectoryW(ProfilePath
, &cbSize
);
811 WARN("GetUserProfileDirectoryW() failed\n");
815 /* Allocate memory for profile */
816 pProfile
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WLX_PROFILE_V2_0
));
819 WARN("HeapAlloc() failed\n");
822 pProfile
->dwType
= WLX_PROFILE_TYPE_V2_0
;
823 pProfile
->pszProfile
= ProfilePath
;
825 cbSize
= sizeof(L
"LOGONSERVER=\\\\") +
826 wcslen(pgContext
->Domain
) * sizeof(WCHAR
) +
827 sizeof(UNICODE_NULL
);
828 lpEnvironment
= HeapAlloc(GetProcessHeap(), 0, cbSize
);
831 WARN("HeapAlloc() failed\n");
835 StringCbPrintfW(lpEnvironment
, cbSize
, L
"LOGONSERVER=\\\\%ls", pgContext
->Domain
);
836 ASSERT(wcslen(lpEnvironment
) == cbSize
/ sizeof(WCHAR
) - 2);
837 lpEnvironment
[cbSize
/ sizeof(WCHAR
) - 1] = UNICODE_NULL
;
839 pProfile
->pszEnvironment
= lpEnvironment
;
841 if (!GetTokenInformation(pgContext
->UserToken
,
847 WARN("Couldn't get Authentication id from user token!\n");
851 *pgContext
->pAuthenticationId
= Stats
.AuthenticationId
;
852 pgContext
->pMprNotifyInfo
->pszUserName
= DuplicationString(UserName
);
853 pgContext
->pMprNotifyInfo
->pszDomain
= DuplicationString(Domain
);
854 pgContext
->pMprNotifyInfo
->pszPassword
= DuplicationString(Password
);
855 pgContext
->pMprNotifyInfo
->pszOldPassword
= NULL
;
856 *pgContext
->pdwOptions
= 0;
857 *pgContext
->pProfile
= pProfile
;
863 HeapFree(GetProcessHeap(), 0, pProfile
->pszEnvironment
);
865 HeapFree(GetProcessHeap(), 0, pProfile
);
866 HeapFree(GetProcessHeap(), 0, ProfilePath
);
873 IN PGINA_CONTEXT pgContext
)
875 HKEY WinLogonKey
= NULL
;
876 LPWSTR AutoLogon
= NULL
;
877 LPWSTR AutoCount
= NULL
;
878 LPWSTR IgnoreShiftOverride
= NULL
;
879 LPWSTR UserName
= NULL
;
880 LPWSTR Domain
= NULL
;
881 LPWSTR Password
= NULL
;
885 NTSTATUS SubStatus
= STATUS_SUCCESS
;
887 TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
888 pgContext
->AutoLogonState
);
890 if (pgContext
->AutoLogonState
== AUTOLOGON_DISABLED
)
895 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon",
899 if (rc
!= ERROR_SUCCESS
)
902 if (pgContext
->AutoLogonState
== AUTOLOGON_CHECK_REGISTRY
)
904 /* Set it by default to disabled, we might reenable it again later */
905 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
907 rc
= ReadRegSzValue(WinLogonKey
, L
"AutoAdminLogon", &AutoLogon
);
908 if (rc
!= ERROR_SUCCESS
)
910 if (wcscmp(AutoLogon
, L
"1") != 0)
913 rc
= ReadRegSzValue(WinLogonKey
, L
"AutoLogonCount", &AutoCount
);
914 if (rc
== ERROR_SUCCESS
&& wcscmp(AutoCount
, L
"0") == 0)
916 else if (rc
!= ERROR_FILE_NOT_FOUND
)
919 rc
= ReadRegSzValue(WinLogonKey
, L
"IgnoreShiftOverride", &UserName
);
920 if (rc
== ERROR_SUCCESS
)
922 if (wcscmp(AutoLogon
, L
"1") != 0 && GetKeyState(VK_SHIFT
) < 0)
925 else if (GetKeyState(VK_SHIFT
) < 0)
927 /* User pressed SHIFT */
931 pgContext
->AutoLogonState
= AUTOLOGON_ONCE
;
934 else /* pgContext->AutoLogonState == AUTOLOGON_ONCE */
936 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
938 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultUserName", &UserName
);
939 if (rc
!= ERROR_SUCCESS
)
941 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultDomain", &Domain
);
942 if (rc
!= ERROR_SUCCESS
&& rc
!= ERROR_FILE_NOT_FOUND
)
944 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultPassword", &Password
);
945 if (rc
!= ERROR_SUCCESS
)
948 Status
= DoLoginTasks(pgContext
, UserName
, Domain
, Password
, &SubStatus
);
949 if (!NT_SUCCESS(Status
))
951 /* FIXME: Handle errors!!! */
956 result
= CreateProfile(pgContext
, UserName
, Domain
, Password
);
959 ZeroMemory(pgContext
->Password
, sizeof(pgContext
->Password
));
960 wcscpy(pgContext
->Password
, Password
);
962 NotifyBootConfigStatus(TRUE
);
967 if (WinLogonKey
!= NULL
)
968 RegCloseKey(WinLogonKey
);
969 HeapFree(GetProcessHeap(), 0, AutoLogon
);
970 HeapFree(GetProcessHeap(), 0, AutoCount
);
971 HeapFree(GetProcessHeap(), 0, IgnoreShiftOverride
);
972 HeapFree(GetProcessHeap(), 0, UserName
);
973 HeapFree(GetProcessHeap(), 0, Domain
);
974 HeapFree(GetProcessHeap(), 0, Password
);
975 TRACE("DoAutoLogon(): AutoLogonState = %lu, returning %d\n",
976 pgContext
->AutoLogonState
, result
);
985 IN PVOID pWlxContext
)
987 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
989 TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext
);
991 if (GetSystemMetrics(SM_REMOTESESSION
))
993 /* User is remotely logged on. Don't display a notice */
994 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
998 if (pgContext
->bAutoAdminLogon
)
1000 /* Don't display the window, we want to do an automatic logon */
1001 pgContext
->AutoLogonState
= AUTOLOGON_ONCE
;
1002 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
1006 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
1008 if (pgContext
->bDisableCAD
)
1010 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
1014 pGinaUI
->DisplaySASNotice(pgContext
);
1016 TRACE("WlxDisplaySASNotice() done\n");
1024 IN PVOID pWlxContext
,
1026 OUT PLUID pAuthenticationId
,
1027 IN OUT PSID pLogonSid
,
1028 OUT PDWORD pdwOptions
,
1029 OUT PHANDLE phToken
,
1030 OUT PWLX_MPR_NOTIFY_INFO pMprNotifyInfo
,
1031 OUT PVOID
*pProfile
)
1033 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
1036 TRACE("WlxLoggedOutSAS()\n");
1038 UNREFERENCED_PARAMETER(dwSasType
);
1039 UNREFERENCED_PARAMETER(pLogonSid
);
1041 pgContext
->pAuthenticationId
= pAuthenticationId
;
1042 pgContext
->pdwOptions
= pdwOptions
;
1043 pgContext
->pMprNotifyInfo
= pMprNotifyInfo
;
1044 pgContext
->pProfile
= pProfile
;
1046 if (0 == GetSystemMetrics(SM_REMOTESESSION
) &&
1047 DoAutoLogon(pgContext
))
1049 /* User is local and registry contains information
1050 * to log on him automatically */
1051 *phToken
= pgContext
->UserToken
;
1052 return WLX_SAS_ACTION_LOGON
;
1055 res
= pGinaUI
->LoggedOutSAS(pgContext
);
1056 *phToken
= pgContext
->UserToken
;
1068 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
1070 TRACE("WlxWkstaLockedSAS()\n");
1072 UNREFERENCED_PARAMETER(dwSasType
);
1074 return pGinaUI
->LockedSAS(pgContext
);
1083 WlxDisplayLockedNotice(PVOID pWlxContext
)
1085 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
1087 TRACE("WlxDisplayLockedNotice()\n");
1089 if (pgContext
->bDisableCAD
)
1091 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
1095 pGinaUI
->DisplayLockedNotice(pgContext
);
1106 TRACE("WlxIsLogoffOk()\n");
1107 UNREFERENCED_PARAMETER(pWlxContext
);
1113 IN HINSTANCE hinstDLL
,
1115 IN LPVOID lpvReserved
)
1117 UNREFERENCED_PARAMETER(lpvReserved
);
1119 if (dwReason
== DLL_PROCESS_ATTACH
)
1121 hDllInstance
= hinstDLL
;
1123 RtlAllocateAndInitializeSid(&SystemAuthority
,
1125 SECURITY_BUILTIN_DOMAIN_RID
,
1126 DOMAIN_ALIAS_RID_ADMINS
,
1136 else if (dwReason
== DLL_PROCESS_DETACH
)
1138 if (AdminSid
!= NULL
)
1139 RtlFreeSid(AdminSid
);