ReactOS 0.4.15-dev-7968-g24a56f8
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 <strsafe.h>
#include <pseh/pseh2.h>
#include <reactos/undocuser.h>
#include <reactos/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_SHUTTINGDOWN(Status)
 
#define WLX_SUSPENDING(Status)
 

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)
 
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)
 
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 216 of file winlogon.h.

◆ UnlockWorkstation

#define UnlockWorkstation (   Session)

Definition at line 217 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_SHUTTINGDOWN

#define WLX_SHUTTINGDOWN (   Status)
Value:
)
Status
Definition: gdiplustypes.h:25
#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 276 of file winlogon.h.

◆ WLX_SUSPENDING

#define WLX_SUSPENDING (   Status)
Value:
)
#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 282 of file winlogon.h.

Typedef Documentation

◆ GINAFUNCTIONS

◆ GINAINSTANCE

◆ LOGON_STATE

◆ NOTIFICATION_TYPE

◆ PFWLXACTIVATEUSERSHELL

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

Definition at line 71 of file winlogon.h.

◆ PFWLXDISPLAYLOCKEDNOTICE

typedef VOID(WINAPI * PFWLXDISPLAYLOCKEDNOTICE) (PVOID)

Definition at line 73 of file winlogon.h.

◆ PFWLXDISPLAYSASNOTICE

typedef VOID(WINAPI * PFWLXDISPLAYSASNOTICE) (PVOID)

Definition at line 67 of file winlogon.h.

◆ PFWLXDISPLAYSTATUSMESSAGE

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

Definition at line 88 of file winlogon.h.

◆ PFWLXGETSTATUSMESSAGE

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

Definition at line 89 of file winlogon.h.

◆ PFWLXINITIALIZE

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

Definition at line 66 of file winlogon.h.

◆ PFWLXISLOCKOK

typedef BOOL(WINAPI * PFWLXISLOCKOK) (PVOID)

Definition at line 75 of file winlogon.h.

◆ PFWLXISLOGOFFOK

typedef BOOL(WINAPI * PFWLXISLOGOFFOK) (PVOID)

Definition at line 76 of file winlogon.h.

◆ PFWLXLOGGEDONSAS

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

Definition at line 72 of file winlogon.h.

◆ PFWLXLOGGEDOUTSAS

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

Definition at line 68 of file winlogon.h.

◆ PFWLXLOGOFF

typedef VOID(WINAPI * PFWLXLOGOFF) (PVOID)

Definition at line 77 of file winlogon.h.

◆ PFWLXNEGOTIATE

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

Definition at line 65 of file winlogon.h.

◆ PFWLXNETWORKPROVIDERLOAD

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

Definition at line 87 of file winlogon.h.

◆ PFWLXREMOVESTATUSMESSAGE

typedef BOOL(WINAPI * PFWLXREMOVESTATUSMESSAGE) (PVOID)

Definition at line 90 of file winlogon.h.

◆ PFWLXSCREENSAVERNOTIFY

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

Definition at line 82 of file winlogon.h.

◆ PFWLXSHUTDOWN

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

Definition at line 78 of file winlogon.h.

◆ PFWLXSTARTAPPLICATION

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

Definition at line 83 of file winlogon.h.

◆ PFWLXWKSTALOCKEDSAS

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

Definition at line 74 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 201 of file winlogon.h.

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

◆ _NOTIFICATION_TYPE

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

Definition at line 256 of file winlogon.h.

