ReactOS 0.4.16-dev-1948-gd260c1d
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)
 
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 (_In_ PVOID pWlxContext, _In_ PWSTR pszDesktopName, _In_ PWSTR pszMprLogonScript, _In_ 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)
 
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 232 of file msgina.c.

◆ pThemeWatch

typedef BOOL(WINAPI * pThemeWatch) (void)

Definition at line 233 of file msgina.c.

Function Documentation

◆ ChooseGinaUI()

static VOID ChooseGinaUI ( VOID  )
static

Definition at line 60 of file msgina.c.

61{
62 HKEY ControlKey = NULL;
63 LPWSTR SystemStartOptions = NULL;
64 LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
65 BOOL ConsoleBoot = FALSE;
66 LONG rc;
67
68 rc = RegOpenKeyExW(
70 L"SYSTEM\\CurrentControlSet\\Control",
71 0,
73 &ControlKey);
74
75 rc = ReadRegSzValue(ControlKey, L"SystemStartOptions", &SystemStartOptions);
76 if (rc != ERROR_SUCCESS)
77 goto cleanup;
78
79 /* Check for CONSOLE switch in SystemStartOptions */
80 CurrentOption = SystemStartOptions;
81 while (CurrentOption)
82 {
83 NextOption = wcschr(CurrentOption, L' ');
84 if (NextOption)
85 *NextOption = L'\0';
86 if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
87 {
88 TRACE("Found %S. Switching to console boot\n", CurrentOption);
89 ConsoleBoot = TRUE;
90 goto cleanup;
91 }
92 CurrentOption = NextOption ? NextOption + 1 : NULL;
93 }
94
96 if (ConsoleBoot)
98 else
100
101 if (ControlKey != NULL)
102 RegCloseKey(ControlKey);
103 HeapFree(GetProcessHeap(), 0, SystemStartOptions);
104}
#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
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
GINA_UI GinaTextUI
Definition: tui.c:276
GINA_UI GinaGraphicalUI
Definition: gui.c:1798
static PGINA_UI pGinaUI
Definition: msgina.c:37
LONG ReadRegSzValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PWSTR *pValue)
Definition: utils.c:57
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
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 759 of file msgina.c.

