ReactOS 0.4.15-dev-7961-gdcf9eb0
msgina.c File Reference
#include "msgina.h"
#include <winsvc.h>
#include <userenv.h>
#include <ndk/sefuncs.h>
Include dependency graph for msgina.c:

Go to the source code of this file.

Typedefs

typedef DWORD(WINAPIpThemeWait) (DWORD dwTimeout)
 
typedef BOOL(WINAPIpThemeWatch) (void)
 

Functions

BOOL WINAPI WlxNegotiate (IN DWORD dwWinlogonVersion, OUT PDWORD pdwDllVersion)
 
LONG ReadRegSzValue (IN HKEY hKey, IN LPCWSTR pszValue, OUT LPWSTR *pValue)
 
static LONG ReadRegDwordValue (IN HKEY hKey, IN LPCWSTR pszValue, OUT LPDWORD pValue)
 
static VOID ChooseGinaUI (VOID)
 
static BOOL GetRegistrySettings (PGINA_CONTEXT pgContext)
 
static void InitThemeSupport (VOID)
 
BOOL WINAPI WlxInitialize (LPWSTR lpWinsta, HANDLE hWlx, PVOID pvReserved, PVOID pWinlogonFunctions, PVOID *pWlxContext)
 
BOOL WINAPI WlxScreenSaverNotify (PVOID pWlxContext, BOOL *pSecure)
 
BOOL WINAPI WlxStartApplication (PVOID pWlxContext, PWSTR pszDesktopName, PVOID pEnvironment, PWSTR pszCmdLine)
 
BOOL WINAPI WlxActivateUserShell (PVOID pWlxContext, PWSTR pszDesktopName, PWSTR pszMprLogonScript, PVOID pEnvironment)
 
int WINAPI WlxLoggedOnSAS (PVOID pWlxContext, DWORD dwSasType, PVOID pReserved)
 
BOOL WINAPI WlxDisplayStatusMessage (IN PVOID pWlxContext, IN HDESK hDesktop, IN DWORD dwOptions, IN PWSTR pTitle, IN PWSTR pMessage)
 
BOOL WINAPI WlxRemoveStatusMessage (IN PVOID pWlxContext)
 
static PWSTR DuplicationString (PWSTR Str)
 
BOOL DoAdminUnlock (IN PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password)
 
NTSTATUS DoLoginTasks (IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password, OUT PNTSTATUS SubStatus)
 
BOOL CreateProfile (IN OUT PGINA_CONTEXT pgContext, IN PWSTR UserName, IN PWSTR Domain, IN PWSTR Password)
 
VOID WINAPI WlxDisplaySASNotice (IN PVOID pWlxContext)
 
INT WINAPI WlxLoggedOutSAS (IN PVOID pWlxContext, IN DWORD dwSasType, OUT PLUID pAuthenticationId, IN OUT PSID pLogonSid, OUT PDWORD pdwOptions, OUT PHANDLE phToken, OUT PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, OUT PVOID *pProfile)
 
int WINAPI WlxWkstaLockedSAS (PVOID pWlxContext, DWORD dwSasType)
 
VOID WINAPI WlxDisplayLockedNotice (PVOID pWlxContext)
 
BOOL WINAPI WlxIsLogoffOk (PVOID pWlxContext)
 
VOID WINAPI WlxLogoff (PVOID pWlxContext)
 
VOID WINAPI WlxShutdown (PVOID pWlxContext, DWORD ShutdownType)
 
BOOL WINAPI DllMain (IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
 

Variables

HINSTANCE hDllInstance
 
GINA_UI GinaGraphicalUI
 
GINA_UI GinaTextUI
 
static PGINA_UI pGinaUI
 
static SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY}
 
static PSID AdminSid
 

Typedef Documentation

◆ pThemeWait

typedef DWORD(WINAPI * pThemeWait) (DWORD dwTimeout)

Definition at line 281 of file msgina.c.

◆ pThemeWatch

typedef BOOL(WINAPI * pThemeWatch) (void)

Definition at line 282 of file msgina.c.

Function Documentation

◆ ChooseGinaUI()

static VOID ChooseGinaUI ( VOID  )
static

Definition at line 118 of file msgina.c.

119{
120 HKEY ControlKey = NULL;
121 LPWSTR SystemStartOptions = NULL;
122 LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
123 BOOL ConsoleBoot = FALSE;
124 LONG rc;
125
126 rc = RegOpenKeyExW(
128 L"SYSTEM\\CurrentControlSet\\Control",
129 0,
131 &ControlKey);
132
133 rc = ReadRegSzValue(ControlKey, L"SystemStartOptions", &SystemStartOptions);
134 if (rc != ERROR_SUCCESS)
135 goto cleanup;
136
137 /* Check for CONSOLE switch in SystemStartOptions */
138 CurrentOption = SystemStartOptions;
139 while (CurrentOption)
140 {
141 NextOption = wcschr(CurrentOption, L' ');
142 if (NextOption)
143 *NextOption = L'\0';
144 if (wcsicmp(CurrentOption, L"CONSOLE") == 0)
145 {
146 TRACE("Found %S. Switching to console boot\n", CurrentOption);
147 ConsoleBoot = TRUE;
148 goto cleanup;
149 }
150 CurrentOption = NextOption ? NextOption + 1 : NULL;
151 }
152
153cleanup:
154 if (ConsoleBoot)
156 else
158
159 if (ControlKey != NULL)
160 RegCloseKey(ControlKey);
161 HeapFree(GetProcessHeap(), 0, SystemStartOptions);
162}
#define RegCloseKey(hKey)
Definition: registry.h:49
#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:3333
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define wcsicmp
Definition: compat.h:15
static void cleanup(void)
Definition: main.c:1335
unsigned int BOOL
Definition: ntddk_ex.h:94
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
LONG ReadRegSzValue(IN HKEY hKey, IN LPCWSTR pszValue, OUT LPWSTR *pValue)
Definition: msgina.c:60
GINA_UI GinaTextUI
Definition: tui.c:276
GINA_UI GinaGraphicalUI
Definition: gui.c:1720
static PGINA_UI pGinaUI
Definition: msgina.c:37
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WlxInitialize().

