ReactOS 0.4.16-dev-1210-gbc03c01
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 SafeGetUnicodeString (_In_ const LSA_UNICODE_STRING *pInput, _Out_ PWSTR pszOutput, _In_ SIZE_T cchMax)
 
static BOOL GetLsaDefaultPassword (_Inout_ PGINA_CONTEXT pgContext)
 
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 327 of file msgina.c.

◆ pThemeWatch

typedef BOOL(WINAPI * pThemeWatch) (void)

Definition at line 328 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
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
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#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 831 of file msgina.c.

836{
837 LPWSTR ProfilePath = NULL;
838 LPWSTR lpEnvironment = NULL;
839 TOKEN_STATISTICS Stats;
840 PWLX_PROFILE_V2_0 pProfile = NULL;
841 DWORD cbStats, cbSize;
843 BOOL bResult;
844
845 /* Store the logon time in the context */
846 GetLocalTime(&pgContext->LogonTime);
847
848 /* Store user and domain in the context */
849 wcscpy(pgContext->UserName, UserName);
850 if (Domain == NULL || wcslen(Domain) == 0)
851 {
852 dwLength = _countof(pgContext->DomainName);
853 GetComputerNameW(pgContext->DomainName, &dwLength);
854 }
855 else
856 {
857 wcscpy(pgContext->DomainName, Domain);
858 }
859
860 /* Get profile path */
861 cbSize = 0;
862 bResult = GetProfilesDirectoryW(NULL, &cbSize);
863 if (!bResult && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
864 {
865 ProfilePath = HeapAlloc(GetProcessHeap(), 0, cbSize * sizeof(WCHAR));
866 if (!ProfilePath)
867 {
868 WARN("HeapAlloc() failed\n");
869 goto cleanup;
870 }
871 bResult = GetProfilesDirectoryW(ProfilePath, &cbSize);
872 }
873 if (!bResult)
874 {
875 WARN("GetUserProfileDirectoryW() failed\n");
876 goto cleanup;
877 }
878
879 /* Allocate memory for profile */
881 if (!pProfile)
882 {
883 WARN("HeapAlloc() failed\n");
884 goto cleanup;
885 }
886 pProfile->dwType = WLX_PROFILE_TYPE_V2_0;
887 pProfile->pszProfile = ProfilePath;
888
889 cbSize = sizeof(L"LOGONSERVER=\\\\") +
890 wcslen(pgContext->DomainName) * sizeof(WCHAR) +
891 sizeof(UNICODE_NULL);
892 lpEnvironment = HeapAlloc(GetProcessHeap(), 0, cbSize);
893 if (!lpEnvironment)
894 {
895 WARN("HeapAlloc() failed\n");
896 goto cleanup;
897 }
898
899 StringCbPrintfW(lpEnvironment, cbSize, L"LOGONSERVER=\\\\%ls", pgContext->DomainName);
900 ASSERT(wcslen(lpEnvironment) == cbSize / sizeof(WCHAR) - 2);
901 lpEnvironment[cbSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
902
903 pProfile->pszEnvironment = lpEnvironment;
904
905 if (!GetTokenInformation(pgContext->UserToken,
907 &Stats,
908 sizeof(Stats),
909 &cbStats))
910 {
911 WARN("Couldn't get Authentication id from user token!\n");
912 goto cleanup;
913 }
914
915 *pgContext->pAuthenticationId = Stats.AuthenticationId;
916 pgContext->pMprNotifyInfo->pszUserName = DuplicationString(UserName);
917 pgContext->pMprNotifyInfo->pszDomain = DuplicationString(Domain);
918 pgContext->pMprNotifyInfo->pszPassword = DuplicationString(Password);
919 pgContext->pMprNotifyInfo->pszOldPassword = NULL;
920 *pgContext->pdwOptions = 0;
921 *pgContext->pProfile = pProfile;
922 return TRUE;
923
924cleanup:
925 if (pProfile)
926 {
927 HeapFree(GetProcessHeap(), 0, pProfile->pszEnvironment);
928 }
929 HeapFree(GetProcessHeap(), 0, pProfile);
930 HeapFree(GetProcessHeap(), 0, ProfilePath);
931 return FALSE;
932}
#define WARN(fmt,...)
Definition: precomp.h:61
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
wcscpy
#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:696
#define UNICODE_NULL
#define _countof(array)
Definition: sndvol32.h:70
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 1106 of file msgina.c.

1110{
1112
1114 {
1115 hDllInstance = hinstDLL;
1116
1118 2,
1127 &AdminSid);
1128
1129 }
1130 else if (dwReason == DLL_PROCESS_DETACH)
1131 {
1132 if (AdminSid != NULL)
1134 }
1135
1136 return TRUE;
1137}
DWORD dwReason
Definition: misc.cpp:135
#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:329
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 711 of file msgina.c.

716{
717 HANDLE hToken = NULL;
718 PTOKEN_GROUPS Groups = NULL;
719 BOOL bIsAdmin = FALSE;
720 ULONG Size;
721 ULONG i;
724
725 TRACE("(%S %S %S)\n", UserName, Domain, Password);
726
727 Status = ConnectToLsa(pgContext);
728 if (!NT_SUCCESS(Status))
729 {
730 WARN("ConnectToLsa() failed\n");
731 return FALSE;
732 }
733
734 Status = MyLogonUser(pgContext->LsaHandle,
735 pgContext->AuthenticationPackage,
736 UserName,
737 Domain,
738 Password,
739 &pgContext->UserToken,
740 &SubStatus);
741 if (!NT_SUCCESS(Status))
742 {
743 WARN("MyLogonUser() failed\n");
744 return FALSE;
745 }
746
749 NULL,
750 0,
751 &Size);
753 {
754 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
755 goto done;
756 }
757
758 Groups = HeapAlloc(GetProcessHeap(), 0, Size);
759 if (Groups == NULL)
760 {
761 TRACE("HeapAlloc() failed\n");
762 goto done;
763 }
764
767 Groups,
768 Size,
769 &Size);
770 if (!NT_SUCCESS(Status))
771 {
772 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
773 goto done;
774 }
775
776 for (i = 0; i < Groups->GroupCount; i++)
777 {
778 if (RtlEqualSid(Groups->Groups[i].Sid, AdminSid))
779 {
780 TRACE("Member of Admins group\n");
781 bIsAdmin = TRUE;
782 break;
783 }
784 }
785
786done:
787 if (Groups != NULL)
788 HeapFree(GetProcessHeap(), 0, Groups);
789
790 if (hToken != NULL)
791 CloseHandle(hToken);
792
793 return bIsAdmin;
794}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#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 798 of file msgina.c.