764{
765 PWLX_PROFILE_V2_0 pProfile = NULL;
766 PWSTR pEnvironment = NULL;
767 TOKEN_STATISTICS Stats;
768 DWORD cbStats, cbSize;
770#if 0
771 BOOL bIsDomainLogon;
772 WCHAR ComputerName[MAX_COMPUTERNAME_LENGTH+1];
773#endif
774
775 /* Store the logon time in the context */
776 GetLocalTime(&pgContext->LogonTime);
777
778 /* Store user and domain in the context */
779 wcscpy(pgContext->UserName, UserName);
780 if (Domain == NULL || !Domain[0])
781 {
782 dwLength = _countof(pgContext->DomainName);
783 GetComputerNameW(pgContext->DomainName, &dwLength);
784 }
785 else
786 {
787 wcscpy(pgContext->DomainName, Domain);
788 }
789 /* From now on we use in UserName and Domain the captured values from pgContext */
790 UserName = pgContext->UserName;
791 Domain = pgContext->DomainName;
792
793#if 0
794 /* Determine whether this is really a domain logon, by verifying
795 * that the specified domain is different from the local computer */
796 dwLength = _countof(ComputerName);
797 GetComputerNameW(ComputerName, &dwLength);
798 bIsDomainLogon = (_wcsicmp(ComputerName, Domain) != 0);
799#endif
800
801 /* Allocate memory for profile */
802 pProfile = LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, sizeof(*pProfile));
803 if (!pProfile)
804 {
805 WARN("HeapAlloc() failed\n");
806 goto cleanup;
807 }
808 pProfile->dwType = WLX_PROFILE_TYPE_V2_0;
809
810 /*
811 * TODO: For domain logon support:
812 *
813 * - pszProfile: Specifies the path to a *roaming* user profile on a
814 * domain server, if any. It is then used to create a local image
815 * (copy) of the profile on the local computer.
816 * ** This data should be retrieved from the LsaLogonUser() call
817 * made by MyLogonUser()! **
818 *
819 * - pszPolicy (for domain logon): Path to a policy file.
820 * Windows' msgina.dll hardcodes it as:
821 * "\<domain_controller>\netlogon\ntconfig.pol"
822 *
823 * - pszNetworkDefaultUserProfile (for domain logon): Path to the
824 * default user profile. Windows' msgina.dll hardcodes it as:
825 * "\<domain_controller>\netlogon\Default User"
826 *
827 * - pszServerName (for domain logon): Name ("domain_controller") of
828 * the server (local computer; Active Directory domain controller...)
829 * that validated the logon.
830 * ** This data should be retrieved from the LsaLogonUser() call
831 * made by MyLogonUser()! **
832 *
833 * NOTES:
834 * - The paths use the domain controllers' "netlogon" share.
835 * - These strings are LocalAlloc'd here, and LocalFree'd by Winlogon.
836 */
837 pProfile->pszProfile = NULL;
838 pProfile->pszPolicy = NULL;
840 pProfile->pszServerName = NULL;
841#if 0
842 if (bIsDomainLogon)
843 {
844 PWSTR pServerName;
845 cbSize = sizeof(L"\\\\") + wcslen(Domain) * sizeof(WCHAR);
846 pServerName = LocalAlloc(LMEM_FIXED, cbSize);
847 if (!pServerName)
848 WARN("HeapAlloc() failed\n"); // Consider this optional, so no failure.
849 else
850 StringCbPrintfW(pServerName, cbSize, L"\\\\%ws", Domain); // See LogonServer below.
851 pProfile->pszServerName = pServerName;
852 }
853#endif
854
855 /* Build the minimal environment string block */
856 // FIXME: LogonServer is the name of the server that processed the logon
857 // request ("domain_controller"). It can be different from the selected
858 // user's logon domain.
859 // See e.g.:
860 // - https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/ns-ntsecapi-msv1_0_interactive_profile
861 // - https://learn.microsoft.com/en-us/windows/win32/api/winwlx/ns-winwlx-wlx_consoleswitch_credentials_info_v1_0
862 cbSize = sizeof(L"LOGONSERVER=\\\\") +
863 wcslen(Domain) * sizeof(WCHAR) +
864 sizeof(UNICODE_NULL);
865 pEnvironment = LocalAlloc(LMEM_FIXED, cbSize);
866 if (!pEnvironment)
867 {
868 WARN("LocalAlloc() failed\n");
869 goto cleanup;
870 }
871
872 StringCbPrintfW(pEnvironment, cbSize, L"LOGONSERVER=\\\\%ws", Domain);
873 ASSERT(wcslen(pEnvironment) == cbSize / sizeof(WCHAR) - 2);
874 pEnvironment[cbSize / sizeof(WCHAR) - 1] = UNICODE_NULL;
875
876 pProfile->pszEnvironment = pEnvironment;
877
878 /* Return the other info */
879 if (!GetTokenInformation(pgContext->UserToken,
881 &Stats,
882 sizeof(Stats),
883 &cbStats))
884 {
885 WARN("Couldn't get Authentication Id from user token!\n");
886 goto cleanup;
887 }
888
889 *pgContext->pAuthenticationId = Stats.AuthenticationId;
890 pgContext->pMprNotifyInfo->pszUserName = DuplicateString(UserName);
891 pgContext->pMprNotifyInfo->pszDomain = DuplicateString(Domain);
892 pgContext->pMprNotifyInfo->pszPassword = DuplicateString(Password);
893 pgContext->pMprNotifyInfo->pszOldPassword = NULL;
894 *pgContext->pdwOptions = 0;
895 *pgContext->pProfile = pProfile;
896 return TRUE;
897
898cleanup:
899 if (pEnvironment)
900 LocalFree(pEnvironment);
901 if (pProfile)
902 LocalFree(pProfile);
903 return FALSE;
904}
#define WARN(fmt,...)
Definition: precomp.h:61
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
wcscpy
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
static DWORD DWORD * dwLength
Definition: fusion.c:86
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define LMEM_ZEROINIT
Definition: minwinbase.h:85
#define LMEM_FIXED
Definition: minwinbase.h:81
#define ASSERT(a)
Definition: mode.c:44
#define UNICODE_NULL
#define _countof(array)
Definition: sndvol32.h:70
#define DuplicateString(x)
Definition: stringutils.h:45
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LUID AuthenticationId
Definition: setypes.h:1099
PWSTR pszPolicy
Definition: winwlx.h:150
PWSTR pszEnvironment
Definition: winwlx.h:153
PWSTR pszServerName
Definition: winwlx.h:152
PWSTR pszProfile
Definition: winwlx.h:149
PWSTR pszNetworkDefaultUserProfile
Definition: winwlx.h:151
@ Password
Definition: telnetd.h:67
uint16_t * PWSTR
Definition: typedefs.h:56
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:267
#define WLX_PROFILE_TYPE_V2_0
Definition: winwlx.h:51
@ TokenStatistics
Definition: setypes.h:987
__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 1095 of file msgina.c.