257{
enum _NOTIFICATION_TYPE NOTIFICATION_TYPE
enum _NOTIFICATION_TYPE * PNOTIFICATION_TYPE
@ StopScreenSaverHandler
Definition: winlogon.h:265
@ PostShellHandler
Definition: winlogon.h:269
@ LastHandler
Definition: winlogon.h:270
@ LogonHandler
Definition: winlogon.h:258
@ LogoffHandler
Definition: winlogon.h:259
@ StartShellHandler
Definition: winlogon.h:268
@ DisconnectHandler
Definition: winlogon.h:266
@ UnlockHandler
Definition: winlogon.h:261
@ ReconnectHandler
Definition: winlogon.h:267
@ LockHandler
Definition: winlogon.h:260
@ StartScreenSaverHandler
Definition: winlogon.h:264
@ ShutdownHandler
Definition: winlogon.h:263
@ StartupHandler
Definition: winlogon.h:262

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 1391 of file security.c.

1393{
1394 BOOL Success = FALSE;
1395 DWORD Index, SidLength, GroupsLength = 0;
1396 PTOKEN_GROUPS TokenGroup = NULL;
1397 PSID LogonSid;
1398
1399 /* Get required buffer size and allocate the TOKEN_GROUPS buffer */
1400 if (!GetTokenInformation(Session->UserToken,
1402 TokenGroup,
1403 0,
1404 &GroupsLength))
1405 {
1407 {
1408 ERR("AllowAccessOnSession(): Unexpected error code returned, must be ERROR_INSUFFICIENT_BUFFER (error code %lu)\n", GetLastError());
1409 return FALSE;
1410 }
1411
1412 TokenGroup = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, GroupsLength);
1413 if (TokenGroup == NULL)
1414 {
1415 ERR("AllowAccessOnSession(): Failed to allocate memory buffer for token group!\n");
1416 return FALSE;
1417 }
1418 }
1419
1420 /* Get the token group information from the access token */
1421 if (!GetTokenInformation(Session->UserToken,
1423 TokenGroup,
1424 GroupsLength,
1425 &GroupsLength))
1426 {
1427 ERR("AllowAccessOnSession(): Failed to retrieve the token group information (error code %lu)\n", GetLastError());
1428 goto Quit;
1429 }
1430
1431 /* Loop through the groups to find the logon SID */
1432 for (Index = 0; Index < TokenGroup->GroupCount; Index++)
1433 {
1434 if ((TokenGroup->Groups[Index].Attributes & SE_GROUP_LOGON_ID)
1436 {
1437 LogonSid = TokenGroup->Groups[Index].Sid;
1438 break;
1439 }
1440 }
1441
1442 /* Allow window station access to this user within this session */
1443 if (!AllowWinstaAccessToUser(Session->InteractiveWindowStation, LogonSid))
1444 {
1445 ERR("AllowAccessOnSession(): Failed to allow winsta access to the logon user!\n");
1446 goto Quit;
1447 }
1448
1449 /* Allow application desktop access to this user within this session */
1450 if (!AllowDesktopAccessToUser(Session->ApplicationDesktop, LogonSid))
1451 {
1452 ERR("AllowAccessOnSession(): Failed to allow application desktop access to the logon user!\n");
1453 goto Quit;
1454 }
1455
1456 /* Get the length of this logon SID */
1457 SidLength = GetLengthSid(LogonSid);
1458
1459 /* Assign the window station to this logged in user */
1460 if (!SetWindowStationUser(Session->InteractiveWindowStation,
1461 &Session->LogonId,
1462 LogonSid,
1463 SidLength))
1464 {
1465 ERR("AllowAccessOnSession(): Failed to assign the window station to the logon user!\n");
1466 goto Quit;
1467 }
1468
1469 Success = TRUE;
1470
1471Quit:
1472 if (TokenGroup != NULL)
1473 {
1474 RtlFreeHeap(RtlGetProcessHeap(), 0, TokenGroup);
1475 }
1476
1477 return Success;
1478}
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:874
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:1165
#define ERR(fmt,...)
Definition: debug.h:110
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#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:1018
$ULONG GroupCount
Definition: setypes.h:1014
_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:967

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 1165 of file security.c.

1168{
1169 BOOL Success = FALSE;
1170 SECURITY_DESCRIPTOR AbsoluteSd;
1171 PSECURITY_DESCRIPTOR RelativeSd = NULL;
1172 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment in CreateWinstaSecurity for information */
1175 PACL Dacl;
1176
1177 /* Create the Winlogon SID */
1179 1,
1181 0, 0, 0, 0, 0, 0, 0,
1182 &WinlogonSid))
1183 {
1184 ERR("AllowDesktopAccessToUser(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
1185 return FALSE;
1186 }
1187
1188 /* Create the admins SID */
1190 2,
1193 0, 0, 0, 0, 0, 0,
1194 &AdminsSid))
1195 {
1196 ERR("AllowDesktopAccessToUser(): Failed to create the admins SID (error code %lu)\n", GetLastError());
1197 goto Quit;
1198 }
1199
1200 /* Create the interactive logon SID */
1202 1,
1204 0, 0, 0, 0, 0, 0, 0,
1206 {
1207 ERR("AllowDesktopAccessToUser(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
1208 goto Quit;
1209 }
1210
1211 /* HACK: Create the network service SID */
1213 1,
1215 0, 0, 0, 0, 0, 0, 0,
1217 {
1218 ERR("AllowDesktopAccessToUser(): Failed to create the network service SID (error code %lu)\n", GetLastError());
1219 goto Quit;
1220 }
1221
1222 /*
1223 * Build up the DACL size. This includes a number
1224 * of four ACEs of four different SIDs. The first ACE
1225 * gives full desktop access to Winlogon, the second one gives
1226 * generic limited desktop access to admins. The last two give
1227 * full power to both interactive logon users and logon user as
1228 * well.
1229 */
1230 DaclSize = sizeof(ACL) +
1231 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
1232 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
1234 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
1235 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(NetworkServiceSid); /* HACK */
1236
1237 /* Allocate the DACL now */
1238 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
1240 DaclSize);
1241 if (Dacl == NULL)
1242 {
1243 ERR("AllowDesktopAccessToUser(): Failed to allocate memory buffer for DACL!\n");
1244 goto Quit;
1245 }
1246
1247 /* Initialize it */
1249 {
1250 ERR("AllowDesktopAccessToUser(): Failed to initialize DACL (error code %lu)\n", GetLastError());
1251 goto Quit;
1252 }
1253
1254 /* First ACE -- Give full desktop access to Winlogon */
1257 0,
1259 WinlogonSid))
1260 {
1261 ERR("AllowDesktopAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
1262 goto Quit;
1263 }
1264
1265 /* Second ACE -- Give limited desktop access to admins */
1268 0,
1270 AdminsSid))
1271 {
1272 ERR("AllowDesktopAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
1273 goto Quit;
1274 }
1275
1276 /* Third ACE -- Give full desktop access to interactive logon users */
1279 0,
1282 {
1283 ERR("AllowDesktopAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1284 goto Quit;
1285 }
1286
1287 /* Fourth ACE -- Give full desktop access to logon user */
1290 0,
1292 LogonSid))
1293 {
1294 ERR("AllowDesktopAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1295 goto Quit;
1296 }
1297
1298 /* HACK: Fifth ACE -- Give full desktop to network services */
1301 0,
1304 {
1305 ERR("AllowDesktopAccessToUser(): Failed to set ACE for network service SID (error code %lu)\n", GetLastError());
1306 goto Quit;
1307 }
1308
1309 /* Initialize the security descriptor */
1311 {
1312 ERR("AllowDesktopAccessToUser(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
1313 goto Quit;
1314 }
1315
1316 /* Set the DACL to the descriptor */
1317 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
1318 {
1319 ERR("AllowDesktopAccessToUser(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
1320 goto Quit;
1321 }
1322
1323 /* Conver it to self-relative format */
1324 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
1325 if (RelativeSd == NULL)
1326 {
1327 ERR("AllowDesktopAccessToUser(): Failed to convert security descriptor to self relative format!\n");
1328 goto Quit;
1329 }
1330
1331 /* Assign new security to desktop based on this descriptor */
1334 {
1335 ERR("AllowDesktopAccessToUser(): Failed to set desktop security descriptor (error code %lu)\n", GetLastError());
1336 goto Quit;
1337 }
1338
1339 Success = TRUE;
1340
1341Quit:
1342 if (WinlogonSid != NULL)
1343 {
1344 FreeSid(WinlogonSid);
1345 }
1346
1347 if (AdminsSid != NULL)
1348 {
1349 FreeSid(AdminsSid);
1350 }
1351
1352 if (InteractiveSid != NULL)
1353 {
1355 }
1356
1357 /* HACK */
1358 if (NetworkServiceSid != NULL)
1359 {
1361 }
1362 /* END HACK */
1363
1364 if (Dacl != NULL)
1365 {
1366 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
1367 }
1368
1369 if (RelativeSd != NULL)
1370 {
1371 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
1372 }
1373
1374 return Success;
1375}
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:1593
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1594
#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 874 of file security.c.

877{
879 SECURITY_DESCRIPTOR AbsoluteSd;
880 PSECURITY_DESCRIPTOR RelativeSd = NULL;
881 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL, NetworkServiceSid = NULL; /* NetworkServiceSid is a HACK, see the comment in CreateWinstaSecurity for information */
884 PACL Dacl;
885
886 /* Create the Winlogon SID */
888 1,
890 0, 0, 0, 0, 0, 0, 0,
891 &WinlogonSid))
892 {
893 ERR("AllowWinstaAccessToUser(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
894 return FALSE;
895 }
896
897 /* Create the admins SID */
899 2,
902 0, 0, 0, 0, 0, 0,
903 &AdminsSid))
904 {
905 ERR("AllowWinstaAccessToUser(): Failed to create the admins SID (error code %lu)\n", GetLastError());
906 goto Quit;
907 }
908
909 /* Create the interactive logon SID */
911 1,
913 0, 0, 0, 0, 0, 0, 0,
915 {
916 ERR("AllowWinstaAccessToUser(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
917 goto Quit;
918 }
919
920 /* HACK: Create the network service SID */
922 1,
924 0, 0, 0, 0, 0, 0, 0,
926 {
927 ERR("AllowWinstaAccessToUser(): Failed to create the network service SID (error code %lu)\n", GetLastError());
928 goto Quit;
929 }
930
931 /*
932 * Build up the DACL size. This includes a number
933 * of eight ACEs of four different SIDs. The first ACE
934 * gives full winsta access to Winlogon, the second one gives
935 * generic access to Winlogon. Such approach is the same
936 * for both interactive logon users and logon user as well.
937 * Only admins are given limited powers.
938 */
939 DaclSize = sizeof(ACL) +
940 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
941 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
942 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
943 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
946 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
947 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(LogonSid) +
948 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(NetworkServiceSid) + /* HACK */
950
951 /* Allocate the DACL now */
952 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
954 DaclSize);
955 if (Dacl == NULL)
956 {
957 ERR("AllowWinstaAccessToUser(): Failed to allocate memory buffer for DACL!\n");
958 goto Quit;
959 }
960
961 /* Initialize it */
963 {
964 ERR("AllowWinstaAccessToUser(): Failed to initialize DACL (error code %lu)\n", GetLastError());
965 goto Quit;
966 }
967
968 /* First ACE -- Give full winsta access to Winlogon */
973 WinlogonSid))
974 {
975 ERR("AllowWinstaAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
976 goto Quit;
977 }
978
979 /* Second ACE -- Give generic access to Winlogon */
984 WinlogonSid))
985 {
986 ERR("AllowWinstaAccessToUser(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
987 goto Quit;
988 }
989
990 /* Third ACE -- Give limited winsta access to admins */
995 AdminsSid))
996 {
997 ERR("AllowWinstaAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
998 goto Quit;
999 }
1000
1001 /* Fourth ACE -- Give limited desktop access to admins */
1006 AdminsSid))
1007 {
1008 ERR("AllowWinstaAccessToUser(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
1009 goto Quit;
1010 }
1011
1012 /* Fifth ACE -- Give full winsta access to interactive logon users */
1016 WINSTA_ALL,
1018 {
1019 ERR("AllowWinstaAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1020 goto Quit;
1021 }
1022
1023 /* Sixth ACE -- Give generic access to interactive logon users */
1029 {
1030 ERR("AllowWinstaAccessToUser(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
1031 goto Quit;
1032 }
1033
1034 /* Seventh ACE -- Give full winsta access to logon user */
1038 WINSTA_ALL,
1039 LogonSid))
1040 {
1041 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1042 goto Quit;
1043 }
1044
1045 /* Eighth ACE -- Give generic access to logon user */
1050 LogonSid))
1051 {
1052 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon user SID (error code %lu)\n", GetLastError());
1053 goto Quit;
1054 }
1055
1056 /* HACK : Ninenth ACE -- Give full winsta access to network services */
1060 WINSTA_ALL,
1062 {
1063 ERR("AllowWinstaAccessToUser(): Failed to set ACE for logon network service SID (error code %lu)\n", GetLastError());
1064 goto Quit;
1065 }
1066
1067 /* HACK: Tenth ACE -- Give generic access to network services */
1073 {
1074 ERR("AllowWinstaAccessToUser(): Failed to set ACE for network service SID (error code %lu)\n", GetLastError());
1075 goto Quit;
1076 }
1077
1078 /* Initialize the security descriptor */
1080 {
1081 ERR("AllowWinstaAccessToUser(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
1082 goto Quit;
1083 }
1084
1085 /* Set the DACL to descriptor */
1086 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
1087 {
1088 ERR("AllowWinstaAccessToUser(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
1089 goto Quit;
1090 }
1091
1092 /* Convert it to self-relative format */
1093 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
1094 if (RelativeSd == NULL)
1095 {
1096 ERR("AllowWinstaAccessToUser(): Failed to convert security descriptor to self relative format!\n");
1097 goto Quit;
1098 }
1099
1100 /* Set new winsta security based on this descriptor */
1102 if (!SetUserObjectSecurity(WinSta, &SecurityInformation, RelativeSd))
1103 {
1104 ERR("AllowWinstaAccessToUser(): Failed to set window station security descriptor (error code %lu)\n", GetLastError());
1105 goto Quit;
1106 }
1107
1108 Success = TRUE;
1109
1110Quit:
1111 if (WinlogonSid != NULL)
1112 {
1113 FreeSid(WinlogonSid);
1114 }
1115
1116 if (AdminsSid != NULL)
1117 {
1118 FreeSid(AdminsSid);
1119 }
1120
1121 if (InteractiveSid != NULL)
1122 {
1124 }
1125
1126 /* HACK */
1127 if (NetworkServiceSid != NULL)
1128 {
1130 }
1131 /* END HACK */
1132
1133 if (Dacl != NULL)
1134 {
1135 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
1136 }
1137
1138 if (RelativeSd != NULL)
1139 {
1140 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
1141 }
1142
1143 return Success;
1144}
#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 390 of file notify.c.

393{
394 PLIST_ENTRY ListEntry;
395 PNOTIFICATION_ITEM NotificationDll;
397 HKEY hNotifyKey = NULL;
398 DWORD dwError;
399
400 TRACE("CallNotificationDlls()\n");
401
403 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
404 0,
406 &hNotifyKey);
407 if (dwError != ERROR_SUCCESS)
408 {
409 TRACE("RegOpenKeyExW()\n");
410 return;
411 }
412
413 Info.Size = sizeof(WLX_NOTIFICATION_INFO);
414
415 switch (Type)
416 {
417 case LogoffHandler:
418 case ShutdownHandler:
419 Info.Flags = 3;
420 break;
421
422 default:
423 Info.Flags = 0;
424 break;
425 }
426
427 Info.UserName = NULL; //UserName;
428 Info.Domain = NULL; //Domain;
429 Info.WindowStation = pSession->InteractiveWindowStationName;
430 Info.hToken = pSession->UserToken;
431
432 switch (Type)
433 {
434 case LogonHandler:
436 Info.hDesktop = pSession->ApplicationDesktop;
437 break;
438
440 Info.hDesktop = pSession->ApplicationDesktop;
441 break;
442
443 default:
444 Info.hDesktop = pSession->WinlogonDesktop;
445 break;
446 }
447
448 Info.pStatusCallback = NULL;
449
450 ListEntry = NotificationDllListHead.Flink;
451 while (ListEntry != &NotificationDllListHead)
452 {
453TRACE("ListEntry %p\n", ListEntry);
454
455 NotificationDll = CONTAINING_RECORD(ListEntry,
457 ListEntry);
458TRACE("NotificationDll: %p\n", NotificationDll);
459 if (NotificationDll != NULL && NotificationDll->bEnabled)
460 CallNotificationDll(hNotifyKey, NotificationDll, Type, &Info);
461
462 ListEntry = ListEntry->Flink;
463 }
464
465 RegCloseKey(hNotifyKey);
466}
Type
Definition: Type.h:7
static LIST_ENTRY NotificationDllListHead
Definition: notify.c:50
static VOID CallNotificationDll(HKEY hNotifyKey, PNOTIFICATION_ITEM NotificationDll, NOTIFICATION_TYPE Type, PWLX_NOTIFICATION_INFO pInfo)
Definition: notify.c:309
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define L(x)
Definition: ntvdm.h:50
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LPWSTR InteractiveWindowStationName
Definition: winlogon.h:227
HANDLE UserToken
Definition: winlogon.h:232
HDESK WinlogonDesktop
Definition: winlogon.h:229
HDESK ApplicationDesktop
Definition: winlogon.h:228
#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
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
struct _WLX_NOTIFICATION_INFO WLX_NOTIFICATION_INFO

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

