ReactOS 0.4.15-dev-7842-g558ab78
msgina.h File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winuser.h>
#include <winwlx.h>
#include <ndk/rtlfuncs.h>
#include <ntsecapi.h>
#include <strsafe.h>
#include <wine/debug.h>
#include "resource.h"
Include dependency graph for msgina.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GINA_CONTEXT
 
struct  _GINA_UI
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 

Typedefs

typedef struct GINA_CONTEXTPGINA_CONTEXT
 
typedef BOOL(* PFGINA_INITIALIZE) (PGINA_CONTEXT)
 
typedef BOOL(* PFGINA_DISPLAYSTATUSMESSAGE) (PGINA_CONTEXT, HDESK, DWORD, PWSTR, PWSTR)
 
typedef BOOL(* PFGINA_REMOVESTATUSMESSAGE) (PGINA_CONTEXT)
 
typedef VOID(* PFGINA_DISPLAYSASNOTICE) (PGINA_CONTEXT)
 
typedef INT(* PFGINA_LOGGEDONSAS) (PGINA_CONTEXT, DWORD)
 
typedef INT(* PFGINA_LOGGEDOUTSAS) (PGINA_CONTEXT)
 
typedef INT(* PFGINA_LOCKEDSAS) (PGINA_CONTEXT)
 
typedef VOID(* PFGINA_DISPLAYLOCKEDNOTICE) (PGINA_CONTEXT)
 
typedef struct _GINA_UI GINA_UI
 
typedef struct _GINA_UIPGINA_UI
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msgina)
 
NTSTATUS ConnectToLsa (PGINA_CONTEXT pgContext)
 
NTSTATUS MyLogonUser (HANDLE LsaHandle, ULONG AuthenticationPackage, LPWSTR lpszUsername, LPWSTR lpszDomain, LPWSTR lpszPassword, PHANDLE phToken, PNTSTATUS SubStatus)
 
LONG ReadRegSzValue (IN HKEY hKey, IN LPCWSTR pszValue, OUT LPWSTR *pValue)
 
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)
 
DWORD GetDefaultShutdownSelState (VOID)
 
DWORD LoadShutdownSelState (VOID)
 
VOID SaveShutdownSelState (DWORD ShutdownCode)
 
DWORD GetDefaultShutdownOptions (VOID)
 
DWORD GetAllowedShutdownOptions (VOID)
 
INT_PTR ShutdownDialog (IN HWND hwndDlg, IN DWORD ShutdownOptions, IN PGINA_CONTEXT pgContext)
 

Variables

HINSTANCE hDllInstance
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 13 of file msgina.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 14 of file msgina.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 12 of file msgina.h.

Typedef Documentation

◆ GINA_UI

◆ PFGINA_DISPLAYLOCKEDNOTICE

typedef VOID(* PFGINA_DISPLAYLOCKEDNOTICE) (PGINA_CONTEXT)

Definition at line 70 of file msgina.h.

◆ PFGINA_DISPLAYSASNOTICE

typedef VOID(* PFGINA_DISPLAYSASNOTICE) (PGINA_CONTEXT)

Definition at line 66 of file msgina.h.

◆ PFGINA_DISPLAYSTATUSMESSAGE

typedef BOOL(* PFGINA_DISPLAYSTATUSMESSAGE) (PGINA_CONTEXT, HDESK, DWORD, PWSTR, PWSTR)

Definition at line 64 of file msgina.h.

◆ PFGINA_INITIALIZE

typedef BOOL(* PFGINA_INITIALIZE) (PGINA_CONTEXT)

Definition at line 63 of file msgina.h.

◆ PFGINA_LOCKEDSAS

typedef INT(* PFGINA_LOCKEDSAS) (PGINA_CONTEXT)

Definition at line 69 of file msgina.h.

◆ PFGINA_LOGGEDONSAS

typedef INT(* PFGINA_LOGGEDONSAS) (PGINA_CONTEXT, DWORD)

Definition at line 67 of file msgina.h.

◆ PFGINA_LOGGEDOUTSAS

typedef INT(* PFGINA_LOGGEDOUTSAS) (PGINA_CONTEXT)

Definition at line 68 of file msgina.h.

◆ PFGINA_REMOVESTATUSMESSAGE