1099{
1101
1103 {
1104 hDllInstance = hinstDLL;
1105
1107 2,
1116 &AdminSid);
1117
1118 }
1119 else if (dwReason == DLL_PROCESS_DETACH)
1120 {
1121 if (AdminSid != NULL)
1123 }
1124
1125 return TRUE;
1126}
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 639 of file msgina.c.

644{
645 HANDLE hToken = NULL;
646 PTOKEN_GROUPS Groups = NULL;
647 BOOL bIsAdmin = FALSE;
648 ULONG Size;
649 ULONG i;
652
653 TRACE("(%S %S %S)\n", UserName, Domain, Password);
654
655 Status = ConnectToLsa(pgContext);
656 if (!NT_SUCCESS(Status))
657 {
658 WARN("ConnectToLsa() failed\n");
659 return FALSE;
660 }
661
662 Status = MyLogonUser(pgContext->LsaHandle,
663 pgContext->AuthenticationPackage,
664 UserName,
665 Domain,
666 Password,
667 &pgContext->UserToken,
668 &SubStatus);
669 if (!NT_SUCCESS(Status))
670 {
671 WARN("MyLogonUser() failed\n");
672 return FALSE;
673 }
674
677 NULL,
678 0,
679 &Size);
681 {
682 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
683 goto done;
684 }
685
686 Groups = HeapAlloc(GetProcessHeap(), 0, Size);
687 if (Groups == NULL)
688 {
689 TRACE("HeapAlloc() failed\n");
690 goto done;
691 }
692
695 Groups,
696 Size,
697 &Size);
698 if (!NT_SUCCESS(Status))
699 {
700 TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
701 goto done;
702 }
703
704 for (i = 0; i < Groups->GroupCount; i++)
705 {
706 if (RtlEqualSid(Groups->Groups[i].Sid, AdminSid))
707 {
708 TRACE("Member of Admins group\n");
709 bIsAdmin = TRUE;
710 break;
711 }
712 }
713
714done:
715 if (Groups != NULL)
716 HeapFree(GetProcessHeap(), 0, Groups);
717
718 if (hToken != NULL)
719 CloseHandle(hToken);
720
721 return bIsAdmin;
722}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
#define HeapAlloc
Definition: compat.h:733
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:1030
$ULONG GroupCount
Definition: setypes.h:1026
_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:4539
@ TokenGroups
Definition: setypes.h:979

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

732{
734
735 Status = ConnectToLsa(pgContext);
736 if (!NT_SUCCESS(Status))
737 {
738 WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status);
739 return Status;
740 }
741
742 Status = MyLogonUser(pgContext->LsaHandle,
743 pgContext->AuthenticationPackage,
744 UserName,
745 Domain,
746 Password,
747 &pgContext->UserToken,
748 SubStatus);
749 if (!NT_SUCCESS(Status))
750 {
751 WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status);
752 }
753
754 return Status;
755}

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ GetLsaDefaultPassword()

static BOOL GetLsaDefaultPassword ( _Inout_ PGINA_CONTEXT  pgContext)
static

Definition at line 122 of file msgina.c.

123{
124 LSA_HANDLE hPolicy;
127
130 if (!NT_SUCCESS(Status))
131 return FALSE;
132
133 RtlInitUnicodeString(&Name, L"DefaultPassword");
134 Status = LsaRetrievePrivateData(hPolicy, &Name, &pPwd);
135 LsaClose(hPolicy);
136
137 if (Status == STATUS_SUCCESS)
138 {
139 if (!SafeGetUnicodeString(pPwd, pgContext->Password,
140 _countof(pgContext->Password)))
141 {
143 }
144 SecureZeroMemory(pPwd->Buffer, pPwd->Length);
145 LsaFreeMemory(pPwd);
146 }
147
148 return Status == STATUS_SUCCESS;
149}
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:107
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define POLICY_GET_PRIVATE_INFORMATION
Definition: ntsecapi.h:63
#define SecureZeroMemory
Definition: winbase.h:1465

Referenced by GetRegistrySettings().

◆ GetRegistrySettings()

static BOOL GetRegistrySettings ( PGINA_CONTEXT  pgContext)
static

Definition at line 153 of file msgina.c.

