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)
32 #include <ndk/sefuncs.h>
34 HINSTANCE hDllInstance
;
36 extern GINA_UI GinaGraphicalUI
;
37 extern GINA_UI GinaTextUI
;
38 static PGINA_UI pGinaUI
;
39 static SID_IDENTIFIER_AUTHORITY SystemAuthority
= {SECURITY_NT_AUTHORITY
};
47 IN DWORD dwWinlogonVersion
,
48 OUT PDWORD pdwDllVersion
)
50 TRACE("WlxNegotiate(%lx, %p)\n", dwWinlogonVersion
, pdwDllVersion
);
52 if(!pdwDllVersion
|| (dwWinlogonVersion
< WLX_VERSION_1_3
))
55 *pdwDllVersion
= WLX_VERSION_1_3
;
72 return ERROR_INVALID_PARAMETER
;
75 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, &dwType
, NULL
, &cbData
);
76 if (rc
!= ERROR_SUCCESS
)
79 return ERROR_FILE_NOT_FOUND
;
80 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
82 return ERROR_NOT_ENOUGH_MEMORY
;
83 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
84 if (rc
!= ERROR_SUCCESS
)
86 HeapFree(GetProcessHeap(), 0, Value
);
89 /* NULL-terminate the string */
90 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
108 return ERROR_INVALID_PARAMETER
;
110 cbData
= sizeof(DWORD
);
111 rc
= RegQueryValueExW(hKey
, pszValue
, NULL
, &dwType
, (LPBYTE
)&dwValue
, &cbData
);
112 if (rc
== ERROR_SUCCESS
&& dwType
== REG_DWORD
)
115 return ERROR_SUCCESS
;
121 HKEY ControlKey
= NULL
;
122 LPWSTR SystemStartOptions
= NULL
;
123 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
124 BOOL ConsoleBoot
= FALSE
;
129 L
"SYSTEM\\CurrentControlSet\\Control",
134 rc
= ReadRegSzValue(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
135 if (rc
!= ERROR_SUCCESS
)
138 /* Check for CONSOLE switch in SystemStartOptions */
139 CurrentOption
= SystemStartOptions
;
140 while (CurrentOption
)
142 NextOption
= wcschr(CurrentOption
, L
' ');
145 if (wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
147 TRACE("Found %S. Switching to console boot\n", CurrentOption
);
151 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
156 pGinaUI
= &GinaTextUI
;
158 pGinaUI
= &GinaGraphicalUI
;
160 if (ControlKey
!= NULL
)
161 RegCloseKey(ControlKey
);
162 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
168 GetRegistrySettings(PGINA_CONTEXT pgContext
)
171 LPWSTR lpAutoAdminLogon
= NULL
;
172 LPWSTR lpDontDisplayLastUserName
= NULL
;
173 LPWSTR lpShutdownWithoutLogon
= NULL
;
174 DWORD dwDisableCAD
= 0;
178 rc
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
179 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
183 if (rc
!= ERROR_SUCCESS
)
185 WARN("RegOpenKeyExW() failed with error %lu\n", rc
);
189 rc
= ReadRegSzValue(hKey
,
192 if (rc
== ERROR_SUCCESS
)
194 if (wcscmp(lpAutoAdminLogon
, L
"1") == 0)
195 pgContext
->bAutoAdminLogon
= TRUE
;
198 TRACE("bAutoAdminLogon: %s\n", pgContext
->bAutoAdminLogon
? "TRUE" : "FALSE");
200 rc
= ReadRegDwordValue(hKey
,
203 if (rc
== ERROR_SUCCESS
)
205 if (dwDisableCAD
!= 0)
206 pgContext
->bDisableCAD
= TRUE
;
209 TRACE("bDisableCAD: %s\n", pgContext
->bDisableCAD
? "TRUE" : "FALSE");
211 pgContext
->bShutdownWithoutLogon
= TRUE
;
212 rc
= ReadRegSzValue(hKey
,
213 L
"ShutdownWithoutLogon",
214 &lpShutdownWithoutLogon
);
215 if (rc
== ERROR_SUCCESS
)
217 if (wcscmp(lpShutdownWithoutLogon
, L
"0") == 0)
218 pgContext
->bShutdownWithoutLogon
= FALSE
;
221 rc
= ReadRegSzValue(hKey
,
222 L
"DontDisplayLastUserName",
223 &lpDontDisplayLastUserName
);
224 if (rc
== ERROR_SUCCESS
)
226 if (wcscmp(lpDontDisplayLastUserName
, L
"1") == 0)
227 pgContext
->bDontDisplayLastUserName
= TRUE
;
230 dwSize
= 256 * sizeof(WCHAR
);
231 rc
= RegQueryValueExW(hKey
,
235 (LPBYTE
)&pgContext
->UserName
,
238 dwSize
= 256 * sizeof(WCHAR
);
239 rc
= RegQueryValueExW(hKey
,
243 (LPBYTE
)&pgContext
->Domain
,
246 if (lpShutdownWithoutLogon
!= NULL
)
247 HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon
);
249 if (lpDontDisplayLastUserName
!= NULL
)
250 HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName
);
252 if (lpAutoAdminLogon
!= NULL
)
253 HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon
);
270 PVOID pWinlogonFunctions
,
273 PGINA_CONTEXT pgContext
;
275 UNREFERENCED_PARAMETER(pvReserved
);
277 pgContext
= (PGINA_CONTEXT
)LocalAlloc(LMEM_FIXED
| LMEM_ZEROINIT
, sizeof(GINA_CONTEXT
));
280 WARN("LocalAlloc() failed\n");
284 if (!GetRegistrySettings(pgContext
))
286 WARN("GetRegistrySettings() failed\n");
287 LocalFree(pgContext
);
291 /* Return the context to winlogon */
292 *pWlxContext
= (PVOID
)pgContext
;
293 pgContext
->hDllInstance
= hDllInstance
;
295 /* Save pointer to dispatch table */
296 pgContext
->pWlxFuncs
= (PWLX_DISPATCH_VERSION_1_3
)pWinlogonFunctions
;
298 /* Save the winlogon handle used to call the dispatch functions */
299 pgContext
->hWlx
= hWlx
;
301 /* Save window station */
302 pgContext
->station
= lpWinsta
;
304 /* Clear status window handle */
305 pgContext
->hStatusWindow
= 0;
307 /* Notify winlogon that we will use the default SAS */
308 pgContext
->pWlxFuncs
->WlxUseCtrlAltDel(hWlx
);
310 /* Locates the authentification package */
311 //LsaRegisterLogonProcess(...);
313 /* Check autologon settings the first time */
314 pgContext
->AutoLogonState
= AUTOLOGON_CHECK_REGISTRY
;
316 pgContext
->nShutdownAction
= WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
;
319 return pGinaUI
->Initialize(pgContext
);
327 WlxScreenSaverNotify(
334 DWORD bufferSize
= sizeof(szBuffer
);
335 DWORD varType
= REG_SZ
;
338 TRACE("(%p %p)\n", pWlxContext
, pSecure
);
344 * HKLM\Software\Policies\Microsoft\Windows\Control Panel\Desktop : ScreenSaverIsSecure
346 * HKCU\Control Panel\Desktop : ScreenSaverIsSecure
349 rc
= RegOpenKeyExW(HKEY_CURRENT_USER
,
350 L
"Control Panel\\Desktop",
354 TRACE("RegOpenKeyExW: %ld\n", rc
);
355 if (rc
== ERROR_SUCCESS
)
357 rc
= RegQueryValueExW(hKey
,
358 L
"ScreenSaverIsSecure",
364 TRACE("RegQueryValueExW: %ld\n", rc
);
366 if (rc
== ERROR_SUCCESS
)
368 TRACE("szBuffer: \"%S\"\n", szBuffer
);
369 *pSecure
= _wtoi(szBuffer
);
375 TRACE("*pSecure: %ld\n", *pSecure
);
389 PWSTR pszDesktopName
,
393 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
394 STARTUPINFOW StartupInfo
;
395 PROCESS_INFORMATION ProcessInformation
;
396 WCHAR CurrentDirectory
[MAX_PATH
];
401 len
= GetWindowsDirectoryW(CurrentDirectory
, MAX_PATH
);
402 if (len
== 0 || len
> MAX_PATH
)
404 ERR("GetWindowsDirectoryW() failed\n");
408 ret
= DuplicateTokenEx(pgContext
->UserToken
, MAXIMUM_ALLOWED
, NULL
, SecurityImpersonation
, TokenPrimary
, &hAppToken
);
411 ERR("DuplicateTokenEx() failed with error %lu\n", GetLastError());
415 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
416 ZeroMemory(&ProcessInformation
, sizeof(ProcessInformation
));
417 StartupInfo
.cb
= sizeof(StartupInfo
);
418 StartupInfo
.lpTitle
= pszCmdLine
;
419 StartupInfo
.dwFlags
= STARTF_USESHOWWINDOW
;
420 StartupInfo
.wShowWindow
= SW_SHOW
;
421 StartupInfo
.lpDesktop
= pszDesktopName
;
423 len
= GetWindowsDirectoryW(CurrentDirectory
, MAX_PATH
);
424 if (len
== 0 || len
> MAX_PATH
)
426 ERR("GetWindowsDirectoryW() failed\n");
429 ret
= CreateProcessAsUserW(
436 CREATE_UNICODE_ENVIRONMENT
,
440 &ProcessInformation
);
441 CloseHandle(ProcessInformation
.hProcess
);
442 CloseHandle(ProcessInformation
.hThread
);
443 CloseHandle(hAppToken
);
445 ERR("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
453 WlxActivateUserShell(
455 PWSTR pszDesktopName
,
456 PWSTR pszMprLogonScript
,
460 DWORD BufSize
, ValueType
;
461 WCHAR pszUserInitApp
[MAX_PATH
+ 1];
462 WCHAR pszExpUserInitApp
[MAX_PATH
];
466 TRACE("WlxActivateUserShell()\n");
468 UNREFERENCED_PARAMETER(pszMprLogonScript
);
470 /* Get the path of userinit */
473 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
477 if (rc
!= ERROR_SUCCESS
)
479 WARN("RegOpenKeyExW() failed with error %lu\n", rc
);
483 /* Query userinit application */
484 BufSize
= sizeof(pszUserInitApp
) - sizeof(UNICODE_NULL
);
485 rc
= RegQueryValueExW(
490 (LPBYTE
)pszUserInitApp
,
493 if (rc
!= ERROR_SUCCESS
|| (ValueType
!= REG_SZ
&& ValueType
!= REG_EXPAND_SZ
))
495 WARN("RegQueryValueExW() failed with error %lu\n", rc
);
498 pszUserInitApp
[MAX_PATH
] = UNICODE_NULL
;
500 len
= ExpandEnvironmentStringsW(pszUserInitApp
, pszExpUserInitApp
, MAX_PATH
);
503 WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len
);
507 /* Start userinit app */
508 return WlxStartApplication(pWlxContext
, pszDesktopName
, pEnvironment
, pszExpUserInitApp
);
520 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
521 INT SasAction
= WLX_SAS_ACTION_NONE
;
523 TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType
);
525 UNREFERENCED_PARAMETER(pReserved
);
529 case WLX_SAS_TYPE_CTRL_ALT_DEL
:
530 case WLX_SAS_TYPE_TIMEOUT
:
532 SasAction
= pGinaUI
->LoggedOnSAS(pgContext
, dwSasType
);
535 case WLX_SAS_TYPE_SC_INSERT
:
537 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
540 case WLX_SAS_TYPE_SC_REMOVE
:
542 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
547 WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType
);
559 WlxDisplayStatusMessage(
560 IN PVOID pWlxContext
,
566 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
568 TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage
);
570 return pGinaUI
->DisplayStatusMessage(pgContext
, hDesktop
, dwOptions
, pTitle
, pMessage
);
577 WlxRemoveStatusMessage(
578 IN PVOID pWlxContext
)
580 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
582 TRACE("WlxRemoveStatusMessage()\n");
584 return pGinaUI
->RemoveStatusMessage(pgContext
);
588 DuplicationString(PWSTR Str
)
593 if (Str
== NULL
) return NULL
;
595 cb
= (wcslen(Str
) + 1) * sizeof(WCHAR
);
596 if ((NewStr
= LocalAlloc(LMEM_FIXED
, cb
)))
597 memcpy(NewStr
, Str
, cb
);
604 IN PGINA_CONTEXT pgContext
,
609 HANDLE hToken
= NULL
;
610 PTOKEN_GROUPS Groups
= NULL
;
611 BOOL bIsAdmin
= FALSE
;
615 NTSTATUS SubStatus
= STATUS_SUCCESS
;
617 TRACE("(%S %S %S)\n", UserName
, Domain
, Password
);
619 Status
= ConnectToLsa(pgContext
);
620 if (!NT_SUCCESS(Status
))
622 WARN("ConnectToLsa() failed\n");
626 Status
= MyLogonUser(pgContext
->LsaHandle
,
627 pgContext
->AuthenticationPackage
,
631 &pgContext
->UserToken
,
633 if (!NT_SUCCESS(Status
))
635 WARN("MyLogonUser() failed\n");
639 Status
= NtQueryInformationToken(hToken
,
644 if ((Status
!= STATUS_SUCCESS
) && (Status
!= STATUS_BUFFER_TOO_SMALL
))
646 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status
);
650 Groups
= HeapAlloc(GetProcessHeap(), 0, Size
);
653 TRACE("HeapAlloc() failed\n");
657 Status
= NtQueryInformationToken(hToken
,
662 if (!NT_SUCCESS(Status
))
664 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status
);
668 for (i
= 0; i
< Groups
->GroupCount
; i
++)
670 if (RtlEqualSid(Groups
->Groups
[i
].Sid
, AdminSid
))
672 TRACE("Member of Admins group\n");
680 HeapFree(GetProcessHeap(), 0, Groups
);
691 IN OUT PGINA_CONTEXT pgContext
,
695 OUT PNTSTATUS SubStatus
)
699 Status
= ConnectToLsa(pgContext
);
700 if (!NT_SUCCESS(Status
))
702 WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status
);
706 Status
= MyLogonUser(pgContext
->LsaHandle
,
707 pgContext
->AuthenticationPackage
,
711 &pgContext
->UserToken
,
713 if (!NT_SUCCESS(Status
))
715 WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status
);
724 IN OUT PGINA_CONTEXT pgContext
,
729 LPWSTR ProfilePath
= NULL
;
730 LPWSTR lpEnvironment
= NULL
;
731 TOKEN_STATISTICS Stats
;
732 PWLX_PROFILE_V2_0 pProfile
= NULL
;
733 DWORD cbStats
, cbSize
;
737 /* Store the logon time in the context */
738 GetLocalTime(&pgContext
->LogonTime
);
740 /* Store user and domain in the context */
741 wcscpy(pgContext
->UserName
, UserName
);
742 if (Domain
== NULL
|| wcslen(Domain
) == 0)
745 GetComputerNameW(pgContext
->Domain
, &dwLength
);
749 wcscpy(pgContext
->Domain
, Domain
);
752 /* Get profile path */
754 bResult
= GetProfilesDirectoryW(NULL
, &cbSize
);
755 if (!bResult
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
757 ProfilePath
= HeapAlloc(GetProcessHeap(), 0, cbSize
* sizeof(WCHAR
));
760 WARN("HeapAlloc() failed\n");
763 bResult
= GetProfilesDirectoryW(ProfilePath
, &cbSize
);
767 WARN("GetUserProfileDirectoryW() failed\n");
771 /* Allocate memory for profile */
772 pProfile
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WLX_PROFILE_V2_0
));
775 WARN("HeapAlloc() failed\n");
778 pProfile
->dwType
= WLX_PROFILE_TYPE_V2_0
;
779 pProfile
->pszProfile
= ProfilePath
;
781 lpEnvironment
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
782 (wcslen(pgContext
->Domain
)+ 14 + 1) * sizeof(WCHAR
));
785 WARN("HeapAlloc() failed\n");
789 wsprintfW(lpEnvironment
, L
"LOGONSERVER=\\\\%s", pgContext
->Domain
);
791 pProfile
->pszEnvironment
= lpEnvironment
;
793 if (!GetTokenInformation(pgContext
->UserToken
,
796 sizeof(TOKEN_STATISTICS
),
799 WARN("Couldn't get Authentication id from user token!\n");
803 *pgContext
->pAuthenticationId
= Stats
.AuthenticationId
;
804 pgContext
->pMprNotifyInfo
->pszUserName
= DuplicationString(UserName
);
805 pgContext
->pMprNotifyInfo
->pszDomain
= DuplicationString(Domain
);
806 pgContext
->pMprNotifyInfo
->pszPassword
= DuplicationString(Password
);
807 pgContext
->pMprNotifyInfo
->pszOldPassword
= NULL
;
808 *pgContext
->pdwOptions
= 0;
809 *pgContext
->pProfile
= pProfile
;
815 HeapFree(GetProcessHeap(), 0, pProfile
->pszEnvironment
);
817 HeapFree(GetProcessHeap(), 0, pProfile
);
818 HeapFree(GetProcessHeap(), 0, ProfilePath
);
825 IN PGINA_CONTEXT pgContext
)
827 HKEY WinLogonKey
= NULL
;
828 LPWSTR AutoLogon
= NULL
;
829 LPWSTR AutoCount
= NULL
;
830 LPWSTR IgnoreShiftOverride
= NULL
;
831 LPWSTR UserName
= NULL
;
832 LPWSTR Domain
= NULL
;
833 LPWSTR Password
= NULL
;
837 NTSTATUS SubStatus
= STATUS_SUCCESS
;
839 TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
840 pgContext
->AutoLogonState
);
842 if (pgContext
->AutoLogonState
== AUTOLOGON_DISABLED
)
847 L
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\WinLogon",
851 if (rc
!= ERROR_SUCCESS
)
854 if (pgContext
->AutoLogonState
== AUTOLOGON_CHECK_REGISTRY
)
856 /* Set it by default to disabled, we might reenable it again later */
857 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
859 rc
= ReadRegSzValue(WinLogonKey
, L
"AutoAdminLogon", &AutoLogon
);
860 if (rc
!= ERROR_SUCCESS
)
862 if (wcscmp(AutoLogon
, L
"1") != 0)
865 rc
= ReadRegSzValue(WinLogonKey
, L
"AutoLogonCount", &AutoCount
);
866 if (rc
== ERROR_SUCCESS
&& wcscmp(AutoCount
, L
"0") == 0)
868 else if (rc
!= ERROR_FILE_NOT_FOUND
)
871 rc
= ReadRegSzValue(WinLogonKey
, L
"IgnoreShiftOverride", &UserName
);
872 if (rc
== ERROR_SUCCESS
)
874 if (wcscmp(AutoLogon
, L
"1") != 0 && GetKeyState(VK_SHIFT
) < 0)
877 else if (GetKeyState(VK_SHIFT
) < 0)
879 /* User pressed SHIFT */
883 pgContext
->AutoLogonState
= AUTOLOGON_ONCE
;
886 else /* pgContext->AutoLogonState == AUTOLOGON_ONCE */
888 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
890 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultUserName", &UserName
);
891 if (rc
!= ERROR_SUCCESS
)
893 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultDomain", &Domain
);
894 if (rc
!= ERROR_SUCCESS
&& rc
!= ERROR_FILE_NOT_FOUND
)
896 rc
= ReadRegSzValue(WinLogonKey
, L
"DefaultPassword", &Password
);
897 if (rc
!= ERROR_SUCCESS
)
900 Status
= DoLoginTasks(pgContext
, UserName
, Domain
, Password
, &SubStatus
);
901 if (!NT_SUCCESS(Status
))
903 /* FIXME: Handle errors!!! */
908 result
= CreateProfile(pgContext
, UserName
, Domain
, Password
);
911 ZeroMemory(pgContext
->Password
, 256 * sizeof(WCHAR
));
912 wcscpy(pgContext
->Password
, Password
);
914 NotifyBootConfigStatus(TRUE
);
919 if (WinLogonKey
!= NULL
)
920 RegCloseKey(WinLogonKey
);
921 HeapFree(GetProcessHeap(), 0, AutoLogon
);
922 HeapFree(GetProcessHeap(), 0, AutoCount
);
923 HeapFree(GetProcessHeap(), 0, IgnoreShiftOverride
);
924 HeapFree(GetProcessHeap(), 0, UserName
);
925 HeapFree(GetProcessHeap(), 0, Domain
);
926 HeapFree(GetProcessHeap(), 0, Password
);
927 TRACE("DoAutoLogon(): AutoLogonState = %lu, returning %d\n",
928 pgContext
->AutoLogonState
, result
);
937 IN PVOID pWlxContext
)
939 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
941 TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext
);
943 if (GetSystemMetrics(SM_REMOTESESSION
))
945 /* User is remotely logged on. Don't display a notice */
946 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
950 if (pgContext
->bAutoAdminLogon
== TRUE
)
952 /* Don't display the window, we want to do an automatic logon */
953 pgContext
->AutoLogonState
= AUTOLOGON_ONCE
;
954 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
958 pgContext
->AutoLogonState
= AUTOLOGON_DISABLED
;
960 if (pgContext
->bDisableCAD
== TRUE
)
962 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
966 pGinaUI
->DisplaySASNotice(pgContext
);
968 TRACE("WlxDisplaySASNotice() done\n");
976 IN PVOID pWlxContext
,
978 OUT PLUID pAuthenticationId
,
979 IN OUT PSID pLogonSid
,
980 OUT PDWORD pdwOptions
,
982 OUT PWLX_MPR_NOTIFY_INFO pMprNotifyInfo
,
985 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
988 TRACE("WlxLoggedOutSAS()\n");
990 UNREFERENCED_PARAMETER(dwSasType
);
991 UNREFERENCED_PARAMETER(pLogonSid
);
993 pgContext
->pAuthenticationId
= pAuthenticationId
;
994 pgContext
->pdwOptions
= pdwOptions
;
995 pgContext
->pMprNotifyInfo
= pMprNotifyInfo
;
996 pgContext
->pProfile
= pProfile
;
998 if (0 == GetSystemMetrics(SM_REMOTESESSION
) &&
999 DoAutoLogon(pgContext
))
1001 /* User is local and registry contains information
1002 * to log on him automatically */
1003 *phToken
= pgContext
->UserToken
;
1004 return WLX_SAS_ACTION_LOGON
;
1007 res
= pGinaUI
->LoggedOutSAS(pgContext
);
1008 *phToken
= pgContext
->UserToken
;
1020 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
1022 TRACE("WlxWkstaLockedSAS()\n");
1024 UNREFERENCED_PARAMETER(dwSasType
);
1026 return pGinaUI
->LockedSAS(pgContext
);
1035 WlxDisplayLockedNotice(PVOID pWlxContext
)
1037 PGINA_CONTEXT pgContext
= (PGINA_CONTEXT
)pWlxContext
;
1039 TRACE("WlxDisplayLockedNotice()\n");
1041 if (pgContext
->bDisableCAD
== TRUE
)
1043 pgContext
->pWlxFuncs
->WlxSasNotify(pgContext
->hWlx
, WLX_SAS_TYPE_CTRL_ALT_DEL
);
1047 pGinaUI
->DisplayLockedNotice(pgContext
);
1058 TRACE("WlxIsLogoffOk()\n");
1059 UNREFERENCED_PARAMETER(pWlxContext
);
1065 IN HINSTANCE hinstDLL
,
1067 IN LPVOID lpvReserved
)
1069 UNREFERENCED_PARAMETER(lpvReserved
);
1071 if (dwReason
== DLL_PROCESS_ATTACH
)
1073 hDllInstance
= hinstDLL
;
1075 RtlAllocateAndInitializeSid(&SystemAuthority
,
1077 SECURITY_BUILTIN_DOMAIN_RID
,
1078 DOMAIN_ALIAS_RID_ADMINS
,
1088 else if (dwReason
== DLL_PROCESS_DETACH
)
1090 if (AdminSid
!= NULL
)
1091 RtlFreeSid(AdminSid
);