◆ CreateProfile()

BOOL CreateProfile ( IN OUT PGINA_CONTEXT  pgContext,
IN PWSTR  UserName,
IN PWSTR  Domain,
IN PWSTR  Password 
)

Definition at line 785 of file msgina.c.

790{
791 LPWSTR ProfilePath = NULL;
792 LPWSTR lpEnvironment = NULL;
793 TOKEN_STATISTICS Stats;
794 PWLX_PROFILE_V2_0 pProfile = NULL;
795 DWORD cbStats, cbSize;
797 BOOL bResult;
798
799 /* Store the logon time in the context */
800 GetLocalTime(&pgContext->LogonTime);
801
802 /* Store user and domain in the context */
803 wcscpy(pgContext->UserName, UserName);
804 if (Domain == NULL || wcslen(Domain) == 0)
805 {
806 dwLength = _countof(pgContext->DomainName);
807 GetComputerNameW(pgContext->DomainName, &dwLength);
808 }
809 else
810 {
811 wcscpy(pgContext->DomainName, Domain);
812 }
813
814 /* Get profile path */
815 cbSize = 0;
816 bResult = GetProfilesDirectoryW(NULL, &cbSize);
817 if (!bResult && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
818 {
819 ProfilePath = HeapAlloc(GetProcessHeap(), 0, cbSize * sizeof(WCHAR));
820 if (!ProfilePath)
821 {
822 WARN("HeapAlloc() failed\n");
823 goto cleanup;
824 }
825 bResult = GetProfilesDirectoryW(ProfilePath, &cbSize);
826 }
827 if (!bResult)
828 {
829 WARN("GetUserProfileDirectoryW() failed\n");
830 goto cleanup;
831 }
832
833 /* Allocate memory for profile */
835 if (!pProfile)
836 {
837 WARN("HeapAlloc() failed\n");
838 goto cleanup;
839 }
840 pProfile->dwType = WLX_PROFILE_TYPE_V2_0;
841 pProfile->pszProfile = ProfilePath;
842
843 cbSize = sizeof(L"LOGONSERVER=\\\\") +
844 wcslen(pgContext->DomainName) * sizeof(WCHAR) +
845 sizeof(UNICODE_NULL);
846 lpEnvironment = HeapAlloc(GetProcessHeap(), 0, cbSize);
847 if (!lpEnvironment)
848 {
849 WARN("HeapAlloc() failed\n");
850 goto cleanup;
851 }
852
853 StringCbPrintfW(lpEnvironment, cbSize, L"LOGONSERVER=\\\\%ls", pgContext->DomainName);
854 ASSERT(wcslen(lpEnvironment) == cbSize / sizeof(WCHAR) - 2);
855 lpEnvironment[cbSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
856
857 pProfile->pszEnvironment = lpEnvironment;
858
859 if (!GetTokenInformation(pgContext->UserToken,
861 &Stats,
862 sizeof(Stats),
863 &cbStats))
864 {
865 WARN("Couldn't get Authentication id from user token!\n");
866 goto cleanup;
867 }
868
869 *pgContext->pAuthenticationId = Stats.AuthenticationId;
870 pgContext->pMprNotifyInfo->pszUserName = DuplicationString(UserName);
871 pgContext->pMprNotifyInfo->pszDomain = DuplicationString(Domain);
872 pgContext->pMprNotifyInfo->pszPassword = DuplicationString(Password);
873 pgContext->pMprNotifyInfo->pszOldPassword = NULL;
874 *pgContext->pdwOptions = 0;
875 *pgContext->pProfile = pProfile;
876 return TRUE;
877
878cleanup:
879 if (pProfile)
880 {
881 HeapFree(GetProcessHeap(), 0, pProfile->pszEnvironment);
882 }
883 HeapFree(GetProcessHeap(), 0, pProfile);
884 HeapFree(GetProcessHeap(), 0, ProfilePath);
885 return FALSE;
886}
#define WARN(fmt,...)
Definition: debug.h:112
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
BOOL WINAPI GetProfilesDirectoryW(_Out_ LPWSTR lpProfilesDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1576
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ASSERT(a)
Definition: mode.c:44
static PWSTR DuplicationString(PWSTR Str)
Definition: msgina.c:650
#define UNICODE_NULL
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LUID AuthenticationId
Definition: setypes.h:1087
PWSTR pszEnvironment
Definition: winwlx.h:153
PWSTR pszProfile
Definition: winwlx.h:149
@ Password
Definition: telnetd.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WLX_PROFILE_TYPE_V2_0
Definition: winwlx.h:51
@ TokenStatistics
Definition: setypes.h:975
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ DllMain()

BOOL WINAPI DllMain ( IN HINSTANCE  hinstDLL,
IN DWORD  dwReason,
IN LPVOID  lpvReserved 
)

@DllMain

Core routine of the Utility Manager's library.

Parameters
[in]hDllInstanceThe entry point instance of the library.
[in]fdwReasonThe reason argument to indicate the motive DllMain is being called.
[in]lpvReservedReserved.
Returns
Returns TRUE when main call initialization has succeeded, FALSE otherwise.

Definition at line 1060 of file msgina.c.

1064{
1066
1068 {
1069 hDllInstance = hinstDLL;
1070
1072 2,
1081 &AdminSid);
1082
1083 }
1084 else if (dwReason == DLL_PROCESS_DETACH)
1085 {
1086 if (AdminSid != NULL)
1088 }
1089
1090 return TRUE;
1091}
DWORD dwReason
Definition: misc.cpp:154
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
static IN DWORD IN LPVOID lpvReserved
static SID_IDENTIFIER_AUTHORITY SystemAuthority
Definition: msgina.c:38
static PSID AdminSid
Definition: msgina.c:39
HINSTANCE hDllInstance
Definition: msgina.c:33
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
Definition: sid.c:290
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_NULL_RID
Definition: setypes.h:540
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

◆ DoAdminUnlock()

BOOL DoAdminUnlock ( IN PGINA_CONTEXT  pgContext,
IN PWSTR  UserName,
IN PWSTR  Domain,
IN PWSTR  Password 
)

Definition at line 665 of file msgina.c.

670{
671 HANDLE hToken = NULL;
672 PTOKEN_GROUPS Groups = NULL;
673 BOOL bIsAdmin = FALSE;
674 ULONG Size;
675 ULONG i;
678
679 TRACE("(%S %S %S)\n", UserName, Domain, Password);
680
681 Status = ConnectToLsa(pgContext);
682 if (!NT_SUCCESS(Status))
683 {
684 WARN("ConnectToLsa() failed\n");
685 return FALSE;
686 }
687
688 Status = MyLogonUser(pgContext->LsaHandle,
689 pgContext->AuthenticationPackage,
690 UserName,
691 Domain,
692 Password,
693 &pgContext->UserToken,
694 &SubStatus);
695 if (!NT_SUCCESS(Status))
696 {
697 WARN("MyLogonUser() failed\n");
698 return FALSE;
699 }
700
703 NULL,
704 0,
705 &Size);
707 {
708 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
709 goto done;
710 }
711
712 Groups = HeapAlloc(GetProcessHeap(), 0, Size);
713 if (Groups == NULL)
714 {
715 TRACE("HeapAlloc() failed\n");
716 goto done;
717 }
718
721 Groups,
722 Size,
723 &Size);
724 if (!NT_SUCCESS(Status))
725 {
726 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
727 goto done;
728 }
729
730 for (i = 0; i < Groups->GroupCount; i++)
731 {
732 if (RtlEqualSid(Groups->Groups[i].Sid, AdminSid))
733 {
734 TRACE("Member of Admins group\n");
735 bIsAdmin = TRUE;
736 break;
737 }
738 }
739
740done:
741 if (Groups != NULL)
742 HeapFree(GetProcessHeap(), 0, Groups);
743
744 if (hToken != NULL)
745 CloseHandle(hToken);
746
747 return bIsAdmin;
748}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CloseHandle
Definition: compat.h:739
NTSTATUS MyLogonUser(HANDLE LsaHandle, ULONG AuthenticationPackage, LPWSTR lpszUsername, LPWSTR lpszDomain, LPWSTR lpszPassword, PHANDLE phToken, PNTSTATUS SubStatus)
Definition: lsa.c:55
NTSTATUS ConnectToLsa(PGINA_CONTEXT pgContext)
Definition: lsa.c:11
Status
Definition: gdiplustypes.h:25
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
NTSYSAPI BOOLEAN NTAPI RtlEqualSid(_In_ PSID Sid1, _In_ PSID Sid2)
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE _Out_ PQUOTA_LIMITS _Out_ PNTSTATUS SubStatus
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:1018
$ULONG GroupCount
Definition: setypes.h:1014
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Queries a specific type of information in regard of an access token based upon the information class....
Definition: tokencls.c:473
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
@ TokenGroups
Definition: setypes.h:967

