ReactOS 0.4.16-dev-1946-g52006dd
winlogon.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <winreg.h>
#include <winwlx.h>
#include <ndk/rtlfuncs.h>
#include <ndk/exfuncs.h>
#include <ndk/kefuncs.h>
#include <strsafe.h>
#include <pseh/pseh2.h>
#include <undocuser.h>
#include <undocmpr.h>
#include <wine/debug.h>
#include "resource.h"
Include dependency graph for winlogon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GINAFUNCTIONS
 
struct  _GINAINSTANCE
 
struct  _WLSESSION
 

Macros

#define USE_GETLASTINPUTINFO
 
#define WIN32_NO_STATUS
 
#define LockWorkstation(Session)
 
#define UnlockWorkstation(Session)
 
#define WLX_LOGGINGOFF(wlxAction)
 
#define WLX_SHUTTINGDOWN(wlxAction)
 
#define WLX_SUSPENDING(wlxAction)
 

Typedefs

typedef BOOL(WINAPIPFWLXNEGOTIATE) (DWORD, DWORD *)
 
typedef BOOL(WINAPIPFWLXINITIALIZE) (LPWSTR, HANDLE, PVOID, PVOID, PVOID *)
 
typedef VOID(WINAPIPFWLXDISPLAYSASNOTICE) (PVOID)
 
typedef int(WINAPIPFWLXLOGGEDOUTSAS) (PVOID, DWORD, PLUID, PSID, PDWORD, PHANDLE, PWLX_MPR_NOTIFY_INFO, PVOID *)
 
typedef BOOL(WINAPIPFWLXACTIVATEUSERSHELL) (PVOID, PWSTR, PWSTR, PVOID)
 
typedef int(WINAPIPFWLXLOGGEDONSAS) (PVOID, DWORD, PVOID)
 
typedef VOID(WINAPIPFWLXDISPLAYLOCKEDNOTICE) (PVOID)
 
typedef int(WINAPIPFWLXWKSTALOCKEDSAS) (PVOID, DWORD)
 
typedef BOOL(WINAPIPFWLXISLOCKOK) (PVOID)
 
typedef BOOL(WINAPIPFWLXISLOGOFFOK) (PVOID)
 
typedef VOID(WINAPIPFWLXLOGOFF) (PVOID)
 
typedef VOID(WINAPIPFWLXSHUTDOWN) (PVOID, DWORD)
 
typedef BOOL(WINAPIPFWLXSCREENSAVERNOTIFY) (PVOID, BOOL *)
 
typedef BOOL(WINAPIPFWLXSTARTAPPLICATION) (PVOID, PWSTR, PVOID, PWSTR)
 
typedef BOOL(WINAPIPFWLXNETWORKPROVIDERLOAD) (PVOID, PWLX_MPR_NOTIFY_INFO)
 
typedef BOOL(WINAPIPFWLXDISPLAYSTATUSMESSAGE) (PVOID, HDESK, DWORD, PWSTR, PWSTR)
 
typedef BOOL(WINAPIPFWLXGETSTATUSMESSAGE) (PVOID, DWORD *, PWSTR, DWORD)
 
typedef BOOL(WINAPIPFWLXREMOVESTATUSMESSAGE) (PVOID)
 
typedef struct _GINAFUNCTIONS GINAFUNCTIONS
 
typedef struct _GINAFUNCTIONSPGINAFUNCTIONS
 
typedef struct _GINAINSTANCE GINAINSTANCE
 
typedef struct _GINAINSTANCEPGINAINSTANCE
 
typedef enum _LOGON_STATE LOGON_STATE
 
typedef enum _LOGON_STATEPLOGON_STATE
 
typedef struct _WLSESSION WLSESSION
 
typedef struct _WLSESSIONPWLSESSION
 
typedef enum _NOTIFICATION_TYPE NOTIFICATION_TYPE
 
typedef enum _NOTIFICATION_TYPEPNOTIFICATION_TYPE
 

Enumerations

enum  _LOGON_STATE {
  STATE_INIT , STATE_LOGGED_OFF , STATE_LOGGED_OFF_SAS , STATE_LOGGED_ON ,
  STATE_LOGGED_ON_SAS , STATE_LOCKED , STATE_LOCKED_SAS , STATE_LOGGING_OFF ,
  STATE_SHUTTING_DOWN , STATE_SHUT_DOWN , STATE_SCREENSAVER
}
 
enum  _NOTIFICATION_TYPE {
  LogonHandler , LogoffHandler , LockHandler , UnlockHandler ,
  StartupHandler , ShutdownHandler , StartScreenSaverHandler , StopScreenSaverHandler ,
  DisconnectHandler , ReconnectHandler , StartShellHandler , PostShellHandler ,
  LastHandler
}
 

Functions