◆ CleanupNotifications()

VOID CleanupNotifications ( VOID  )

Definition at line 470 of file notify.c.

471{
472 PLIST_ENTRY ListEntry;
473 PNOTIFICATION_ITEM NotificationDll;
474
475 ListEntry = NotificationDllListHead.Flink;
476 while (ListEntry != &NotificationDllListHead)
477 {
478 NotificationDll = CONTAINING_RECORD(ListEntry,
480 ListEntry);
481 if (NotificationDll != NULL)
482 {
483 if (NotificationDll->pszKeyName != NULL)
484 RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll->pszKeyName);
485
486 if (NotificationDll->pszDllName != NULL)
487 RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll->pszDllName);
488 }
489
490 ListEntry = ListEntry->Flink;
491
492 RemoveEntryList(&NotificationDll->ListEntry);
493
494 RtlFreeHeap(RtlGetProcessHeap(), 0, NotificationDll);
495 }
496}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
LIST_ENTRY ListEntry
Definition: notify.c:37
PWSTR pszKeyName
Definition: notify.c:38
PWSTR pszDllName
Definition: notify.c:39

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
107 PostMessage(Current->hWnd, WLX_WM_SAS, 0, 0);
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:5832
#define WLX_WM_SAS
Definition: winwlx.h:71
static LIST_ENTRY DialogListHead
Definition: wlx.c:26

Referenced by DispatchSAS().

◆ 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 our buffer to allocate */
71 if (!MakeSelfRelativeSD(AbsoluteSd, NULL, &DescriptorLength) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
72 {
73 ERR("ConvertToSelfRelative(): Unexpected error code (error code %lu -- must be ERROR_INSUFFICIENT_BUFFER)\n", GetLastError());
74 return NULL;
75 }
76
77 /* Allocate the buffer now */
78 RelativeSd = RtlAllocateHeap(RtlGetProcessHeap(),
80 DescriptorLength);
81 if (RelativeSd == NULL)
82 {
83 ERR("ConvertToSelfRelative(): Failed to allocate buffer for relative SD!\n");
84 return NULL;
85 }
86
87 /* Convert the security descriptor now */
88 if (!MakeSelfRelativeSD(AbsoluteSd, RelativeSd, &DescriptorLength))
89 {
90 ERR("ConvertToSelfRelative(): Failed to convert the security descriptor to a self relative format (error code %lu)\n", GetLastError());
91 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
92 return NULL;
93 }
94
95 return RelativeSd;
96}
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 359 of file security.c.

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

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 690 of file security.c.