154{
155 HKEY hKey = NULL;
156 DWORD dwValue, dwSize;
157 DWORD dwDisableCAD = 0;
158 LONG rc;
159
161 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
162 0,
164 &hKey);
165 if (rc != ERROR_SUCCESS)
166 {
167 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
168 return FALSE;
169 }
170
171 rc = ReadRegDwordValue(hKey, L"AutoAdminLogon", &dwValue);
172 if (rc == ERROR_SUCCESS)
173 pgContext->bAutoAdminLogon = !!dwValue;
174 TRACE("bAutoAdminLogon: %s\n", pgContext->bAutoAdminLogon ? "TRUE" : "FALSE");
175
176 // TODO: What to do also depends whether we are on Terminal Services.
177 rc = ReadRegDwordValue(hKey, L"DisableCAD", &dwDisableCAD);
178 if (rc == ERROR_SUCCESS)
179 {
180 if (dwDisableCAD != 0)
181 pgContext->bDisableCAD = TRUE;
182 }
183 TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
184
185 // NOTE: The default value is always read from the registry (Workstation: TRUE; Server: FALSE).
186 // TODO: Set it to TRUE always on SafeMode. Keep it FALSE for remote sessions.
187 pgContext->bShutdownWithoutLogon = TRUE;
188 rc = ReadRegDwordValue(hKey, L"ShutdownWithoutLogon", &dwValue);
189 if (rc == ERROR_SUCCESS)
190 pgContext->bShutdownWithoutLogon = !!dwValue;
191
192 rc = ReadRegDwordValue(hKey, L"DontDisplayLastUserName", &dwValue);
193 if (rc == ERROR_SUCCESS)
194 pgContext->bDontDisplayLastUserName = !!dwValue;
195
196 rc = ReadRegDwordValue(hKey, L"IgnoreShiftOverride", &dwValue);
197 if (rc == ERROR_SUCCESS)
198 pgContext->bIgnoreShiftOverride = !!dwValue;
199
200 dwSize = sizeof(pgContext->UserName);
202 L"DefaultUserName",
203 NULL,
204 NULL,
205 (PBYTE)&pgContext->UserName,
206 &dwSize);
207
208 dwSize = sizeof(pgContext->DomainName);
210 L"DefaultDomainName",
211 NULL,
212 NULL,
213 (PBYTE)&pgContext->DomainName,
214 &dwSize);
215
216 dwSize = sizeof(pgContext->Password);
218 L"DefaultPassword",
219 NULL,
220 NULL,
221 (PBYTE)&pgContext->Password,
222 &dwSize);
223 if (rc)
224 GetLsaDefaultPassword(pgContext);
225
226 if (hKey != NULL)
228
229 return TRUE;
230}
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:122
LONG ReadRegDwordValue(_In_ HKEY hKey, _In_ PCWSTR pszValue, _Out_ PDWORD pValue)
Definition: utils.c:90
BYTE * PBYTE
Definition: pedump.c:66
BOOL bAutoAdminLogon
Definition: msgina.h:43
WCHAR DomainName[256]
Definition: msgina.h:52
BOOL bIgnoreShiftOverride
Definition: msgina.h:46
BOOL bDontDisplayLastUserName
Definition: msgina.h:44
BOOL bShutdownWithoutLogon
Definition: msgina.h:45
BOOL bDisableCAD
Definition: msgina.h:42
WCHAR UserName[256]
Definition: msgina.h:51
WCHAR Password[256]
Definition: msgina.h:53

Referenced by WlxInitialize().

◆ InitThemeSupport()

static void InitThemeSupport ( VOID  )
static

Definition at line 236 of file msgina.c.

237{
238 HMODULE hDll = LoadLibraryW(L"shsvcs.dll");
239 pThemeWait themeWait;
240 pThemeWatch themeWatch;
241
242 if(!hDll)
243 return;
244
245 themeWait = (pThemeWait) GetProcAddress(hDll, (LPCSTR)2);
246 themeWatch = (pThemeWatch) GetProcAddress(hDll, (LPCSTR)1);
247
248 if(themeWait && themeWatch)
249 {
250 themeWait(5000);
251 themeWatch();
252 }
253}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD(WINAPI * pThemeWait)(DWORD dwTimeout)
Definition: msgina.c:232
BOOL(WINAPI * pThemeWatch)(void)
Definition: msgina.c:233
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by WlxInitialize().

◆ SafeGetUnicodeString()

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

Definition at line 107 of file msgina.c.