BOOL WINAPI SetWindowStationUser (IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
 
 WINE_DEFAULT_DEBUG_CHANNEL (winlogon)
 
FORCEINLINE VOID SetLogonTimestamp (_Inout_ PWLSESSION Session)
 
FORCEINLINE BOOL IsFirstLogon (_In_ PWLSESSION Session)
 
BOOL CreateUserEnvironment (IN PWLSESSION Session)
 
BOOL InitNotifications (VOID)
 
VOID CleanupNotifications (VOID)
 
VOID CallNotificationDlls (PWLSESSION pSession, NOTIFICATION_TYPE Type)
 
BOOL StartRpcServer (VOID)
 
BOOL SetDefaultLanguage (IN PWLSESSION Session)
 
NTSTATUS HandleShutdown (IN OUT PWLSESSION Session, IN DWORD wlxAction)
 
BOOL InitializeSAS (IN OUT PWLSESSION Session)
 
BOOL InitializeScreenSaver (IN OUT PWLSESSION Session)
 
VOID StartScreenSaver (IN PWLSESSION Session)
 
PSECURITY_DESCRIPTOR ConvertToSelfRelative (_In_ PSECURITY_DESCRIPTOR AbsoluteSd)
 Converts an absolute security descriptor to a self-relative format.
 
BOOL CreateWinstaSecurity (_Out_ PSECURITY_DESCRIPTOR *WinstaSd)
 Creates a security descriptor for the default window station upon its creation.
 
BOOL CreateApplicationDesktopSecurity (_Out_ PSECURITY_DESCRIPTOR *ApplicationDesktopSd)
 Creates a security descriptor for the default application desktop upon its creation.
 
BOOL CreateWinlogonDesktopSecurity (_Out_ PSECURITY_DESCRIPTOR *WinlogonDesktopSd)
 Creates a security descriptor for the default Winlogon desktop. This descriptor serves as a security measure for the winlogon desktop so that only Winlogon itself (and admins) can interact with it.
 
BOOL CreateScreenSaverSecurity (_Out_ PSECURITY_DESCRIPTOR *ScreenSaverDesktopSd)
 Creates a security descriptor for the screen saver desktop.
 
BOOL AllowWinstaAccessToUser (_In_ HWINSTA WinSta, _In_ PSID LogonSid)
 Assigns access to the specific logon user to the default window station. Such access is given to the user when it has logged in.
 
BOOL AllowDesktopAccessToUser (_In_ HDESK Desktop, _In_ PSID LogonSid)
 Assigns access to the specific logon user to the default desktop. Such access is given to the user when it has logged in.
 
BOOL AllowAccessOnSession (_In_ PWLSESSION Session)
 Assigns both window station and desktop access to the specific session currently active on the system.
 
DWORD GetSetupType (VOID)
 
BOOL RunSetup (VOID)
 
DWORD TerminateSystemShutdown (VOID)
 
DWORD StartSystemShutdown (IN PUNICODE_STRING pMessage, IN ULONG dwTimeout, IN BOOLEAN bForceAppsClosed, IN BOOLEAN bRebootAfterShutdown, IN ULONG dwReason)
 
PWSTR WlStrDup (_In_opt_ PCWSTR String)
 Duplicates the given string, allocating a buffer on the heap.
 
BOOL PlaySoundRoutine (IN LPCWSTR FileName, IN UINT Logon, IN UINT Flags)
 
BOOL DisplayStatusMessage (IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
 
BOOL RemoveStatusMessage (IN PWLSESSION Session)
 
VOID InitDialogListHead (VOID)
 
VOID CloseAllDialogWindows (VOID)
 
BOOL GinaInit (IN OUT PWLSESSION Session)
 
BOOL CreateWindowStationAndDesktops (_Inout_ PWLSESSION Session)
 
VOID WINAPI WlxUseCtrlAltDel (HANDLE hWlx)
 
VOID WINAPI WlxSetContextPointer (HANDLE hWlx, PVOID pWlxContext)
 
VOID WINAPI WlxSasNotify (HANDLE hWlx, DWORD dwSasType)
 
BOOL WINAPI WlxSetTimeout (HANDLE hWlx, DWORD Timeout)
 
int WINAPI WlxAssignShellProtection (HANDLE hWlx, HANDLE hToken, HANDLE hProcess, HANDLE hThread)
 
int WINAPI WlxMessageBox (HANDLE hWlx, HWND hwndOwner, LPWSTR lpszText, LPWSTR lpszTitle, UINT fuStyle)
 
int WINAPI WlxDialogBox (HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc)
 
int WINAPI WlxDialogBoxParam (HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
 
int WINAPI WlxDialogBoxIndirect (HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc)
 
int WINAPI WlxDialogBoxIndirectParam (HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
 
int WINAPI WlxSwitchDesktopToUser (HANDLE hWlx)
 
int WINAPI WlxSwitchDesktopToWinlogon (HANDLE hWlx)
 
int WINAPI WlxChangePasswordNotify (HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo)
 
BOOL WINAPI WlxGetSourceDesktop (HANDLE hWlx, PWLX_DESKTOP *ppDesktop)
 
BOOL WINAPI WlxSetReturnDesktop (HANDLE hWlx, PWLX_DESKTOP pDesktop)
 
BOOL WINAPI WlxCreateUserDesktop (HANDLE hWlx, HANDLE hToken, DWORD Flags, PWSTR pszDesktopName, PWLX_DESKTOP *ppDesktop)
 
int WINAPI WlxChangePasswordNotifyEx (HANDLE hWlx, PWLX_MPR_NOTIFY_INFO pMprInfo, DWORD dwChangeInfo, PWSTR ProviderName, PVOID Reserved)
 
BOOL WINAPI WlxCloseUserDesktop (HANDLE hWlx, PWLX_DESKTOP pDesktop, HANDLE hToken)
 
BOOL WINAPI WlxSetOption (HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR *OldValue)
 
BOOL WINAPI WlxGetOption (HANDLE hWlx, DWORD Option, ULONG_PTR *Value)
 
VOID WINAPI WlxWin31Migrate (HANDLE hWlx)
 
BOOL WINAPI WlxQueryClientCredentials (PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred)
 
BOOL WINAPI WlxQueryInetConnectorCredentials (PWLX_CLIENT_CREDENTIALS_INFO_V1_0 pCred)
 
DWORD WINAPI WlxQueryConsoleSwitchCredentials (PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0 pCred)
 
BOOL WINAPI WlxQueryTsLogonCredentials (PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pCred)
 
BOOL WINAPI WlxDisconnect (VOID)
 
DWORD WINAPI WlxQueryTerminalServicesData (HANDLE hWlx, PWLX_TERMINAL_SERVICES_DATA pTSData, WCHAR *UserName, WCHAR *Domain)
 

Variables

HINSTANCE hAppInstance
 
PWLSESSION WLSession
 
LUID LuidNone
 

Macro Definition Documentation

◆ LockWorkstation

#define LockWorkstation (   Session)

Definition at line 217 of file winlogon.h.

◆ UnlockWorkstation

#define UnlockWorkstation (   Session)

Definition at line 218 of file winlogon.h.

◆ USE_GETLASTINPUTINFO

#define USE_GETLASTINPUTINFO

Definition at line 29 of file winlogon.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 35 of file winlogon.h.

◆ WLX_LOGGINGOFF

#define WLX_LOGGINGOFF (   wlxAction)
Value:
(((wlxAction) == WLX_SAS_ACTION_LOGOFF) || \
((wlxAction) == WLX_SAS_ACTION_FORCE_LOGOFF))
#define WLX_SAS_ACTION_FORCE_LOGOFF
Definition: winwlx.h:61
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56

Definition at line 282 of file winlogon.h.

◆ WLX_SHUTTINGDOWN

#define WLX_SHUTTINGDOWN (   wlxAction)
Value:
(((wlxAction) == WLX_SAS_ACTION_SHUTDOWN) || \
((wlxAction) == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF) || \
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
#define WLX_SAS_ACTION_SHUTDOWN
Definition: winwlx.h:57
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63

Definition at line 286 of file winlogon.h.

◆ WLX_SUSPENDING

#define WLX_SUSPENDING (   wlxAction)
Value:
(((wlxAction) == WLX_SAS_ACTION_SHUTDOWN_SLEEP) || \
((wlxAction) == WLX_SAS_ACTION_SHUTDOWN_SLEEP2) || \
#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_SLEEP2
Definition: winwlx.h:65

Definition at line 291 of file winlogon.h.

Typedef Documentation

◆ GINAFUNCTIONS

◆ GINAINSTANCE

◆ LOGON_STATE

◆ NOTIFICATION_TYPE

◆ PFWLXACTIVATEUSERSHELL

typedef BOOL(WINAPI * PFWLXACTIVATEUSERSHELL) (PVOID, PWSTR, PWSTR, PVOID)

Definition at line 72 of file winlogon.h.

◆ PFWLXDISPLAYLOCKEDNOTICE

typedef VOID(WINAPI * PFWLXDISPLAYLOCKEDNOTICE) (PVOID)

Definition at line 74 of file winlogon.h.

◆ PFWLXDISPLAYSASNOTICE

typedef VOID(WINAPI * PFWLXDISPLAYSASNOTICE) (PVOID)

Definition at line 68 of file winlogon.h.

◆ PFWLXDISPLAYSTATUSMESSAGE

typedef BOOL(WINAPI * PFWLXDISPLAYSTATUSMESSAGE) (PVOID, HDESK, DWORD, PWSTR, PWSTR)

Definition at line 89 of file winlogon.h.

◆ PFWLXGETSTATUSMESSAGE

typedef BOOL(WINAPI * PFWLXGETSTATUSMESSAGE) (PVOID, DWORD *, PWSTR, DWORD)

Definition at line 90 of file winlogon.h.

◆ PFWLXINITIALIZE

typedef BOOL(WINAPI * PFWLXINITIALIZE) (LPWSTR, HANDLE, PVOID, PVOID, PVOID *)

Definition at line 67 of file winlogon.h.

◆ PFWLXISLOCKOK

typedef BOOL(WINAPI * PFWLXISLOCKOK) (PVOID)

Definition at line 76 of file winlogon.h.

◆ PFWLXISLOGOFFOK

typedef BOOL(WINAPI * PFWLXISLOGOFFOK) (PVOID)

Definition at line 77 of file winlogon.h.

◆ PFWLXLOGGEDONSAS

typedef int(WINAPI * PFWLXLOGGEDONSAS) (PVOID, DWORD, PVOID)

Definition at line 73 of file winlogon.h.

◆ PFWLXLOGGEDOUTSAS

typedef int(WINAPI * PFWLXLOGGEDOUTSAS) (PVOID, DWORD, PLUID, PSID, PDWORD, PHANDLE, PWLX_MPR_NOTIFY_INFO, PVOID *)

Definition at line 69 of file winlogon.h.

◆ PFWLXLOGOFF

typedef VOID(WINAPI * PFWLXLOGOFF) (PVOID)

Definition at line 78 of file winlogon.h.

◆ PFWLXNEGOTIATE

typedef BOOL(WINAPI * PFWLXNEGOTIATE) (DWORD, DWORD *)

Definition at line 66 of file winlogon.h.

◆ PFWLXNETWORKPROVIDERLOAD

typedef BOOL(WINAPI * PFWLXNETWORKPROVIDERLOAD) (PVOID, PWLX_MPR_NOTIFY_INFO)

Definition at line 88 of file winlogon.h.

◆ PFWLXREMOVESTATUSMESSAGE

typedef BOOL(WINAPI * PFWLXREMOVESTATUSMESSAGE) (PVOID)

Definition at line 91 of file winlogon.h.

◆ PFWLXSCREENSAVERNOTIFY

typedef BOOL(WINAPI * PFWLXSCREENSAVERNOTIFY) (PVOID, BOOL *)

Definition at line 83 of file winlogon.h.

◆ PFWLXSHUTDOWN

typedef VOID(WINAPI * PFWLXSHUTDOWN) (PVOID, DWORD)

Definition at line 79 of file winlogon.h.

◆ PFWLXSTARTAPPLICATION

typedef BOOL(WINAPI * PFWLXSTARTAPPLICATION) (PVOID, PWSTR, PVOID, PWSTR)

Definition at line 84 of file winlogon.h.

◆ PFWLXWKSTALOCKEDSAS

typedef int(WINAPI * PFWLXWKSTALOCKEDSAS) (PVOID, DWORD)

Definition at line 75 of file winlogon.h.

◆ PGINAFUNCTIONS

◆ PGINAINSTANCE

◆ PLOGON_STATE

◆ PNOTIFICATION_TYPE

◆ PWLSESSION

◆ WLSESSION

Enumeration Type Documentation

◆ _LOGON_STATE

Enumerator
STATE_INIT 
STATE_LOGGED_OFF 
STATE_LOGGED_OFF_SAS 
STATE_LOGGED_ON 
STATE_LOGGED_ON_SAS 
STATE_LOCKED 
STATE_LOCKED_SAS 
STATE_LOGGING_OFF 
STATE_SHUTTING_DOWN 
STATE_SHUT_DOWN 
STATE_SCREENSAVER 

Definition at line 202 of file winlogon.h.

203{
211 STATE_LOGGING_OFF, // not used yet
212 STATE_SHUTTING_DOWN, // not used yet
213 STATE_SHUT_DOWN, // not used yet
214 STATE_SCREENSAVER // not used yet
enum _LOGON_STATE LOGON_STATE
@ STATE_LOGGED_ON
Definition: winlogon.h:207
@ STATE_LOGGED_OFF_SAS
Definition: winlogon.h:206
@ STATE_LOCKED_SAS
Definition: winlogon.h:210
@ STATE_INIT
Definition: winlogon.h:204
@ STATE_LOGGED_OFF
Definition: winlogon.h:205
@ STATE_LOGGING_OFF
Definition: winlogon.h:211
@ STATE_SHUT_DOWN
Definition: winlogon.h:213
@ STATE_LOGGED_ON_SAS
Definition: winlogon.h:208
@ STATE_SCREENSAVER
Definition: winlogon.h:214
@ STATE_LOCKED
Definition: winlogon.h:209
@ STATE_SHUTTING_DOWN
Definition: winlogon.h:212
enum _LOGON_STATE * PLOGON_STATE

◆ _NOTIFICATION_TYPE

Enumerator
LogonHandler 
LogoffHandler 
LockHandler 
UnlockHandler 
StartupHandler 
ShutdownHandler 
StartScreenSaverHandler 
StopScreenSaverHandler 
DisconnectHandler 
ReconnectHandler 
StartShellHandler 
PostShellHandler 
LastHandler 

Definition at line 262 of file winlogon.h.

263{
enum _NOTIFICATION_TYPE NOTIFICATION_TYPE
enum _NOTIFICATION_TYPE * PNOTIFICATION_TYPE
@ StopScreenSaverHandler
Definition: winlogon.h:271
@ PostShellHandler
Definition: winlogon.h:275
@ LastHandler
Definition: winlogon.h:276
@ LogonHandler
Definition: winlogon.h:264
@ LogoffHandler
Definition: winlogon.h:265
@ StartShellHandler
Definition: winlogon.h:274
@ DisconnectHandler
Definition: winlogon.h:272
@ UnlockHandler
Definition: winlogon.h:267
@ ReconnectHandler
Definition: winlogon.h:273
@ LockHandler
Definition: winlogon.h:266
@ StartScreenSaverHandler
Definition: winlogon.h:270
@ ShutdownHandler
Definition: winlogon.h:269
@ StartupHandler
Definition: winlogon.h:268

Function Documentation

◆ AllowAccessOnSession()

BOOL AllowAccessOnSession ( _In_ PWLSESSION  Session)

Assigns both window station and desktop access to the specific session currently active on the system.

Parameters
[in]SessionA pointer to an active session.
Returns
Returns TRUE if the function has successfully assigned access to the current session, FALSE otherwise.

Definition at line 1392 of file security.c.

1394{
1395 BOOL Success = FALSE;
1396 DWORD Index, SidLength, GroupsLength = 0;
1397 PTOKEN_GROUPS TokenGroup = NULL;
1398 PSID LogonSid;
1399
1400 /* Get required buffer size and allocate the TOKEN_GROUPS buffer */
1401 if (!GetTokenInformation(Session->UserToken,
1403 TokenGroup,
1404 0,
1405 &GroupsLength))
1406 {
1408 {
1409 ERR("AllowAccessOnSession(): Unexpected error code returned, must be ERROR_INSUFFICIENT_BUFFER (error code %lu)\n", GetLastError());
1410 return FALSE;
1411 }
1412
1413 TokenGroup = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, GroupsLength);
1414 if (TokenGroup == NULL)
1415 {
1416 ERR("AllowAccessOnSession(): Failed to allocate memory buffer for token group!\n");
1417 return FALSE;
1418 }
1419 }
1420
1421 /* Get the token group information from the access token */
1422 if (!GetTokenInformation(Session->UserToken,
1424 TokenGroup,
1425 GroupsLength,
1426 &GroupsLength))
1427 {
1428 ERR("AllowAccessOnSession(): Failed to retrieve the token group information (error code %lu)\n", GetLastError());
1429 goto Quit;
1430 }
1431
1432 /* Loop through the groups to find the logon SID */
1433 for (Index = 0; Index < TokenGroup->GroupCount; Index++)
1434 {
1435 if ((TokenGroup->Groups[Index].Attributes & SE_GROUP_LOGON_ID)
1437 {
1438 LogonSid = TokenGroup->Groups[Index].Sid;
1439 break;
1440 }
1441 }
1442
1443 /* Allow window station access to this user within this session */
1444 if (!AllowWinstaAccessToUser(Session->InteractiveWindowStation, LogonSid))
1445 {
1446 ERR("AllowAccessOnSession(): Failed to allow winsta access to the logon user!\n");
1447 goto Quit;
1448 }
1449
1450 /* Allow application desktop access to this user within this session */
1451 if (!AllowDesktopAccessToUser(Session->ApplicationDesktop, LogonSid))
1452 {
1453 ERR("AllowAccessOnSession(): Failed to allow application desktop access to the logon user!\n");
1454 goto Quit;
1455 }
1456
1457 /* Get the length of this logon SID */
1458 SidLength = GetLengthSid(LogonSid);
1459
1460 /* Assign the window station to this logged in user */
1461 if (!SetWindowStationUser(Session->InteractiveWindowStation,
1462 &Session->LogonId,
1463 LogonSid,
1464 SidLength))
1465 {
1466 ERR("AllowAccessOnSession(): Failed to assign the window station to the logon user!\n");
1467 goto Quit;
1468 }
1469
1470 Success = TRUE;
1471
1472Quit:
1473 if (TokenGroup != NULL)
1474 {
1475 RtlFreeHeap(RtlGetProcessHeap(), 0, TokenGroup);
1476 }
1477
1478 return Success;
1479}
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL AllowWinstaAccessToUser(_In_ HWINSTA WinSta, _In_ PSID LogonSid)
Assigns access to the specific logon user to the default window station. Such access is given to the ...
Definition: security.c:875
BOOL AllowDesktopAccessToUser(_In_ HDESK Desktop, _In_ PSID LogonSid)
Assigns access to the specific logon user to the default desktop. Such access is given to the user wh...
Definition: security.c:1166
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#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
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SE_GROUP_LOGON_ID
Definition: setypes.h:98
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:1030
$ULONG GroupCount
Definition: setypes.h:1026
_In_ WDFCOLLECTION _In_ ULONG Index
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI SetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:419
@ TokenGroups
Definition: setypes.h:979

Referenced by HandleLogon().

◆ AllowDesktopAccessToUser()

BOOL AllowDesktopAccessToUser ( _In_ HDESK  Desktop,
_In_ PSID  LogonSid 
)

Assigns access to the specific logon user to the default desktop. Such access is given to the user when it has logged in.

Parameters
[in]DesktopA handle to a desktop where the user is given access to it.
[in]LogonSidA pointer to a logon SID that represents the logged in user in question.
Returns
Returns TRUE if the function has successfully assigned access to the user, FALSE otherwise.

Definition at line 1166 of file security.c.

1169{
1170 BOOL Success = FALSE;
1171 SECURITY_DESCRIPTOR AbsoluteSd;
1172 PSECURITY_DESCRIPTOR RelativeSd = NULL;
1173 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment in CreateWinstaSecurity for information */
1176 PACL Dacl;
1177
1178 /* Create the Winlogon SID */
1180 1,
1182 0, 0, 0, 0, 0, 0, 0,
1183 &WinlogonSid))
1184 {
1185 ERR("AllowDesktopAccessToUser(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
1186 return FALSE;
1187 }
1188
1189 /* Create the admins SID */
1191 2,
1194 0, 0, 0, 0, 0, 0,
1195 &AdminsSid))
1196 {
1197 ERR("AllowDesktopAccessToUser(): Failed to create the admins SID (error code %lu)\n", GetLastError());
1198 goto Quit;
1199 }
1200
1201 /* Create the interactive logon SID */
1203 1,
1205 0, 0, 0, 0, 0, 0, 0,
1207 {
1208 ERR("AllowDesktopAccessToUser(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
1209 goto Quit;
1210 }
1211
1212 /* HACK: Create the network service SID */
1214 1,
1216 0, 0, 0, 0, 0, 0, 0,
1218 {
1219 ERR("AllowDesktopAccessToUser(): Failed to create the network service SID (error code %lu)\n", GetLastError());
1220 goto Quit;
1221 }
1222
1223 /*
1224 * Build up the DACL size. This includes a number
1225 * of four ACEs of four different SIDs. The first ACE
1226 * gives full desktop access to Winlogon, the second one gives
1227 * generic limited desktop access to admins. The last two give
1228 * full power to both interactive logon users and logon user as
1229 * well.
1230 */
1231 DaclSize = sizeof(ACL) +
1232 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
1233 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
1235 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
1236 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(NetworkServiceSid); /* HACK */
1237
1238 /* Allocate the DACL now */
1239 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
1241 DaclSize);
1242 if (Dacl == NULL)
1243 {
1244 ERR("AllowDesktopAccessToUser(): Failed to allocate memory buffer for DACL!\n");
1245 goto Quit;
1246 }
1247
1248 /* Initialize it */
1250 {
1251 ERR("AllowDesktopAccessToUser(): Failed to initialize DACL (error code %lu)\n", GetLastError());
1252 goto Quit;
1253 }
1254
1255 /* First ACE -- Give full desktop access to Winlogon */
1258 0,
1260 WinlogonSid))
1261 {
1262 ERR("AllowDesktopAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
1263 goto Quit;
1264 }
1265
1266 /* Second ACE -- Give limited desktop access to admins */
1269 0,
1271 AdminsSid))
1272 {
1273 ERR("AllowDesktopAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
1274 goto Quit;
1275 }
1276
1277 /* Third ACE -- Give full desktop access to interactive logon users */
1280 0,
1283 {
1284 ERR("AllowDesktopAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1285 goto Quit;
1286 }
1287
1288 /* Fourth ACE -- Give full desktop access to logon user */
1291 0,
1293 LogonSid))
1294 {
1295 ERR("AllowDesktopAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1296 goto Quit;
1297 }
1298
1299 /* HACK: Fifth ACE -- Give full desktop to network services */
1302 0,
1305 {
1306 ERR("AllowDesktopAccessToUser(): Failed to set ACE for network service SID (error code %lu)\n", GetLastError());
1307 goto Quit;
1308 }
1309
1310 /* Initialize the security descriptor */
1312 {
1313 ERR("AllowDesktopAccessToUser(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
1314 goto Quit;
1315 }
1316
1317 /* Set the DACL to the descriptor */
1318 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
1319 {
1320 ERR("AllowDesktopAccessToUser(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
1321 goto Quit;
1322 }
1323
1324 /* Conver it to self-relative format */
1325 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
1326 if (RelativeSd == NULL)
1327 {
1328 ERR("AllowDesktopAccessToUser(): Failed to convert security descriptor to self relative format!\n");
1329 goto Quit;
1330 }
1331
1332 /* Assign new security to desktop based on this descriptor */
1335 {
1336 ERR("AllowDesktopAccessToUser(): Failed to set desktop security descriptor (error code %lu)\n", GetLastError());
1337 goto Quit;
1338 }
1339
1340 Success = TRUE;
1341
1342Quit:
1343 if (WinlogonSid != NULL)
1344 {
1345 FreeSid(WinlogonSid);
1346 }
1347
1348 if (AdminsSid != NULL)
1349 {
1350 FreeSid(AdminsSid);
1351 }
1352
1353 if (InteractiveSid != NULL)
1354 {
1356 }
1357
1358 /* HACK */
1359 if (NetworkServiceSid != NULL)
1360 {
1362 }
1363 /* END HACK */
1364
1365 if (Dacl != NULL)
1366 {
1367 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
1368 }
1369
1370 if (RelativeSd != NULL)
1371 {
1372 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
1373 }
1374
1375 return Success;
1376}
PSID InteractiveSid
Definition: globals.c:15
PSID NetworkServiceSid
Definition: globals.c:16
#define DESKTOP_ADMINS_LIMITED
Definition: security.c:19
PSECURITY_DESCRIPTOR ConvertToSelfRelative(_In_ PSECURITY_DESCRIPTOR AbsoluteSd)
Converts an absolute security descriptor to a self-relative format.
Definition: security.c:64
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
#define DESKTOP_ALL
Definition: security.c:14
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAceEx(PACL pAcl, DWORD dwAceRevision, DWORD AceFlags, DWORD AccessMask, PSID pSid)
Definition: security.c:1063
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ SECURITY_INFORMATION SecurityInformation
Definition: fltkernel.h:1340
DWORD SECURITY_INFORMATION
Definition: ms-dtyp.idl:311
struct _ACL ACL
struct _ACCESS_ALLOWED_ACE ACCESS_ALLOWED_ACE
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1625
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1626
#define DWORD
Definition: nt_native.h:44
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL WINAPI SetUserObjectSecurity(_In_ HANDLE, _In_ PSECURITY_INFORMATION, _In_ PSECURITY_DESCRIPTOR)
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define DACL_SECURITY_INFORMATION
Definition: setypes.h:125
#define SECURITY_INTERACTIVE_RID
Definition: setypes.h:559
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define SECURITY_NETWORK_SERVICE_RID
Definition: setypes.h:576
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by AllowAccessOnSession().

◆ AllowWinstaAccessToUser()

BOOL AllowWinstaAccessToUser ( _In_ HWINSTA  WinSta,
_In_ PSID  LogonSid 
)

Assigns access to the specific logon user to the default window station. Such access is given to the user when it has logged in.

Parameters
[in]WinStaA handle to a window station where the user is given access to it.
[in]LogonSidA pointer to a logon SID that represents the logged in user in question.
Returns
Returns TRUE if the function has successfully assigned access to the user, FALSE otherwise.

Definition at line 875 of file security.c.

878{
880 SECURITY_DESCRIPTOR AbsoluteSd;
881 PSECURITY_DESCRIPTOR RelativeSd = NULL;
882 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment in CreateWinstaSecurity for information */
885 PACL Dacl;
886
887 /* Create the Winlogon SID */
889 1,
891 0, 0, 0, 0, 0, 0, 0,
892 &WinlogonSid))
893 {
894 ERR("AllowWinstaAccessToUser(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
895 return FALSE;
896 }
897
898 /* Create the admins SID */
900 2,
903 0, 0, 0, 0, 0, 0,
904 &AdminsSid))
905 {
906 ERR("AllowWinstaAccessToUser(): Failed to create the admins SID (error code %lu)\n", GetLastError());
907 goto Quit;
908 }
909
910 /* Create the interactive logon SID */
912 1,
914 0, 0, 0, 0, 0, 0, 0,
916 {
917 ERR("AllowWinstaAccessToUser(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
918 goto Quit;
919 }
920
921 /* HACK: Create the network service SID */
923 1,
925 0, 0, 0, 0, 0, 0, 0,
927 {
928 ERR("AllowWinstaAccessToUser(): Failed to create the network service SID (error code %lu)\n", GetLastError());
929 goto Quit;
930 }
931
932 /*
933 * Build up the DACL size. This includes a number
934 * of eight ACEs of four different SIDs. The first ACE
935 * gives full winsta access to Winlogon, the second one gives
936 * generic access to Winlogon. Such approach is the same
937 * for both interactive logon users and logon user as well.
938 * Only admins are given limited powers.
939 */
940 DaclSize = sizeof(ACL) +
941 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
942 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
943 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
944 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
947 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
948 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
949 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(NetworkServiceSid) + /* HACK */
951
952 /* Allocate the DACL now */
953 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
955 DaclSize);
956 if (Dacl == NULL)
957 {
958 ERR("AllowWinstaAccessToUser(): Failed to allocate memory buffer for DACL!\n");
959 goto Quit;
960 }
961
962 /* Initialize it */
964 {
965 ERR("AllowWinstaAccessToUser(): Failed to initialize DACL (error code %lu)\n", GetLastError());
966 goto Quit;
967 }
968
969 /* First ACE -- Give full winsta access to Winlogon */
974 WinlogonSid))
975 {
976 ERR("AllowWinstaAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
977 goto Quit;
978 }
979
980 /* Second ACE -- Give generic access to Winlogon */
985 WinlogonSid))
986 {
987 ERR("AllowWinstaAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
988 goto Quit;
989 }
990
991 /* Third ACE -- Give limited winsta access to admins */
996 AdminsSid))
997 {
998 ERR("AllowWinstaAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
999 goto Quit;
1000 }
1001
1002 /* Fourth ACE -- Give limited desktop access to admins */
1007 AdminsSid))
1008 {
1009 ERR("AllowWinstaAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
1010 goto Quit;
1011 }
1012
1013 /* Fifth ACE -- Give full winsta access to interactive logon users */
1017 WINSTA_ALL,
1019 {
1020 ERR("AllowWinstaAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1021 goto Quit;
1022 }
1023
1024 /* Sixth ACE -- Give generic access to interactive logon users */
1030 {
1031 ERR("AllowWinstaAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1032 goto Quit;
1033 }
1034
1035 /* Seventh ACE -- Give full winsta access to logon user */
1039 WINSTA_ALL,
1040 LogonSid))
1041 {
1042 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1043 goto Quit;
1044 }
1045
1046 /* Eighth ACE -- Give generic access to logon user */
1051 LogonSid))
1052 {
1053 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1054 goto Quit;
1055 }
1056
1057 /* HACK : Ninenth ACE -- Give full winsta access to network services */
1061 WINSTA_ALL,
1063 {
1064 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon network service SID (error code %lu)\n", GetLastError());
1065 goto Quit;
1066 }
1067
1068 /* HACK: Tenth ACE -- Give generic access to network services */
1074 {
1075 ERR("AllowWinstaAccessToUser(): Failed to set ACE for network service SID (error code %lu)\n", GetLastError());
1076 goto Quit;
1077 }
1078
1079 /* Initialize the security descriptor */
1081 {
1082 ERR("AllowWinstaAccessToUser(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
1083 goto Quit;
1084 }
1085
1086 /* Set the DACL to descriptor */
1087 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
1088 {
1089 ERR("AllowWinstaAccessToUser(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
1090 goto Quit;
1091 }
1092
1093 /* Convert it to self-relative format */
1094 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
1095 if (RelativeSd == NULL)
1096 {
1097 ERR("AllowWinstaAccessToUser(): Failed to convert security descriptor to self relative format!\n");
1098 goto Quit;
1099 }
1100
1101 /* Set new winsta security based on this descriptor */
1103 if (!SetUserObjectSecurity(WinSta, &SecurityInformation, RelativeSd))
1104 {
1105 ERR("AllowWinstaAccessToUser(): Failed to set window station security descriptor (error code %lu)\n", GetLastError());
1106 goto Quit;
1107 }
1108
1109 Success = TRUE;
1110
1111Quit:
1112 if (WinlogonSid != NULL)
1113 {
1114 FreeSid(WinlogonSid);
1115 }
1116
1117 if (AdminsSid != NULL)
1118 {
1119 FreeSid(AdminsSid);
1120 }
1121
1122 if (InteractiveSid != NULL)
1123 {
1125 }
1126
1127 /* HACK */
1128 if (NetworkServiceSid != NULL)
1129 {
1131 }
1132 /* END HACK */
1133
1134 if (Dacl != NULL)
1135 {
1136 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
1137 }
1138
1139 if (RelativeSd != NULL)
1140 {
1141 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
1142 }
1143
1144 return Success;
1145}
#define GENERIC_ACCESS
Definition: security.c:35
#define WINSTA_ADMINS_LIMITED
Definition: security.c:33
#define WINSTA_ALL
Definition: security.c:27
#define CONTAINER_INHERIT_ACE
Definition: setypes.h:747
#define INHERIT_ONLY_ACE
Definition: setypes.h:749
#define OBJECT_INHERIT_ACE
Definition: setypes.h:746
#define NO_PROPAGATE_INHERIT_ACE
Definition: setypes.h:748

Referenced by AllowAccessOnSession().

◆ CallNotificationDlls()

VOID CallNotificationDlls ( PWLSESSION  pSession,
NOTIFICATION_TYPE  Type 
)

Definition at line 530 of file notify.c.

533{
534 PLIST_ENTRY ListEntry;
536
537 /* Check for invalid notification type */
539
540 TRACE("CallNotificationDlls(%s)\n", FuncNames[Type]);
541
542 /* Set up the notification info structure template */
543 Info.Size = sizeof(Info);
544
545 switch (Type)
546 {
547 case LogoffHandler:
548 case ShutdownHandler:
549 Info.Flags = 3;
550 break;
551
552 default:
553 Info.Flags = 0;
554 break;
555 }
556
557 Info.UserName = pSession->UserName;
558 Info.Domain = pSession->Domain;
559 Info.WindowStation = pSession->InteractiveWindowStationName;
560 Info.hToken = pSession->UserToken;
561
562 switch (Type)
563 {
564 case LogonHandler:
566 Info.hDesktop = pSession->ApplicationDesktop;
567 break;
568
570 Info.hDesktop = pSession->ApplicationDesktop;
571 break;
572
573 default:
574 Info.hDesktop = pSession->WinlogonDesktop;
575 break;
576 }
577
578 Info.pStatusCallback = NULL;
579
580 for (ListEntry = NotificationDllListHead.Flink;
581 ListEntry != &NotificationDllListHead;
582 ListEntry = ListEntry->Flink)
583 {
585 CONTAINING_RECORD(ListEntry, NOTIFICATION_ITEM, ListEntry);
586 if (Notification->bEnabled)
588 }
589}
Type
Definition: Type.h:7
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:49
static VOID CallNotificationDll(_In_ PNOTIFICATION_ITEM NotificationDll, _In_ NOTIFICATION_TYPE Type, _In_ PWLX_NOTIFICATION_INFO pInfo)
Definition: notify.c:473
static PSTR FuncNames[LastHandler]
Definition: notify.c:17
#define ASSERT(a)
Definition: mode.c:44
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
HANDLE UserToken
Definition: winlogon.h:237
HDESK WinlogonDesktop
Definition: winlogon.h:234
PWSTR UserName
Definition: winlogon.h:231
PWSTR Domain
Definition: winlogon.h:232
PWSTR InteractiveWindowStationName
Definition: winlogon.h:230
HDESK ApplicationDesktop
Definition: winlogon.h:233
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115

Referenced by DoGenericAction(), HandleLogoff(), HandleLogon(), HandleShutdown(), StartScreenSaver(), and WinMain().

◆ CleanupNotifications()

VOID CleanupNotifications ( VOID  )

Definition at line 593 of file notify.c.

594{
596 {
599 CONTAINING_RECORD(ListEntry, NOTIFICATION_ITEM, ListEntry);
601 }
602}
static VOID DeleteNotification(_In_ PNOTIFICATION_ITEM Notification)
Frees the resources associated to a notification.
Definition: notify.c:155
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964

Referenced by WinMain().

◆ CloseAllDialogWindows()

VOID CloseAllDialogWindows ( VOID  )

Definition at line 95 of file wlx.c.

96{
97 PDIALOG_LIST_ENTRY Current;
98 PLIST_ENTRY ListEntry;
99
100 ListEntry = DialogListHead.Flink;
101 while (ListEntry != &DialogListHead)
102 {
103 Current = CONTAINING_RECORD(ListEntry,
105 Entry);
106
108
109 ListEntry = ListEntry->Flink;
110 }
111}
base of all file and directory entries
Definition: entries.h:83
Definition: wlx.c:16
HWND hWnd
Definition: wlx.c:18
#define PostMessage
Definition: winuser.h:5943
#define WLX_SAS_TYPE_TIMEOUT
Definition: winwlx.h:35
#define WLX_WM_SAS
Definition: winwlx.h:71
static LIST_ENTRY DialogListHead
Definition: wlx.c:26

Referenced by DispatchSAS(), and DoGenericAction().

◆ ConvertToSelfRelative()

PSECURITY_DESCRIPTOR ConvertToSelfRelative ( _In_ PSECURITY_DESCRIPTOR  AbsoluteSd)

Converts an absolute security descriptor to a self-relative format.

Parameters
[in]AbsoluteSdA pointer to an absolute security descriptor to be converted.
Returns
Returns a pointer to a converted security descriptor in self-relative format. If the function fails, NULL is returned otherwise.
Remarks
The function allocates the security descriptor buffer in memory heap, the caller is entirely responsible for freeing such buffer from when it's no longer needed.

Definition at line 64 of file security.c.

66{
67 PSECURITY_DESCRIPTOR RelativeSd;
68 DWORD DescriptorLength = 0;
69
70 /* Determine the size for allocating our buffer */
71 if (MakeSelfRelativeSD(AbsoluteSd, NULL, &DescriptorLength) ||
73 {
74 ERR("ConvertToSelfRelative(): error %lu, expected ERROR_INSUFFICIENT_BUFFER\n", GetLastError());
75 return NULL;
76 }
77
78 /* Allocate the buffer now */
79 RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(),
81 DescriptorLength);
82 if (RelativeSd == NULL)
83 {
84 ERR("ConvertToSelfRelative(): Failed to allocate buffer for relative SD\n");
85 return NULL;
86 }
87
88 /* Convert the security descriptor now */
89 if (!MakeSelfRelativeSD(AbsoluteSd, RelativeSd, &DescriptorLength))
90 {
91 ERR("ConvertToSelfRelative(): Failed to convert the security descriptor to a self relative format (error %lu)\n", GetLastError());
92 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
93 return NULL;
94 }
95
96 return RelativeSd;
97}
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
Definition: sec.c:214

Referenced by AllowDesktopAccessToUser(), AllowWinstaAccessToUser(), CreateApplicationDesktopSecurity(), CreateScreenSaverSecurity(), CreateWinlogonDesktopSecurity(), and CreateWinstaSecurity().

◆ CreateApplicationDesktopSecurity()

BOOL CreateApplicationDesktopSecurity ( _Out_ PSECURITY_DESCRIPTOR ApplicationDesktopSd)

Creates a security descriptor for the default application desktop upon its creation.

Parameters
[out]ApplicationDesktopSdA pointer to a created security descriptor for the application desktop.
Returns
Returns TRUE if the function has successfully created the security descriptor, FALSE otherwise.

Definition at line 360 of file security.c.

362{
364 SECURITY_DESCRIPTOR AbsoluteSd;
365 PSECURITY_DESCRIPTOR RelativeSd = NULL;
366 PSID WinlogonSid = NULL, AdminsSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment in CreateWinstaSecurity for information */
368 PACL Dacl;
369
370 /* Create the Winlogon SID */
372 1,
374 0, 0, 0, 0, 0, 0, 0,
375 &WinlogonSid))
376 {
377 ERR("CreateApplicationDesktopSecurity(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
378 return FALSE;
379 }
380
381 /* Create the admins SID */
383 2,
386 0, 0, 0, 0, 0, 0,
387 &AdminsSid))
388 {
389 ERR("CreateApplicationDesktopSecurity(): Failed to create the admins SID (error code %lu)\n", GetLastError());
390 goto Quit;
391 }
392
393 /* HACK: Create the network service SID */
395 1,
397 0, 0, 0, 0, 0, 0, 0,
399 {
400 ERR("CreateApplicationDesktopSecurity(): Failed to create the network service SID (error code %lu)\n", GetLastError());
401 goto Quit;
402 }
403
404 /*
405 * Build up the DACL size. This includes a number
406 * of two ACEs of two different SIDs. The first ACE
407 * gives full access to Winlogon, the last one gives
408 * limited desktop access to admins.
409 */
410 DaclSize = sizeof(ACL) +
411 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
412 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
413 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(NetworkServiceSid); /* HACK */
414
415 /* Allocate the DACL now */
416 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
418 DaclSize);
419 if (Dacl == NULL)
420 {
421 ERR("CreateApplicationDesktopSecurity(): Failed to allocate memory buffer for DACL!\n");
422 goto Quit;
423 }
424
425 /* Initialize it */
427 {
428 ERR("CreateApplicationDesktopSecurity(): Failed to initialize DACL (error code %lu)\n", GetLastError());
429 goto Quit;
430 }
431
432 /* First ACE -- Give full desktop power to Winlogon */
435 0,
437 WinlogonSid))
438 {
439 ERR("CreateApplicationDesktopSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
440 goto Quit;
441 }
442
443 /* Second ACE -- Give limited desktop power to admins */
446 0,
448 AdminsSid))
449 {
450 ERR("CreateApplicationDesktopSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
451 goto Quit;
452 }
453
454 /* HACK: Third ACE -- Give full desktop power to network services */
457 0,
460 {
461 ERR("CreateApplicationDesktopSecurity(): Failed to set ACE for network services (error code %lu)\n", GetLastError());
462 goto Quit;
463 }
464
465 /* Initialize the security descriptor */
467 {
468 ERR("CreateApplicationDesktopSecurity(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
469 goto Quit;
470 }
471
472 /* Set the DACL to the descriptor */
473 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
474 {
475 ERR("CreateApplicationDesktopSecurity(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
476 goto Quit;
477 }
478
479 /* Conver it to self-relative format */
480 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
481 if (RelativeSd == NULL)
482 {
483 ERR("CreateApplicationDesktopSecurity(): Failed to convert security descriptor to self relative format!\n");
484 goto Quit;
485 }
486
487 /* Give the descriptor to the caller */
488 *ApplicationDesktopSd = RelativeSd;
489 Success = TRUE;
490
491Quit:
492 if (WinlogonSid != NULL)
493 {
494 FreeSid(WinlogonSid);
495 }
496
497 if (AdminsSid != NULL)
498 {
499 FreeSid(AdminsSid);
500 }
501
502 /* HACK */
503 if (NetworkServiceSid != NULL)
504 {
506 }
507 /* END HACK */
508
509 if (Dacl != NULL)
510 {
511 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
512 }
513
514 if (Success == FALSE)
515 {
516 if (RelativeSd != NULL)
517 {
518 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
519 }
520 }
521
522 return Success;
523}

Referenced by CreateWindowStationAndDesktops().

◆ CreateScreenSaverSecurity()

BOOL CreateScreenSaverSecurity ( _Out_ PSECURITY_DESCRIPTOR ScreenSaverDesktopSd)

Creates a security descriptor for the screen saver desktop.

Parameters
[out]ScreenSaverDesktopSdA pointer to a created security descriptor for the screen-saver desktop.
Returns
Returns TRUE if the function has successfully created the security descriptor, FALSE otherwise.

Definition at line 691 of file security.c.

693{
695 SECURITY_DESCRIPTOR AbsoluteSd;
696 PSECURITY_DESCRIPTOR RelativeSd = NULL;
697 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL;
699 PACL Dacl;
700
701 /* Create the Winlogon SID */
703 1,
705 0, 0, 0, 0, 0, 0, 0,
706 &WinlogonSid))
707 {
708 ERR("CreateScreenSaverSecurity(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
709 return FALSE;
710 }
711
712 /* Create the admins SID */
714 2,
717 0, 0, 0, 0, 0, 0,
718 &AdminsSid))
719 {
720 ERR("CreateScreenSaverSecurity(): Failed to create the admins SID (error code %lu)\n", GetLastError());
721 goto Quit;
722 }
723
724 /* Create the interactive logon SID */
726 1,
728 0, 0, 0, 0, 0, 0, 0,
730 {
731 ERR("CreateScreenSaverSecurity(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
732 goto Quit;
733 }
734
735 /*
736 * Build up the DACL size. This includes a number
737 * of three ACEs of three different SIDs. The first ACE
738 * gives full access to Winlogon, the second one gives
739 * limited desktop access to admins and the last one
740 * gives full desktop access to users who have logged in
741 * interactively.
742 */
743 DaclSize = sizeof(ACL) +
744 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
745 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
747
748 /* Allocate the DACL now */
749 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
751 DaclSize);
752 if (Dacl == NULL)
753 {
754 ERR("CreateScreenSaverSecurity(): Failed to allocate memory buffer for DACL!\n");
755 goto Quit;
756 }
757
758 /* Initialize it */
760 {
761 ERR("CreateScreenSaverSecurity(): Failed to initialize DACL (error code %lu)\n", GetLastError());
762 goto Quit;
763 }
764
765 /* First ACE -- Give full desktop access to Winlogon */
768 0,
770 WinlogonSid))
771 {
772 ERR("CreateScreenSaverSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
773 goto Quit;
774 }
775
776 /* Second ACE -- Give limited desktop access to admins */
781 AdminsSid))
782 {
783 ERR("CreateScreenSaverSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
784 goto Quit;
785 }
786
787 /* Third ACE -- Give full desktop access to interactive logon users */
793 {
794 ERR("CreateScreenSaverSecurity(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
795 goto Quit;
796 }
797
798 /* Initialize the security descriptor */
800 {
801 ERR("CreateScreenSaverSecurity(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
802 goto Quit;
803 }
804
805 /* Set the DACL to the descriptor */
806 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
807 {
808 ERR("CreateScreenSaverSecurity(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
809 goto Quit;
810 }
811
812 /* Conver it to self-relative format */
813 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
814 if (RelativeSd == NULL)
815 {
816 ERR("CreateScreenSaverSecurity(): Failed to convert security descriptor to self relative format!\n");
817 goto Quit;
818 }
819
820 /* Give the descriptor to the caller */
821 *ScreenSaverDesktopSd = RelativeSd;
822 Success = TRUE;
823
824Quit:
825 if (WinlogonSid != NULL)
826 {
827 FreeSid(WinlogonSid);
828 }
829
830 if (AdminsSid != NULL)
831 {
832 FreeSid(AdminsSid);
833 }
834
835 if (InteractiveSid != NULL)
836 {
838 }
839
840 if (Dacl != NULL)
841 {
842 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
843 }
844
845 if (Success == FALSE)
846 {
847 if (RelativeSd != NULL)
848 {
849 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
850 }
851 }
852
853 return Success;
854}
#define DESKTOP_INTERACTIVE_LIMITED
Definition: security.c:22

Referenced by CreateWindowStationAndDesktops().

◆ CreateUserEnvironment()

BOOL CreateUserEnvironment ( IN PWLSESSION  Session)

Definition at line 128 of file environment.c.

130{
131 HKEY hKeyCurrentUser;
132 LONG lError;
133
134 TRACE("WL: CreateUserEnvironment called\n");
135
136 /* Impersonate the new user */
137 if (!ImpersonateLoggedOnUser(Session->UserToken))
138 {
139 ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
140 return FALSE;
141 }
142
143 /* Open the new user HKCU key */
145 &hKeyCurrentUser);
146 if (lError == ERROR_SUCCESS)
147 {
149 hKeyCurrentUser);
150 RegCloseKey(hKeyCurrentUser);
151 }
152
153 /* Revert the impersonation */
154 RevertToSelf();
155
156 TRACE("WL: CreateUserEnvironment done\n");
157
158 return TRUE;
159}
static VOID BuildVolatileEnvironment(IN PWLSESSION Session, IN HKEY hKeyCurrentUser)
Definition: environment.c:19
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
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
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1021
long LONG
Definition: pedump.c:60

Referenced by HandleLogon().

◆ CreateWindowStationAndDesktops()

BOOL CreateWindowStationAndDesktops ( _Inout_ PWLSESSION  Session)

Definition at line 953 of file wlx.c.

955{
956 SECURITY_ATTRIBUTES WinstaSecurity;
957 SECURITY_ATTRIBUTES ApplicationDesktopSecurity;
958 SECURITY_ATTRIBUTES WinlogonDesktopSecurity;
959 SECURITY_ATTRIBUTES ScreenSaverDesktopSecurity;
960 PSECURITY_DESCRIPTOR WlWinstaSecurityDescriptor;
961 PSECURITY_DESCRIPTOR WlApplicationDesktopSecurityDescriptor;
962 PSECURITY_DESCRIPTOR WlWinlogonDesktopSecurityDescriptor;
963 PSECURITY_DESCRIPTOR WlScreenSaverDesktopSecurityDescriptor;
964 BOOL ret = FALSE;
965
966 if (!CreateWinstaSecurity(&WlWinstaSecurityDescriptor))
967 {
968 ERR("WL: Failed to create winsta security!\n");
969 return ret;
970 }
971
972 WinstaSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
973 WinstaSecurity.lpSecurityDescriptor = WlWinstaSecurityDescriptor;
974 WinstaSecurity.bInheritHandle = TRUE;
975
976 if (!CreateApplicationDesktopSecurity(&WlApplicationDesktopSecurityDescriptor))
977 {
978 ERR("WL: Failed to create application desktop security!\n");
979 goto cleanup;
980 }
981
982 ApplicationDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
983 ApplicationDesktopSecurity.lpSecurityDescriptor = WlApplicationDesktopSecurityDescriptor;
984 ApplicationDesktopSecurity.bInheritHandle = TRUE;
985
986 if (!CreateWinlogonDesktopSecurity(&WlWinlogonDesktopSecurityDescriptor))
987 {
988 ERR("WL: Failed to create winlogon desktop security!\n");
989 goto cleanup;
990 }
991
992 WinlogonDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
993 WinlogonDesktopSecurity.lpSecurityDescriptor = WlWinlogonDesktopSecurityDescriptor;
994 WinlogonDesktopSecurity.bInheritHandle = FALSE;
995
996 if (!CreateScreenSaverSecurity(&WlScreenSaverDesktopSecurityDescriptor))
997 {
998 ERR("WL: Failed to create winlogon desktop security!\n");
999 goto cleanup;
1000 }
1001
1002 ScreenSaverDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
1003 ScreenSaverDesktopSecurity.lpSecurityDescriptor = WlScreenSaverDesktopSecurityDescriptor;
1004 ScreenSaverDesktopSecurity.bInheritHandle = TRUE;
1005
1006 /*
1007 * Create the interactive window station
1008 */
1009 Session->InteractiveWindowStationName = L"WinSta0";
1010 Session->InteractiveWindowStation = CreateWindowStationW(
1011 Session->InteractiveWindowStationName,
1012 0,
1014 &WinstaSecurity);
1015 if (!Session->InteractiveWindowStation)
1016 {
1017 ERR("WL: Failed to create window station (%lu)\n", GetLastError());
1018 goto cleanup;
1019 }
1020
1021 if (!SetProcessWindowStation(Session->InteractiveWindowStation))
1022 {
1023 ERR("WL: SetProcessWindowStation() failed (error %lu)\n", GetLastError());
1024 goto cleanup;
1025 }
1026
1027 /*
1028 * Create the application desktop
1029 */
1030 Session->ApplicationDesktop = CreateDesktopW(
1031 L"Default",
1032 NULL,
1033 NULL,
1034 0, /* FIXME: Add DF_ALLOWOTHERACCOUNTHOOK flag? */
1036 &ApplicationDesktopSecurity);
1037 if (!Session->ApplicationDesktop)
1038 {
1039 ERR("WL: Failed to create Default desktop (%lu)\n", GetLastError());
1040 goto cleanup;
1041 }
1042
1043 /*
1044 * Create the winlogon desktop
1045 */
1046 Session->WinlogonDesktop = CreateDesktopW(
1047 L"Winlogon",
1048 NULL,
1049 NULL,
1050 0,
1052 &WinlogonDesktopSecurity);
1053 if (!Session->WinlogonDesktop)
1054 {
1055 ERR("WL: Failed to create Winlogon desktop (%lu)\n", GetLastError());
1056 goto cleanup;
1057 }
1058
1059 /*
1060 * Create the screen saver desktop
1061 */
1062 Session->ScreenSaverDesktop = CreateDesktopW(
1063 L"Screen-Saver",
1064 NULL,
1065 NULL,
1066 0,
1068 &ScreenSaverDesktopSecurity);
1069 if(!Session->ScreenSaverDesktop)
1070 {
1071 ERR("WL: Failed to create Screen-Saver desktop (%lu)\n", GetLastError());
1072 goto cleanup;
1073 }
1074
1075 /*
1076 * Switch to winlogon desktop
1077 */
1078 if (!SetThreadDesktop(Session->WinlogonDesktop) ||
1079 !SwitchDesktop(Session->WinlogonDesktop))
1080 {
1081 ERR("WL: Cannot switch to Winlogon desktop (%lu)\n", GetLastError());
1082 goto cleanup;
1083 }
1084
1085 SetWindowStationUser(Session->InteractiveWindowStation,
1086 &LuidNone, NULL, 0);
1087
1088 ret = TRUE;
1089
1090cleanup:
1091 if (!ret)
1092 {
1093 if (Session->ApplicationDesktop)
1094 {
1095 CloseDesktop(Session->ApplicationDesktop);
1096 Session->ApplicationDesktop = NULL;
1097 }
1098 if (Session->WinlogonDesktop)
1099 {
1100 CloseDesktop(Session->WinlogonDesktop);
1101 Session->WinlogonDesktop = NULL;
1102 }
1103 if (Session->ScreenSaverDesktop)
1104 {
1105 CloseDesktop(Session->ScreenSaverDesktop);
1106 Session->ScreenSaverDesktop = NULL;
1107 }
1108 if (Session->InteractiveWindowStation)
1109 {
1110 CloseWindowStation(Session->InteractiveWindowStation);
1111 Session->InteractiveWindowStation = NULL;
1112 }
1113 if (WlWinstaSecurityDescriptor)
1114 {
1115 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinstaSecurityDescriptor);
1116 }
1117 if (WlApplicationDesktopSecurityDescriptor)
1118 {
1119 RtlFreeHeap(RtlGetProcessHeap(), 0, WlApplicationDesktopSecurityDescriptor);
1120 }
1121 if (WlWinlogonDesktopSecurityDescriptor)
1122 {
1123 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinlogonDesktopSecurityDescriptor);
1124 }
1125 if (WlScreenSaverDesktopSecurityDescriptor)
1126 {
1127 RtlFreeHeap(RtlGetProcessHeap(), 0, WlScreenSaverDesktopSecurityDescriptor);
1128 }
1129 }
1130
1131 return ret;
1132}
BOOL CreateApplicationDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *ApplicationDesktopSd)
Creates a security descriptor for the default application desktop upon its creation.
Definition: security.c:360
BOOL CreateWinstaSecurity(_Out_ PSECURITY_DESCRIPTOR *WinstaSd)
Creates a security descriptor for the default window station upon its creation.
Definition: security.c:113
BOOL CreateWinlogonDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *WinlogonDesktopSd)
Creates a security descriptor for the default Winlogon desktop. This descriptor serves as a security ...
Definition: security.c:542
BOOL CreateScreenSaverSecurity(_Out_ PSECURITY_DESCRIPTOR *ScreenSaverDesktopSd)
Creates a security descriptor for the screen saver desktop.
Definition: security.c:691
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
static void cleanup(void)
Definition: main.c:1335
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
LUID LuidNone
Definition: sas.c:49
LPVOID lpSecurityDescriptor
Definition: compat.h:193
HDESK WINAPI CreateDesktopW(LPCWSTR lpszDesktop, LPCWSTR lpszDevice, LPDEVMODEW pDevmode, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
Definition: desktop.c:473
BOOL WINAPI SwitchDesktop(_In_ HDESK)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
HWINSTA WINAPI CreateWindowStationW(_In_opt_ LPCWSTR lpwinsta, _In_ DWORD dwFlags, _In_ ACCESS_MASK dwDesiredAccess, _In_opt_ LPSECURITY_ATTRIBUTES lpsa)
BOOL WINAPI CloseWindowStation(_In_ HWINSTA)
BOOL WINAPI SetProcessWindowStation(_In_ HWINSTA)
BOOL WINAPI CloseDesktop(_In_ HDESK)

Referenced by WinMain().

◆ CreateWinlogonDesktopSecurity()

BOOL CreateWinlogonDesktopSecurity ( _Out_ PSECURITY_DESCRIPTOR WinlogonDesktopSd)

Creates a security descriptor for the default Winlogon desktop. This descriptor serves as a security measure for the winlogon desktop so that only Winlogon itself (and admins) can interact with it.

Parameters
[out]WinlogonDesktopSdA pointer to a created security descriptor for the Winlogon desktop.
Returns
Returns TRUE if the function has successfully created the security descriptor, FALSE otherwise.

Definition at line 542 of file security.c.

544{
546 SECURITY_DESCRIPTOR AbsoluteSd;
547 PSECURITY_DESCRIPTOR RelativeSd = NULL;
548 PSID WinlogonSid = NULL, AdminsSid = NULL;
550 PACL Dacl;
551
552 /* Create the Winlogon SID */
554 1,
556 0, 0, 0, 0, 0, 0, 0,
557 &WinlogonSid))
558 {
559 ERR("CreateWinlogonDesktopSecurity(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
560 return FALSE;
561 }
562
563 /* Create the admins SID */
565 2,
568 0, 0, 0, 0, 0, 0,
569 &AdminsSid))
570 {
571 ERR("CreateWinlogonDesktopSecurity(): Failed to create the admins SID (error code %lu)\n", GetLastError());
572 goto Quit;
573 }
574
575 /*
576 * Build up the DACL size. This includes a number
577 * of two ACEs of two different SIDs. The first ACE
578 * gives full access to Winlogon, the last one gives
579 * limited desktop access to admins.
580 */
581 DaclSize = sizeof(ACL) +
582 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
583 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid);
584
585 /* Allocate the DACL now */
586 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
588 DaclSize);
589 if (Dacl == NULL)
590 {
591 ERR("CreateWinlogonDesktopSecurity(): Failed to allocate memory buffer for DACL!\n");
592 goto Quit;
593 }
594
595 /* Initialize it */
597 {
598 ERR("CreateWinlogonDesktopSecurity(): Failed to initialize DACL (error code %lu)\n", GetLastError());
599 goto Quit;
600 }
601
602 /* First ACE -- Give full desktop access to Winlogon */
605 0,
607 WinlogonSid))
608 {
609 ERR("CreateWinlogonDesktopSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
610 goto Quit;
611 }
612
613 /* Second ACE -- Give limited desktop access to admins */
616 0,
618 AdminsSid))
619 {
620 ERR("CreateWinlogonDesktopSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
621 goto Quit;
622 }
623
624 /* Initialize the security descriptor */
626 {
627 ERR("CreateWinlogonDesktopSecurity(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
628 goto Quit;
629 }
630
631 /* Set the DACL to the descriptor */
632 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
633 {
634 ERR("CreateWinlogonDesktopSecurity(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
635 goto Quit;
636 }
637
638 /* Conver it to self-relative format */
639 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
640 if (RelativeSd == NULL)
641 {
642 ERR("CreateWinlogonDesktopSecurity(): Failed to convert security descriptor to self relative format!\n");
643 goto Quit;
644 }
645
646 /* Give the descriptor to the caller */
647 *WinlogonDesktopSd = RelativeSd;
648 Success = TRUE;
649
650Quit:
651 if (WinlogonSid != NULL)
652 {
653 FreeSid(WinlogonSid);
654 }
655
656 if (AdminsSid != NULL)
657 {
658 FreeSid(AdminsSid);
659 }
660
661 if (Dacl != NULL)
662 {
663 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
664 }
665
666 if (Success == FALSE)
667 {
668 if (RelativeSd != NULL)
669 {
670 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
671 }
672 }
673
674 return Success;
675}
#define DESKTOP_WINLOGON_ADMINS_LIMITED
Definition: security.c:25

Referenced by CreateWindowStationAndDesktops().

◆ CreateWinstaSecurity()

BOOL CreateWinstaSecurity ( _Out_ PSECURITY_DESCRIPTOR WinstaSd)

Creates a security descriptor for the default window station upon its creation.

Parameters
[out]WinstaSdA pointer to a created security descriptor for the window station.
Returns
Returns TRUE if the function has successfully created the security descriptor, FALSE otherwise.

Definition at line 113 of file security.c.

115{
117 SECURITY_DESCRIPTOR AbsoluteSd;
118 PSECURITY_DESCRIPTOR RelativeSd = NULL;
119 PSID WinlogonSid = NULL, AdminsSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment below for information */
121 PACL Dacl;
122
123 /* Create the Winlogon SID */
125 1,
127 0, 0, 0, 0, 0, 0, 0,
128 &WinlogonSid))
129 {
130 ERR("CreateWinstaSecurity(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
131 return FALSE;
132 }
133
134 /* Create the admins SID */
136 2,
139 0, 0, 0, 0, 0, 0,
140 &AdminsSid))
141 {
142 ERR("CreateWinstaSecurity(): Failed to create the admins SID (error code %lu)\n", GetLastError());
143 goto Quit;
144 }
145
146 /* HACK: Create the network service SID */
148 1,
150 0, 0, 0, 0, 0, 0, 0,
152 {
153 ERR("CreateWinstaSecurity(): Failed to create the network service SID (error code %lu)\n", GetLastError());
154 goto Quit;
155 }
156
157 /*
158 * Build up the DACL size. This includes a number
159 * of four ACEs of two different SIDs. The first two
160 * ACEs give both window station and generic access
161 * to Winlogon, the last two give limited window station
162 * and desktop access to admins.
163 *
164 * ===================== !!!MUST READ!!! =====================
165 *
166 * HACK -- Include in the DACL two more ACEs for network
167 * service SID. Network services will be granted full
168 * access to the default window station. Whilst technically
169 * services that are either network or local ones are part
170 * and act on behalf of the system, what we are doing here
171 * is a hack because of two reasons:
172 *
173 * 1) Winlogon does not allow default window station (Winsta0)
174 * access to network services on Windows. As a matter of fact,
175 * network services must access their own service window station
176 * (aka Service-0x0-3e4$) which never gets created. Why it never
177 * gets created is explained on the second point.
178 *
179 * 2) Our LSASS terribly lacks in code that handles special logon
180 * service types, NetworkService and LocalService. For this reason
181 * whenever an access token is created for a network service process
182 * for example, its authentication ID (aka LogonId represented as a LUID)
183 * is a uniquely generated ID by LSASS for this process. This is wrong
184 * on so many levels, partly because a network service is not a regular
185 * service and network services have their own special authentication logon
186 * ID (with its respective LUID as {0x3e4, 0x0}). On top of that, a network
187 * service process must have an impersonation token but for whatever reason
188 * we are creating a primary access token instead.
189 *
190 * FOR ANYONE WHO'S INTERESTED ON FIXING THIS, DO NOT FORGET TO REMOVE THIS
191 * HACK!!!
192 *
193 * =========================== !!!END!!! ================================
194 */
195 DaclSize = sizeof(ACL) +
196 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
197 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
198 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
199 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
202
203 /* Allocate the DACL now */
204 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
206 DaclSize);
207 if (Dacl == NULL)
208 {
209 ERR("CreateWinstaSecurity(): Failed to allocate memory buffer for DACL!\n");
210 goto Quit;
211 }
212
213 /* Initialize it */
215 {
216 ERR("CreateWinstaSecurity(): Failed to initialize DACL (error code %lu)\n", GetLastError());
217 goto Quit;
218 }
219
220 /* First ACE -- give full winsta access to Winlogon */
225 WinlogonSid))
226 {
227 ERR("CreateWinstaSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
228 goto Quit;
229 }
230
231 /* Second ACE -- give full generic access to Winlogon */
236 WinlogonSid))
237 {
238 ERR("CreateWinstaSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
239 goto Quit;
240 }
241
242 /* Third ACE -- give limited winsta access to admins */
247 AdminsSid))
248 {
249 ERR("CreateWinstaSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
250 goto Quit;
251 }
252
253 /* Fourth ACE -- give limited desktop access to admins */
258 AdminsSid))
259 {
260 ERR("CreateWinstaSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
261 goto Quit;
262 }
263
264 /* HACK: Fifth ACE -- give full access to network services */
270 {
271 ERR("CreateWinstaSecurity(): Failed to set ACE for network service (error code %lu)\n", GetLastError());
272 goto Quit;
273 }
274
275 /* HACK: Sixth ACE -- give full generic access to network services */
281 {
282 ERR("CreateWinstaSecurity(): Failed to set ACE for network service (error code %lu)\n", GetLastError());
283 goto Quit;
284 }
285
286 /* Initialize the security descriptor */
288 {
289 ERR("CreateWinstaSecurity(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
290 goto Quit;
291 }
292
293 /* Set the DACL to the descriptor */
294 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
295 {
296 ERR("CreateWinstaSecurity(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
297 goto Quit;
298 }
299
300 /* Convert it to self-relative format */
301 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
302 if (RelativeSd == NULL)
303 {
304 ERR("CreateWinstaSecurity(): Failed to convert security descriptor to self relative format!\n");
305 goto Quit;
306 }
307
308 /* Give the descriptor to the caller */
309 *WinstaSd = RelativeSd;
310 Success = TRUE;
311
312Quit:
313 if (WinlogonSid != NULL)
314 {
315 FreeSid(WinlogonSid);
316 }
317
318 if (AdminsSid != NULL)
319 {
320 FreeSid(AdminsSid);
321 }
322
323 /* HACK */
324 if (NetworkServiceSid != NULL)
325 {
327 }
328 /* END HACK */
329
330 if (Dacl != NULL)
331 {
332 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
333 }
334
335 if (Success == FALSE)
336 {
337 if (RelativeSd != NULL)
338 {
339 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
340 }
341 }
342
343 return Success;
344}

Referenced by CreateWindowStationAndDesktops().

◆ DisplayStatusMessage()

BOOL DisplayStatusMessage ( IN PWLSESSION  Session,
IN HDESK  hDesktop,
IN UINT  ResourceId 
)

Definition at line 370 of file winlogon.c.

374{
375 WCHAR StatusMsg[MAX_PATH];
376
377 if (Session->Gina.Version < WLX_VERSION_1_3)
378 return TRUE;
379
380 if (Session->SuppressStatus)
381 return TRUE;
382
383 if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
384 return FALSE;
385
386 return Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, hDesktop, 0, NULL, StatusMsg);
387}
INT ResourceId
Definition: LoadImageGCC.c:72
#define MAX_PATH
Definition: compat.h:34
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
HINSTANCE hAppInstance
Definition: winlogon.c:19
#define WLX_VERSION_1_3
Definition: winwlx.h:31
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by HandleLogoff(), HandleLogon(), HandleShutdown(), and WinMain().

◆ GetSetupType()

DWORD GetSetupType ( VOID  )

Definition at line 16 of file setup.c.

17{
18 DWORD dwError;
19 HKEY hKey;
20 DWORD dwType;
22 DWORD dwSetupType;
23
24 TRACE("GetSetupType()\n");
25
26 /* Open key */
28 L"SYSTEM\\Setup",
29 0,
31 &hKey);
32 if (dwError != ERROR_SUCCESS)
33 return 0;
34
35 /* Read key */
36 dwSize = sizeof(DWORD);
37 dwError = RegQueryValueExW(hKey,
38 L"SetupType",
39 NULL,
40 &dwType,
41 (LPBYTE)&dwSetupType,
42 &dwSize);
43
44 /* Close key, and check if returned values are correct */
46 if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != sizeof(DWORD))
47 return 0;
48
49 TRACE("GetSetupType() returns %lu\n", dwSetupType);
50 return dwSetupType;
51}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:1019
#define REG_DWORD
Definition: sdbapi.c:615
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by SASWindowProc(), and WinMain().