692{
694 SECURITY_DESCRIPTOR AbsoluteSd;
695 PSECURITY_DESCRIPTOR RelativeSd = NULL;
696 PSID WinlogonSid = NULL, AdminsSid = NULL, InteractiveSid = NULL;
698 PACL Dacl;
699
700 /* Create the Winlogon SID */
702 1,
704 0, 0, 0, 0, 0, 0, 0,
705 &WinlogonSid))
706 {
707 ERR("CreateScreenSaverSecurity(): Failed to create the Winlogon SID (error code %lu)\n", GetLastError());
708 return FALSE;
709 }
710
711 /* Create the admins SID */
713 2,
716 0, 0, 0, 0, 0, 0,
717 &AdminsSid))
718 {
719 ERR("CreateScreenSaverSecurity(): Failed to create the admins SID (error code %lu)\n", GetLastError());
720 goto Quit;
721 }
722
723 /* Create the interactive logon SID */
725 1,
727 0, 0, 0, 0, 0, 0, 0,
729 {
730 ERR("CreateScreenSaverSecurity(): Failed to create the interactive SID (error code %lu)\n", GetLastError());
731 goto Quit;
732 }
733
734 /*
735 * Build up the DACL size. This includes a number
736 * of three ACEs of three different SIDs. The first ACE
737 * gives full access to Winlogon, the second one gives
738 * limited desktop access to admins and the last one
739 * gives full desktop access to users who have logged in
740 * interactively.
741 */
742 DaclSize = sizeof(ACL) +
743 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(WinlogonSid) +
744 sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(AdminsSid) +
746
747 /* Allocate the DACL now */
748 Dacl = RtlAllocateHeap(RtlGetProcessHeap(),
750 DaclSize);
751 if (Dacl == NULL)
752 {
753 ERR("CreateScreenSaverSecurity(): Failed to allocate memory buffer for DACL!\n");
754 goto Quit;
755 }
756
757 /* Initialize it */
759 {
760 ERR("CreateScreenSaverSecurity(): Failed to initialize DACL (error code %lu)\n", GetLastError());
761 goto Quit;
762 }
763
764 /* First ACE -- Give full desktop access to Winlogon */
767 0,
769 WinlogonSid))
770 {
771 ERR("CreateScreenSaverSecurity(): Failed to set ACE for Winlogon (error code %lu)\n", GetLastError());
772 goto Quit;
773 }
774
775 /* Second ACE -- Give limited desktop access to admins */
780 AdminsSid))
781 {
782 ERR("CreateScreenSaverSecurity(): Failed to set ACE for admins (error code %lu)\n", GetLastError());
783 goto Quit;
784 }
785
786 /* Third ACE -- Give full desktop access to interactive logon users */
792 {
793 ERR("CreateScreenSaverSecurity(): Failed to set ACE for interactive SID (error code %lu)\n", GetLastError());
794 goto Quit;
795 }
796
797 /* Initialize the security descriptor */
799 {
800 ERR("CreateScreenSaverSecurity(): Failed to initialize absolute security descriptor (error code %lu)\n", GetLastError());
801 goto Quit;
802 }
803
804 /* Set the DACL to the descriptor */
805 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
806 {
807 ERR("CreateScreenSaverSecurity(): Failed to set up DACL to absolute security descriptor (error code %lu)\n", GetLastError());
808 goto Quit;
809 }
810
811 /* Conver it to self-relative format */
812 RelativeSd = ConvertToSelfRelative(&AbsoluteSd);
813 if (RelativeSd == NULL)
814 {
815 ERR("CreateScreenSaverSecurity(): Failed to convert security descriptor to self relative format!\n");
816 goto Quit;
817 }
818
819 /* Give the descriptor to the caller */
820 *ScreenSaverDesktopSd = RelativeSd;
821 Success = TRUE;
822
823Quit:
824 if (WinlogonSid != NULL)
825 {
826 FreeSid(WinlogonSid);
827 }
828
829 if (AdminsSid != NULL)
830 {
831 FreeSid(AdminsSid);
832 }
833
834 if (InteractiveSid != NULL)
835 {
837 }
838
839 if (Dacl != NULL)
840 {
841 RtlFreeHeap(RtlGetProcessHeap(), 0, Dacl);
842 }
843
844 if (Success == FALSE)
845 {
846 if (RelativeSd != NULL)
847 {
848 RtlFreeHeap(RtlGetProcessHeap(), 0, RelativeSd);
849 }
850 }
851
852 return Success;
853}
#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
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
long LONG
Definition: pedump.c:60
BOOL WINAPI RevertToSelf(void)
Definition: security.c:1608

Referenced by HandleLogon().

◆ CreateWindowStationAndDesktops()

BOOL CreateWindowStationAndDesktops ( _Inout_ PWLSESSION  Session)

Definition at line 928 of file wlx.c.

930{
931 SECURITY_ATTRIBUTES WinstaSecurity;
932 SECURITY_ATTRIBUTES ApplicationDesktopSecurity;
933 SECURITY_ATTRIBUTES WinlogonDesktopSecurity;
934 SECURITY_ATTRIBUTES ScreenSaverDesktopSecurity;
935 PSECURITY_DESCRIPTOR WlWinstaSecurityDescriptor;
936 PSECURITY_DESCRIPTOR WlApplicationDesktopSecurityDescriptor;
937 PSECURITY_DESCRIPTOR WlWinlogonDesktopSecurityDescriptor;
938 PSECURITY_DESCRIPTOR WlScreenSaverDesktopSecurityDescriptor;
939 BOOL ret = FALSE;
940
941 if (!CreateWinstaSecurity(&WlWinstaSecurityDescriptor))
942 {
943 ERR("WL: Failed to create winsta security!\n");
944 return ret;
945 }
946
947 WinstaSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
948 WinstaSecurity.lpSecurityDescriptor = WlWinstaSecurityDescriptor;
949 WinstaSecurity.bInheritHandle = TRUE;
950
951 if (!CreateApplicationDesktopSecurity(&WlApplicationDesktopSecurityDescriptor))
952 {
953 ERR("WL: Failed to create application desktop security!\n");
954 goto cleanup;
955 }
956
957 ApplicationDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
958 ApplicationDesktopSecurity.lpSecurityDescriptor = WlApplicationDesktopSecurityDescriptor;
959 ApplicationDesktopSecurity.bInheritHandle = TRUE;
960
961 if (!CreateWinlogonDesktopSecurity(&WlWinlogonDesktopSecurityDescriptor))
962 {
963 ERR("WL: Failed to create winlogon desktop security!\n");
964 goto cleanup;
965 }
966
967 WinlogonDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
968 WinlogonDesktopSecurity.lpSecurityDescriptor = WlWinlogonDesktopSecurityDescriptor;
969 WinlogonDesktopSecurity.bInheritHandle = FALSE;
970
971 if (!CreateScreenSaverSecurity(&WlScreenSaverDesktopSecurityDescriptor))
972 {
973 ERR("WL: Failed to create winlogon desktop security!\n");
974 goto cleanup;
975 }
976
977 ScreenSaverDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
978 ScreenSaverDesktopSecurity.lpSecurityDescriptor = WlScreenSaverDesktopSecurityDescriptor;
979 ScreenSaverDesktopSecurity.bInheritHandle = TRUE;
980
981 /*
982 * Create the interactive window station
983 */
984 Session->InteractiveWindowStationName = L"WinSta0";
985 Session->InteractiveWindowStation = CreateWindowStationW(
986 Session->InteractiveWindowStationName,
987 0,
989 &WinstaSecurity);
990 if (!Session->InteractiveWindowStation)
991 {
992 ERR("WL: Failed to create window station (%lu)\n", GetLastError());
993 goto cleanup;
994 }
995
996 if (!SetProcessWindowStation(Session->InteractiveWindowStation))
997 {
998 ERR("WL: SetProcessWindowStation() failed (error %lu)\n", GetLastError());
999 goto cleanup;
1000 }
1001
1002 /*
1003 * Create the application desktop
1004 */
1005 Session->ApplicationDesktop = CreateDesktopW(
1006 L"Default",
1007 NULL,
1008 NULL,
1009 0, /* FIXME: Add DF_ALLOWOTHERACCOUNTHOOK flag? */
1011 &ApplicationDesktopSecurity);
1012 if (!Session->ApplicationDesktop)
1013 {
1014 ERR("WL: Failed to create Default desktop (%lu)\n", GetLastError());
1015 goto cleanup;
1016 }
1017
1018 /*
1019 * Create the winlogon desktop
1020 */
1021 Session->WinlogonDesktop = CreateDesktopW(
1022 L"Winlogon",
1023 NULL,
1024 NULL,
1025 0,
1027 &WinlogonDesktopSecurity);
1028 if (!Session->WinlogonDesktop)
1029 {
1030 ERR("WL: Failed to create Winlogon desktop (%lu)\n", GetLastError());
1031 goto cleanup;
1032 }
1033
1034 /*
1035 * Create the screen saver desktop
1036 */
1037 Session->ScreenSaverDesktop = CreateDesktopW(
1038 L"Screen-Saver",
1039 NULL,
1040 NULL,
1041 0,
1043 &ScreenSaverDesktopSecurity);
1044 if(!Session->ScreenSaverDesktop)
1045 {
1046 ERR("WL: Failed to create Screen-Saver desktop (%lu)\n", GetLastError());
1047 goto cleanup;
1048 }
1049
1050 /*
1051 * Switch to winlogon desktop
1052 */
1053 if (!SetThreadDesktop(Session->WinlogonDesktop) ||
1054 !SwitchDesktop(Session->WinlogonDesktop))
1055 {
1056 ERR("WL: Cannot switch to Winlogon desktop (%lu)\n", GetLastError());
1057 goto cleanup;
1058 }
1059
1060 SetWindowStationUser(Session->InteractiveWindowStation,
1061 &LuidNone, NULL, 0);
1062
1063 ret = TRUE;
1064
1065cleanup:
1066 if (!ret)
1067 {
1068 if (Session->ApplicationDesktop)
1069 {
1070 CloseDesktop(Session->ApplicationDesktop);
1071 Session->ApplicationDesktop = NULL;
1072 }
1073 if (Session->WinlogonDesktop)
1074 {
1075 CloseDesktop(Session->WinlogonDesktop);
1076 Session->WinlogonDesktop = NULL;
1077 }
1078 if (Session->ScreenSaverDesktop)
1079 {
1080 CloseDesktop(Session->ScreenSaverDesktop);
1081 Session->ScreenSaverDesktop = NULL;
1082 }
1083 if (Session->InteractiveWindowStation)
1084 {
1085 CloseWindowStation(Session->InteractiveWindowStation);
1086 Session->InteractiveWindowStation = NULL;
1087 }
1088 if (WlWinstaSecurityDescriptor)
1089 {
1090 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinstaSecurityDescriptor);
1091 }
1092 if (WlApplicationDesktopSecurityDescriptor)
1093 {
1094 RtlFreeHeap(RtlGetProcessHeap(), 0, WlApplicationDesktopSecurityDescriptor);
1095 }
1096 if (WlWinlogonDesktopSecurityDescriptor)
1097 {
1098 RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinlogonDesktopSecurityDescriptor);
1099 }
1100 if (WlScreenSaverDesktopSecurityDescriptor)
1101 {
1102 RtlFreeHeap(RtlGetProcessHeap(), 0, WlScreenSaverDesktopSecurityDescriptor);
1103 }
1104 }
1105
1106 return ret;
1107}
BOOL CreateApplicationDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *ApplicationDesktopSd)
Creates a security descriptor for the default application desktop upon its creation.
Definition: security.c:359
BOOL CreateWinstaSecurity(_Out_ PSECURITY_DESCRIPTOR *WinstaSd)
Creates a security descriptor for the default window station upon its creation.
Definition: security.c:112
BOOL CreateWinlogonDesktopSecurity(_Out_ PSECURITY_DESCRIPTOR *WinlogonDesktopSd)
Creates a security descriptor for the default Winlogon desktop. This descriptor serves as a security ...
Definition: security.c:541
BOOL CreateScreenSaverSecurity(_Out_ PSECURITY_DESCRIPTOR *ScreenSaverDesktopSd)
Creates a security descriptor for the screen saver desktop.
Definition: security.c:690
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
static void cleanup(void)
Definition: main.c:1335
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
LUID LuidNone
Definition: sas.c:47
LPVOID lpSecurityDescriptor
Definition: compat.h:193
int ret
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 541 of file security.c.

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

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