804{
806
807 Status = ConnectToLsa(pgContext);
808 if (!NT_SUCCESS(Status))
809 {
810 WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status);
811 return Status;
812 }
813
814 Status = MyLogonUser(pgContext->LsaHandle,
815 pgContext->AuthenticationPackage,
816 UserName,
817 Domain,
818 Password,
819 &pgContext->UserToken,
820 SubStatus);
821 if (!NT_SUCCESS(Status))
822 {
823 WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status);
824 }
825
826 return Status;
827}

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ DuplicationString()

static PWSTR DuplicationString ( PWSTR  Str)
static

Definition at line 696 of file msgina.c.

697{
698 DWORD cb;
699 PWSTR NewStr;
700
701 if (Str == NULL) return NULL;
702
703 cb = (wcslen(Str) + 1) * sizeof(WCHAR);
704 if ((NewStr = LocalAlloc(LMEM_FIXED, cb)))
705 memcpy(NewStr, Str, cb);
706 return NewStr;
707}
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:401

Referenced by CreateProfile().

◆ GetLsaDefaultPassword()

static BOOL GetLsaDefaultPassword ( _Inout_ PGINA_CONTEXT  pgContext)
static

Definition at line 180 of file msgina.c.

181{
182 LSA_HANDLE hPolicy;
185
188 if (!NT_SUCCESS(Status))
189 return FALSE;
190
191 RtlInitUnicodeString(&Name, L"DefaultPassword");
192 Status = LsaRetrievePrivateData(hPolicy, &Name, &pPwd);
193 LsaClose(hPolicy);
194
195 if (Status == STATUS_SUCCESS)
196 {
197 if (!SafeGetUnicodeString(pPwd, pgContext->Password,
198 _countof(pgContext->Password)))
199 {
201 }
202 SecureZeroMemory(pPwd->Buffer, pPwd->Length);
203 LsaFreeMemory(pPwd);
204 }
205
206 return Status == STATUS_SUCCESS;
207}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
LPWSTR Name
Definition: desk.c:124
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
Definition: lsa.c:1183
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:701
NTSTATUS WINAPI LsaRetrievePrivateData(IN LSA_HANDLE PolicyHandle, IN PLSA_UNICODE_STRING KeyName, OUT PLSA_UNICODE_STRING *PrivateData)
Definition: lsa.c:1814
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
Definition: lsa.c:194
static BOOL SafeGetUnicodeString(_In_ const LSA_UNICODE_STRING *pInput, _Out_ PWSTR pszOutput, _In_ SIZE_T cchMax)
Definition: msgina.c:165
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define POLICY_GET_PRIVATE_INFORMATION
Definition: ntsecapi.h:63
#define SecureZeroMemory
Definition: winbase.h:1754