◆ GinaInit()

BOOL GinaInit ( IN OUT PWLSESSION  Session)

Definition at line 930 of file wlx.c.

932{
933 DWORD GinaDllVersion;
934
935 if (!LoadGina(&Session->Gina.Functions, &GinaDllVersion, &Session->Gina.hDllInstance))
936 return FALSE;
937
938 Session->Gina.Context = NULL;
939 Session->Gina.Version = GinaDllVersion;
940 Session->Gina.UseCtrlAltDelete = FALSE;
941 Session->SuppressStatus = FALSE;
942
943 TRACE("Calling WlxInitialize(\"%S\")\n", Session->InteractiveWindowStationName);
944 return Session->Gina.Functions.WlxInitialize(
945 Session->InteractiveWindowStationName,
946 (HANDLE)Session,
947 NULL,
949 &Session->Gina.Context);
950}
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:747
static BOOL LoadGina(IN OUT PGINAFUNCTIONS Functions, OUT DWORD *DllVersion, OUT HMODULE *GinaInstance)
Definition: wlx.c:830

Referenced by WinMain().

◆ HandleShutdown()

NTSTATUS HandleShutdown ( IN OUT PWLSESSION  Session,
IN DWORD  wlxAction 
)

Definition at line 1149 of file sas.c.

