ReactOS  0.4.14-dev-317-g96040ec
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,
29  &SecurityMode);
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 }
#define MSV1_0_PACKAGE_NAME
Definition: ntsecapi.h:42
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
NTSTATUS NTAPI LsaLookupAuthenticationPackage(IN HANDLE LsaHandle, IN PLSA_STRING PackageName, OUT PULONG AuthenticationPackage)
Definition: lsa.c:136
_IRQL_requires_same_ _Out_ PHANDLE _Out_ PLSA_OPERATIONAL_MODE SecurityMode
smooth NULL
Definition: ftsmooth.c:416
HANDLE LsaHandle
Definition: msgina.h:39
ULONG LSA_OPERATIONAL_MODE
Definition: ntsecapi.h:364
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG AuthenticationPackage
Definition: msgina.h:40
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
NTSTATUS NTAPI LsaRegisterLogonProcess(IN PLSA_STRING LogonProcessName, OUT PHANDLE LsaHandle, OUT PLSA_OPERATIONAL_MODE OperationalMode)
Definition: lsa.c:249
return STATUS_SUCCESS
Definition: btrfs.c:2938

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;
796  DWORD dwLength;
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 
878 cleanup:
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 }
LUID AuthenticationId
Definition: setypes.h:1033
#define TRUE
Definition: types.h:120
#define _countof(array)
Definition: fontsub.cpp:30
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:440
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
BOOL WINAPI GetProfilesDirectoryW(_Out_ LPWSTR lpProfilesDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1493
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PWSTR pszProfile
Definition: winwlx.h:149
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static PWSTR DuplicationString(PWSTR Str)
Definition: msgina.c:650
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WLX_PROFILE_TYPE_V2_0
Definition: winwlx.h:51
PWSTR pszEnvironment
Definition: winwlx.h:153
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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;
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 
702  TokenGroups,
703  NULL,
704  0,
705  &Size);
707  {
708  TRACE("NtQueryInformationToken() failed (Status 0x%08lx)\n", Status);
709  goto done;
710  }
711 
713  if (Groups == NULL)
714  {
715  TRACE("HeapAlloc() failed\n");
716  goto done;
717  }
718 
720  TokenGroups,
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 
740 done:
741  if (Groups != NULL)
743 
744  if (hToken != NULL)
745  CloseHandle(hToken);
746 
747  return bIsAdmin;
748 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
NTSTATUS MyLogonUser(HANDLE LsaHandle, ULONG AuthenticationPackage, LPWSTR lpszUsername, LPWSTR lpszDomain, LPWSTR lpszPassword, PHANDLE phToken, PNTSTATUS SubStatus)
Definition: lsa.c:55
static PSID AdminSid
Definition: msgina.c:39
NTSTATUS ConnectToLsa(PGINA_CONTEXT pgContext)
Definition: lsa.c:11
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
TOpcodeData Groups[17][8]
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
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
_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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_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)
Definition: token.c:1839
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define HeapFree(x, y, z)
Definition: compat.h:394
NTSYSAPI BOOLEAN NTAPI RtlEqualSid(_In_ PSID Sid1, _In_ PSID Sid2)

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 }
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
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
_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 NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24

Referenced by DoLogon(), and TUILoggedOutSAS().

◆ GetAllowedShutdownOptions()

DWORD GetAllowedShutdownOptions ( VOID  )

Definition at line 227 of file shutdown.c.

228 {
229  DWORD Options = 0;
230 
231  // FIXME: Compute those options accordings to current user's rights!
233 
234  if (IsPwrSuspendAllowed())
236 
237  if (IsPwrHibernateAllowed())
239 
240  return Options;
241 }
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:19
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:21
enum OPTION_FLAGS Options
Definition: stats.c:44
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:16
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:15
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:17
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450

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

◆ GetDefaultShutdownOptions()

DWORD GetDefaultShutdownOptions ( VOID  )

Definition at line 221 of file shutdown.c.

222 {
224 }
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:16
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:17

Referenced by OnShutDown().

◆ GetDefaultShutdownSelState()

DWORD GetDefaultShutdownSelState ( VOID  )

Definition at line 95 of file shutdown.c.

96 {
98 }
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62

Referenced by OnShutDown().