Referenced by GetRegistrySettings().

◆ GetRegistrySettings()

static BOOL GetRegistrySettings ( PGINA_CONTEXT  pgContext)
static

Definition at line 211 of file msgina.c.

212{
213 HKEY hKey = NULL;
214 LPWSTR lpAutoAdminLogon = NULL;
215 LPWSTR lpDontDisplayLastUserName = NULL;
216 LPWSTR lpShutdownWithoutLogon = NULL;
217 LPWSTR lpIgnoreShiftOverride = NULL;
218 DWORD dwDisableCAD = 0;
220 LONG rc;
221
223 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
224 0,
226 &hKey);
227 if (rc != ERROR_SUCCESS)
228 {
229 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
230 return FALSE;
231 }
232
233 rc = ReadRegSzValue(hKey,
234 L"AutoAdminLogon",
235 &lpAutoAdminLogon);
236 if (rc == ERROR_SUCCESS)
237 {
238 if (wcscmp(lpAutoAdminLogon, L"1") == 0)
239 pgContext->bAutoAdminLogon = TRUE;
240 }
241
242 TRACE("bAutoAdminLogon: %s\n", pgContext->bAutoAdminLogon ? "TRUE" : "FALSE");
243
245 L"DisableCAD",
246 &dwDisableCAD);
247 if (rc == ERROR_SUCCESS)
248 {
249 if (dwDisableCAD != 0)
250 pgContext->bDisableCAD = TRUE;
251 }
252
253 TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
254
255 pgContext->bShutdownWithoutLogon = TRUE;
256 rc = ReadRegSzValue(hKey,
257 L"ShutdownWithoutLogon",
258 &lpShutdownWithoutLogon);
259 if (rc == ERROR_SUCCESS)
260 {
261 if (wcscmp(lpShutdownWithoutLogon, L"0") == 0)
262 pgContext->bShutdownWithoutLogon = FALSE;
263 }
264
265 rc = ReadRegSzValue(hKey,
266 L"DontDisplayLastUserName",
267 &lpDontDisplayLastUserName);
268 if (rc == ERROR_SUCCESS)
269 {
270 if (wcscmp(lpDontDisplayLastUserName, L"1") == 0)
271 pgContext->bDontDisplayLastUserName = TRUE;
272 }
273
274 rc = ReadRegSzValue(hKey,
275 L"IgnoreShiftOverride",
276 &lpIgnoreShiftOverride);
277 if (rc == ERROR_SUCCESS)
278 {
279 if (wcscmp(lpIgnoreShiftOverride, L"1") == 0)
280 pgContext->bIgnoreShiftOverride = TRUE;
281 }
282
283 dwSize = sizeof(pgContext->UserName);
285 L"DefaultUserName",
286 NULL,
287 NULL,
288 (LPBYTE)&pgContext->UserName,
289 &dwSize);
290
291 dwSize = sizeof(pgContext->DomainName);
293 L"DefaultDomainName",
294 NULL,
295 NULL,
296 (LPBYTE)&pgContext->DomainName,
297 &dwSize);
298
299 dwSize = sizeof(pgContext->Password);
301 L"DefaultPassword",
302 NULL,
303 NULL,
304 (LPBYTE)&pgContext->Password,
305 &dwSize);
306 if (rc)
307 GetLsaDefaultPassword(pgContext);
308
309 if (lpIgnoreShiftOverride != NULL)
310 HeapFree(GetProcessHeap(), 0, lpIgnoreShiftOverride);
311
312 if (lpShutdownWithoutLogon != NULL)
313 HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon);
314
315 if (lpDontDisplayLastUserName != NULL)
316 HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName);
317
318 if (lpAutoAdminLogon != NULL)
319 HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon);
320
321 if (hKey != NULL)
323
324 return TRUE;
325}
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 BOOL GetLsaDefaultPassword(_Inout_ PGINA_CONTEXT pgContext)
Definition: msgina.c:180
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 331 of file msgina.c.