1152{
1154 UINT uMsgId;
1155 BOOLEAN Old;
1156
1157 /* Display the appropriate shutdown or reboot message */
1158 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1159 uMsgId = IDS_REACTOSISRESTARTING;
1160 else
1162
1163 // SwitchDesktop(Session->WinlogonDesktop);
1164 DisplayStatusMessage(Session, Session->WinlogonDesktop, uMsgId);
1165
1166 /* Invoke Shutdown notifications and notify GINA */
1168 Session->Gina.Functions.WlxShutdown(Session->Gina.Context, wlxAction);
1169
1170 /* Run the shutdown thread. *IGNORE* all failures as we want to force shutting down! */
1171 Status = RunLogoffShutdownThread(Session, NULL, wlxAction);
1172 if (!NT_SUCCESS(Status))
1173 ERR("Failed to start the Shutdown thread, Status 0x%08lx\n", Status);
1174
1175 /* Show again the shutdown message */
1176 // SwitchDesktop(Session->WinlogonDesktop); // Re-enable if you notice the desktop may have switched to something else.
1177 DisplayStatusMessage(Session, Session->WinlogonDesktop, uMsgId);
1178
1179 /* Destroy SAS window */
1180 UninitializeSAS(Session);
1181
1182 /* Now we can shut down NT */
1183 ERR("Shutting down NT...\n");
1185 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1186 {
1188 }
1189 else
1190 {
1191 if (FALSE)
1192 {
1193 /* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */
1196 }
1197 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF)
1199 else // if (wlxAction == WLX_SAS_ACTION_SHUTDOWN)
1201 }
1203 return STATUS_SUCCESS;
1204}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
HINSTANCE hAppInstance
Definition: mmc.c:23
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:530
#define IDS_REACTOSISSHUTTINGDOWN
Definition: resource.h:33
#define IDD_SHUTDOWNCOMPUTER
Definition: resource.h:9
#define IDS_REACTOSISRESTARTING
Definition: resource.h:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
unsigned int UINT
Definition: ndis.h:50
@ ShutdownReboot
Definition: extypes.h:177
@ ShutdownPowerOff
Definition: extypes.h:178
@ ShutdownNoReboot
Definition: extypes.h:176
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
static INT_PTR CALLBACK ShutdownComputerWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:1103
static NTSTATUS RunLogoffShutdownThread(_In_ PWLSESSION Session, _In_opt_ PSECURITY_ATTRIBUTES psa, _In_ DWORD wlxAction)
Definition: sas.c:779
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1135
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:370
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define DialogBox
Definition: winuser.h:5872