Referenced by DoUnlock().

◆ DoLoginTasks()

NTSTATUS DoLoginTasks ( IN OUT PGINA_CONTEXT  pgContext,
IN PWSTR  UserName,
IN PWSTR  Domain,
IN PWSTR  Password,
OUT PNTSTATUS  SubStatus 
)

Definition at line 752 of file msgina.c.

758{
760
761 Status = ConnectToLsa(pgContext);
762 if (!NT_SUCCESS(Status))
763 {
764 WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status);
765 return Status;
766 }
767
768 Status = MyLogonUser(pgContext->LsaHandle,
769 pgContext->AuthenticationPackage,
770 UserName,
771 Domain,
772 Password,
773 &pgContext->UserToken,
774 SubStatus);
775 if (!NT_SUCCESS(Status))
776 {
777 WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status);
778 }
779
780 return Status;
781}

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ DuplicationString()

static PWSTR DuplicationString ( PWSTR  Str)
static

Definition at line 650 of file msgina.c.

651{
652 DWORD cb;
653 PWSTR NewStr;
654
655 if (Str == NULL) return NULL;
656
657 cb = (wcslen(Str) + 1) * sizeof(WCHAR);
658 if ((NewStr = LocalAlloc(LMEM_FIXED, cb)))
659 memcpy(NewStr, Str, cb);
660 return NewStr;
661}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
uint16_t * PWSTR
Definition: typedefs.h:56
#define LMEM_FIXED
Definition: winbase.h:368