332{
333 HMODULE hDll = LoadLibraryW(L"shsvcs.dll");
334 pThemeWait themeWait;
335 pThemeWatch themeWatch;
336
337 if(!hDll)
338 return;
339
340 themeWait = (pThemeWait) GetProcAddress(hDll, (LPCSTR)2);
341 themeWatch = (pThemeWatch) GetProcAddress(hDll, (LPCSTR)1);
342
343 if(themeWait && themeWatch)
344 {
345 themeWait(5000);
346 themeWatch();
347 }
348}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD(WINAPI * pThemeWait)(DWORD dwTimeout)
Definition: msgina.c:327
BOOL(WINAPI * pThemeWatch)(void)
Definition: msgina.c:328
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().

◆ SafeGetUnicodeString()

static BOOL SafeGetUnicodeString ( _In_ const LSA_UNICODE_STRING pInput,
_Out_ PWSTR  pszOutput,
_In_ SIZE_T  cchMax 
)
static

Definition at line 165 of file msgina.c.

169{
170 HRESULT hr;
171 hr = StringCbCopyNExW(pszOutput, cchMax * sizeof(WCHAR),
172 pInput->Buffer, pInput->Length,
173 NULL, NULL,
175 return (hr == S_OK);
176}
UINT cchMax
#define S_OK
Definition: intsafe.h:52
#define STRSAFE_NULL_ON_FAILURE
Definition: ntstrsafe.h:34
#define STRSAFE_NO_TRUNCATION
Definition: ntstrsafe.h:35
HRESULT hr
Definition: shlfolder.c:183
STRSAFEAPI StringCbCopyNExW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcbRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:299

Referenced by GetLsaDefaultPassword().

◆ WlxActivateUserShell()

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

Definition at line 561 of file msgina.c.

566{
567 HKEY hKey;
569 WCHAR pszUserInitApp[MAX_PATH + 1];
570 WCHAR pszExpUserInitApp[MAX_PATH];
571 DWORD len;
572 LONG rc;
573
574 TRACE("WlxActivateUserShell()\n");
575
576 UNREFERENCED_PARAMETER(pszMprLogonScript);
577
578 /* Get the path of userinit */
579 rc = RegOpenKeyExW(
581 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
582 0,
584 &hKey);
585 if (rc != ERROR_SUCCESS)
586 {
587 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
588 return FALSE;
589 }
590
591 /* Query userinit application */
592 BufSize = sizeof(pszUserInitApp) - sizeof(UNICODE_NULL);
593 rc = RegQueryValueExW(
594 hKey,
595 L"Userinit",
596 NULL,
597 &ValueType,
598 (LPBYTE)pszUserInitApp,
599 &BufSize);
601 if (rc != ERROR_SUCCESS || (ValueType != REG_SZ && ValueType != REG_EXPAND_SZ))
602 {
603 WARN("RegQueryValueExW() failed with error %lu\n", rc);
604 return FALSE;
605 }
606 pszUserInitApp[MAX_PATH] = UNICODE_NULL;
607
608 len = ExpandEnvironmentStringsW(pszUserInitApp, pszExpUserInitApp, MAX_PATH);
609 if (len > MAX_PATH)
610 {
611 WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len);
612 return FALSE;
613 }
614
615 /* Start userinit app */
616 return WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
617}
#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:495
#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 1033 of file msgina.c.