Referenced by DoGenericAction(), and WinMain().

◆ InitDialogListHead()

VOID InitDialogListHead ( VOID  )

Definition at line 31 of file wlx.c.

32{
34}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by WinMain().

◆ InitializeSAS()

BOOL InitializeSAS ( IN OUT PWLSESSION  Session)

Definition at line 1740 of file sas.c.

1742{
1743 WNDCLASSEXW swc;
1744 BOOL ret = FALSE;
1745
1746 if (!SwitchDesktop(Session->WinlogonDesktop))
1747 {
1748 ERR("WL: Failed to switch to winlogon desktop\n");
1749 goto cleanup;
1750 }
1751
1752 /* Register SAS window class */
1753 swc.cbSize = sizeof(WNDCLASSEXW);
1754 swc.style = CS_SAVEBITS;
1756 swc.cbClsExtra = 0;
1757 swc.cbWndExtra = 0;
1758 swc.hInstance = hAppInstance;
1759 swc.hIcon = NULL;
1760 swc.hCursor = NULL;
1761 swc.hbrBackground = NULL;
1762 swc.lpszMenuName = NULL;
1764 swc.hIconSm = NULL;
1765 if (RegisterClassExW(&swc) == 0)
1766 {
1767 ERR("WL: Failed to register SAS window class\n");
1768 goto cleanup;
1769 }
1770
1771 /* Create invisible SAS window */
1772 Session->SASWindow = CreateWindowExW(
1773 0,
1776 WS_POPUP,
1777 0, 0, 0, 0, 0, 0,
1778 hAppInstance, Session);
1779 if (!Session->SASWindow)
1780 {
1781 ERR("WL: Failed to create SAS window\n");
1782 goto cleanup;
1783 }
1784
1785 /* Register SAS window to receive SAS notifications */
1786 if (!SetLogonNotifyWindow(Session->SASWindow))
1787 {
1788 ERR("WL: Failed to register SAS window\n");
1789 goto cleanup;
1790 }
1791
1793 return FALSE;
1794
1795 ret = TRUE;
1796
1797cleanup:
1798 if (!ret)
1799 UninitializeSAS(Session);
1800 return ret;
1801}
#define WS_POPUP
Definition: pedump.c:616
#define WINLOGON_SAS_TITLE
Definition: sas.c:27
#define WINLOGON_SAS_CLASS
Definition: sas.c:26
static LRESULT CALLBACK SASWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:1526
BOOL SetDefaultLanguage(IN PWLSESSION Session)
Definition: sas.c:119
LPCWSTR lpszClassName
Definition: winuser.h:3328
LPCWSTR lpszMenuName
Definition: winuser.h:3327
HBRUSH hbrBackground
Definition: winuser.h:3326
WNDPROC lpfnWndProc
Definition: winuser.h:3320
UINT cbSize
Definition: winuser.h:3318
int cbWndExtra
Definition: winuser.h:3322
HCURSOR hCursor
Definition: winuser.h:3325
HICON hIconSm
Definition: winuser.h:3329
HINSTANCE hInstance
Definition: winuser.h:3323
UINT style
Definition: winuser.h:3319
int cbClsExtra
Definition: winuser.h:3321
HICON hIcon
Definition: winuser.h:3324
BOOL WINAPI SetLogonNotifyWindow(HWND Wnd)
Definition: logon.c:91
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define CS_SAVEBITS
Definition: winuser.h:665
struct _WNDCLASSEXW WNDCLASSEXW