Referenced by CreateProfile().

◆ GetRegistrySettings()

static BOOL GetRegistrySettings ( PGINA_CONTEXT  pgContext)
static

Definition at line 167 of file msgina.c.

168{
169 HKEY hKey = NULL;
170 LPWSTR lpAutoAdminLogon = NULL;
171 LPWSTR lpDontDisplayLastUserName = NULL;
172 LPWSTR lpShutdownWithoutLogon = NULL;
173 LPWSTR lpIgnoreShiftOverride = NULL;
174 DWORD dwDisableCAD = 0;
176 LONG rc;
177
179 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
180 0,
182 &hKey);
183 if (rc != ERROR_SUCCESS)
184 {
185 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
186 return FALSE;
187 }
188
189 rc = ReadRegSzValue(hKey,
190 L"AutoAdminLogon",
191 &lpAutoAdminLogon);
192 if (rc == ERROR_SUCCESS)
193 {
194 if (wcscmp(lpAutoAdminLogon, L"1") == 0)
195 pgContext->bAutoAdminLogon = TRUE;
196 }
197
198 TRACE("bAutoAdminLogon: %s\n", pgContext->bAutoAdminLogon ? "TRUE" : "FALSE");
199
201 L"DisableCAD",
202 &dwDisableCAD);
203 if (rc == ERROR_SUCCESS)
204 {
205 if (dwDisableCAD != 0)
206 pgContext->bDisableCAD = TRUE;
207 }
208
209 TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
210
211 pgContext->bShutdownWithoutLogon = TRUE;
212 rc = ReadRegSzValue(hKey,
213 L"ShutdownWithoutLogon",
214 &lpShutdownWithoutLogon);
215 if (rc == ERROR_SUCCESS)
216 {
217 if (wcscmp(lpShutdownWithoutLogon, L"0") == 0)
218 pgContext->bShutdownWithoutLogon = FALSE;
219 }
220
221 rc = ReadRegSzValue(hKey,
222 L"DontDisplayLastUserName",
223 &lpDontDisplayLastUserName);
224 if (rc == ERROR_SUCCESS)
225 {
226 if (wcscmp(lpDontDisplayLastUserName, L"1") == 0)
227 pgContext->bDontDisplayLastUserName = TRUE;
228 }
229
230 rc = ReadRegSzValue(hKey,
231 L"IgnoreShiftOverride",
232 &lpIgnoreShiftOverride);
233 if (rc == ERROR_SUCCESS)
234 {
235 if (wcscmp(lpIgnoreShiftOverride, L"1") == 0)
236 pgContext->bIgnoreShiftOverride = TRUE;
237 }
238
239 dwSize = sizeof(pgContext->UserName);
241 L"DefaultUserName",
242 NULL,
243 NULL,
244 (LPBYTE)&pgContext->UserName,
245 &dwSize);
246
247 dwSize = sizeof(pgContext->DomainName);
249 L"DefaultDomainName",
250 NULL,
251 NULL,
252 (LPBYTE)&pgContext->DomainName,
253 &dwSize);
254
255 dwSize = sizeof(pgContext->Password);
257 L"DefaultPassword",
258 NULL,
259 NULL,
260 (LPBYTE)&pgContext->Password,
261 &dwSize);
262
263 if (lpIgnoreShiftOverride != NULL)
264 HeapFree(GetProcessHeap(), 0, lpIgnoreShiftOverride);
265
266 if (lpShutdownWithoutLogon != NULL)
267 HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon);
268
269 if (lpDontDisplayLastUserName != NULL)
270 HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName);
271
272 if (lpAutoAdminLogon != NULL)
273 HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon);
274
275 if (hKey != NULL)
277
278 return TRUE;
279}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LONG ReadRegDwordValue(IN HKEY hKey, IN LPCWSTR pszValue, OUT LPDWORD pValue)
Definition: msgina.c:96
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL bAutoAdminLogon
Definition: msgina.h:42
WCHAR DomainName[256]
Definition: msgina.h:51
BOOL bIgnoreShiftOverride
Definition: msgina.h:45
BOOL bDontDisplayLastUserName
Definition: msgina.h:43
BOOL bShutdownWithoutLogon
Definition: msgina.h:44
BOOL bDisableCAD
Definition: msgina.h:41
WCHAR UserName[256]
Definition: msgina.h:50
WCHAR Password[256]
Definition: msgina.h:52
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by WlxInitialize().

◆ InitThemeSupport()

static void InitThemeSupport ( VOID  )
static

Definition at line 285 of file msgina.c.

286{
287 HMODULE hDll = LoadLibraryW(L"shsvcs.dll");
288 pThemeWait themeWait;
289 pThemeWatch themeWatch;
290
291 if(!hDll)
292 return;
293
294 themeWait = (pThemeWait) GetProcAddress(hDll, (LPCSTR)2);
295 themeWatch = (pThemeWatch) GetProcAddress(hDll, (LPCSTR)1);
296
297 if(themeWait && themeWatch)
298 {
299 themeWait(5000);
300 themeWatch();
301 }
302}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD(WINAPI * pThemeWait)(DWORD dwTimeout)
Definition: msgina.c:281
BOOL(WINAPI * pThemeWatch)(void)
Definition: msgina.c:282
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by WlxInitialize().