1034{
1035 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1036
1037 TRACE("WlxDisplayLockedNotice()\n");
1038
1039 if (pgContext->bDisableCAD)
1040 {
1041 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
1042 return;
1043 }
1044
1045 pGinaUI->DisplayLockedNotice(pgContext);
1046}
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 939 of file msgina.c.

941{
942 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
943
944 TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext);
945
947 {
948 /* User is remotely logged on. Don't display a notice */
949 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
950 return;
951 }
952
953 if (pgContext->bAutoAdminLogon)
954 {
955 if (pgContext->bIgnoreShiftOverride ||
956 (GetKeyState(VK_SHIFT) >= 0))
957 {
958 /* Don't display the window, we want to do an automatic logon */
959 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
960 return;
961 }
962
963 pgContext->bAutoAdminLogon = FALSE;
964 }
965
966 if (pgContext->bDisableCAD)
967 {
968 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
969 return;
970 }
971
972 pGinaUI->DisplaySASNotice(pgContext);
973
974 TRACE("WlxDisplaySASNotice() done\n");
975}
PFGINA_DISPLAYSASNOTICE DisplaySASNotice
Definition: msgina.h:77
#define VK_SHIFT
Definition: winuser.h:2221
#define SM_REMOTESESSION
Definition: winuser.h:1069
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 667 of file msgina.c.

673{
674 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
675
676 TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage);
677
678 return pGinaUI->DisplayStatusMessage(pgContext, hDesktop, dwOptions, pTitle, pMessage);
679}
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 354 of file msgina.c.

360{
361 PGINA_CONTEXT pgContext;
362
364
366
368 if(!pgContext)
369 {
370 WARN("LocalAlloc() failed\n");
371 return FALSE;
372 }
373
374 if (!GetRegistrySettings(pgContext))
375 {
376 WARN("GetRegistrySettings() failed\n");
377 LocalFree(pgContext);
378 return FALSE;
379 }
380
381 /* Return the context to winlogon */
382 *pWlxContext = (PVOID)pgContext;
383 pgContext->hDllInstance = hDllInstance;
384
385 /* Save pointer to dispatch table */
386 pgContext->pWlxFuncs = (PWLX_DISPATCH_VERSION_1_3)pWinlogonFunctions;
387
388 /* Save the winlogon handle used to call the dispatch functions */
389 pgContext->hWlx = hWlx;
390
391 /* Save window station */
392 pgContext->station = lpWinsta;
393
394 /* Clear status window handle */
395 pgContext->hStatusWindow = NULL;
396
397 /* Notify winlogon that we will use the default SAS */
398 pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx);
399
400 /* Locates the authentication package */
401 //LsaRegisterLogonProcess(...);
402
404
405 ChooseGinaUI();
406 return pGinaUI->Initialize(pgContext);
407}
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:211
static VOID ChooseGinaUI(VOID)
Definition: msgina.c:118
static void InitThemeSupport(VOID)
Definition: msgina.c:331
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:408
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 1053 of file msgina.c.