Referenced by CreateWindowStationAndDesktops().

◆ DisplayStatusMessage()

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

Definition at line 349 of file winlogon.c.

353{
354 WCHAR StatusMsg[MAX_PATH];
355
356 if (Session->Gina.Version < WLX_VERSION_1_3)
357 return TRUE;
358
359 if (Session->SuppressStatus)
360 return TRUE;
361
362 if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
363 return FALSE;
364
365 return Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, hDesktop, 0, NULL, StatusMsg);
366}
INT ResourceId
Definition: LoadImageGCC.c:72
#define MAX_PATH
Definition: compat.h:34
HINSTANCE hAppInstance
Definition: winlogon.c:19
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#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 RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by SASWindowProc(), and WinMain().

◆ GinaInit()

BOOL GinaInit ( IN OUT PWLSESSION  Session)

Definition at line 905 of file wlx.c.

907{
908 DWORD GinaDllVersion;
909
910 if (!LoadGina(&Session->Gina.Functions, &GinaDllVersion, &Session->Gina.hDllInstance))
911 return FALSE;
912
913 Session->Gina.Context = NULL;
914 Session->Gina.Version = GinaDllVersion;
915 Session->Gina.UseCtrlAltDelete = FALSE;
916 Session->SuppressStatus = FALSE;
917
918 TRACE("Calling WlxInitialize(\"%S\")\n", Session->InteractiveWindowStationName);
919 return Session->Gina.Functions.WlxInitialize(
920 Session->InteractiveWindowStationName,
921 (HANDLE)Session,
922 NULL,
924 &Session->Gina.Context);
925}
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:722
static BOOL LoadGina(IN OUT PGINAFUNCTIONS Functions, OUT DWORD *DllVersion, OUT HMODULE *GinaInstance)
Definition: wlx.c:805

Referenced by WinMain().

◆ HandleShutdown()

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

Definition at line 932 of file sas.c.

935{
938 DWORD exitCode;
939 BOOLEAN Old;
940
941 // SwitchDesktop(Session->WinlogonDesktop);
942
943 /* If the system is rebooting, show the appropriate string */
944 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
945 DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISRESTARTING);
946 else
947 DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISSHUTTINGDOWN);
948
949 /* Prepare data for shutdown thread */
950 LSData = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGOFF_SHUTDOWN_DATA));
951 if (!LSData)
952 {
953 ERR("Failed to allocate mem for thread data\n");
954 return STATUS_NO_MEMORY;
955 }
956 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF)
957 LSData->Flags = EWX_POWEROFF;
958 else if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
959 LSData->Flags = EWX_REBOOT;
960 else
961 LSData->Flags = EWX_SHUTDOWN;
962 LSData->Session = Session;
963
964 // FIXME: We may need to specify this flag to really force application kill
965 // (we are shutting down ReactOS, not just logging off so no hangs, etc...
966 // should be allowed).
967 // LSData->Flags |= EWX_FORCE;
968
969 /* Run shutdown thread */
971 if (!hThread)
972 {
973 ERR("Unable to create shutdown thread, error %lu\n", GetLastError());
974 HeapFree(GetProcessHeap(), 0, LSData);
975 return STATUS_UNSUCCESSFUL;
976 }
978 HeapFree(GetProcessHeap(), 0, LSData);
979 if (!GetExitCodeThread(hThread, &exitCode))
980 {
981 ERR("Unable to get exit code of shutdown thread (error %lu)\n", GetLastError());
983 return STATUS_UNSUCCESSFUL;
984 }
986 if (exitCode == 0)
987 {
988 ERR("Shutdown thread returned failure\n");
989 return STATUS_UNSUCCESSFUL;
990 }
991
993
994 /* Destroy SAS window */
995 UninitializeSAS(Session);
996
997 /* Now we can shut down NT */
998 ERR("Shutting down NT...\n");
1000 if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1001 {
1003 }
1004 else
1005 {
1006 if (FALSE)
1007 {
1008 /* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */
1011 }
1013 }
1015 return STATUS_SUCCESS;
1016}
unsigned char BOOLEAN
HINSTANCE hAppInstance
Definition: mmc.c:23
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:390
#define IDS_REACTOSISSHUTTINGDOWN
Definition: resource.h:31
#define IDD_SHUTDOWNCOMPUTER
Definition: resource.h:7
#define IDS_REACTOSISRESTARTING
Definition: resource.h:38
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
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
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:541
#define INFINITE
Definition: serial.h:102
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
@ ShutdownReboot
Definition: extypes.h:177
@ ShutdownNoReboot
Definition: extypes.h:176
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
HANDLE hThread
Definition: wizard.c:28
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
static INT_PTR CALLBACK ShutdownComputerWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:886
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:918
static DWORD WINAPI LogoffShutdownThread(LPVOID Parameter)
Definition: sas.c:587
#define STATUS_SUCCESS
Definition: shellext.h:65
PWLSESSION Session
Definition: sas.c:42
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:349
#define EWX_POWEROFF
Definition: winuser.h:637
#define EWX_SHUTDOWN
Definition: winuser.h:639
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define EWX_REBOOT
Definition: winuser.h:638
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DialogBox
Definition: winuser.h:5761

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 1482 of file sas.c.