◆ ReadRegDwordValue()

static LONG ReadRegDwordValue ( IN HKEY  hKey,
IN LPCWSTR  pszValue,
OUT LPDWORD  pValue 
)
static

Definition at line 96 of file msgina.c.

100{
101 LONG rc;
102 DWORD dwType;
103 DWORD cbData;
104 DWORD dwValue;
105
106 if (!pValue)
108
109 cbData = sizeof(DWORD);
110 rc = RegQueryValueExW(hKey, pszValue, NULL, &dwType, (LPBYTE)&dwValue, &cbData);
111 if (rc == ERROR_SUCCESS && dwType == REG_DWORD)
112 *pValue = dwValue;
113
114 return ERROR_SUCCESS;
115}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PWCHAR pValue
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by GetRegistrySettings().

◆ ReadRegSzValue()

LONG ReadRegSzValue ( IN HKEY  hKey,
IN LPCWSTR  pszValue,
OUT LPWSTR pValue 
)

Definition at line 60 of file msgina.c.

64{
65 LONG rc;
66 DWORD dwType;
67 DWORD cbData = 0;
69
70 if (!pValue)
72
73 *pValue = NULL;
74 rc = RegQueryValueExW(hKey, pszValue, NULL, &dwType, NULL, &cbData);
75 if (rc != ERROR_SUCCESS)
76 return rc;
77 if (dwType != REG_SZ)
79 Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
80 if (!Value)
82 rc = RegQueryValueExW(hKey, pszValue, NULL, NULL, (LPBYTE)Value, &cbData);
83 if (rc != ERROR_SUCCESS)
84 {
86 return rc;
87 }
88 /* NULL-terminate the string */
89 Value[cbData / sizeof(WCHAR)] = '\0';
90
91 *pValue = Value;
92 return ERROR_SUCCESS;
93}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by ChooseGinaUI(), GetRegistrySettings(), and GUILoggedOutSAS().

◆ WlxActivateUserShell()

BOOL WINAPI WlxActivateUserShell ( PVOID  pWlxContext,
PWSTR  pszDesktopName,
PWSTR  pszMprLogonScript,
PVOID  pEnvironment 
)

Definition at line 515 of file msgina.c.

520{
521 HKEY hKey;
523 WCHAR pszUserInitApp[MAX_PATH + 1];
524 WCHAR pszExpUserInitApp[MAX_PATH];
525 DWORD len;
526 LONG rc;
527
528 TRACE("WlxActivateUserShell()\n");
529
530 UNREFERENCED_PARAMETER(pszMprLogonScript);
531
532 /* Get the path of userinit */
533 rc = RegOpenKeyExW(
535 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
536 0,
538 &hKey);
539 if (rc != ERROR_SUCCESS)
540 {
541 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
542 return FALSE;
543 }
544
545 /* Query userinit application */
546 BufSize = sizeof(pszUserInitApp) - sizeof(UNICODE_NULL);
547 rc = RegQueryValueExW(
548 hKey,
549 L"Userinit",
550 NULL,
551 &ValueType,
552 (LPBYTE)pszUserInitApp,
553 &BufSize);
555 if (rc != ERROR_SUCCESS || (ValueType != REG_SZ && ValueType != REG_EXPAND_SZ))
556 {
557 WARN("RegQueryValueExW() failed with error %lu\n", rc);
558 return FALSE;
559 }
560 pszUserInitApp[MAX_PATH] = UNICODE_NULL;
561
562 len = ExpandEnvironmentStringsW(pszUserInitApp, pszExpUserInitApp, MAX_PATH);
563 if (len > MAX_PATH)
564 {
565 WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len);
566 return FALSE;
567 }
568
569 /* Start userinit app */
570 return WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
571}
#define BufSize
Definition: FsRtlTunnel.c:28
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI WlxStartApplication(PVOID pWlxContext, PWSTR pszDesktopName, PVOID pEnvironment, PWSTR pszCmdLine)
Definition: msgina.c:449
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282

◆ WlxDisplayLockedNotice()

VOID WINAPI WlxDisplayLockedNotice ( PVOID  pWlxContext)

Definition at line 987 of file msgina.c.

988{
989 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
990
991 TRACE("WlxDisplayLockedNotice()\n");
992
993 if (pgContext->bDisableCAD)
994 {
995 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
996 return;
997 }
998
999 pGinaUI->DisplayLockedNotice(pgContext);
1000}
struct GINA_CONTEXT * PGINA_CONTEXT
HANDLE hWlx
Definition: msgina.h:34
PWLX_DISPATCH_VERSION_1_3 pWlxFuncs
Definition: msgina.h:36
PFGINA_DISPLAYLOCKEDNOTICE DisplayLockedNotice
Definition: msgina.h:81
PWLX_SAS_NOTIFY WlxSasNotify
Definition: winwlx.h:559
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36

◆ WlxDisplaySASNotice()

VOID WINAPI WlxDisplaySASNotice ( IN PVOID  pWlxContext)

Definition at line 893 of file msgina.c.