typedef BOOL(* PFGINA_REMOVESTATUSMESSAGE) (PGINA_CONTEXT)

Definition at line 65 of file msgina.h.

◆ PGINA_CONTEXT

◆ PGINA_UI

Function Documentation

◆ ConnectToLsa()

NTSTATUS ConnectToLsa ( PGINA_CONTEXT  pgContext)

Definition at line 11 of file lsa.c.

13{
14 LSA_STRING LogonProcessName;
15 LSA_STRING PackageName;
18
19 /* We are already connected to the LSA */
20 if (pgContext->LsaHandle != NULL)
21 return STATUS_SUCCESS;
22
23 /* Connect to the LSA server */
24 RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
25 "MSGINA");
26
27 Status = LsaRegisterLogonProcess(&LogonProcessName,
28 &pgContext->LsaHandle,
30 if (!NT_SUCCESS(Status))
31 {
32 ERR("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
33 return Status;
34 }
35
36 /* Get the authentication package */
37 RtlInitAnsiString((PANSI_STRING)&PackageName,
39
41 &PackageName,
42 &pgContext->AuthenticationPackage);
43 if (!NT_SUCCESS(Status))
44 {
45 ERR("LsaLookupAuthenticationPackage failed (Status 0x%08lx)\n", Status);
46 }
47
48 return Status;
49}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
_IRQL_requires_same_ _Out_ PHANDLE _Out_ PLSA_OPERATIONAL_MODE SecurityMode
NTSTATUS NTAPI LsaLookupAuthenticationPackage(HANDLE, PLSA_STRING, PULONG)
#define MSV1_0_PACKAGE_NAME
Definition: ntsecapi.h:42
ULONG LSA_OPERATIONAL_MODE
Definition: ntsecapi.h:367
NTSTATUS NTAPI LsaRegisterLogonProcess(PLSA_STRING, PHANDLE, PLSA_OPERATIONAL_MODE)
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE LsaHandle
Definition: msgina.h:39
ULONG AuthenticationPackage
Definition: msgina.h:40

Referenced by DoAdminUnlock(), DoChangePassword(), DoLoginTasks(), and TUILockedSAS().

◆ 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
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static DWORD DWORD * dwLength
Definition: fusion.c:86
static void cleanup(void)
Definition: main.c:1335
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
BOOL WINAPI GetProfilesDirectoryW(_Out_ LPWSTR lpProfilesDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1576
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define L(x)
Definition: ntvdm.h:50
_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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ 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}
#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
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
static PSID AdminSid
Definition: msgina.c:39
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_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TRACE(s)
Definition: solgame.cpp:4
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().

◆ GetAllowedShutdownOptions()

DWORD GetAllowedShutdownOptions ( VOID  )

Definition at line 783 of file shutdown.c.

784{
785 DWORD Options = 0;
786
787 // FIXME: Compute those options accordings to current user's rights!
789
792
795
796 return Options;
797}
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:20
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:18
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:22
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:19
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:24
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534

Referenced by OnShutDown(), ShellShutdownDialog(), and ShutdownDialog().

◆ GetDefaultShutdownOptions()

DWORD GetDefaultShutdownOptions ( VOID  )

Definition at line 777 of file shutdown.c.

Referenced by OnShutDown().

◆ GetDefaultShutdownSelState()

DWORD GetDefaultShutdownSelState ( VOID  )

Definition at line 435 of file shutdown.c.

436{
438}
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

Referenced by OnShutDown().

◆ LoadShutdownSelState()

DWORD LoadShutdownSelState ( VOID  )

Definition at line 441 of file shutdown.c.

442{
443 LONG lRet;
444 HKEY hKeyCurrentUser, hKey;
445 DWORD dwValue, dwTemp, dwSize;
446
447 /* Default to shutdown */
449
450 /* Open the current user HKCU key */
451 lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
452 if (lRet == ERROR_SUCCESS)
453 {
454 /* Open the subkey */
455 lRet = RegOpenKeyExW(hKeyCurrentUser,
456 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
457 0, KEY_QUERY_VALUE, &hKey);
458 RegCloseKey(hKeyCurrentUser);
459 }
460 if (lRet != ERROR_SUCCESS)
461 return dwValue;
462
463 /* Read the value */
464 dwSize = sizeof(dwTemp);
465 lRet = RegQueryValueExW(hKey,
466 L"Shutdown Setting",
467 NULL, NULL,
468 (LPBYTE)&dwTemp, &dwSize);
470
471 if (lRet == ERROR_SUCCESS)
472 {
473 switch (dwTemp)
474 {
476 dwValue = WLX_SAS_ACTION_LOGOFF;
477 break;
478
481 break;
482
485 break;
486
487 // 0x08
488
491 break;
492
493 // 0x20
494
497 break;
498
499 // 0x80
500 }
501 }
502
503 return dwValue;
504}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
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
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
long LONG
Definition: pedump.c:60
unsigned char * LPBYTE
Definition: typedefs.h:53
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56

Referenced by OnShutDown(), ShellShutdownDialog(), and ShutdownDialog().

◆ MyLogonUser()

NTSTATUS MyLogonUser ( HANDLE  LsaHandle,
ULONG  AuthenticationPackage,
LPWSTR  lpszUsername,
LPWSTR  lpszDomain,
LPWSTR  lpszPassword,
PHANDLE  phToken,
PNTSTATUS  SubStatus 
)

Definition at line 55 of file lsa.c.

63{
66 PSID LogonSid = NULL;
69 UNICODE_STRING DomainName;
70 UNICODE_STRING UserName;
73 ULONG AuthInfoLength;
79 LUID Luid = {0, 0};
80 LUID LogonId = {0, 0};
82 QUOTA_LIMITS QuotaLimits;
84
85 *phToken = NULL;
86
88 "MSGINA Logon");
89
90 RtlInitUnicodeString(&DomainName,
92
93 RtlInitUnicodeString(&UserName,
94 lpszUsername);
95
98
99 AuthInfoLength = sizeof(MSV1_0_INTERACTIVE_LOGON)+
100 DomainName.MaximumLength +
101 UserName.MaximumLength +
102 Password.MaximumLength;
103
104 AuthInfo = RtlAllocateHeap(RtlGetProcessHeap(),
106 AuthInfoLength);
107 if (AuthInfo == NULL)
108 {
110 goto done;
111 }
112
114
115 Ptr = (ULONG_PTR)AuthInfo + sizeof(MSV1_0_INTERACTIVE_LOGON);
116
117 AuthInfo->LogonDomainName.Length = DomainName.Length;
118 AuthInfo->LogonDomainName.MaximumLength = DomainName.MaximumLength;
119 AuthInfo->LogonDomainName.Buffer = (DomainName.Buffer == NULL) ? NULL : (PWCHAR)Ptr;
120 if (DomainName.MaximumLength > 0)
121 {
123 DomainName.Buffer,
124 DomainName.MaximumLength);
125
126 Ptr += DomainName.MaximumLength;
127 }
128
129 AuthInfo->UserName.Length = UserName.Length;
130 AuthInfo->UserName.MaximumLength = UserName.MaximumLength;
131 AuthInfo->UserName.Buffer = (PWCHAR)Ptr;
132 if (UserName.MaximumLength > 0)
133 RtlCopyMemory(AuthInfo->UserName.Buffer,
134 UserName.Buffer,
135 UserName.MaximumLength);
136
137 Ptr += UserName.MaximumLength;
138
139 AuthInfo->Password.Length = Password.Length;
140 AuthInfo->Password.MaximumLength = Password.MaximumLength;
141 AuthInfo->Password.Buffer = (PWCHAR)Ptr;
142 if (Password.MaximumLength > 0)
143 RtlCopyMemory(AuthInfo->Password.Buffer,
144 Password.Buffer,
145 Password.MaximumLength);
146
147 /* Create the Logon SID*/
152 LogonId.HighPart,
153 LogonId.LowPart,
159 &LogonSid);
160 if (!NT_SUCCESS(Status))
161 goto done;
162
163 /* Create the Local SID*/
164 Status = RtlAllocateAndInitializeSid(&LocalAuthority,
165 1,
174 &LocalSid);
175 if (!NT_SUCCESS(Status))
176 goto done;
177
178 /* Allocate and set the token groups */
179 TokenGroups = RtlAllocateHeap(RtlGetProcessHeap(),
181 sizeof(TOKEN_GROUPS) + ((2 - ANYSIZE_ARRAY) * sizeof(SID_AND_ATTRIBUTES)));
182 if (TokenGroups == NULL)
183 {
185 goto done;
186 }
187
188 TokenGroups->GroupCount = 2;
189 TokenGroups->Groups[0].Sid = LogonSid;
190 TokenGroups->Groups[0].Attributes = SE_GROUP_MANDATORY | SE_GROUP_ENABLED |
192 TokenGroups->Groups[1].Sid = LocalSid;
193 TokenGroups->Groups[1].Attributes = SE_GROUP_MANDATORY | SE_GROUP_ENABLED |
195
196 /* Set the token source */
197 RtlCopyMemory(TokenSource.SourceName, User32TokenSourceName, sizeof(TokenSource.SourceName));
198 AllocateLocallyUniqueId(&TokenSource.SourceIdentifier);
199
201 &OriginName,
204 (PVOID)AuthInfo,
205 AuthInfoLength,
210 &Luid,
212 &QuotaLimits,
213 SubStatus);
214 if (!NT_SUCCESS(Status))
215 {
216 ERR("LsaLogonUser failed (Status 0x%08lx)\n", Status);
217 goto done;
218 }
219
220 if (ProfileBuffer != NULL)
221 {
222 TRACE("ProfileBuffer: %p\n", ProfileBuffer);
223 TRACE("MessageType: %u\n", ProfileBuffer->MessageType);
224
225 TRACE("FullName: %p\n", ProfileBuffer->FullName.Buffer);
226 TRACE("FullName: %S\n", ProfileBuffer->FullName.Buffer);
227
228 TRACE("LogonServer: %p\n", ProfileBuffer->LogonServer.Buffer);
229 TRACE("LogonServer: %S\n", ProfileBuffer->LogonServer.Buffer);
230 }
231
232 TRACE("Luid: 0x%08lx%08lx\n", Luid.HighPart, Luid.LowPart);
233
234 if (TokenHandle != NULL)
235 {
236 TRACE("TokenHandle: %p\n", TokenHandle);
237 }
238
240
241done:
242 if (ProfileBuffer != NULL)
244
245 if (!NT_SUCCESS(Status))
246 {
247 if (TokenHandle != NULL)
249 }
250
251 if (TokenGroups != NULL)
252 RtlFreeHeap(RtlGetProcessHeap(), 0, TokenGroups);
253
254 if (LocalSid != NULL)
256
257 if (LogonSid != NULL)
258 RtlFreeSid(LogonSid);
259
260 if (AuthInfo != NULL)
261 RtlFreeHeap(RtlGetProcessHeap(), 0, AuthInfo);
262
263 return Status;
264}
PSID LocalSid
Definition: globals.c:15
HANDLE LsaHandle
Definition: wkssvc.c:41
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
ULONG AuthenticationPackage
Definition: logon.c:18
BOOL WINAPI AllocateLocallyUniqueId(PLUID Luid)
Definition: security.c:1218
static const CHAR User32TokenSourceName[]
Definition: lsa.c:51
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
static SID_IDENTIFIER_AUTHORITY SystemAuthority
Definition: msgina.c:38
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:726
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
#define SE_GROUP_LOGON_ID
Definition: setypes.h:98
#define SE_GROUP_MANDATORY
Definition: setypes.h:90
#define SE_GROUP_ENABLED_BY_DEFAULT
Definition: setypes.h:91
#define SE_GROUP_ENABLED
Definition: setypes.h:92
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID * ProfileBuffer
_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 ProfileBufferLength
_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 LogonId
_IRQL_requires_same_ _In_ PLSA_STRING OriginName
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
NTSTATUS NTAPI LsaLogonUser(HANDLE, PLSA_STRING, SECURITY_LOGON_TYPE, ULONG, PVOID, ULONG, PTOKEN_GROUPS, PTOKEN_SOURCE, PVOID *, PULONG, PLUID, PHANDLE, PQUOTA_LIMITS, PNTSTATUS)
@ Interactive
Definition: ntsecapi.h:289
NTSTATUS NTAPI LsaFreeReturnBuffer(PVOID)
struct _MSV1_0_INTERACTIVE_LOGON MSV1_0_INTERACTIVE_LOGON
@ MsV1_0InteractiveLogon
Definition: ntsecapi.h:199
PCHAR Buffer
Definition: ntsecapi.h:174
LONG HighPart
DWORD LowPart
UNICODE_STRING Password
Definition: ntsecapi.h:437
UNICODE_STRING UserName
Definition: ntsecapi.h:436
MSV1_0_LOGON_SUBMIT_TYPE MessageType
Definition: ntsecapi.h:434
UNICODE_STRING LogonDomainName
Definition: ntsecapi.h:435
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2715
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2712
_In_opt_ LPSTR lpszDomain
Definition: winbase.h:2711
#define SECURITY_LOGON_IDS_RID
Definition: setypes.h:560
#define SECURITY_LOCAL_SID_AUTHORITY
Definition: setypes.h:530
#define SECURITY_LOCAL_RID
Definition: setypes.h:542
#define SECURITY_NULL_RID
Definition: setypes.h:540
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
@ TokenSource
Definition: setypes.h:972
#define SECURITY_LOGON_IDS_RID_COUNT
Definition: setypes.h:561