1055{
1056 TRACE("WlxIsLogoffOk()\n");
1057 UNREFERENCED_PARAMETER(pWlxContext);
1058 return TRUE;
1059}

◆ WlxLoggedOnSAS()

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

Definition at line 623 of file msgina.c.

627{
628 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
629 INT SasAction = WLX_SAS_ACTION_NONE;
630
631 TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
632
633 UNREFERENCED_PARAMETER(pReserved);
634
635 switch (dwSasType)
636 {
639 {
640 SasAction = pGinaUI->LoggedOnSAS(pgContext, dwSasType);
641 break;
642 }
644 {
645 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
646 break;
647 }
649 {
650 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
651 break;
652 }
653 default:
654 {
655 WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType);
656 break;
657 }
658 }
659
660 return SasAction;
661}
#define FIXME(fmt,...)
Definition: precomp.h:53
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 981 of file msgina.c.

990{
991 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
992 INT res;
993
994 TRACE("WlxLoggedOutSAS()\n");
995
996 UNREFERENCED_PARAMETER(dwSasType);
997 UNREFERENCED_PARAMETER(pLogonSid);
998
999 pgContext->pAuthenticationId = pAuthenticationId;
1000 pgContext->pdwOptions = pdwOptions;
1001 pgContext->pMprNotifyInfo = pMprNotifyInfo;
1002 pgContext->pProfile = pProfile;
1003
1004
1005 res = pGinaUI->LoggedOutSAS(pgContext);
1006 *phToken = pgContext->UserToken;
1007 return res;
1008}
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:2756

◆ WlxLogoff()

VOID WINAPI WlxLogoff ( PVOID  pWlxContext)

Definition at line 1066 of file msgina.c.

1068{
1069 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1070
1071 TRACE("WlxLogoff(%p)\n", pWlxContext);
1072
1073 /* Delete the password */
1074 ZeroMemory(pgContext->Password, sizeof(pgContext->Password));
1075
1076 /* Close the user token */
1077 CloseHandle(pgContext->UserToken);
1078 pgContext->UserToken = NULL;
1079}
#define ZeroMemory
Definition: winbase.h:1753

◆ 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 685 of file msgina.c.

687{
688 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
689
690 TRACE("WlxRemoveStatusMessage()\n");
691
692 return pGinaUI->RemoveStatusMessage(pgContext);
693}
PFGINA_REMOVESTATUSMESSAGE RemoveStatusMessage
Definition: msgina.h:76

◆ WlxScreenSaverNotify()

BOOL WINAPI WlxScreenSaverNotify ( PVOID  pWlxContext,
BOOL pSecure 
)

Definition at line 414 of file msgina.c.