111{
112 HRESULT hr;
113 hr = StringCbCopyNExW(pszOutput, cchMax * sizeof(WCHAR),
114 pInput->Buffer, pInput->Length,
115 NULL, NULL,
117 return (hr == S_OK);
118}
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 ( _In_ PVOID  pWlxContext,
_In_ PWSTR  pszDesktopName,
_In_ PWSTR  pszMprLogonScript,
_In_ PVOID  pEnvironment 
)

Definition at line 467 of file msgina.c.

472{
473 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
474 HKEY hKey, hKeyCurrentUser;
476 DWORD len;
477 LONG rc;
478 BOOL ret;
479 WCHAR pszUserInitApp[MAX_PATH + 1];
480 WCHAR pszExpUserInitApp[MAX_PATH];
481
482 TRACE("WlxActivateUserShell()\n");
483
484 UNREFERENCED_PARAMETER(pszMprLogonScript);
485
486 /* Get the path of Userinit */
488 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
489 0,
491 &hKey);
492 if (rc != ERROR_SUCCESS)
493 {
494 WARN("RegOpenKeyExW() failed with error %lu\n", rc);
495 return FALSE;
496 }
497
498 BufSize = sizeof(pszUserInitApp) - sizeof(UNICODE_NULL);
500 L"Userinit",
501 NULL,
502 &ValueType,
503 (PBYTE)pszUserInitApp,
504 &BufSize);
506 if (rc != ERROR_SUCCESS || (ValueType != REG_SZ && ValueType != REG_EXPAND_SZ))
507 {
508 WARN("RegQueryValueExW() failed with error %lu\n", rc);
509 return FALSE;
510 }
511 pszUserInitApp[MAX_PATH] = UNICODE_NULL;
512
513 len = ExpandEnvironmentStringsW(pszUserInitApp, pszExpUserInitApp, _countof(pszExpUserInitApp));
514 if (len > _countof(pszExpUserInitApp))
515 {
516 WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len);
517 return FALSE;
518 }
519
520 /* Start the Userinit application */
521 ret = WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
522 if (!ret)
523 return ret;
524
525 /* For convenience, store in the logged-in user's Explorer key, the user name
526 * that was entered verbatim in the "Log On" dialog to log into the system.
527 * This name may differ from the resulting user name used during authentication. */
528
529 /* Open the per-user registry key */
530 rc = RegOpenLoggedOnHKCU(pgContext->UserToken,
532 &hKeyCurrentUser);
533 if (rc != ERROR_SUCCESS)
534 {
535 ERR("RegOpenLoggedOnHKCU() failed with error %ld\n", rc);
536 return ret;
537 }
538
539 /* Open the subkey and write the value */
540 rc = RegOpenKeyExW(hKeyCurrentUser,
541 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
542 0,
544 &hKey);
545 if (rc == ERROR_SUCCESS)
546 {
547 len = wcslen(pgContext->UserName) + 1;
549 L"Logon User Name",
550 0,
551 REG_SZ,
552 (PBYTE)pgContext->UserName,
553 len * sizeof(WCHAR));
555 }
556 RegCloseKey(hKeyCurrentUser);
557
558 return ret;
559}
#define BufSize
Definition: FsRtlTunnel.c:28
#define ERR(fmt,...)
Definition: precomp.h:57
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
return ret
Definition: mutex.c:146
GLenum GLsizei len
Definition: glext.h:6722
#define REG_SZ
Definition: layer.c:22
BOOL WINAPI WlxStartApplication(PVOID pWlxContext, PWSTR pszDesktopName, PVOID pEnvironment, PWSTR pszCmdLine)
Definition: msgina.c:400
struct GINA_CONTEXT * PGINA_CONTEXT
LONG RegOpenLoggedOnHKCU(_In_opt_ HANDLE hUserToken, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Opens and retrieves a handle to the HKEY_CURRENT_USER corresponding to the specified logged-on user.
Definition: utils.c:31
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define KEY_SET_VALUE
Definition: nt_native.h:1020
HANDLE UserToken
Definition: msgina.h:55
_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 1008 of file msgina.c.

1009{
1010 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1011
1012 TRACE("WlxDisplayLockedNotice()\n");
1013
1014 if (pgContext->bDisableCAD)
1015 {
1016 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
1017 return;
1018 }
1019
1020 pGinaUI->DisplayLockedNotice(pgContext);
1021}
HANDLE hWlx
Definition: msgina.h:35
PWLX_DISPATCH_VERSION_1_3 pWlxFuncs
Definition: msgina.h:37
PFGINA_DISPLAYLOCKEDNOTICE DisplayLockedNotice
Definition: msgina.h:82
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 911 of file msgina.c.

913{
914 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
915
916 TRACE("WlxDisplaySASNotice(%p)\n", pWlxContext);
917
919 {
920 /* User is remotely logged on. Don't display a notice */
921 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
922 return;
923 }
924
925 if (pgContext->bAutoAdminLogon)
926 {
927 if (pgContext->bIgnoreShiftOverride ||
928 (GetKeyState(VK_SHIFT) >= 0))
929 {
930 /* Don't display the window, we want to do an automatic logon */
931 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
932 return;
933 }
934
935 pgContext->bAutoAdminLogon = FALSE;
936 }
937
938 if (pgContext->bDisableCAD)
939 {
940 pgContext->pWlxFuncs->WlxSasNotify(pgContext->hWlx, WLX_SAS_TYPE_CTRL_ALT_DEL);
941 return;
942 }
943
944 pGinaUI->DisplaySASNotice(pgContext);
945
946 TRACE("WlxDisplaySASNotice() done\n");
947}
PFGINA_DISPLAYSASNOTICE DisplaySASNotice
Definition: msgina.h:78
#define VK_SHIFT
Definition: winuser.h:2238
#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 609 of file msgina.c.

615{
616 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
617
618 TRACE("WlxDisplayStatusMessage(\"%S\")\n", pMessage);
619
620 return pGinaUI->DisplayStatusMessage(pgContext, hDesktop, dwOptions, pTitle, pMessage);
621}
DWORD dwOptions
Definition: solitaire.cpp:25
PFGINA_DISPLAYSTATUSMESSAGE DisplayStatusMessage
Definition: msgina.h:76

◆ WlxInitialize()

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

Definition at line 259 of file msgina.c.

265{
266 PGINA_CONTEXT pgContext;
267
269
271
273 if(!pgContext)
274 {
275 WARN("LocalAlloc() failed\n");
276 return FALSE;
277 }
278
279 if (!GetRegistrySettings(pgContext))
280 {
281 WARN("GetRegistrySettings() failed\n");
282 LocalFree(pgContext);
283 return FALSE;
284 }
285
286 /* Return the context to winlogon */
287 *pWlxContext = (PVOID)pgContext;
288 pgContext->hDllInstance = hDllInstance;
289
290 /* Save pointer to dispatch table */
291 pgContext->pWlxFuncs = (PWLX_DISPATCH_VERSION_1_3)pWinlogonFunctions;
292
293 /* Save the winlogon handle used to call the dispatch functions */
294 pgContext->hWlx = hWlx;
295
296 /* Save window station */
297 pgContext->station = lpWinsta;
298
299 /* Clear status window handle */
300 pgContext->hStatusWindow = NULL;
301
302 /* Notify winlogon that we will use the default SAS */
303 pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx);
304
305 /* Locates the authentication package */
306 //LsaRegisterLogonProcess(...);
307
309
310 ChooseGinaUI();
311 return pGinaUI->Initialize(pgContext);
312}
static LPCWSTR LPVOID pvReserved
Definition: asmcache.c:749
static BOOL GetRegistrySettings(PGINA_CONTEXT pgContext)
Definition: msgina.c:153
static VOID ChooseGinaUI(VOID)
Definition: msgina.c:60
static void InitThemeSupport(VOID)
Definition: msgina.c:236
LPWSTR station
Definition: msgina.h:36
HWND hStatusWindow
Definition: msgina.h:39
ULONG nShutdownAction
Definition: msgina.h:48
HANDLE hDllInstance
Definition: msgina.h:38
PFGINA_INITIALIZE Initialize
Definition: msgina.h:75
PWLX_USE_CTRL_ALT_DEL WlxUseCtrlAltDel
Definition: winwlx.h:557
void * PVOID
Definition: typedefs.h:50
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 1028 of file msgina.c.