1484{
1485 WNDCLASSEXW swc;
1486 BOOL ret = FALSE;
1487
1488 if (!SwitchDesktop(Session->WinlogonDesktop))
1489 {
1490 ERR("WL: Failed to switch to winlogon desktop\n");
1491 goto cleanup;
1492 }
1493
1494 /* Register SAS window class */
1495 swc.cbSize = sizeof(WNDCLASSEXW);
1496 swc.style = CS_SAVEBITS;
1498 swc.cbClsExtra = 0;
1499 swc.cbWndExtra = 0;
1500 swc.hInstance = hAppInstance;
1501 swc.hIcon = NULL;
1502 swc.hCursor = NULL;
1503 swc.hbrBackground = NULL;
1504 swc.lpszMenuName = NULL;
1506 swc.hIconSm = NULL;
1507 if (RegisterClassExW(&swc) == 0)
1508 {
1509 ERR("WL: Failed to register SAS window class\n");
1510 goto cleanup;
1511 }
1512
1513 /* Create invisible SAS window */
1514 Session->SASWindow = CreateWindowExW(
1515 0,
1518 WS_POPUP,
1519 0, 0, 0, 0, 0, 0,
1520 hAppInstance, Session);
1521 if (!Session->SASWindow)
1522 {
1523 ERR("WL: Failed to create SAS window\n");
1524 goto cleanup;
1525 }
1526
1527 /* Register SAS window to receive SAS notifications */
1528 if (!SetLogonNotifyWindow(Session->SASWindow))
1529 {
1530 ERR("WL: Failed to register SAS window\n");
1531 goto cleanup;
1532 }
1533
1535 return FALSE;
1536
1537 ret = TRUE;
1538
1539cleanup:
1540 if (!ret)
1541 UninitializeSAS(Session);
1542 return ret;
1543}
#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:1282
BOOL SetDefaultLanguage(IN PWLSESSION Session)
Definition: sas.c:111
LPCWSTR lpszClassName
Definition: winuser.h:3226
LPCWSTR lpszMenuName
Definition: winuser.h:3225
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
int cbWndExtra
Definition: winuser.h:3220
HCURSOR hCursor
Definition: winuser.h:3223
HICON hIconSm
Definition: winuser.h:3227
HINSTANCE hInstance
Definition: winuser.h:3221
UINT style
Definition: winuser.h:3217
int cbClsExtra
Definition: winuser.h:3219
HICON hIcon
Definition: winuser.h:3222
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:657
struct _WNDCLASSEXW WNDCLASSEXW

Referenced by WinMain().

◆ InitializeScreenSaver()

BOOL InitializeScreenSaver ( IN OUT PWLSESSION  Session)

Definition at line 204 of file screensaver.c.

206{
207 HANDLE ScreenSaverThread;
208
209#ifndef USE_GETLASTINPUTINFO
210 /* Register hooks to detect keyboard and mouse activity */
211 Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardActivityProc, hAppInstance, 0);
212 if (!Session->KeyboardHook)
213 {
214 ERR("WL: Unable to register keyboard hook\n");
215 return FALSE;
216 }
217
218 Session->MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseActivityProc, hAppInstance, 0);
219 if (!Session->MouseHook)
220 {
221 ERR("WL: Unable to register mouse hook\n");
222 return FALSE;
223 }
224#endif
225
226 Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, FALSE, NULL);
227 if (!Session->hScreenSaverParametersChanged)
228 {
229 WARN("WL: Unable to create screen saver event (error %lu)\n", GetLastError());
230 return TRUE;
231 }
232
233 Session->hEndOfScreenSaverThread = CreateEventW(NULL, FALSE, FALSE, NULL);
234 if (!Session->hEndOfScreenSaverThread)
235 {
236 WARN("WL: Unable to create screen saver event (error %lu)\n", GetLastError());
237 CloseHandle(Session->hScreenSaverParametersChanged);
238 return TRUE;
239 }
240
241 ScreenSaverThread = CreateThread(NULL,
242 0,
244 Session,
245 0,
246 NULL);
247 if (ScreenSaverThread)
248 CloseHandle(ScreenSaverThread);
249 else
250 ERR("WL: Unable to start screen saver thread\n");
251
252 return TRUE;
253}
static DWORD WINAPI ScreenSaverThreadMain(IN LPVOID lpParameter)
Definition: screensaver.c:76
#define WARN(fmt,...)
Definition: debug.h:112
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:5856
#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 253 of file notify.c.

254{
255 HKEY hNotifyKey = NULL;
256 LONG lError;
257 DWORD dwIndex;
258 WCHAR szKeyName[80];
259 DWORD dwKeyName;
260
261 TRACE("InitNotifications()\n");
262
264
266
268 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify",
269 0,
271 &hNotifyKey);
272 if (lError != ERROR_SUCCESS)
273 {
274 TRACE("RegOpenKeyExW()\n");
275 return TRUE;
276 }
277
278 dwIndex = 0;
279 for(;;)
280 {
281 dwKeyName = ARRAYSIZE(szKeyName);
282 lError = RegEnumKeyExW(hNotifyKey,
283 dwIndex,
284 szKeyName,
285 &dwKeyName,
286 NULL,
287 NULL,
288 NULL,
289 NULL);
290 if (lError != ERROR_SUCCESS)
291 break;
292
293 TRACE("Notification DLL: %S\n", szKeyName);
294 AddNotificationDll(hNotifyKey, szKeyName);
295
296 dwIndex++;
297 }
298
299 RegCloseKey(hNotifyKey);
300
301 TRACE("InitNotifications() done\n");
302
303 return TRUE;
304}
static VOID AddNotificationDll(HKEY hNotifyKey, PWSTR pszKeyName)
Definition: notify.c:109
static VOID AddSfcNotification(VOID)
Definition: notify.c:57
#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

Referenced by WinMain().

◆ PlaySoundRoutine()

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

Definition at line 240 of file sas.c.

244{
245 typedef BOOL (WINAPI *PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
246 typedef UINT (WINAPI *WAVEOUTGETNUMDEVS)(VOID);
247 PLAYSOUNDW Play;
248 WAVEOUTGETNUMDEVS waveOutGetNumDevs;
249 UINT NumDevs;
251 BOOL Ret = FALSE;
252
253 hLibrary = LoadLibraryW(L"winmm.dll");
254 if (!hLibrary)
255 return FALSE;
256
257 waveOutGetNumDevs = (WAVEOUTGETNUMDEVS)GetProcAddress(hLibrary, "waveOutGetNumDevs");
258 Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
259
261 {
263 {
264 NumDevs = waveOutGetNumDevs();
265 if (!NumDevs)
266 {
267 if (!bLogon)
268 Beep(440, 125);
270 }
271 }
272
273 if (Play)
274 Ret = Play(FileName, NULL, Flags);
275 }
277 {
278 ERR("WL: Exception while playing sound '%S', Status 0x%08lx\n",
280 }
281 _SEH2_END;
282
284
285 return Ret;
286}
#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 _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
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(), PlayLogoffSound(), and PlayLogonSoundThread().

◆ RemoveStatusMessage()

BOOL RemoveStatusMessage ( IN PWLSESSION  Session)

Definition at line 370 of file winlogon.c.

372{
373 if (Session->Gina.Version < WLX_VERSION_1_3)
374 return TRUE;
375
376 return Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
377}

Referenced by DoGenericAction(), 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

Referenced by WinMain().

◆ SetDefaultLanguage()

BOOL SetDefaultLanguage ( IN PWLSESSION  Session)

Definition at line 111 of file sas.c.

113{
114 BOOL ret = FALSE;
115 BOOL UserProfile;
116 LONG rc;
117 HKEY UserKey, hKey = NULL;
118 LPCWSTR SubKey, ValueName;
119 DWORD dwType, dwSize;
120 LPWSTR Value = NULL;
121 UNICODE_STRING ValueString;
123 LCID Lcid;
124
125 UserProfile = (Session && Session->UserToken);
126
127 if (UserProfile && !ImpersonateLoggedOnUser(Session->UserToken))
128 {
129 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
130 return FALSE;
131 // FIXME: ... or use the default language of the system??
132 // UserProfile = FALSE;
133 }
134
135 if (UserProfile)
136 {
137 rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &UserKey);
138 if (rc != ERROR_SUCCESS)
139 {
140 TRACE("RegOpenCurrentUser() failed with error %lu\n", rc);
141 goto cleanup;
142 }
143
144 SubKey = L"Control Panel\\International";
145 ValueName = L"Locale";
146 }
147 else
148 {
149 UserKey = NULL;
150 SubKey = L"System\\CurrentControlSet\\Control\\Nls\\Language";
151 ValueName = L"Default";
152 }
153
154 rc = RegOpenKeyExW(UserKey ? UserKey : HKEY_LOCAL_MACHINE,
155 SubKey,
156 0,
157 KEY_READ,
158 &hKey);
159
160 if (UserKey)
161 RegCloseKey(UserKey);
162
163 if (rc != ERROR_SUCCESS)
164 {
165 TRACE("RegOpenKeyEx() failed with error %lu\n", rc);
166 goto cleanup;
167 }
168
170 ValueName,
171 NULL,
172 &dwType,
173 NULL,
174 &dwSize);
175 if (rc != ERROR_SUCCESS)
176 {
177 TRACE("RegQueryValueEx() failed with error %lu\n", rc);
178 goto cleanup;
179 }
180 else if (dwType != REG_SZ)
181 {
182 TRACE("Wrong type for %S\\%S registry entry (got 0x%lx, expected 0x%x)\n",
183 SubKey, ValueName, dwType, REG_SZ);
184 goto cleanup;
185 }
186
188 if (!Value)
189 {
190 TRACE("HeapAlloc() failed\n");
191 goto cleanup;
192 }
194 ValueName,
195 NULL,
196 NULL,
197 (LPBYTE)Value,
198 &dwSize);
199 if (rc != ERROR_SUCCESS)
200 {
201 TRACE("RegQueryValueEx() failed with error %lu\n", rc);
202 goto cleanup;
203 }
204
205 /* Convert Value to a Lcid */
206 ValueString.Length = ValueString.MaximumLength = (USHORT)dwSize;
207 ValueString.Buffer = Value;
208 Status = RtlUnicodeStringToInteger(&ValueString, 16, (PULONG)&Lcid);
209 if (!NT_SUCCESS(Status))
210 {
211 TRACE("RtlUnicodeStringToInteger() failed with status 0x%08lx\n", Status);
212 goto cleanup;
213 }
214
215 TRACE("%s language is 0x%08lx\n",
216 UserProfile ? "User" : "System", Lcid);
217 Status = NtSetDefaultLocale(UserProfile, Lcid);
218 if (!NT_SUCCESS(Status))
219 {
220 TRACE("NtSetDefaultLocale() failed with status 0x%08lx\n", Status);
221 goto cleanup;
222 }
223
224 ret = TRUE;
225
226cleanup:
227 if (Value)
229
230 if (hKey)
232
233 if (UserProfile)
234 RevertToSelf();
235
236 return ret;
237}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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().