Referenced by WinMain().

◆ InitializeScreenSaver()

BOOL InitializeScreenSaver ( IN OUT PWLSESSION  Session)

Definition at line 205 of file screensaver.c.

207{
208 HANDLE ScreenSaverThread;
209
210#ifndef USE_GETLASTINPUTINFO
211 /* Register hooks to detect keyboard and mouse activity */
212 Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardActivityProc, hAppInstance, 0);
213 if (!Session->KeyboardHook)
214 {
215 ERR("WL: Unable to register keyboard hook\n");
216 return FALSE;
217 }
218
219 Session->MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseActivityProc, hAppInstance, 0);
220 if (!Session->MouseHook)
221 {
222 ERR("WL: Unable to register mouse hook\n");
223 return FALSE;
224 }
225#endif
226
227 Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, FALSE, NULL);
228 if (!Session->hScreenSaverParametersChanged)
229 {
230 WARN("WL: Unable to create screen saver event (error %lu)\n", GetLastError());
231 return TRUE;
232 }
233
234 Session->hEndOfScreenSaverThread = CreateEventW(NULL, FALSE, FALSE, NULL);
235 if (!Session->hEndOfScreenSaverThread)
236 {
237 WARN("WL: Unable to create screen saver event (error %lu)\n", GetLastError());
238 CloseHandle(Session->hScreenSaverParametersChanged);
239 return TRUE;
240 }
241
242 ScreenSaverThread = CreateThread(NULL,
243 0,
245 Session,
246 0,
247 NULL);
248 if (ScreenSaverThread)
249 CloseHandle(ScreenSaverThread);
250 else
251 ERR("WL: Unable to start screen saver thread\n");
252
253 return TRUE;
254}
#define WARN(fmt,...)
Definition: precomp.h:61
static DWORD WINAPI ScreenSaverThreadMain(IN LPVOID lpParameter)
Definition: screensaver.c:77
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define SetWindowsHookEx
Definition: winuser.h:5967
#define WH_MOUSE_LL
Definition: winuser.h:44
#define WH_KEYBOARD_LL
Definition: winuser.h:43

Referenced by HandleLogon().

◆ InitNotifications()

BOOL InitNotifications ( VOID  )

Definition at line 420 of file notify.c.

421{
422 HKEY hNotifyKey = NULL;
423 LONG lError;
424 DWORD dwIndex;
425 DWORD dwKeyName;
426 WCHAR szKeyName[80];
427
428 TRACE("InitNotifications()\n");
429
431
433
435 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
436 0,
437 KEY_READ,
438 &hNotifyKey);
439 if (lError != ERROR_SUCCESS)
440 {
441 TRACE("RegOpenKeyExW()\n");
442 return TRUE;
443 }
444
445 for (dwIndex = 0; ; ++dwIndex)
446 {
447 dwKeyName = ARRAYSIZE(szKeyName);
448 lError = RegEnumKeyExW(hNotifyKey,
449 dwIndex,
450 szKeyName,
451 &dwKeyName,
452 NULL,
453 NULL,
454 NULL,
455 NULL);
456 if (lError != ERROR_SUCCESS)
457 break;
458
459 TRACE("Notification DLL: %S\n", szKeyName);
460 AddNotificationDll(hNotifyKey, szKeyName);
461 }
462
463 RegCloseKey(hNotifyKey);
464
465 TRACE("InitNotifications() done\n");
466
467 return TRUE;
468}
static VOID AddNotificationDll(_In_ HKEY hNotifyKey, _In_ PCWSTR pszKeyName)
Definition: notify.c:235
static VOID AddSfcNotification(VOID)
Initializes the internal SFC notifications.
Definition: notify.c:176
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define KEY_READ
Definition: nt_native.h:1026

Referenced by WinMain().

◆ IsFirstLogon()

FORCEINLINE BOOL IsFirstLogon ( _In_ PWLSESSION  Session)

Definition at line 306 of file winlogon.h.

308{
309 /* The WLSESSION::LastLogon is initialized to 0 so this is OK */
310 return (Session->LastLogon.QuadPart == 0);
311}

Referenced by PlayLogonSound().

◆ PlaySoundRoutine()

BOOL PlaySoundRoutine ( IN LPCWSTR  FileName,
IN UINT  Logon,
IN UINT  Flags 
)

Definition at line 248 of file sas.c.