895{
896 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
897
898 TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext);
899
901 {
902 /* User is remotely logged on. Don't display a notice */
903 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
904 return;
905 }
906
907 if (pgContext->bAutoAdminLogon)
908 {
909 if (pgContext->bIgnoreShiftOverride ||
910 (GetKeyState(VK_SHIFT) >= 0))
911 {
912 /* Don't display the window, we want to do an automatic logon */
913 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
914 return;
915 }
916
917 pgContext->bAutoAdminLogon = FALSE;
918 }
919
920 if (pgContext->bDisableCAD)
921 {
922 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
923 return;
924 }
925
926 pGinaUI->DisplaySASNotice(pgContext);
927
928 TRACE("WlxDisplaySASNotice() done\n");
929}
PFGINA_DISPLAYSASNOTICE DisplaySASNotice
Definition: msgina.h:77
#define VK_SHIFT
Definition: winuser.h:2202
#define SM_REMOTESESSION
Definition: winuser.h:1058
int WINAPI GetSystemMetrics(_In_ int)
SHORT WINAPI GetKeyState(_In_ int)

◆ WlxDisplayStatusMessage()

BOOL WINAPI WlxDisplayStatusMessage ( IN PVOID  pWlxContext,
IN HDESK  hDesktop,
IN DWORD  dwOptions,
IN PWSTR  pTitle,
IN PWSTR  pMessage 
)

Definition at line 621 of file msgina.c.

627{
628 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
629
630 TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage);
631
632 return pGinaUI->DisplayStatusMessage(pgContext, hDesktop, dwOptions, pTitle, pMessage);
633}
DWORD dwOptions
Definition: solitaire.cpp:25
PFGINA_DISPLAYSTATUSMESSAGE DisplayStatusMessage
Definition: msgina.h:75

◆ WlxInitialize()

BOOL WINAPI WlxInitialize ( LPWSTR  lpWinsta,
HANDLE  hWlx,
PVOID  pvReserved,
PVOID  pWinlogonFunctions,
PVOID pWlxContext 
)

Definition at line 308 of file msgina.c.

314{
315 PGINA_CONTEXT pgContext;
316
318
320
322 if(!pgContext)
323 {
324 WARN("LocalAlloc() failed\n");
325 return FALSE;
326 }
327
328 if (!GetRegistrySettings(pgContext))
329 {
330 WARN("GetRegistrySettings() failed\n");
331 LocalFree(pgContext);
332 return FALSE;
333 }
334
335 /* Return the context to winlogon */
336 *pWlxContext = (PVOID)pgContext;
337 pgContext->hDllInstance = hDllInstance;
338
339 /* Save pointer to dispatch table */
340 pgContext->pWlxFuncs = (PWLX_DISPATCH_VERSION_1_3)pWinlogonFunctions;
341
342 /* Save the winlogon handle used to call the dispatch functions */
343 pgContext->hWlx = hWlx;
344
345 /* Save window station */
346 pgContext->station = lpWinsta;
347
348 /* Clear status window handle */
349 pgContext->hStatusWindow = NULL;
350
351 /* Notify winlogon that we will use the default SAS */
352 pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx);
353
354 /* Locates the authentication package */
355 //LsaRegisterLogonProcess(...);
356
358
359 ChooseGinaUI();
360 return pGinaUI->Initialize(pgContext);
361}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
static BOOL GetRegistrySettings(PGINA_CONTEXT pgContext)
Definition: msgina.c:167
static VOID ChooseGinaUI(VOID)
Definition: msgina.c:118
static void InitThemeSupport(VOID)
Definition: msgina.c:285
LPWSTR station
Definition: msgina.h:35
HWND hStatusWindow
Definition: msgina.h:38
ULONG nShutdownAction
Definition: msgina.h:47
HANDLE hDllInstance
Definition: msgina.h:37
PFGINA_INITIALIZE Initialize
Definition: msgina.h:74
PWLX_USE_CTRL_ALT_DEL WlxUseCtrlAltDel
Definition: winwlx.h:557
void * PVOID
Definition: typedefs.h:50
#define LMEM_ZEROINIT
Definition: winbase.h:375
struct _WLX_DISPATCH_VERSION_1_3 * PWLX_DISPATCH_VERSION_1_3
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

◆ WlxIsLogoffOk()

BOOL WINAPI WlxIsLogoffOk ( PVOID  pWlxContext)

Definition at line 1007 of file msgina.c.

1009{
1010 TRACE("WlxIsLogoffOk()\n");
1011 UNREFERENCED_PARAMETER(pWlxContext);
1012 return TRUE;
1013}

◆ WlxLoggedOnSAS()

int WINAPI WlxLoggedOnSAS ( PVOID  pWlxContext,
DWORD  dwSasType,
PVOID  pReserved 
)

Definition at line 577 of file msgina.c.

581{
582 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
583 INT SasAction = WLX_SAS_ACTION_NONE;
584
585 TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
586
587 UNREFERENCED_PARAMETER(pReserved);
588
589 switch (dwSasType)
590 {
593 {
594 SasAction = pGinaUI->LoggedOnSAS(pgContext, dwSasType);
595 break;
596 }
598 {
599 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
600 break;
601 }
603 {
604 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
605 break;
606 }
607 default:
608 {
609 WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType);
610 break;
611 }
612 }
613
614 return SasAction;
615}
#define FIXME(fmt,...)
Definition: debug.h:111
PFGINA_LOGGEDONSAS LoggedOnSAS
Definition: msgina.h:78
int32_t INT
Definition: typedefs.h:58
#define WLX_SAS_TYPE_TIMEOUT
Definition: winwlx.h:35
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54
#define WLX_SAS_TYPE_SC_INSERT
Definition: winwlx.h:40
#define WLX_SAS_TYPE_SC_REMOVE
Definition: winwlx.h:41