◆ 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:1995
VOID FASTCALL Logon(BOOL IsLogon)
Definition: logon.c:74
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301

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: seclogon.c:18
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
PSTART_RPC_SERVER StartRpcServer
Definition: svc.h:114

◆ StartScreenSaver()

VOID StartScreenSaver ( IN PWLSESSION  Session)

Definition at line 257 of file screensaver.c.

259{
260 HKEY hKey = NULL, hCurrentUser = NULL;
261 WCHAR szApplicationName[MAX_PATH];
262 WCHAR szCommandLine[MAX_PATH + 3];
263 DWORD bufferSize = sizeof(szApplicationName) - sizeof(WCHAR);
264 DWORD dwType;
265 STARTUPINFOW StartupInfo;
266 PROCESS_INFORMATION ProcessInformation;
267 HANDLE HandleArray[2];
268 LONG rc;
270 BOOL ret = FALSE;
271
272 if (!ImpersonateLoggedOnUser(Session->UserToken))
273 {
274 ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
275 goto cleanup;
276 }
277
279 &hCurrentUser);
280 if (rc != ERROR_SUCCESS)
281 {
282 ERR("WL: RegOpenCurrentUser error %lu\n", rc);
283 goto cleanup;
284 }
285
286 rc = RegOpenKeyExW(hCurrentUser,
287 L"Control Panel\\Desktop",
288 0,
290 &hKey);
291 if (rc != ERROR_SUCCESS)
292 {
293 ERR("WL: RegOpenKeyEx error %lu\n", rc);
294 goto cleanup;
295 }
296
298 L"SCRNSAVE.EXE",
299 0,
300 &dwType,
301 (LPBYTE)szApplicationName,
302 &bufferSize);
303 if (rc != ERROR_SUCCESS || dwType != REG_SZ)
304 {
305 if (rc != ERROR_FILE_NOT_FOUND)
306 ERR("WL: RegQueryValueEx error %lu\n", rc);
307 goto cleanup;
308 }
309
310 if (bufferSize == 0)
311 {
312 ERR("WL: Buffer size is NULL!\n");
313 goto cleanup;
314 }
315
316 szApplicationName[bufferSize / sizeof(WCHAR)] = 0; /* Terminate the string */
317
318 if (wcslen(szApplicationName) == 0)
319 {
320 ERR("WL: Application Name length is zero!\n");
321 goto cleanup;
322 }
323
324 wsprintfW(szCommandLine, L"%s /s", szApplicationName);
325 TRACE("WL: Executing %S\n", szCommandLine);
326
327 ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
328 ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
329 StartupInfo.cb = sizeof(STARTUPINFOW);
330 StartupInfo.dwFlags = STARTF_SCREENSAVER;
331
332 /* FIXME: Run the screen saver on the secure screen saver desktop if required */
333 StartupInfo.lpDesktop = L"WinSta0\\Default";
334
335 ret = CreateProcessAsUserW(Session->UserToken,
336 szApplicationName,
337 szCommandLine,
338 NULL,
339 NULL,
340 FALSE,
342 NULL,
343 NULL,
344 &StartupInfo,
345 &ProcessInformation);
346 if (!ret)
347 {
348 ERR("WL: Unable to start %S, error %lu\n", szApplicationName, GetLastError());
349 goto cleanup;
350 }
351
352 CloseHandle(ProcessInformation.hThread);
353
354 SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0);
355
357
358 /* Wait the end of the process or some other activity */
359 ResetEvent(Session->hUserActivity);
360 HandleArray[0] = ProcessInformation.hProcess;
361 HandleArray[1] = Session->hUserActivity;
362 Status = WaitForMultipleObjects(2, HandleArray, FALSE, INFINITE);
363 if (Status == WAIT_OBJECT_0 + 1)
364 {
365 /* Kill the screen saver */
366 TerminateProcess(ProcessInformation.hProcess, 0);
367 }
368
369 SetEvent(Session->hEndOfScreenSaver);
370
371 CloseHandle(ProcessInformation.hProcess);
372
374
375cleanup:
376 if (hKey)
378
379 if (hCurrentUser)
380 RegCloseKey(hCurrentUser);
381
382 RevertToSelf();
383
384 if (!ret)
385 {
387#ifndef USE_GETLASTINPUTINFO
388 InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());
389#endif
390 }
391}
#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:993
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
size_t bufferSize
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPWSTR lpDesktop
Definition: winbase.h:854
DWORD cb
Definition: winbase.h:852
DWORD dwFlags
Definition: winbase.h:863
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:165
#define ZeroMemory
Definition: winbase.h:1712
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:182
struct _STARTUPINFOW STARTUPINFOW
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 */
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
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:154
#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
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
char _InterlockedCompareExchange8(_Interlocked_operand_ char volatile *_Destination, char _Exchange, char _Comparand)
#define UNICODE_NULL
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
BOOLEAN bShuttingDown
Definition: shutdown.c:35
BOOLEAN bForceAppsClosed
Definition: shutdown.c:37
BOOLEAN bRebootAfterShutdown
Definition: shutdown.c:36
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
#define ERROR_SHUTDOWN_IN_PROGRESS
Definition: winerror.h:651

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:652

Referenced by BaseAbortSystemShutdown().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( winlogon  )

◆ WlxAssignShellProtection()

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

Definition at line 248 of file wlx.c.

253{
258
260 return 0;
261}
#define UNIMPLEMENTED
Definition: debug.h:115
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ WlxChangePasswordNotify()

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

Definition at line 423 of file wlx.c.

427{
429 UNREFERENCED_PARAMETER(pMprInfo);
430 UNREFERENCED_PARAMETER(dwChangeInfo);
431
433 return 0;
434}

◆ WlxChangePasswordNotifyEx()

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

Definition at line 495 of file wlx.c.

501{
503 UNREFERENCED_PARAMETER(pMprInfo);
504 UNREFERENCED_PARAMETER(dwChangeInfo);
505 UNREFERENCED_PARAMETER(ProviderName);
507
509 return 0;
510}
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

◆ WlxCloseUserDesktop()

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

Definition at line 517 of file wlx.c.

521{
523 UNREFERENCED_PARAMETER(pDesktop);
525
527 return FALSE;
528}

◆ WlxCreateUserDesktop()

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

Definition at line 473 of file wlx.c.

479{
483 UNREFERENCED_PARAMETER(pszDesktopName);
484 UNREFERENCED_PARAMETER(ppDesktop);
485
487 return FALSE;
488}

◆ WlxDialogBox()

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

Definition at line 287 of file wlx.c.

293{
295
296 TRACE("WlxDialogBox()\n");
297
298 return (int)WlxDialogBoxParam(hWlx, hInst, lpszTemplate, hwndOwner, dlgprc, 0);
299}
HINSTANCE hInst
Definition: dxdiag.c:13
int WINAPI WlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:306

◆ WlxDialogBoxIndirect()

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

Definition at line 340 of file wlx.c.