252{
253 typedef BOOL (WINAPI *PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
254 typedef UINT (WINAPI *WAVEOUTGETNUMDEVS)(VOID);
255 PLAYSOUNDW Play;
256 WAVEOUTGETNUMDEVS waveOutGetNumDevs;
257 UINT NumDevs;
259 BOOL Ret = FALSE;
260
261 hLibrary = LoadLibraryW(L"winmm.dll");
262 if (!hLibrary)
263 return FALSE;
264
265 waveOutGetNumDevs = (WAVEOUTGETNUMDEVS)GetProcAddress(hLibrary, "waveOutGetNumDevs");
266 Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
267
269 {
271 {
272 NumDevs = waveOutGetNumDevs();
273 if (!NumDevs)
274 {
275 if (!bLogon)
276 Beep(440, 125);
278 }
279 }
280
281 if (Play)
282 Ret = Play(FileName, NULL, Flags);
283 }
285 {
286 ERR("WL: Exception while playing sound '%S', Status 0x%08lx\n",
288 }
289 _SEH2_END;
290
292
293 return Ret;
294}
#define VOID
Definition: acefi.h:82
HMODULE hLibrary
Definition: odbccp32.c:12
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define BOOL
Definition: nt_native.h:43
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_LEAVE
Definition: pseh2_64.h:183
HANDLE HMODULE
Definition: typedefs.h:77
#define WINAPI
Definition: msvc.h:6
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2137
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by PlayEventSound(), PlayLogoffShutdownSound(), and PlayLogonSoundThread().

◆ RemoveStatusMessage()

BOOL RemoveStatusMessage ( IN PWLSESSION  Session)

Definition at line 391 of file winlogon.c.

393{
394 if (Session->Gina.Version < WLX_VERSION_1_3)
395 return TRUE;
396
397 return Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
398}

Referenced by DoGenericAction(), HandleLogoff(), HandleLogon(), and WinMain().

◆ RunSetup()

BOOL RunSetup ( VOID  )

Definition at line 153 of file setup.c.

154{
156
158 0,
160 NULL,
161 0,
162 NULL);
163 if (hThread != NULL)
165
166 return hThread != NULL;
167}
static DWORD WINAPI RunSetupThreadProc(IN LPVOID lpParameter)
Definition: setup.c:57
HANDLE hThread
Definition: wizard.c:28

Referenced by WinMain().

◆ SetDefaultLanguage()

BOOL SetDefaultLanguage ( IN PWLSESSION  Session)

Definition at line 119 of file sas.c.

121{
122 BOOL ret = FALSE;
123 BOOL UserProfile;
124 LONG rc;
125 HKEY UserKey, hKey = NULL;
126 LPCWSTR SubKey, ValueName;
127 DWORD dwType, dwSize;
128 LPWSTR Value = NULL;
129 UNICODE_STRING ValueString;
131 LCID Lcid;
132
133 UserProfile = (Session && Session->UserToken);
134
135 if (UserProfile && !ImpersonateLoggedOnUser(Session->UserToken))
136 {
137 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
138 return FALSE;
139 // FIXME: ... or use the default language of the system??
140 // UserProfile = FALSE;
141 }
142
143 if (UserProfile)
144 {
145 rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &UserKey);
146 if (rc != ERROR_SUCCESS)
147 {
148 TRACE("RegOpenCurrentUser() failed with error %lu\n", rc);
149 goto cleanup;
150 }
151
152 SubKey = L"Control Panel\\International";
153 ValueName = L"Locale";
154 }
155 else
156 {
157 UserKey = NULL;
158 SubKey = L"System\\CurrentControlSet\\Control\\Nls\\Language";
159 ValueName = L"Default";
160 }
161
162 rc = RegOpenKeyExW(UserKey ? UserKey : HKEY_LOCAL_MACHINE,
163 SubKey,
164 0,
165 KEY_READ,
166 &hKey);
167
168 if (UserKey)
169 RegCloseKey(UserKey);
170
171 if (rc != ERROR_SUCCESS)
172 {
173 TRACE("RegOpenKeyEx() failed with error %lu\n", rc);
174 goto cleanup;
175 }
176
178 ValueName,
179 NULL,
180 &dwType,
181 NULL,
182 &dwSize);
183 if (rc != ERROR_SUCCESS)
184 {
185 TRACE("RegQueryValueEx() failed with error %lu\n", rc);
186 goto cleanup;
187 }
188 else if (dwType != REG_SZ)
189 {
190 TRACE("Wrong type for %S\\%S registry entry (got 0x%lx, expected 0x%x)\n",
191 SubKey, ValueName, dwType, REG_SZ);
192 goto cleanup;
193 }
194
196 if (!Value)
197 {
198 TRACE("HeapAlloc() failed\n");
199 goto cleanup;
200 }
202 ValueName,
203 NULL,
204 NULL,
205 (LPBYTE)Value,
206 &dwSize);
207 if (rc != ERROR_SUCCESS)
208 {
209 TRACE("RegQueryValueEx() failed with error %lu\n", rc);
210 goto cleanup;
211 }
212
213 /* Convert Value to a Lcid */
214 ValueString.Length = ValueString.MaximumLength = (USHORT)dwSize;
215 ValueString.Buffer = Value;
216 Status = RtlUnicodeStringToInteger(&ValueString, 16, (PULONG)&Lcid);
217 if (!NT_SUCCESS(Status))
218 {
219 TRACE("RtlUnicodeStringToInteger() failed with status 0x%08lx\n", Status);
220 goto cleanup;
221 }
222
223 TRACE("%s language is 0x%08lx\n",
224 UserProfile ? "User" : "System", Lcid);
225 Status = NtSetDefaultLocale(UserProfile, Lcid);
226 if (!NT_SUCCESS(Status))
227 {
228 TRACE("NtSetDefaultLocale() failed with status 0x%08lx\n", Status);
229 goto cleanup;
230 }
231
232 ret = TRUE;
233
234cleanup:
235 if (Value)
237
238 if (hKey)
240
241 if (UserProfile)
242 RevertToSelf();
243
244 return ret;
245}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
NTSTATUS NTAPI NtSetDefaultLocale(IN BOOLEAN UserProfile, IN LCID DefaultLocaleId)
Definition: locale.c:437
unsigned short USHORT
Definition: pedump.c:61
DWORD LCID
Definition: nls.h:13
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t * PULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ CONST DEVPROPKEY _In_ LCID Lcid
Definition: iofuncs.h:2415
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by HandleLogon(), and InitializeSAS().

◆ SetLogonTimestamp()

FORCEINLINE VOID SetLogonTimestamp ( _Inout_ PWLSESSION  Session)

Definition at line 298 of file winlogon.h.

300{
301 NtQuerySystemTime(&Session->LastLogon);
302}
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:569

Referenced by HandleLogon().

◆ SetWindowStationUser()

BOOL WINAPI SetWindowStationUser ( IN HWINSTA  hWindowStation,
IN PLUID  pluid,
IN PSID psid  OPTIONAL,
IN DWORD  size 
)

Definition at line 419 of file winsta.c.

424{
426
427 Success = NtUserSetWindowStationUser(hWindowStation, pluid, psid, size);
428 if (Success)
429 {
430 /* Signal log-on/off to WINSRV */
431
432 /* User is logging on if *pluid != LuidNone, otherwise it is a log-off */
433 LUID LuidNone = {0, 0};
434 BOOL IsLogon = (pluid && !RtlEqualLuid(pluid, &LuidNone));
435
436 Logon(IsLogon);
437 }
438
439 return Success;
440}
GLsizeiptr size
Definition: glext.h:5919
BOOL NTAPI NtUserSetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:2012
VOID FASTCALL Logon(BOOL IsLogon)
Definition: logon.c:74
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304

Referenced by AllowAccessOnSession(), CreateWindowStationAndDesktops(), HandleLogoff(), and HandleLogon().

◆ StartRpcServer()

BOOL StartRpcServer ( VOID  )

Definition at line 32 of file rpcserver.c.

33{
35
36 Status = lpServiceGlobals->StartRpcServer(L"seclogon", ISeclogon_v1_0_s_ifspec);
37 TRACE("StartRpcServer returned 0x%08lx\n", Status);
38
40}
PSVCHOST_GLOBAL_DATA lpServiceGlobals
Definition: browser.c:18
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
PSTART_RPC_SERVER StartRpcServer
Definition: svc.h:114

◆ StartScreenSaver()

VOID StartScreenSaver ( IN PWLSESSION  Session)

Definition at line 258 of file screensaver.c.

260{
261 HKEY hKey = NULL, hCurrentUser = NULL;
262 WCHAR szApplicationName[MAX_PATH];
263 WCHAR szCommandLine[MAX_PATH + 3];
264 DWORD bufferSize = sizeof(szApplicationName) - sizeof(WCHAR);
265 DWORD dwType;
266 STARTUPINFOW StartupInfo;
267 PROCESS_INFORMATION ProcessInformation;
268 HANDLE HandleArray[2];
269 LONG rc;
271 BOOL ret = FALSE;
272
273 if (!ImpersonateLoggedOnUser(Session->UserToken))
274 {
275 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
276 goto cleanup;
277 }
278
280 &hCurrentUser);
281 if (rc != ERROR_SUCCESS)
282 {
283 ERR("WL: RegOpenCurrentUser error %lu\n", rc);
284 goto cleanup;
285 }
286
287 rc = RegOpenKeyExW(hCurrentUser,
288 L"Control Panel\\Desktop",
289 0,
291 &hKey);
292 if (rc != ERROR_SUCCESS)
293 {
294 ERR("WL: RegOpenKeyEx error %lu\n", rc);
295 goto cleanup;
296 }
297
299 L"SCRNSAVE.EXE",
300 0,
301 &dwType,
302 (LPBYTE)szApplicationName,
303 &bufferSize);
304 if (rc != ERROR_SUCCESS || dwType != REG_SZ)
305 {
306 if (rc != ERROR_FILE_NOT_FOUND)
307 ERR("WL: RegQueryValueEx error %lu\n", rc);
308 goto cleanup;
309 }
310
311 if (bufferSize == 0)
312 {
313 ERR("WL: Buffer size is NULL!\n");
314 goto cleanup;
315 }
316
317 szApplicationName[bufferSize / sizeof(WCHAR)] = 0; /* Terminate the string */
318
319 if (wcslen(szApplicationName) == 0)
320 {
321 ERR("WL: Application Name length is zero!\n");
322 goto cleanup;
323 }
324
325 wsprintfW(szCommandLine, L"%s /s", szApplicationName);
326 TRACE("WL: Executing %S\n", szCommandLine);
327
328 ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
329 ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
330 StartupInfo.cb = sizeof(STARTUPINFOW);
331 StartupInfo.dwFlags = STARTF_SCREENSAVER;
332
333 /* FIXME: Run the screen saver on the secure screen saver desktop if required */
334 StartupInfo.lpDesktop = L"WinSta0\\Default";
335
336 ret = CreateProcessAsUserW(Session->UserToken,
337 szApplicationName,
338 szCommandLine,
339 NULL,
340 NULL,
341 FALSE,
343 NULL,
344 NULL,
345 &StartupInfo,
346 &ProcessInformation);
347 if (!ret)
348 {
349 ERR("WL: Unable to start %S, error %lu\n", szApplicationName, GetLastError());
350 goto cleanup;
351 }
352
353 CloseHandle(ProcessInformation.hThread);
354
355 SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0);
356
358
359 /* Wait the end of the process or some other activity */
360 ResetEvent(Session->hUserActivity);
361 HandleArray[0] = ProcessInformation.hProcess;
362 HandleArray[1] = Session->hUserActivity;
363 Status = WaitForMultipleObjects(2, HandleArray, FALSE, INFINITE);
364 if (Status == WAIT_OBJECT_0 + 1)
365 {
366 /* Kill the screen saver */
367 TerminateProcess(ProcessInformation.hProcess, 0);
368 }
369
370 SetEvent(Session->hEndOfScreenSaver);
371
372 CloseHandle(ProcessInformation.hProcess);
373
375
376cleanup:
377 if (hKey)
379
380 if (hCurrentUser)
381 RegCloseKey(hCurrentUser);
382
383 RevertToSelf();
384
385 if (!ret)
386 {
388#ifndef USE_GETLASTINPUTINFO
389 InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());
390#endif
391 }
392}
#define InterlockedExchange
Definition: armddk.h:54
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 TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1534
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
#define INFINITE
Definition: serial.h:102
size_t bufferSize
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ZeroMemory
Definition: minwinbase.h:31
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
struct _STARTUPINFOW STARTUPINFOW
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define STARTF_SCREENSAVER
Definition: undocuser.h:167
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:186
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WLX_SAS_TYPE_SCRNSVR_ACTIVITY
Definition: winwlx.h:38

Referenced by DispatchSAS().

◆ StartSystemShutdown()

DWORD StartSystemShutdown ( IN PUNICODE_STRING  pMessage,
IN ULONG  dwTimeout,
IN BOOLEAN  bForceAppsClosed,
IN BOOLEAN  bRebootAfterShutdown,
IN ULONG  dwReason 
)

Definition at line 337 of file shutdown.c.