◆ WlxLoggedOutSAS()

INT WINAPI WlxLoggedOutSAS ( IN PVOID  pWlxContext,
IN DWORD  dwSasType,
OUT PLUID  pAuthenticationId,
IN OUT PSID  pLogonSid,
OUT PDWORD  pdwOptions,
OUT PHANDLE  phToken,
OUT PWLX_MPR_NOTIFY_INFO  pMprNotifyInfo,
OUT PVOID pProfile 
)

Definition at line 935 of file msgina.c.

944{
945 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
946 INT res;
947
948 TRACE("WlxLoggedOutSAS()\n");
949
950 UNREFERENCED_PARAMETER(dwSasType);
951 UNREFERENCED_PARAMETER(pLogonSid);
952
953 pgContext->pAuthenticationId = pAuthenticationId;
954 pgContext->pdwOptions = pdwOptions;
955 pgContext->pMprNotifyInfo = pMprNotifyInfo;
956 pgContext->pProfile = pProfile;
957
958
959 res = pGinaUI->LoggedOutSAS(pgContext);
960 *phToken = pgContext->UserToken;
961 return res;
962}
GLuint res
Definition: glext.h:9613
PLUID pAuthenticationId
Definition: msgina.h:55
HANDLE UserToken
Definition: msgina.h:54
PVOID * pProfile
Definition: msgina.h:58
PWLX_MPR_NOTIFY_INFO pMprNotifyInfo
Definition: msgina.h:57
PDWORD pdwOptions
Definition: msgina.h:56
PFGINA_LOGGEDOUTSAS LoggedOutSAS
Definition: msgina.h:79
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2715

◆ WlxLogoff()

VOID WINAPI WlxLogoff ( PVOID  pWlxContext)

Definition at line 1020 of file msgina.c.

1022{
1023 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1024
1025 TRACE("WlxLogoff(%p)\n", pWlxContext);
1026
1027 /* Delete the password */
1028 ZeroMemory(pgContext->Password, sizeof(pgContext->Password));
1029
1030 /* Close the user token */
1031 CloseHandle(pgContext->UserToken);
1032 pgContext->UserToken = NULL;
1033}
#define ZeroMemory
Definition: winbase.h:1712

◆ WlxNegotiate()

BOOL WINAPI WlxNegotiate ( IN DWORD  dwWinlogonVersion,
OUT PDWORD  pdwDllVersion 
)

Definition at line 45 of file msgina.c.

48{
49 TRACE("WlxNegotiate(%lx, %p)\n", dwWinlogonVersion, pdwDllVersion);
50
51 if(!pdwDllVersion || (dwWinlogonVersion < WLX_VERSION_1_3))
52 return FALSE;
53
54 *pdwDllVersion = WLX_VERSION_1_3;
55
56 return TRUE;
57}
#define WLX_VERSION_1_3
Definition: winwlx.h:31

◆ WlxRemoveStatusMessage()

BOOL WINAPI WlxRemoveStatusMessage ( IN PVOID  pWlxContext)

Definition at line 639 of file msgina.c.

641{
642 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
643
644 TRACE("WlxRemoveStatusMessage()\n");
645
646 return pGinaUI->RemoveStatusMessage(pgContext);
647}
PFGINA_REMOVESTATUSMESSAGE RemoveStatusMessage
Definition: msgina.h:76

◆ WlxScreenSaverNotify()

BOOL WINAPI WlxScreenSaverNotify ( PVOID  pWlxContext,
BOOL pSecure 
)

Definition at line 368 of file msgina.c.

371{
372#if 0
373 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
374 WCHAR szBuffer[2];
375 HKEY hKeyCurrentUser, hKey;
376 DWORD bufferSize = sizeof(szBuffer);
377 DWORD varType = REG_SZ;
378 LONG rc;
379
380 TRACE("(%p %p)\n", pWlxContext, pSecure);
381
382 *pSecure = TRUE;
383
384 /*
385 * Policy setting:
386 * HKLM\Software\Policies\Microsoft\Windows\Control Panel\Desktop : ScreenSaverIsSecure
387 * User setting:
388 * HKCU\Control Panel\Desktop : ScreenSaverIsSecure
389 */
390
391 if (!ImpersonateLoggedOnUser(pgContext->UserToken))
392 {
393 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
394 *pSecure = FALSE;
395 return TRUE;
396 }
397
398 /* Open the current user HKCU key */
399 rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
400 TRACE("RegOpenCurrentUser: %ld\n", rc);
401 if (rc == ERROR_SUCCESS)
402 {
403 /* Open the subkey */
404 rc = RegOpenKeyExW(hKeyCurrentUser,
405 L"Control Panel\\Desktop",
406 0,
408 &hKey);
409 TRACE("RegOpenKeyExW: %ld\n", rc);
410 RegCloseKey(hKeyCurrentUser);
411 }
412
413 /* Read the value */
414 if (rc == ERROR_SUCCESS)
415 {
417 L"ScreenSaverIsSecure",
418 NULL,
419 &varType,
420 (LPBYTE)szBuffer,
421 &bufferSize);
422
423 TRACE("RegQueryValueExW: %ld\n", rc);
424
425 if (rc == ERROR_SUCCESS)
426 {
427 TRACE("szBuffer: \"%S\"\n", szBuffer);
428 *pSecure = _wtoi(szBuffer);
429 }
430
432 }
433
434 /* Revert the impersonation */
435 RevertToSelf();
436
437 TRACE("*pSecure: %ld\n", *pSecure);
438#endif
439
440 *pSecure = FALSE;
441
442 return TRUE;
443}
#define ERR(fmt,...)
Definition: debug.h:110
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
size_t bufferSize
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
BOOL WINAPI RevertToSelf(void)
Definition: security.c:1608