1030{
1031 TRACE("WlxIsLogoffOk()\n");
1032 UNREFERENCED_PARAMETER(pWlxContext);
1033 return TRUE;
1034}

◆ WlxLoggedOnSAS()

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

Definition at line 565 of file msgina.c.

569{
570 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
571 INT SasAction = WLX_SAS_ACTION_NONE;
572
573 TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
574
576
577 switch (dwSasType)
578 {
581 {
582 SasAction = pGinaUI->LoggedOnSAS(pgContext, dwSasType);
583 break;
584 }
586 {
587 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_INSERT not supported!\n");
588 break;
589 }
591 {
592 FIXME("WlxLoggedOnSAS: SasType WLX_SAS_TYPE_SC_REMOVE not supported!\n");
593 break;
594 }
595 default:
596 {
597 WARN("WlxLoggedOnSAS: Unknown SasType: 0x%x\n", dwSasType);
598 break;
599 }
600 }
601
602 return SasAction;
603}
#define FIXME(fmt,...)
Definition: precomp.h:53
_Out_ PVOID pReserved
Definition: netsh.h:77
PFGINA_LOGGEDONSAS LoggedOnSAS
Definition: msgina.h:79
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 953 of file msgina.c.

962{
963 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
964 INT res;
965
966 TRACE("WlxLoggedOutSAS()\n");
967
968 UNREFERENCED_PARAMETER(dwSasType);
969 UNREFERENCED_PARAMETER(pLogonSid);
970
971 pgContext->pAuthenticationId = pAuthenticationId;
972 pgContext->pdwOptions = pdwOptions;
973 pgContext->pMprNotifyInfo = pMprNotifyInfo;
974 pgContext->pProfile = pProfile;
975
976 res = pGinaUI->LoggedOutSAS(pgContext);
977
978 /* Return the logon information only if necessary */
980 *phToken = pgContext->UserToken;
981
982 return res;
983}
GLuint res
Definition: glext.h:9613
PLUID pAuthenticationId
Definition: msgina.h:56
PVOID * pProfile
Definition: msgina.h:59
PWLX_MPR_NOTIFY_INFO pMprNotifyInfo
Definition: msgina.h:58
PDWORD pdwOptions
Definition: msgina.h:57
PFGINA_LOGGEDOUTSAS LoggedOutSAS
Definition: msgina.h:80
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2469
#define WLX_SAS_ACTION_LOGON
Definition: winwlx.h:53