Referenced by DoAdminUnlock(), DoLoginTasks(), and TUILockedSAS().

◆ 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 ERROR_INVALID_PARAMETER
Definition: compat.h:101
PWCHAR pValue
#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().

◆ SaveShutdownSelState()

VOID SaveShutdownSelState ( DWORD  ShutdownCode)

Referenced by OnShutDown().

◆ ShutdownDialog()

INT_PTR ShutdownDialog ( IN HWND  hwndDlg,
IN DWORD  ShutdownOptions,
IN PGINA_CONTEXT  pgContext 
)

Definition at line 1149 of file shutdown.c.

1153{
1154 INT_PTR ret;
1156
1157#if 0
1158 DWORD ShutdownOptions;
1159
1160 // FIXME: User impersonation!!
1161 pgContext->nShutdownAction = LoadShutdownSelState();
1162 ShutdownOptions = GetAllowedShutdownOptions();
1163#endif
1164
1165 Context.pgContext = pgContext;
1166 Context.ShutdownOptions = ShutdownOptions;
1167 Context.ShutdownDialogId = IDD_SHUTDOWN;
1168 Context.bCloseDlg = FALSE;
1169 Context.bReasonUI = GetShutdownReasonUI();
1170 Context.bFriendlyUI = ShellIsFriendlyUIActive();
1171
1172 if (pgContext->hWlx && pgContext->pWlxFuncs && !Context.bFriendlyUI)
1173 {
1174 ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
1175 pgContext->hDllInstance,
1177 hwndDlg,
1179 (LPARAM)&Context);
1180 }
1181 else
1182 {
1183 if (Context.bFriendlyUI)
1184 {
1186 {
1187 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY_LONG;
1188 }
1189 else
1190 {
1191 Context.ShutdownDialogId = IDD_SHUTDOWN_FANCY;
1192 }
1193 }
1194
1195 ret = DialogBoxParamW(pgContext->hDllInstance,
1196 MAKEINTRESOURCEW(Context.bReasonUI ? IDD_SHUTDOWN_REASON : Context.ShutdownDialogId),
1197 hwndDlg,
1199 (LPARAM)&Context);
1200 }
1201
1202#if 0
1203 // FIXME: User impersonation!!
1204 if (ret == IDOK)
1205 SaveShutdownSelState(pgContext->nShutdownAction);
1206#endif
1207
1208 return ret;
1209}
#define IDD_SHUTDOWN_FANCY
Definition: resource.h:44
#define IDD_SHUTDOWN
Definition: resource.h:43
#define IDD_SHUTDOWN_REASON
Definition: resource.h:46
#define IDD_SHUTDOWN_FANCY_LONG
Definition: resource.h:45
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:783
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:441
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:78
static INT_PTR CALLBACK ShutdownDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:1017
static BOOL IsShowHibernateButtonActive(VOID)
Definition: shutdown.c:230
BOOL WINAPI ShellIsFriendlyUIActive(VOID)
Definition: shutdown.c:422
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:723
int32_t INT_PTR
Definition: typedefs.h:64
int ret
LONG_PTR LPARAM
Definition: windef.h:208
#define IDOK
Definition: winuser.h:830
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by OnShutDown(), and ShellShutdownDialog().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msgina  )

Variable Documentation

◆ hDllInstance

HINSTANCE hDllInstance
extern

Definition at line 17 of file browser.c.