417{
418#if 0
419 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
420 WCHAR szBuffer[2];
421 HKEY hKeyCurrentUser, hKey;
422 DWORD bufferSize = sizeof(szBuffer);
423 DWORD varType = REG_SZ;
424 LONG rc;
425
426 TRACE("(%p %p)\n", pWlxContext, pSecure);
427
428 *pSecure = TRUE;
429
430 /*
431 * Policy setting:
432 * HKLM\Software\Policies\Microsoft\Windows\Control Panel\Desktop : ScreenSaverIsSecure
433 * User setting:
434 * HKCU\Control Panel\Desktop : ScreenSaverIsSecure
435 */
436
437 if (!ImpersonateLoggedOnUser(pgContext->UserToken))
438 {
439 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
440 *pSecure = FALSE;
441 return TRUE;
442 }
443
444 /* Open the current user HKCU key */
445 rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
446 TRACE("RegOpenCurrentUser: %ld\n", rc);
447 if (rc == ERROR_SUCCESS)
448 {
449 /* Open the subkey */
450 rc = RegOpenKeyExW(hKeyCurrentUser,
451 L"Control Panel\\Desktop",
452 0,
454 &hKey);
455 TRACE("RegOpenKeyExW: %ld\n", rc);
456 RegCloseKey(hKeyCurrentUser);
457 }
458
459 /* Read the value */
460 if (rc == ERROR_SUCCESS)
461 {
463 L"ScreenSaverIsSecure",
464 NULL,
465 &varType,
466 (LPBYTE)szBuffer,
467 &bufferSize);
468
469 TRACE("RegQueryValueExW: %ld\n", rc);
470
471 if (rc == ERROR_SUCCESS)
472 {
473 TRACE("szBuffer: \"%S\"\n", szBuffer);
474 *pSecure = _wtoi(szBuffer);
475 }
476
478 }
479
480 /* Revert the impersonation */
481 RevertToSelf();
482
483 TRACE("*pSecure: %ld\n", *pSecure);
484#endif
485
486 *pSecure = FALSE;
487
488 return TRUE;
489}
#define ERR(fmt,...)
Definition: precomp.h:57
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 1086 of file msgina.c.

1089{
1090 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1092
1093 TRACE("WlxShutdown(%p %lx)\n", pWlxContext, ShutdownType);
1094
1095 /* Close the LSA handle */
1096 pgContext->AuthenticationPackage = 0;
1098 if (!NT_SUCCESS(Status))
1099 {
1100 ERR("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n", Status);
1101 }
1102}
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 495 of file msgina.c.

500{
501 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
502 STARTUPINFOW StartupInfo;
503 PROCESS_INFORMATION ProcessInformation;
505 HANDLE hAppToken;
506 UINT len;
507 BOOL ret;
508
510 if (len == 0 || len > MAX_PATH)
511 {
512 ERR("GetWindowsDirectoryW() failed\n");
513 return FALSE;
514 }
515
517 if (!ret)
518 {
519 ERR("DuplicateTokenEx() failed with error %lu\n", GetLastError());
520 return FALSE;
521 }
522
523 ZeroMemory(&StartupInfo, sizeof(StartupInfo));
524 ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
525 StartupInfo.cb = sizeof(StartupInfo);
526 StartupInfo.lpTitle = pszCmdLine;
527 StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
528 StartupInfo.wShowWindow = SW_SHOW;
529 StartupInfo.lpDesktop = pszDesktopName;
530
532 if (len == 0 || len > MAX_PATH)
533 {
534 ERR("GetWindowsDirectoryW() failed\n");
535 return FALSE;
536 }
538 hAppToken,
539 pszCmdLine,
540 NULL,
541 NULL,
542 NULL,
543 FALSE,
545 pEnvironment,
547 &StartupInfo,
548 &ProcessInformation);
549 CloseHandle(ProcessInformation.hProcess);
550 CloseHandle(ProcessInformation.hThread);
551 CloseHandle(hAppToken);
552 if (!ret)
553 ERR("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
554 return ret;
555}
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:889
DWORD cb
Definition: winbase.h:887
DWORD dwFlags
Definition: winbase.h:898
LPWSTR lpTitle
Definition: winbase.h:890
WORD wShowWindow
Definition: winbase.h:899
int ret
#define STARTF_USESHOWWINDOW
Definition: winbase.h:524
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:196
#define SW_SHOW
Definition: winuser.h:786

Referenced by WlxActivateUserShell().

◆ WlxWkstaLockedSAS()

int WINAPI WlxWkstaLockedSAS ( PVOID  pWlxContext,
DWORD  dwSasType 
)

Definition at line 1014 of file msgina.c.

1017{
1018 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1019
1020 TRACE("WlxWkstaLockedSAS()\n");
1021
1022 UNREFERENCED_PARAMETER(dwSasType);
1023
1024 return pGinaUI->LockedSAS(pgContext);
1025}
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().