◆ WlxLogoff()

VOID WINAPI WlxLogoff ( PVOID  pWlxContext)

Definition at line 1041 of file msgina.c.

1043{
1044 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1045
1046 TRACE("WlxLogoff(%p)\n", pWlxContext);
1047
1048 /* Reset the captured Winlogon pointers */
1049 pgContext->pAuthenticationId = NULL;
1050 pgContext->pdwOptions = NULL;
1051 pgContext->pMprNotifyInfo = NULL;
1052 pgContext->pProfile = NULL;
1053
1054 /*
1055 * Reset user login information.
1056 * Keep pgContext->UserName and pgContext->DomainName around
1057 * if we want to show them as default (last logged user) in
1058 * the Log-On dialog.
1059 */
1060 ZeroMemory(&pgContext->LogonTime, sizeof(pgContext->LogonTime));
1061
1062 /* Delete the password */
1063 SecureZeroMemory(pgContext->Password, sizeof(pgContext->Password));
1064
1065 /* Close the user token */
1066 CloseHandle(pgContext->UserToken);
1067 pgContext->UserToken = NULL;
1068}
#define ZeroMemory
Definition: minwinbase.h:31
SYSTEMTIME LogonTime
Definition: msgina.h:54

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

629{
630 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
631
632 TRACE("WlxRemoveStatusMessage()\n");
633
634 return pGinaUI->RemoveStatusMessage(pgContext);
635}
PFGINA_REMOVESTATUSMESSAGE RemoveStatusMessage
Definition: msgina.h:77

◆ WlxScreenSaverNotify()

BOOL WINAPI WlxScreenSaverNotify ( PVOID  pWlxContext,
BOOL pSecure 
)

Definition at line 319 of file msgina.c.