343{
345
346 /* Fail if the timeout is 10 years or more */
347 if (dwTimeout >= SECONDS_PER_DECADE)
349
352
353 if ((dwTimeout != 0) && pMessage && pMessage->Length && pMessage->Buffer)
354 {
357 pMessage->Length + sizeof(UNICODE_NULL));
359 {
361 return GetLastError();
362 }
363
365 pMessage->Buffer,
366 pMessage->Length / sizeof(WCHAR));
367 }
368 else
369 {
371 }
372
373 g_ShutdownParams.dwTimeout = dwTimeout;
374 g_ShutdownParams.bForceAppsClosed = bForceAppsClosed;
375 g_ShutdownParams.bRebootAfterShutdown = bRebootAfterShutdown;
377
378 /* If dwTimeout is zero perform an immediate system shutdown,
379 * otherwise display the countdown shutdown dialog. */
381 {
383 return ERROR_SUCCESS;
384 }
385 else
386 {
389 if (hThread)
390 {
392 return ERROR_SUCCESS;
393 }
394 }
395
397 {
400 }
401
403 return GetLastError();
404}
DWORD dwReason
Definition: misc.cpp:135
#define SECONDS_PER_DECADE
Definition: shutdown.c:22
static BOOL DoSystemShutdown(IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
Definition: shutdown.c:49
static DWORD WINAPI InitiateSystemShutdownThread(IN LPVOID lpParameter)
Definition: shutdown.c:231
SYS_SHUTDOWN_PARAMS g_ShutdownParams
Definition: shutdown.c:43
wcsncpy
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
char _InterlockedCompareExchange8(_Interlocked_operand_ char volatile *_Destination, char _Exchange, char _Comparand)
#define UNICODE_NULL
BOOLEAN bShuttingDown
Definition: shutdown.c:35
BOOLEAN bForceAppsClosed
Definition: shutdown.c:37
BOOLEAN bRebootAfterShutdown
Definition: shutdown.c:36
#define ERROR_SHUTDOWN_IN_PROGRESS
Definition: winerror.h:975

Referenced by BaseInitiateSystemShutdownEx().

◆ TerminateSystemShutdown()

DWORD TerminateSystemShutdown ( VOID  )

Definition at line 328 of file shutdown.c.

329{
332
333 return ERROR_SUCCESS;
334}
#define ERROR_NO_SHUTDOWN_IN_PROGRESS
Definition: winerror.h:976

Referenced by BaseAbortSystemShutdown().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( winlogon  )

◆ WlStrDup()

PWSTR WlStrDup ( _In_opt_ PCWSTR  String)

Duplicates the given string, allocating a buffer on the heap.

Definition at line 29 of file winlogon.c.

31{
32 PWSTR ptr;
33
34 if (!String)
35 return NULL;
36
37 ptr = RtlAllocateHeap(RtlGetProcessHeap(), 0,
38 (wcslen(String) + 1) * sizeof(WCHAR));
39 if (ptr)
41 return ptr;
42}
wcscpy
static PVOID ptr
Definition: dispmode.c:27
uint16_t * PWSTR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439

Referenced by AddNotificationDll(), AddSfcNotification(), and HandleLogon().

◆ WlxAssignShellProtection()

int WINAPI WlxAssignShellProtection ( HANDLE  hWlx,
HANDLE  hToken,
HANDLE  hProcess,
HANDLE  hThread 
)

Definition at line 265 of file wlx.c.

270{
275
277 return 0;
278}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

◆ WlxChangePasswordNotify()

int WINAPI WlxChangePasswordNotify ( HANDLE  hWlx,
PWLX_MPR_NOTIFY_INFO  pMprInfo,
DWORD  dwChangeInfo 
)

Definition at line 448 of file wlx.c.

452{
454 UNREFERENCED_PARAMETER(pMprInfo);
455 UNREFERENCED_PARAMETER(dwChangeInfo);
456
458 return 0;
459}

◆ WlxChangePasswordNotifyEx()

int WINAPI WlxChangePasswordNotifyEx ( HANDLE  hWlx,
PWLX_MPR_NOTIFY_INFO  pMprInfo,
DWORD  dwChangeInfo,
PWSTR  ProviderName,
PVOID  Reserved 
)

Definition at line 520 of file wlx.c.

526{
528 UNREFERENCED_PARAMETER(pMprInfo);
529 UNREFERENCED_PARAMETER(dwChangeInfo);
530 UNREFERENCED_PARAMETER(ProviderName);
532
534 return 0;
535}
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

◆ WlxCloseUserDesktop()

BOOL WINAPI WlxCloseUserDesktop ( HANDLE  hWlx,
PWLX_DESKTOP  pDesktop,
HANDLE  hToken 
)

Definition at line 542 of file wlx.c.

546{
548 UNREFERENCED_PARAMETER(pDesktop);
550
552 return FALSE;
553}

◆ WlxCreateUserDesktop()

BOOL WINAPI WlxCreateUserDesktop ( HANDLE  hWlx,
HANDLE  hToken,
DWORD  Flags,
PWSTR  pszDesktopName,
PWLX_DESKTOP ppDesktop 
)

Definition at line 498 of file wlx.c.

504{
508 UNREFERENCED_PARAMETER(pszDesktopName);
509 UNREFERENCED_PARAMETER(ppDesktop);
510
512 return FALSE;
513}

◆ WlxDialogBox()

int WINAPI WlxDialogBox ( HANDLE  hWlx,
HANDLE  hInst,
LPWSTR  lpszTemplate,
HWND  hwndOwner,
DLGPROC  dlgprc 
)

Definition at line 304 of file wlx.c.

310{
312
313 TRACE("WlxDialogBox()\n");
314
315 return (int)WlxDialogBoxParam(hWlx, hInst, lpszTemplate, hwndOwner, dlgprc, 0);
316}
HINSTANCE hInst
Definition: dxdiag.c:13
int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:323

◆ WlxDialogBoxIndirect()

int WINAPI WlxDialogBoxIndirect ( HANDLE  hWlx,
HANDLE  hInst,
LPCDLGTEMPLATE  hDialogTemplate,
HWND  hwndOwner,
DLGPROC  dlgprc 
)

Definition at line 357 of file wlx.c.

363{
365
366 TRACE("WlxDialogBoxIndirect()\n");
367
368 return (int)WlxDialogBoxIndirectParam(hWlx, hInst, hDialogTemplate, hwndOwner, dlgprc, 0);
369}
int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:376

◆ WlxDialogBoxIndirectParam()

int WINAPI WlxDialogBoxIndirectParam ( HANDLE  hWlx,
HANDLE  hInst,
LPCDLGTEMPLATE  hDialogTemplate,
HWND  hwndOwner,
DLGPROC  dlgprc,
LPARAM  dwInitParam 
)

Definition at line 376 of file wlx.c.

383{
384 PDIALOG_LIST_ENTRY ListEntry;
385 int ret;
386
388
389 TRACE("WlxDialogBoxIndirectParam()\n");
390
391 ListEntry = AddDialogListEntry();
392 if (ListEntry == NULL)
393 return -1;
394
395 ListEntry->DlgProc = dlgprc;
396 ListEntry->lParam = dwInitParam;
397
398 ret = (int)DialogBoxIndirectParamW(hInst, hDialogTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
399
400 RemoveDialogListEntry(ListEntry);
401
402 return ret;
403}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
DLGPROC DlgProc
Definition: wlx.c:19
LPARAM lParam
Definition: wlx.c:20
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
static VOID RemoveDialogListEntry(PDIALOG_LIST_ENTRY ListEntry)
Definition: wlx.c:58
static PDIALOG_LIST_ENTRY AddDialogListEntry(VOID)
Definition: wlx.c:39
static INT_PTR CALLBACK DefaultWlxWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: wlx.c:117

Referenced by WlxDialogBoxIndirect().

◆ WlxDialogBoxParam()

int WINAPI WlxDialogBoxParam ( HANDLE  hWlx,
HANDLE  hInst,
LPWSTR  lpszTemplate,
HWND  hwndOwner,
DLGPROC  dlgprc,
LPARAM  dwInitParam 
)

Definition at line 323 of file wlx.c.

330{
331 PDIALOG_LIST_ENTRY ListEntry;
332 int ret;
333
335
336 TRACE("WlxDialogBoxParam()\n");
337
338 ListEntry = AddDialogListEntry();
339 if (ListEntry == NULL)
340 return -1;
341
342 ListEntry->DlgProc = dlgprc;
343 ListEntry->lParam = dwInitParam;
344
345 ret = (int)DialogBoxParamW(hInst, lpszTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
346
347 RemoveDialogListEntry(ListEntry);
348
349 return ret;
350}
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by WlxDialogBox().

◆ WlxDisconnect()

BOOL WINAPI WlxDisconnect ( VOID  )

Definition at line 692 of file wlx.c.

693{
695 return FALSE;
696}

◆ WlxGetOption()

BOOL WINAPI WlxGetOption ( HANDLE  hWlx,
DWORD  Option,
ULONG_PTR Value 
)

Definition at line 593 of file wlx.c.

597{
598 PWLSESSION Session = (PWLSESSION)hWlx;
599
600 TRACE("WlxGetOption(%lu)\n", Option);
601
602 switch (Option)
603 {
606 return TRUE;
608 {
609 *Value = (ULONG_PTR)Session->Gina.Context;
610 return TRUE;
611 }
616 return FALSE;
618 {
619 switch (Session->Gina.Version)
620 {
621 case WLX_VERSION_1_0:
623 break;
624 case WLX_VERSION_1_1:
626 break;
627 case WLX_VERSION_1_2:
629 break;
630 case WLX_VERSION_1_3:
632 break;
633 case WLX_VERSION_1_4:
635 break;
636 default:
637 return FALSE;
638 }
639 return TRUE;
640 }
641 }
642
643 return FALSE;
644}
#define ULONG_PTR
Definition: config.h:101
PVOID Context
Definition: winlogon.h:130
BOOL UseCtrlAltDelete
Definition: winlogon.h:132
DWORD Version
Definition: winlogon.h:131
GINAINSTANCE Gina
Definition: winlogon.h:222
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _WLSESSION * PWLSESSION
#define WLX_OPTION_USE_CTRL_ALT_DEL
Definition: winwlx.h:322
#define WLX_VERSION_1_1
Definition: winwlx.h:29
struct _WLX_DISPATCH_VERSION_1_3 WLX_DISPATCH_VERSION_1_3
#define WLX_OPTION_USE_SMART_CARD
Definition: winwlx.h:324
#define WLX_VERSION_1_4
Definition: winwlx.h:32
#define WLX_OPTION_SMART_CARD_PRESENT
Definition: winwlx.h:329
#define WLX_OPTION_DISPATCH_TABLE_SIZE
Definition: winwlx.h:331
#define WLX_VERSION_1_2
Definition: winwlx.h:30
struct _WLX_DISPATCH_VERSION_1_0 WLX_DISPATCH_VERSION_1_0
struct _WLX_DISPATCH_VERSION_1_1 WLX_DISPATCH_VERSION_1_1
struct _WLX_DISPATCH_VERSION_1_2 WLX_DISPATCH_VERSION_1_2
#define WLX_OPTION_CONTEXT_POINTER
Definition: winwlx.h:323
#define WLX_VERSION_1_0
Definition: winwlx.h:28
#define WLX_OPTION_SMART_CARD_INFO
Definition: winwlx.h:330
struct _WLX_DISPATCH_VERSION_1_4 WLX_DISPATCH_VERSION_1_4

◆ WlxGetSourceDesktop()

BOOL WINAPI WlxGetSourceDesktop ( HANDLE  hWlx,
PWLX_DESKTOP ppDesktop 
)

Definition at line 466 of file wlx.c.

469{
471 UNREFERENCED_PARAMETER(ppDesktop);
472
474 return FALSE;
475}

◆ WlxMessageBox()

int WINAPI WlxMessageBox ( HANDLE  hWlx,
HWND  hwndOwner,
LPWSTR  lpszText,
LPWSTR  lpszTitle,
UINT  fuStyle 
)

Definition at line 285 of file wlx.c.

291{
293
294 TRACE("WlxMessageBox()\n");
295 /* FIXME: Provide a custom window proc to be able to handle timeout */
296 return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle);
297}
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)

◆ WlxQueryClientCredentials()

BOOL WINAPI WlxQueryClientCredentials ( PWLX_CLIENT_CREDENTIALS_INFO_V1_0  pCred)

Definition at line 664 of file wlx.c.

666{
668
670 return FALSE;
671}

◆ WlxQueryConsoleSwitchCredentials()

DWORD WINAPI WlxQueryConsoleSwitchCredentials ( PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0  pCred)

Definition at line 723 of file wlx.c.

725{
727
729 return 0;
730}

◆ WlxQueryInetConnectorCredentials()

BOOL WINAPI WlxQueryInetConnectorCredentials ( PWLX_CLIENT_CREDENTIALS_INFO_V1_0  pCred)

Definition at line 678 of file wlx.c.

680{
682
684 return FALSE;
685}

◆ WlxQueryTerminalServicesData()

DWORD WINAPI WlxQueryTerminalServicesData ( HANDLE  hWlx,
PWLX_TERMINAL_SERVICES_DATA  pTSData,
WCHAR UserName,
WCHAR Domain 
)

Definition at line 703 of file wlx.c.

708{
710 UNREFERENCED_PARAMETER(pTSData);
711 UNREFERENCED_PARAMETER(UserName);
713
715 return 0;
716}

◆ WlxQueryTsLogonCredentials()

BOOL WINAPI WlxQueryTsLogonCredentials ( PWLX_CLIENT_CREDENTIALS_INFO_V2_0  pCred)

Definition at line 737 of file wlx.c.

739{
741
743 return FALSE;
744}

◆ WlxSasNotify()

VOID WINAPI WlxSasNotify ( HANDLE  hWlx,
DWORD  dwSasType 
)

Definition at line 231 of file wlx.c.

234{
235 PWLSESSION Session = (PWLSESSION)hWlx;
236
237 TRACE("WlxSasNotify(0x%lx)\n", dwSasType);
238
239 if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL || dwSasType > WLX_SAS_TYPE_MAX_MSFT_VALUE)
240 PostMessageW(Session->SASWindow, WLX_WM_SAS, dwSasType, 0);
241}
HWND SASWindow
Definition: winlogon.h:228
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WLX_SAS_TYPE_MAX_MSFT_VALUE
Definition: winwlx.h:46

◆ WlxSetContextPointer()

VOID WINAPI WlxSetContextPointer ( HANDLE  hWlx,
PVOID  pWlxContext 
)

Definition at line 215 of file wlx.c.

218{
219 ULONG_PTR OldValue;
220
221 TRACE("WlxSetContextPointer(%p)\n", pWlxContext);
222
223 WlxSetOption(hWlx, WLX_OPTION_CONTEXT_POINTER, (ULONG_PTR)pWlxContext, &OldValue);
224}
BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR *OldValue)
Definition: wlx.c:560

◆ WlxSetOption()

BOOL WINAPI WlxSetOption ( HANDLE  hWlx,
DWORD  Option,
ULONG_PTR  Value,
ULONG_PTR OldValue 
)

Definition at line 560 of file wlx.c.

565{
566 PWLSESSION Session = (PWLSESSION)hWlx;
567
568 TRACE("WlxSetOption(%lu)\n", Option);
569
570 switch (Option)
571 {
573 *OldValue = (ULONG_PTR)Session->Gina.UseCtrlAltDelete;
574 Session->Gina.UseCtrlAltDelete = (BOOL)Value;
575 return TRUE;
577 *OldValue = (ULONG_PTR)Session->Gina.Context;
578 Session->Gina.Context = (PVOID)Value;
579 return TRUE;
582 return FALSE;
583 }
584
585 return FALSE;
586}

Referenced by WlxSetContextPointer(), and WlxUseCtrlAltDel().

◆ WlxSetReturnDesktop()

BOOL WINAPI WlxSetReturnDesktop ( HANDLE  hWlx,
PWLX_DESKTOP  pDesktop 
)

Definition at line 482 of file wlx.c.

485{
487 UNREFERENCED_PARAMETER(pDesktop);
488
490 return FALSE;
491}

◆ WlxSetTimeout()

BOOL WINAPI WlxSetTimeout ( HANDLE  hWlx,
DWORD  Timeout 
)

Definition at line 248 of file wlx.c.

251{
252 PWLSESSION Session = (PWLSESSION)hWlx;
253
254 TRACE("WlxSetTimeout(%lu)\n", Timeout);
255
256 Session->DialogTimeout = Timeout;
257 return TRUE;
258}
static ULONG Timeout
Definition: ping.c:61
DWORD DialogTimeout
Definition: winlogon.h:240

◆ WlxSwitchDesktopToUser()

int WINAPI WlxSwitchDesktopToUser ( HANDLE  hWlx)

Definition at line 410 of file wlx.c.

412{
413 PWLSESSION Session = (PWLSESSION)hWlx;
414 BOOL bRet;
415
416 TRACE("WlxSwitchDesktopToUser()\n");
417
418 bRet = SwitchDesktop(Session->ApplicationDesktop);
419 if (bRet)
421 return (int)bRet;
422}

◆ WlxSwitchDesktopToWinlogon()

int WINAPI WlxSwitchDesktopToWinlogon ( HANDLE  hWlx)

Definition at line 429 of file wlx.c.

431{
432 PWLSESSION Session = (PWLSESSION)hWlx;
433 BOOL bRet;
434
435 TRACE("WlxSwitchDesktopToWinlogon()\n");
436
437 bRet = SwitchDesktop(Session->WinlogonDesktop);
438 if (bRet)
440 return (int)bRet;
441}

◆ WlxUseCtrlAltDel()

VOID WINAPI WlxUseCtrlAltDel ( HANDLE  hWlx)

Definition at line 200 of file wlx.c.

202{
203 ULONG_PTR OldValue;
204
205 TRACE("WlxUseCtrlAltDel()\n");
206
208}

◆ WlxWin31Migrate()

VOID WINAPI WlxWin31Migrate ( HANDLE  hWlx)

Definition at line 651 of file wlx.c.

653{
655
657}

Variable Documentation

◆ hAppInstance

◆ LuidNone

LUID LuidNone
extern

◆ WLSession

PWLSESSION WLSession
extern

Definition at line 20 of file winlogon.c.

Referenced by DefaultWlxScreenSaverNotify(), RunSetupThreadProc(), and WinMain().