◆ LoadShutdownSelState()

DWORD LoadShutdownSelState ( VOID  )

Definition at line 101 of file shutdown.c.

102 {
103  LONG lRet;
104  HKEY hKeyCurrentUser, hKey;
105  DWORD dwValue, dwTemp, dwSize;
106 
107  /* Default to shutdown */
109 
110  /* Open the current user HKCU key */
111  lRet = RegOpenCurrentUser(MAXIMUM_ALLOWED, &hKeyCurrentUser);
112  if (lRet == ERROR_SUCCESS)
113  {
114  /* Open the subkey */
115  lRet = RegOpenKeyExW(hKeyCurrentUser,
116  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
117  0, KEY_QUERY_VALUE, &hKey);
118  RegCloseKey(hKeyCurrentUser);
119  }
120  if (lRet != ERROR_SUCCESS)
121  return dwValue;
122 
123  /* Read the value */
124  dwSize = sizeof(dwTemp);
125  lRet = RegQueryValueExW(hKey,
126  L"Shutdown Setting",
127  NULL, NULL,
128  (LPBYTE)&dwTemp, &dwSize);
129  RegCloseKey(hKey);
130 
131  if (lRet == ERROR_SUCCESS)
132  {
133  switch (dwTemp)
134  {
136  dwValue = WLX_SAS_ACTION_LOGOFF;
137  break;
138 
141  break;
142 
145  break;
146 
147  // 0x08
148 
151  break;
152 
153  // 0x20
154 
157  break;
158 
159  // 0x80
160  }
161  }
162 
163  return dwValue;
164 }
#define WLX_SAS_ACTION_SHUTDOWN_HIBERNATE
Definition: winwlx.h:66
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define WLX_SHUTDOWN_STATE_SLEEP
Definition: shutdown.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WLX_SHUTDOWN_STATE_HIBERNATE
Definition: shutdown.c:21
#define WLX_SHUTDOWN_STATE_POWER_OFF
Definition: shutdown.c:16
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
smooth NULL
Definition: ftsmooth.c:416
#define WLX_SHUTDOWN_STATE_LOGOFF
Definition: shutdown.c:15
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define WLX_SAS_ACTION_SHUTDOWN_SLEEP
Definition: winwlx.h:64
#define WLX_SHUTDOWN_STATE_REBOOT
Definition: shutdown.c:17
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3232
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

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;
67  PSID LocalSid = NULL;
69  UNICODE_STRING DomainName;
70  UNICODE_STRING UserName;
73  ULONG AuthInfoLength;
74  ULONG_PTR Ptr;
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,
91  lpszDomain);
92 
93  RtlInitUnicodeString(&UserName,
94  lpszUsername);
95 
97  lpszPassword);
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,
202  Interactive,
204  (PVOID)AuthInfo,
205  AuthInfoLength,
206  TokenGroups,
207  &TokenSource,
208  (PVOID*)&ProfileBuffer,
210  &Luid,
211  &TokenHandle,
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 
239  *phToken = TokenHandle;
240 
241 done:
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 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:398
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
MSV1_0_LOGON_SUBMIT_TYPE MessageType
Definition: ntsecapi.h:431
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2658
_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
uint16_t * PWCHAR
Definition: typedefs.h:54
PSID LocalSid
Definition: globals.c:15
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
_IRQL_requires_same_ _In_ PLSA_STRING OriginName
UNICODE_STRING Password
Definition: ntsecapi.h:434
NTSTATUS NTAPI LsaLogonUser(IN HANDLE LsaHandle, IN PLSA_STRING OriginName, IN SECURITY_LOGON_TYPE LogonType, IN ULONG AuthenticationPackage, IN PVOID AuthenticationInformation, IN ULONG AuthenticationInformationLength, IN PTOKEN_GROUPS LocalGroups OPTIONAL, IN PTOKEN_SOURCE SourceContext, OUT PVOID *ProfileBuffer, OUT PULONG ProfileBufferLength, OUT PLUID LogonId, OUT PHANDLE Token, OUT PQUOTA_LIMITS Quotas, OUT PNTSTATUS SubStatus)
Definition: lsa.c:184
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define SECURITY_LOGON_IDS_RID_COUNT
Definition: setypes.h:533
HANDLE LsaHandle
Definition: logon.c:17
_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 SECURITY_LOCAL_SID_AUTHORITY
Definition: setypes.h:502
smooth NULL
Definition: ftsmooth.c:416
#define SE_GROUP_ENABLED_BY_DEFAULT
Definition: setypes.h:91
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:715
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
struct _MSV1_0_INTERACTIVE_LOGON MSV1_0_INTERACTIVE_LOGON
UNICODE_STRING UserName
Definition: ntsecapi.h:433
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SE_GROUP_ENABLED
Definition: setypes.h:92
DWORD LowPart
static const CHAR User32TokenSourceName[]
Definition: lsa.c:51
#define SECURITY_LOCAL_RID
Definition: setypes.h:514
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2658
PCHAR Buffer
Definition: ntsecapi.h:174
#define SE_GROUP_MANDATORY
Definition: setypes.h:90
#define SECURITY_NULL_RID
Definition: setypes.h:512
LONG HighPart
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID * ProfileBuffer
ULONG AuthenticationPackage
Definition: logon.c:18
Status
Definition: gdiplustypes.h:24
#define SE_GROUP_LOGON_ID
Definition: setypes.h:98
NTSTATUS NTAPI LsaFreeReturnBuffer(IN PVOID Buffer)
Definition: lsa.c:120
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI AllocateLocallyUniqueId(PLUID Luid)
Definition: security.c:1097
_In_opt_ LPSTR lpszDomain
Definition: winbase.h:2658
_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
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define SECURITY_LOGON_IDS_RID
Definition: setypes.h:532
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING LogonDomainName
Definition: ntsecapi.h:432
static SID_IDENTIFIER_AUTHORITY SystemAuthority
Definition: msgina.c:38

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;
68  LPWSTR Value;
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)
78  return ERROR_FILE_NOT_FOUND;
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 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
#define REG_SZ
Definition: layer.c:22

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 493 of file shutdown.c.