322{
323#if 0
324 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
325 WCHAR szBuffer[2];
326 HKEY hKeyCurrentUser, hKey;
327 DWORD bufferSize = sizeof(szBuffer);
328 DWORD varType = REG_SZ;
329 LONG rc;
330
331 TRACE("(%p %p)\n", pWlxContext, pSecure);
332
333 *pSecure = TRUE;
334
335 /*
336 * Policy setting:
337 * HKLM\Software\Policies\Microsoft\Windows\Control Panel\Desktop : ScreenSaverIsSecure
338 * User setting:
339 * HKCU\Control Panel\Desktop : ScreenSaverIsSecure
340 */
341
342 if (!ImpersonateLoggedOnUser(pgContext->UserToken))
343 {
344 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
345 *pSecure = FALSE;
346 return TRUE;
347 }
348
349 /* Open the current user HKCU key */
350 rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
351 TRACE("RegOpenCurrentUser: %ld\n", rc);
352 if (rc == ERROR_SUCCESS)
353 {
354 /* Open the subkey */
355 rc = RegOpenKeyExW(hKeyCurrentUser,
356 L"Control Panel\\Desktop",
357 0,
359 &hKey);
360 TRACE("RegOpenKeyExW: %ld\n", rc);
361 RegCloseKey(hKeyCurrentUser);
362 }
363
364 /* Read the value */
365 if (rc == ERROR_SUCCESS)
366 {
368 L"ScreenSaverIsSecure",
369 NULL,
370 &varType,
371 (LPBYTE)szBuffer,
372 &bufferSize);
373
374 TRACE("RegQueryValueExW: %ld\n", rc);
375
376 if (rc == ERROR_SUCCESS)
377 {
378 TRACE("szBuffer: \"%S\"\n", szBuffer);
379 *pSecure = _wtoi(szBuffer);
380 }
381
383 }
384
385 /* Revert the impersonation */
386 RevertToSelf();
387
388 TRACE("*pSecure: %ld\n", *pSecure);
389#endif
390
391 *pSecure = FALSE;
392
393 return TRUE;
394}
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
BOOL WINAPI RevertToSelf(void)
Definition: security.c:855
size_t bufferSize
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ WlxShutdown()

VOID WINAPI WlxShutdown ( PVOID  pWlxContext,
DWORD  ShutdownType 
)

Definition at line 1075 of file msgina.c.

1078{
1079 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
1081
1082 TRACE("WlxShutdown(%p %lx)\n", pWlxContext, ShutdownType);
1083
1084 /* Close the LSA handle */
1085 pgContext->AuthenticationPackage = 0;
1087 if (!NT_SUCCESS(Status))
1088 {
1089 ERR("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n", Status);
1090 }
1091}
NTSTATUS NTAPI LsaDeregisterLogonProcess(HANDLE)
HANDLE LsaHandle
Definition: msgina.h:40
ULONG AuthenticationPackage
Definition: msgina.h:41

◆ WlxStartApplication()

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

Definition at line 400 of file msgina.c.

405{
406 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
407 STARTUPINFOW StartupInfo;
408 PROCESS_INFORMATION ProcessInformation;
410 HANDLE hAppToken;
411 UINT len;
412 BOOL ret;
413
415 if (len == 0 || len > MAX_PATH)
416 {
417 ERR("GetWindowsDirectoryW() failed\n");
418 return FALSE;
419 }
420
422 if (!ret)
423 {
424 ERR("DuplicateTokenEx() failed with error %lu\n", GetLastError());
425 return FALSE;
426 }
427
428 ZeroMemory(&StartupInfo, sizeof(StartupInfo));
429 ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
430 StartupInfo.cb = sizeof(StartupInfo);
431 StartupInfo.lpTitle = pszCmdLine;
432 StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
433 StartupInfo.wShowWindow = SW_SHOW;
434 StartupInfo.lpDesktop = pszDesktopName;
435
437 if (len == 0 || len > MAX_PATH)
438 {
439 ERR("GetWindowsDirectoryW() failed\n");
440 return FALSE;
441 }
443 hAppToken,
444 pszCmdLine,
445 NULL,
446 NULL,
447 NULL,
448 FALSE,
450 pEnvironment,
452 &StartupInfo,
453 &ProcessInformation);
454 CloseHandle(ProcessInformation.hProcess);
455 CloseHandle(ProcessInformation.hThread);
456 CloseHandle(hAppToken);
457 if (!ret)
458 ERR("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
459 return ret;
460}
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:987
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
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:190
#define SW_SHOW
Definition: winuser.h:786

Referenced by WlxActivateUserShell().

◆ WlxWkstaLockedSAS()

int WINAPI WlxWkstaLockedSAS ( PVOID  pWlxContext,
DWORD  dwSasType 
)

Definition at line 989 of file msgina.c.

992{
993 PGINA_CONTEXT pgContext = (PGINA_CONTEXT)pWlxContext;
994
995 TRACE("WlxWkstaLockedSAS()\n");
996
997 UNREFERENCED_PARAMETER(dwSasType);
998
999 return pGinaUI->LockedSAS(pgContext);
1000}
PFGINA_LOCKEDSAS LockedSAS
Definition: msgina.h:81

Variable Documentation

◆ AdminSid

◆ GinaGraphicalUI

GINA_UI GinaGraphicalUI
extern

Definition at line 1798 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().