◆ WlxShutdown()

VOID WINAPI WlxShutdown ( PVOID  pWlxContext,
DWORD  ShutdownType 
)

Definition at line 1040 of file msgina.c.

1043{
1044 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1046
1047 TRACE("WlxShutdown(%p %lx)\n", pWlxContext, ShutdownType);
1048
1049 /* Close the LSA handle */
1050 pgContext->AuthenticationPackage = 0;
1052 if (!NT_SUCCESS(Status))
1053 {
1054 ERR("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n", Status);
1055 }
1056}
NTSTATUS NTAPI LsaDeregisterLogonProcess(HANDLE)
HANDLE LsaHandle
Definition: msgina.h:39
ULONG AuthenticationPackage
Definition: msgina.h:40

◆ WlxStartApplication()

BOOL WINAPI WlxStartApplication ( PVOID  pWlxContext,
PWSTR  pszDesktopName,
PVOID  pEnvironment,
PWSTR  pszCmdLine 
)

Definition at line 449 of file msgina.c.

454{
455 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
456 STARTUPINFOW StartupInfo;
457 PROCESS_INFORMATION ProcessInformation;
459 HANDLE hAppToken;
460 UINT len;
461 BOOL ret;
462
464 if (len == 0 || len > MAX_PATH)
465 {
466 ERR("GetWindowsDirectoryW() failed\n");
467 return FALSE;
468 }
469
471 if (!ret)
472 {
473 ERR("DuplicateTokenEx() failed with error %lu\n", GetLastError());
474 return FALSE;
475 }
476
477 ZeroMemory(&StartupInfo, sizeof(StartupInfo));
478 ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
479 StartupInfo.cb = sizeof(StartupInfo);
480 StartupInfo.lpTitle = pszCmdLine;
481 StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
482 StartupInfo.wShowWindow = SW_SHOW;
483 StartupInfo.lpDesktop = pszDesktopName;
484
486 if (len == 0 || len > MAX_PATH)
487 {
488 ERR("GetWindowsDirectoryW() failed\n");
489 return FALSE;
490 }
492 hAppToken,
493 pszCmdLine,
494 NULL,
495 NULL,
496 NULL,
497 FALSE,
499 pEnvironment,
501 &StartupInfo,
502 &ProcessInformation);
503 CloseHandle(ProcessInformation.hProcess);
504 CloseHandle(ProcessInformation.hThread);
505 CloseHandle(hAppToken);
506 if (!ret)
507 ERR("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
508 return ret;
509}
WCHAR CurrentDirectory[1024]
Definition: chkdsk.c:74
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
Definition: logon.c:993
BOOL WINAPI DuplicateTokenEx(IN HANDLE ExistingTokenHandle, IN DWORD dwDesiredAccess, IN LPSECURITY_ATTRIBUTES lpTokenAttributes OPTIONAL, IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, IN TOKEN_TYPE TokenType, OUT PHANDLE DuplicateTokenHandle)
Definition: security.c:3859
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
@ SecurityImpersonation
Definition: lsa.idl:57
@ TokenPrimary
Definition: imports.h:273
unsigned int UINT
Definition: ndis.h:50
LPWSTR lpDesktop
Definition: winbase.h:854
DWORD cb
Definition: winbase.h:852
DWORD dwFlags
Definition: winbase.h:863
LPWSTR lpTitle
Definition: winbase.h:855
WORD wShowWindow
Definition: winbase.h:864
int ret
#define STARTF_USESHOWWINDOW
Definition: winbase.h:491
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:186
#define SW_SHOW
Definition: winuser.h:775

Referenced by WlxActivateUserShell().

◆ WlxWkstaLockedSAS()

int WINAPI WlxWkstaLockedSAS ( PVOID  pWlxContext,
DWORD  dwSasType 
)

Definition at line 968 of file msgina.c.

971{
972 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
973
974 TRACE("WlxWkstaLockedSAS()\n");
975
976 UNREFERENCED_PARAMETER(dwSasType);
977
978 return pGinaUI->LockedSAS(pgContext);
979}
PFGINA_LOCKEDSAS LockedSAS
Definition: msgina.h:80

Variable Documentation

◆ AdminSid

◆ GinaGraphicalUI

GINA_UI GinaGraphicalUI
extern

Definition at line 1720 of file gui.c.

Referenced by ChooseGinaUI().

◆ GinaTextUI

GINA_UI GinaTextUI
extern

Definition at line 276 of file tui.c.

Referenced by ChooseGinaUI().

◆ hDllInstance

HINSTANCE hDllInstance

Definition at line 33 of file msgina.c.

Referenced by DllMain(), and WlxInitialize().

◆ pGinaUI

◆ SystemAuthority

SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY}
static

Definition at line 38 of file msgina.c.

Referenced by BuildTokenGroups(), CSR_API(), DllMain(), LogonUserExW(), and MyLogonUser().