346{
348
349 TRACE("WlxDialogBoxIndirect()\n");
350
351 return (int)WlxDialogBoxIndirectParam(hWlx, hInst, hDialogTemplate, hwndOwner, dlgprc, 0);
352}
int WINAPI WlxDialogBoxIndirectParam(HANDLE hWlx, HANDLE hInst, LPCDLGTEMPLATE hDialogTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
Definition: wlx.c:359

◆ WlxDialogBoxIndirectParam()

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

Definition at line 359 of file wlx.c.

366{
367 PDIALOG_LIST_ENTRY ListEntry;
368 int ret;
369
371
372 TRACE("WlxDialogBoxIndirectParam()\n");
373
374 ListEntry = AddDialogListEntry();
375 if (ListEntry == NULL)
376 return -1;
377
378 ListEntry->DlgProc = dlgprc;
379 ListEntry->lParam = dwInitParam;
380
381 ret = (int)DialogBoxIndirectParamW(hInst, hDialogTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
382
383 RemoveDialogListEntry(ListEntry);
384
385 return ret;
386}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
DLGPROC DlgProc
Definition: wlx.c:19
LPARAM lParam
Definition: wlx.c:20
LONG_PTR LPARAM
Definition: windef.h:208
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 306 of file wlx.c.

313{
314 PDIALOG_LIST_ENTRY ListEntry;
315 int ret;
316
318
319 TRACE("WlxDialogBoxParam()\n");
320
321 ListEntry = AddDialogListEntry();
322 if (ListEntry == NULL)
323 return -1;
324
325 ListEntry->DlgProc = dlgprc;
326 ListEntry->lParam = dwInitParam;
327
328 ret = (int)DialogBoxParamW(hInst, lpszTemplate, hwndOwner, DefaultWlxWindowProc, (LPARAM)ListEntry);
329
330 RemoveDialogListEntry(ListEntry);
331
332 return ret;
333}
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 667 of file wlx.c.

668{
670 return FALSE;
671}

◆ WlxGetOption()

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

Definition at line 568 of file wlx.c.

572{
573 PWLSESSION Session = (PWLSESSION)hWlx;
574
575 TRACE("WlxGetOption(%lu)\n", Option);
576
577 switch (Option)
578 {
581 return TRUE;
583 {
584 *Value = (ULONG_PTR)Session->Gina.Context;
585 return TRUE;
586 }
591 return FALSE;
593 {
594 switch (Session->Gina.Version)
595 {
596 case WLX_VERSION_1_0:
598 break;
599 case WLX_VERSION_1_1:
601 break;
602 case WLX_VERSION_1_2:
604 break;
605 case WLX_VERSION_1_3:
607 break;
608 case WLX_VERSION_1_4:
610 break;
611 default:
612 return FALSE;
613 }
614 return TRUE;
615 }
616 }
617
618 return FALSE;
619}
#define ULONG_PTR
Definition: config.h:101
PVOID Context
Definition: winlogon.h:129
BOOL UseCtrlAltDelete
Definition: winlogon.h:131
DWORD Version
Definition: winlogon.h:130
GINAINSTANCE Gina
Definition: winlogon.h:221
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 441 of file wlx.c.

444{
446 UNREFERENCED_PARAMETER(ppDesktop);
447
449 return FALSE;
450}

◆ WlxMessageBox()

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

Definition at line 268 of file wlx.c.

274{
276
277 TRACE("WlxMessageBox()\n");
278 /* FIXME: Provide a custom window proc to be able to handle timeout */
279 return MessageBoxW(hwndOwner, lpszText, lpszTitle, fuStyle);
280}
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 639 of file wlx.c.

641{
643
645 return FALSE;
646}

◆ WlxQueryConsoleSwitchCredentials()

DWORD WINAPI WlxQueryConsoleSwitchCredentials ( PWLX_CONSOLESWITCH_CREDENTIALS_INFO_V1_0  pCred)

Definition at line 698 of file wlx.c.

700{
702
704 return 0;
705}

◆ WlxQueryInetConnectorCredentials()

BOOL WINAPI WlxQueryInetConnectorCredentials ( PWLX_CLIENT_CREDENTIALS_INFO_V1_0  pCred)

Definition at line 653 of file wlx.c.

655{
657
659 return FALSE;
660}

◆ WlxQueryTerminalServicesData()

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

Definition at line 678 of file wlx.c.

683{
685 UNREFERENCED_PARAMETER(pTSData);
686 UNREFERENCED_PARAMETER(UserName);
688
690 return 0;
691}

◆ WlxQueryTsLogonCredentials()

BOOL WINAPI WlxQueryTsLogonCredentials ( PWLX_CLIENT_CREDENTIALS_INFO_V2_0  pCred)

Definition at line 712 of file wlx.c.

714{
716
718 return FALSE;
719}

◆ WlxSasNotify()

VOID WINAPI WlxSasNotify ( HANDLE  hWlx,
DWORD  dwSasType 
)

Definition at line 214 of file wlx.c.

217{
218 PWLSESSION Session = (PWLSESSION)hWlx;
219
220 TRACE("WlxSasNotify(0x%lx)\n", dwSasType);
221
222 if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL || dwSasType > WLX_SAS_TYPE_MAX_MSFT_VALUE)
223 PostMessageW(Session->SASWindow, WLX_WM_SAS, dwSasType, 0);
224}
HWND SASWindow
Definition: winlogon.h:225
#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 198 of file wlx.c.

201{
202 ULONG_PTR OldValue;
203
204 TRACE("WlxSetContextPointer(%p)\n", pWlxContext);
205
206 WlxSetOption(hWlx, WLX_OPTION_CONTEXT_POINTER, (ULONG_PTR)pWlxContext, &OldValue);
207}
BOOL WINAPI WlxSetOption(HANDLE hWlx, DWORD Option, ULONG_PTR Value, ULONG_PTR *OldValue)
Definition: wlx.c:535

◆ WlxSetOption()

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

Definition at line 535 of file wlx.c.

540{
541 PWLSESSION Session = (PWLSESSION)hWlx;
542
543 TRACE("WlxSetOption(%lu)\n", Option);
544
545 switch (Option)
546 {
548 *OldValue = (ULONG_PTR)Session->Gina.UseCtrlAltDelete;
549 Session->Gina.UseCtrlAltDelete = (BOOL)Value;
550 return TRUE;
552 *OldValue = (ULONG_PTR)Session->Gina.Context;
553 Session->Gina.Context = (PVOID)Value;
554 return TRUE;
557 return FALSE;
558 }
559
560 return FALSE;
561}

Referenced by WlxSetContextPointer(), and WlxUseCtrlAltDel().

◆ WlxSetReturnDesktop()

BOOL WINAPI WlxSetReturnDesktop ( HANDLE  hWlx,
PWLX_DESKTOP  pDesktop 
)

Definition at line 457 of file wlx.c.

460{
462 UNREFERENCED_PARAMETER(pDesktop);
463
465 return FALSE;
466}

◆ WlxSetTimeout()

BOOL WINAPI WlxSetTimeout ( HANDLE  hWlx,
DWORD  Timeout 
)

Definition at line 231 of file wlx.c.

234{
235 PWLSESSION Session = (PWLSESSION)hWlx;
236
237 TRACE("WlxSetTimeout(%lu)\n", Timeout);
238
239 Session->DialogTimeout = Timeout;
240 return TRUE;
241}
static ULONG Timeout
Definition: ping.c:61
DWORD DialogTimeout
Definition: winlogon.h:235

◆ WlxSwitchDesktopToUser()

int WINAPI WlxSwitchDesktopToUser ( HANDLE  hWlx)

Definition at line 393 of file wlx.c.

395{
396 PWLSESSION Session = (PWLSESSION)hWlx;
397
398 TRACE("WlxSwitchDesktopToUser()\n");
399
400 return (int)SwitchDesktop(Session->ApplicationDesktop);
401}

◆ WlxSwitchDesktopToWinlogon()

int WINAPI WlxSwitchDesktopToWinlogon ( HANDLE  hWlx)

Definition at line 408 of file wlx.c.

410{
411 PWLSESSION Session = (PWLSESSION)hWlx;
412
413 TRACE("WlxSwitchDesktopToWinlogon()\n");
414
415 return (int)SwitchDesktop(Session->WinlogonDesktop);
416}

◆ WlxUseCtrlAltDel()

VOID WINAPI WlxUseCtrlAltDel ( HANDLE  hWlx)

Definition at line 183 of file wlx.c.

185{
186 ULONG_PTR OldValue;
187
188 TRACE("WlxUseCtrlAltDel()\n");
189
191}

◆ WlxWin31Migrate()

VOID WINAPI WlxWin31Migrate ( HANDLE  hWlx)

Definition at line 626 of file wlx.c.

628{
630
632}

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().