497 {
498  INT_PTR ret;
500 
501 #if 0
502  DWORD ShutdownOptions;
503 
504  // FIXME: User impersonation!!
505  pgContext->nShutdownAction = LoadShutdownSelState();
506  ShutdownOptions = GetAllowedShutdownOptions();
507 #endif
508 
509  Context.pgContext = pgContext;
510  Context.ShutdownOptions = ShutdownOptions;
511  Context.bCloseDlg = FALSE;
512  Context.bReasonUI = GetShutdownReasonUI();
513 
514  if (pgContext->hWlx && pgContext->pWlxFuncs)
515  {
516  ret = pgContext->pWlxFuncs->WlxDialogBoxParam(pgContext->hWlx,
517  pgContext->hDllInstance,
519  hwndDlg,
521  (LPARAM)&Context);
522  }
523  else
524  {
525  ret = DialogBoxParamW(pgContext->hDllInstance,
527  hwndDlg,
529  (LPARAM)&Context);
530  }
531 
532 #if 0
533  // FIXME: User impersonation!!
534  if (ret == IDOK)
535  SaveShutdownSelState(pgContext->nShutdownAction);
536 #endif
537 
538  return ret;
539 }
#define IDD_SHUTDOWN
Definition: resource.h:43
#define IDOK
Definition: winuser.h:824
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
DWORD LoadShutdownSelState(VOID)
Definition: shutdown.c:101
static INT_PTR CALLBACK ShutdownDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: shutdown.c:403
int32_t INT_PTR
Definition: typedefs.h:62
DWORD GetAllowedShutdownOptions(VOID)
Definition: shutdown.c:227
LONG_PTR LPARAM
Definition: windef.h:208
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static BOOL GetShutdownReasonUI(VOID)
Definition: shutdown.c:36
#define IDD_SHUTDOWN_REASON
Definition: resource.h:45
struct tagContext Context
Definition: acpixf.h:1024
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID SaveShutdownSelState(IN DWORD ShutdownCode)
Definition: shutdown.c:167

Referenced by OnShutDown(), and ShellShutdownDialog().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msgina  )

Variable Documentation

◆ hDllInstance

HINSTANCE hDllInstance

Definition at line 18 of file dnsrslvr.c.