ReactOS  0.4.13-dev-464-g6b95727
sas.c File Reference
#include "winlogon.h"
#include <aclapi.h>
#include <mmsystem.h>
#include <userenv.h>
#include <ndk/setypes.h>
#include <ndk/sefuncs.h>
Include dependency graph for sas.c:

Go to the source code of this file.

Classes

struct  tagLOGOFF_SHUTDOWN_DATA
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WINLOGON_SAS_CLASS   L"SAS Window class"
 
#define WINLOGON_SAS_TITLE   L"SAS window"
 
#define HK_CTRL_ALT_DEL   0
 
#define HK_CTRL_SHIFT_ESC   1
 
#define EWX_ACTION_MASK   0x5C0F
 

Typedefs

typedef struct tagLOGOFF_SHUTDOWN_DATA LOGOFF_SHUTDOWN_DATA
 
typedef struct tagLOGOFF_SHUTDOWN_DATAPLOGOFF_SHUTDOWN_DATA
 

Functions

static BOOL StartTaskManager (IN OUT PWLSESSION Session)
 
static BOOL StartUserShell (IN OUT PWLSESSION Session)
 
BOOL SetDefaultLanguage (IN PWLSESSION Session)
 
BOOL PlaySoundRoutine (IN LPCWSTR FileName, IN UINT bLogon, IN UINT Flags)
 
DWORD WINAPI PlayLogonSoundThread (IN LPVOID lpParameter)
 
static VOID PlayLogonSound (IN OUT PWLSESSION Session)
 
static BOOL AllowWinstaAccess (PWLSESSION Session)
 
static VOID RestoreAllConnections (PWLSESSION Session)
 
static BOOL HandleLogon (IN OUT PWLSESSION Session)
 
static DWORD WINAPI LogoffShutdownThread (LPVOID Parameter)
 
static DWORD WINAPI KillComProcesses (LPVOID Parameter)
 
static NTSTATUS CreateLogoffSecurityAttributes (OUT PSECURITY_ATTRIBUTES *ppsa)
 
static VOID DestroyLogoffSecurityAttributes (IN PSECURITY_ATTRIBUTES psa)
 
static NTSTATUS HandleLogoff (IN OUT PWLSESSION Session, IN UINT Flags)
 
static INT_PTR CALLBACK ShutdownComputerWindowProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static VOID UninitializeSAS (IN OUT PWLSESSION Session)
 
NTSTATUS HandleShutdown (IN OUT PWLSESSION Session, IN DWORD wlxAction)
 
static VOID DoGenericAction (IN OUT PWLSESSION Session, IN DWORD wlxAction)
 
static VOID DispatchSAS (IN OUT PWLSESSION Session, IN DWORD dwSasType)
 
static BOOL RegisterHotKeys (IN PWLSESSION Session, IN HWND hwndSAS)
 
static BOOL UnregisterHotKeys (IN PWLSESSION Session, IN HWND hwndSAS)
 
BOOL WINAPI HandleMessageBeep (UINT uType)
 
static LRESULT CALLBACK SASWindowProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
BOOL InitializeSAS (IN OUT PWLSESSION Session)
 

Variables

static BOOL ExitReactOSInProgress = FALSE
 
LUID LuidNone = {0, 0}
 

Macro Definition Documentation

◆ EWX_ACTION_MASK

#define EWX_ACTION_MASK   0x5C0F

Definition at line 36 of file sas.c.

◆ HK_CTRL_ALT_DEL

#define HK_CTRL_ALT_DEL   0

Definition at line 28 of file sas.c.

◆ HK_CTRL_SHIFT_ESC

#define HK_CTRL_SHIFT_ESC   1

Definition at line 29 of file sas.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 16 of file sas.c.

◆ WINLOGON_SAS_CLASS

#define WINLOGON_SAS_CLASS   L"SAS Window class"

Definition at line 25 of file sas.c.

◆ WINLOGON_SAS_TITLE

#define WINLOGON_SAS_TITLE   L"SAS window"

Definition at line 26 of file sas.c.

Typedef Documentation

◆ LOGOFF_SHUTDOWN_DATA

◆ PLOGOFF_SHUTDOWN_DATA

Function Documentation

◆ AllowWinstaAccess()

static BOOL AllowWinstaAccess ( PWLSESSION  Session)
static

Definition at line 431 of file sas.c.

432 {
433  BOOL bSuccess = FALSE;
434  DWORD dwIndex;
435  DWORD dwLength = 0;
436  PTOKEN_GROUPS ptg = NULL;
437  PSID psid;
438  TOKEN_STATISTICS Stats;
439  DWORD cbStats;
440  DWORD ret;
441 
442  // Get required buffer size and allocate the TOKEN_GROUPS buffer.
443 
444  if (!GetTokenInformation(Session->UserToken,
445  TokenGroups,
446  ptg,
447  0,
448  &dwLength))
449  {
451  return FALSE;
452 
454  if (ptg == NULL)
455  return FALSE;
456  }
457 
458  // Get the token group information from the access token.
459  if (!GetTokenInformation(Session->UserToken,
460  TokenGroups,
461  ptg,
462  dwLength,
463  &dwLength))
464  {
465  goto Cleanup;
466  }
467 
468  // Loop through the groups to find the logon SID.
469 
470  for (dwIndex = 0; dwIndex < ptg->GroupCount; dwIndex++)
471  {
472  if ((ptg->Groups[dwIndex].Attributes & SE_GROUP_LOGON_ID)
474  {
475  psid = ptg->Groups[dwIndex].Sid;
476  break;
477  }
478  }
479 
480  dwLength = GetLengthSid(psid);
481 
482  if (!GetTokenInformation(Session->UserToken,
484  &Stats,
485  sizeof(TOKEN_STATISTICS),
486  &cbStats))
487  {
488  WARN("Couldn't get Authentication id from user token!\n");
489  goto Cleanup;
490  }
491 
493 
495  &Stats.AuthenticationId,
496  psid,
497  dwLength);
498  TRACE("SetWindowStationUser returned 0x%x\n", ret);
499 
500  bSuccess = TRUE;
501 
502 Cleanup:
503 
504  // Free the buffer for the token groups.
505  if (ptg != NULL)
506  HeapFree(GetProcessHeap(), 0, (LPVOID)ptg);
507 
508  return bSuccess;
509 }
LUID AuthenticationId
Definition: setypes.h:1033
BOOL WINAPI SetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:419
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
HANDLE UserToken
Definition: winlogon.h:227
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static BOOLEAN bSuccess
Definition: drive.cpp:417
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
struct _TOKEN_GROUPS * PTOKEN_GROUPS
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:83
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:798
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR Cleanup[]
Definition: register.c:80
#define SE_GROUP_LOGON_ID
Definition: setypes.h:98
BOOL AddAceToWindowStation(IN HWINSTA WinSta, IN PSID Sid)
Definition: wlx.c:942
HWINSTA InteractiveWindowStation
Definition: winlogon.h:221
SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]
Definition: setypes.h:964
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
$ULONG GroupCount
Definition: setypes.h:960
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by HandleLogon().

◆ CreateLogoffSecurityAttributes()

static NTSTATUS CreateLogoffSecurityAttributes ( OUT PSECURITY_ATTRIBUTES ppsa)
static

Definition at line 769 of file sas.c.

771 {
772  /* The following code is not working yet and messy */
773  /* Still, it gives some ideas about data types and functions involved and */
774  /* required to set up a SECURITY_DESCRIPTOR for a SECURITY_ATTRIBUTES */
775  /* instance for a thread, to allow that thread to ImpersonateLoggedOnUser(). */
776  /* Specifically THREAD_SET_THREAD_TOKEN is required. */
779  BYTE* pMem;
780  PACL pACL;
781  EXPLICIT_ACCESS Access;
782  PSID pEveryoneSID = NULL;
784 
785  *ppsa = NULL;
786 
787  // Let's first try to enumerate what kind of data we need for this to ever work:
788  // 1. The Winlogon SID, to be able to give it THREAD_SET_THREAD_TOKEN.
789  // 2. The users SID (the user trying to logoff, or rather shut down the system).
790  // 3. At least two EXPLICIT_ACCESS instances:
791  // 3.1 One for Winlogon itself, giving it the rights
792  // required to THREAD_SET_THREAD_TOKEN (as it's needed to successfully call
793  // ImpersonateLoggedOnUser).
794  // 3.2 One for the user, to allow *that* thread to perform its work.
795  // 4. An ACL to hold the these EXPLICIT_ACCESS ACE's.
796  // 5. A SECURITY_DESCRIPTOR to hold the ACL, and finally.
797  // 6. A SECURITY_ATTRIBUTES instance to pull all of this required stuff
798  // together, to hand it to CreateThread.
799  //
800  // However, it seems struct LOGOFF_SHUTDOWN_DATA doesn't contain
801  // these required SID's, why they'd have to be added.
802  // The Winlogon's own SID should probably only be created once,
803  // while the user's SID obviously must be created for each new user.
804  // Might as well store it when the user logs on?
805 
807  1,
809  0, 0, 0, 0, 0, 0, 0,
810  &pEveryoneSID))
811  {
812  ERR("Failed to initialize security descriptor for logoff thread!\n");
813  return STATUS_UNSUCCESSFUL;
814  }
815 
816  /* set up the required security attributes to be able to shut down */
817  /* To save space and time, allocate a single block of memory holding */
818  /* both SECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR */
819  pMem = HeapAlloc(GetProcessHeap(),
820  0,
821  sizeof(SECURITY_ATTRIBUTES) +
823  sizeof(ACL));
824  if (!pMem)
825  {
826  ERR("Failed to allocate memory for logoff security descriptor!\n");
827  return STATUS_NO_MEMORY;
828  }
829 
830  /* Note that the security descriptor needs to be in _absolute_ format, */
831  /* meaning its members must be pointers to other structures, rather */
832  /* than the relative format using offsets */
833  psa = (PSECURITY_ATTRIBUTES)pMem;
836 
837  // Initialize an EXPLICIT_ACCESS structure for an ACE.
838  // The ACE will allow this thread to log off (and shut down the system, currently).
839  ZeroMemory(&Access, sizeof(Access));
841  Access.grfAccessMode = SET_ACCESS; // GRANT_ACCESS?
845  Access.Trustee.ptstrName = pEveryoneSID;
846 
847  if (SetEntriesInAcl(1, &Access, NULL, &pACL) != ERROR_SUCCESS)
848  {
849  ERR("Failed to set Access Rights for logoff thread. Logging out will most likely fail.\n");
850 
851  HeapFree(GetProcessHeap(), 0, pMem);
852  return STATUS_UNSUCCESSFUL;
853  }
854 
856  {
857  ERR("Failed to initialize security descriptor for logoff thread!\n");
858  HeapFree(GetProcessHeap(), 0, pMem);
859  return STATUS_UNSUCCESSFUL;
860  }
861 
863  TRUE, // bDaclPresent flag
864  pACL,
865  FALSE)) // not a default DACL
866  {
867  ERR("SetSecurityDescriptorDacl Error %lu\n", GetLastError());
868  HeapFree(GetProcessHeap(), 0, pMem);
869  return STATUS_UNSUCCESSFUL;
870  }
871 
872  psa->nLength = sizeof(SECURITY_ATTRIBUTES);
873  psa->lpSecurityDescriptor = SecurityDescriptor;
874  psa->bInheritHandle = FALSE;
875 
876  *ppsa = psa;
877 
878  return STATUS_SUCCESS;
879 }
struct _SECURITY_DESCRIPTOR * PSECURITY_DESCRIPTOR
Definition: security.c:97
TRUSTEE_TYPE TrusteeType
Definition: accctrl.h:207
#define NO_INHERITANCE
Definition: accctrl.h:103
#define TRUE
Definition: types.h:120
ACCESS_MODE grfAccessMode
Definition: accctrl.h:333
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SECURITY_DESCRIPTOR_MIN_LENGTH
Definition: setypes.h:761
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:808
static SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: security.c:14
TRUSTEE_A Trustee
Definition: accctrl.h:335
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
#define THREAD_SET_THREAD_TOKEN
Definition: pstypes.h:142
LPSTR ptstrName
Definition: accctrl.h:208
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
smooth NULL
Definition: ftsmooth.c:416
struct _ACL * PACL
Definition: security.c:104
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SECURITY_WORLD_SID_AUTHORITY
Definition: setypes.h:499
#define SECURITY_WORLD_RID
Definition: setypes.h:513
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
DWORD grfInheritance
Definition: accctrl.h:334
unsigned char BYTE
Definition: mem.h:68
#define ERR(fmt,...)
Definition: debug.h:109
#define SetEntriesInAcl
Definition: aclapi.h:240
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
DWORD grfAccessPermissions
Definition: accctrl.h:332
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
struct _SECURITY_ATTRIBUTES * PSECURITY_ATTRIBUTES
TRUSTEE_FORM TrusteeForm
Definition: accctrl.h:206
return STATUS_SUCCESS
Definition: btrfs.c:2777
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:394
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
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:553

Referenced by HandleLogoff().

◆ DestroyLogoffSecurityAttributes()

static VOID DestroyLogoffSecurityAttributes ( IN PSECURITY_ATTRIBUTES  psa)
static

Definition at line 883 of file sas.c.

885 {
886  if (psa)
887  {
888  HeapFree(GetProcessHeap(), 0, psa);
889  }
890 }
#define GetProcessHeap()
Definition: compat.h:395
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by HandleLogoff().

◆ DispatchSAS()

static VOID DispatchSAS ( IN OUT PWLSESSION  Session,
IN DWORD  dwSasType 
)
static

Definition at line 1212 of file sas.c.

1215 {
1216  DWORD wlxAction = WLX_SAS_ACTION_NONE;
1217  PSID LogonSid = NULL; /* FIXME */
1218  BOOL bSecure = TRUE;
1219 
1220  switch (dwSasType)
1221  {
1223  switch (Session->LogonState)
1224  {
1225  case STATE_INIT:
1226  Session->LogonState = STATE_LOGGED_OFF;
1227  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1228  return;
1229 
1230  case STATE_LOGGED_OFF:
1231  Session->LogonState = STATE_LOGGED_OFF_SAS;
1232 
1234 
1235  Session->Options = 0;
1236 
1237  wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS(
1238  Session->Gina.Context,
1239  Session->SASAction,
1240  &Session->LogonId,
1241  LogonSid,
1242  &Session->Options,
1243  &Session->UserToken,
1244  &Session->MprNotifyInfo,
1245  (PVOID*)&Session->Profile);
1246  break;
1247 
1248  case STATE_LOGGED_OFF_SAS:
1249  /* Ignore SAS if we are already in an SAS state */
1250  return;
1251 
1252  case STATE_LOGGED_ON:
1253  Session->LogonState = STATE_LOGGED_ON_SAS;
1254  wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOnSAS(Session->Gina.Context, dwSasType, NULL);
1255  break;
1256 
1257  case STATE_LOGGED_ON_SAS:
1258  /* Ignore SAS if we are already in an SAS state */
1259  return;
1260 
1261  case STATE_LOCKED:
1262  Session->LogonState = STATE_LOCKED_SAS;
1263 
1265 
1266  wlxAction = (DWORD)Session->Gina.Functions.WlxWkstaLockedSAS(Session->Gina.Context, dwSasType);
1267  break;
1268 
1269  case STATE_LOCKED_SAS:
1270  /* Ignore SAS if we are already in an SAS state */
1271  return;
1272 
1273  default:
1274  return;
1275  }
1276  break;
1277 
1278  case WLX_SAS_TYPE_TIMEOUT:
1279  return;
1280 
1282  if (!Session->Gina.Functions.WlxScreenSaverNotify(Session->Gina.Context, &bSecure))
1283  {
1284  /* Skip start of screen saver */
1285  SetEvent(Session->hEndOfScreenSaver);
1286  }
1287  else
1288  {
1289  StartScreenSaver(Session);
1290  if (bSecure)
1291  {
1292  wlxAction = WLX_SAS_ACTION_LOCK_WKSTA;
1293 // DoGenericAction(Session, WLX_SAS_ACTION_LOCK_WKSTA);
1294  }
1295  }
1296  break;
1297 
1299  SetEvent(Session->hUserActivity);
1300  break;
1301  }
1302 
1303  DoGenericAction(Session, wlxAction);
1304 }
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define TRUE
Definition: types.h:120
#define WLX_SAS_TYPE_SCRNSVR_ACTIVITY
Definition: winwlx.h:38
VOID StartScreenSaver(IN PWLSESSION Session)
Definition: screensaver.c:257
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define WLX_SAS_TYPE_TIMEOUT
Definition: winwlx.h:35
static VOID DoGenericAction(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1122
#define DWORD
Definition: nt_native.h:44
#define WLX_SAS_TYPE_SCRNSVR_TIMEOUT
Definition: winwlx.h:37
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
VOID CloseAllDialogWindows(VOID)
Definition: wlx.c:109
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54

Referenced by SASWindowProc().

◆ DoGenericAction()

static VOID DoGenericAction ( IN OUT PWLSESSION  Session,
IN DWORD  wlxAction 
)
static

Definition at line 1122 of file sas.c.

1125 {
1126  switch (wlxAction)
1127  {
1128  case WLX_SAS_ACTION_LOGON: /* 0x01 */
1129  if (Session->LogonState == STATE_LOGGED_OFF_SAS)
1130  {
1131  if (!HandleLogon(Session))
1132  {
1133  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1135  }
1136  }
1137  break;
1138  case WLX_SAS_ACTION_NONE: /* 0x02 */
1139  if (Session->LogonState == STATE_LOGGED_OFF_SAS)
1140  {
1141  Session->LogonState = STATE_LOGGED_OFF;
1142  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1143  }
1144  else if (Session->LogonState == STATE_LOGGED_ON_SAS)
1145  {
1146  Session->LogonState = STATE_LOGGED_ON;
1147  }
1148  else if (Session->LogonState == STATE_LOCKED_SAS)
1149  {
1150  Session->LogonState = STATE_LOCKED;
1151  Session->Gina.Functions.WlxDisplayLockedNotice(Session->Gina.Context);
1152  }
1153  break;
1154  case WLX_SAS_ACTION_LOCK_WKSTA: /* 0x03 */
1155  if (Session->Gina.Functions.WlxIsLockOk(Session->Gina.Context))
1156  {
1157  SwitchDesktop(Session->WinlogonDesktop);
1158  Session->LogonState = STATE_LOCKED;
1159  Session->Gina.Functions.WlxDisplayLockedNotice(Session->Gina.Context);
1161  }
1162  break;
1163  case WLX_SAS_ACTION_LOGOFF: /* 0x04 */
1164  case WLX_SAS_ACTION_SHUTDOWN: /* 0x05 */
1165  case WLX_SAS_ACTION_SHUTDOWN_POWER_OFF: /* 0x0a */
1166  case WLX_SAS_ACTION_SHUTDOWN_REBOOT: /* 0x0b */
1167  if (Session->LogonState != STATE_LOGGED_OFF)
1168  {
1169  if (!Session->Gina.Functions.WlxIsLogoffOk(Session->Gina.Context))
1170  break;
1171  if (!NT_SUCCESS(HandleLogoff(Session, EWX_LOGOFF)))
1172  {
1173  RemoveStatusMessage(Session);
1174  break;
1175  }
1176  Session->Gina.Functions.WlxLogoff(Session->Gina.Context);
1177  }
1178  if (WLX_SHUTTINGDOWN(wlxAction))
1179  {
1180  // FIXME: WlxShutdown should be done from inside HandleShutdown,
1181  // after having displayed "ReactOS is shutting down" message.
1182  Session->Gina.Functions.WlxShutdown(Session->Gina.Context, wlxAction);
1183  if (!NT_SUCCESS(HandleShutdown(Session, wlxAction)))
1184  {
1185  RemoveStatusMessage(Session);
1186  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1187  }
1188  }
1189  else
1190  {
1191  RemoveStatusMessage(Session);
1192  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1193  }
1194  break;
1195  case WLX_SAS_ACTION_TASKLIST: /* 0x07 */
1196  SwitchDesktop(Session->ApplicationDesktop);
1197  Session->LogonState = STATE_LOGGED_ON;
1198  StartTaskManager(Session);
1199  break;
1200  case WLX_SAS_ACTION_UNLOCK_WKSTA: /* 0x08 */
1201  SwitchDesktop(Session->ApplicationDesktop);
1202  Session->LogonState = STATE_LOGGED_ON;
1204  break;
1205  default:
1206  WARN("Unknown SAS action 0x%lx\n", wlxAction);
1207  }
1208 }
#define WLX_SAS_ACTION_SHUTDOWN
Definition: winwlx.h:57
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:237
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL StartTaskManager(IN OUT PWLSESSION Session)
Definition: sas.c:51
NTSTATUS HandleShutdown(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1039
#define EWX_LOGOFF
Definition: winuser.h:631
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
#define WLX_SAS_ACTION_UNLOCK_WKSTA
Definition: winwlx.h:60
static BOOL HandleLogon(IN OUT PWLSESSION Session)
Definition: sas.c:577
#define WLX_SHUTTINGDOWN(Status)
Definition: winlogon.h:271
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL WINAPI SwitchDesktop(_In_ HDESK)
#define WLX_SAS_ACTION_LOGON
Definition: winwlx.h:53
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:249
#define WLX_SAS_ACTION_NONE
Definition: winwlx.h:54
#define WLX_SAS_ACTION_TASKLIST
Definition: winwlx.h:59
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
static NTSTATUS HandleLogoff(IN OUT PWLSESSION Session, IN UINT Flags)
Definition: sas.c:895

Referenced by DispatchSAS(), and SASWindowProc().

◆ HandleLogoff()

static NTSTATUS HandleLogoff ( IN OUT PWLSESSION  Session,
IN UINT  Flags 
)
static

Definition at line 895 of file sas.c.

898 {
899  PLOGOFF_SHUTDOWN_DATA LSData;
901  HANDLE hThread;
902  DWORD exitCode;
904 
905  /* Prepare data for logoff thread */
906  LSData = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGOFF_SHUTDOWN_DATA));
907  if (!LSData)
908  {
909  ERR("Failed to allocate mem for thread data\n");
910  return STATUS_NO_MEMORY;
911  }
912  LSData->Flags = Flags;
913  LSData->Session = Session;
914 
916  if (!NT_SUCCESS(Status))
917  {
918  ERR("Failed to create a required security descriptor. Status 0x%08lx\n", Status);
919  HeapFree(GetProcessHeap(), 0, LSData);
920  return Status;
921  }
922 
923  /* Run logoff thread */
925  if (!hThread)
926  {
927  ERR("Unable to create logoff thread, error %lu\n", GetLastError());
929  HeapFree(GetProcessHeap(), 0, LSData);
930  return STATUS_UNSUCCESSFUL;
931  }
933  if (!GetExitCodeThread(hThread, &exitCode))
934  {
935  ERR("Unable to get exit code of logoff thread (error %lu)\n", GetLastError());
938  HeapFree(GetProcessHeap(), 0, LSData);
939  return STATUS_UNSUCCESSFUL;
940  }
942  if (exitCode == 0)
943  {
944  ERR("Logoff thread returned failure\n");
946  HeapFree(GetProcessHeap(), 0, LSData);
947  return STATUS_UNSUCCESSFUL;
948  }
949 
950  SwitchDesktop(Session->WinlogonDesktop);
951 
952  // TODO: Play logoff sound!
953 
954  SetWindowStationUser(Session->InteractiveWindowStation,
955  &LuidNone, NULL, 0);
956 
957  // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOGGINGOFF);
958 
959  // FIXME: Closing network connections!
960  // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_CLOSINGNETWORKCONNECTIONS);
961 
962  /* Kill remaining COM apps. Only at logoff! */
963  hThread = CreateThread(psa, 0, KillComProcesses, (LPVOID)LSData, 0, NULL);
964  if (hThread)
965  {
968  }
969 
970  /* We're done with the SECURITY_DESCRIPTOR */
972  psa = NULL;
973 
974  HeapFree(GetProcessHeap(), 0, LSData);
975 
976  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_SAVEYOURSETTINGS);
977 
978  UnloadUserProfile(Session->UserToken, Session->hProfileInfo);
979 
981 
982  CloseHandle(Session->UserToken);
984  Session->LogonState = STATE_LOGGED_OFF;
985  Session->UserToken = NULL;
986 
987  return STATUS_SUCCESS;
988 }
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:216
BOOL WINAPI SetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:419
#define CloseHandle
Definition: compat.h:398
static DWORD WINAPI KillComProcesses(LPVOID Parameter)
Definition: sas.c:739
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
PWLSESSION Session
Definition: sas.c:41
static VOID DestroyLogoffSecurityAttributes(IN PSECURITY_ATTRIBUTES psa)
Definition: sas.c:883
LUID LuidNone
Definition: sas.c:46
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
Definition: profile.c:2101
static DWORD WINAPI LogoffShutdownThread(LPVOID Parameter)
Definition: sas.c:694
static NTSTATUS CreateLogoffSecurityAttributes(OUT PSECURITY_ATTRIBUTES *ppsa)
Definition: sas.c:769
#define IDS_SAVEYOURSETTINGS
Definition: resource.h:34
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:502
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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:111
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SwitchDesktop(_In_ HDESK)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:249
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
HANDLE hThread
Definition: wizard.c:27
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
DWORD WINAPI UpdatePerUserSystemParameters(DWORD dw1, DWORD dw2)
#define INFINITE
Definition: serial.h:102
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DoGenericAction().

◆ HandleLogon()

static BOOL HandleLogon ( IN OUT PWLSESSION  Session)
static

Definition at line 577 of file sas.c.

579 {
580  PROFILEINFOW ProfileInfo;
581  BOOL ret = FALSE;
582 
583  /* Loading personal settings */
584  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS);
585  ProfileInfo.hProfile = INVALID_HANDLE_VALUE;
586  if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
587  {
588  if (Session->Profile == NULL
589  || (Session->Profile->dwType != WLX_PROFILE_TYPE_V1_0
590  && Session->Profile->dwType != WLX_PROFILE_TYPE_V2_0))
591  {
592  ERR("WL: Wrong profile\n");
593  goto cleanup;
594  }
595 
596  /* Load the user profile */
597  ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW));
598  ProfileInfo.dwSize = sizeof(PROFILEINFOW);
599  ProfileInfo.dwFlags = 0;
600  ProfileInfo.lpUserName = Session->MprNotifyInfo.pszUserName;
601  ProfileInfo.lpProfilePath = Session->Profile->pszProfile;
602  if (Session->Profile->dwType >= WLX_PROFILE_TYPE_V2_0)
603  {
604  ProfileInfo.lpDefaultPath = Session->Profile->pszNetworkDefaultUserProfile;
605  ProfileInfo.lpServerName = Session->Profile->pszServerName;
606  ProfileInfo.lpPolicyPath = Session->Profile->pszPolicy;
607  }
608 
609  if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
610  {
611  ERR("WL: LoadUserProfileW() failed\n");
612  goto cleanup;
613  }
614  }
615 
616  /* Create environment block for the user */
617  if (!CreateUserEnvironment(Session))
618  {
619  WARN("WL: SetUserEnvironment() failed\n");
620  goto cleanup;
621  }
622 
624 
625  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
627 
628  /* Set default user language */
629  if (!SetDefaultLanguage(Session))
630  {
631  WARN("WL: SetDefaultLanguage() failed\n");
632  goto cleanup;
633  }
634 
635  AllowWinstaAccess(Session);
636 
637  /* Connect remote resources */
638  RestoreAllConnections(Session);
639 
640  if (!StartUserShell(Session))
641  {
642  //WCHAR StatusMsg[256];
643  WARN("WL: WlxActivateUserShell() failed\n");
644  //LoadStringW(hAppInstance, IDS_FAILEDACTIVATEUSERSHELL, StatusMsg, sizeof(StatusMsg) / sizeof(StatusMsg[0]));
645  //MessageBoxW(0, StatusMsg, NULL, MB_ICONERROR);
646  goto cleanup;
647  }
648 
650 
651  if (!InitializeScreenSaver(Session))
652  WARN("WL: Failed to initialize screen saver\n");
653 
654  Session->hProfileInfo = ProfileInfo.hProfile;
655 
656  /* Logon has succeeded. Play sound. */
657  PlayLogonSound(Session);
658 
659  ret = TRUE;
660 
661 cleanup:
662  if (Session->Profile)
663  {
664  HeapFree(GetProcessHeap(), 0, Session->Profile->pszProfile);
665  HeapFree(GetProcessHeap(), 0, Session->Profile);
666  }
667  Session->Profile = NULL;
668  if (!ret && ProfileInfo.hProfile != INVALID_HANDLE_VALUE)
669  {
670  UnloadUserProfile(Session->UserToken, ProfileInfo.hProfile);
671  }
672  RemoveStatusMessage(Session);
673  if (!ret)
674  {
675  SetWindowStationUser(Session->InteractiveWindowStation,
676  &LuidNone, NULL, 0);
677  CloseHandle(Session->UserToken);
678  Session->UserToken = NULL;
679  }
680 
681  if (ret)
682  {
683  SwitchDesktop(Session->ApplicationDesktop);
684  Session->LogonState = STATE_LOGGED_ON;
685  }
686 
687  return ret;
688 }
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:216
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:237
#define IDS_APPLYINGYOURPERSONALSETTINGS
Definition: resource.h:26
BOOL WINAPI SetWindowStationUser(IN HWINSTA hWindowStation, IN PLUID pluid, IN PSID psid OPTIONAL, IN DWORD size)
Definition: winsta.c:419
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
HANDLE hProfile
Definition: userenv.h:43
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1635
BOOL CreateUserEnvironment(IN PWLSESSION Session)
Definition: environment.c:128
LUID LuidNone
Definition: sas.c:46
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
Definition: profile.c:2101
LPWSTR lpDefaultPath
Definition: userenv.h:40
LPWSTR lpUserName
Definition: userenv.h:38
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lpServerName
Definition: userenv.h:41
static VOID RestoreAllConnections(PWLSESSION Session)
Definition: sas.c:513
LPWSTR lpPolicyPath
Definition: userenv.h:42
#define GetProcessHeap()
Definition: compat.h:395
BOOL InitializeScreenSaver(IN OUT PWLSESSION Session)
Definition: screensaver.c:204
BOOL WINAPI SwitchDesktop(_In_ HDESK)
DWORD dwSize
Definition: userenv.h:36
BOOL SetDefaultLanguage(IN PWLSESSION Session)
Definition: sas.c:110
int ret
DWORD dwFlags
Definition: userenv.h:37
#define WLX_LOGON_OPT_NO_PROFILE
Definition: winwlx.h:48
struct _PROFILEINFOW PROFILEINFOW
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL StartUserShell(IN OUT PWLSESSION Session)
Definition: sas.c:79
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:249
static VOID PlayLogonSound(IN OUT PWLSESSION Session)
Definition: sas.c:420
LPWSTR lpProfilePath
Definition: userenv.h:39
static BOOL AllowWinstaAccess(PWLSESSION Session)
Definition: sas.c:431
BOOL WINAPI LoadUserProfileW(_In_ HANDLE hToken, _Inout_ LPPROFILEINFOW lpProfileInfo)
Definition: profile.c:1922
char * cleanup(char *str)
Definition: wpickclick.c:99
DWORD WINAPI UpdatePerUserSystemParameters(DWORD dw1, DWORD dw2)
#define WLX_PROFILE_TYPE_V2_0
Definition: winwlx.h:51
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WLX_PROFILE_TYPE_V1_0
Definition: winwlx.h:50
#define IDS_LOADINGYOURPERSONALSETTINGS
Definition: resource.h:29

Referenced by DoGenericAction().

◆ HandleMessageBeep()

BOOL WINAPI HandleMessageBeep ( UINT  uType)

Definition at line 1343 of file sas.c.

1344 {
1345  LPWSTR EventName;
1346 
1347  switch(uType)
1348  {
1349  case 0xFFFFFFFF:
1350  EventName = NULL;
1351  break;
1352  case MB_OK:
1353  EventName = L"SystemDefault";
1354  break;
1355  case MB_ICONASTERISK:
1356  EventName = L"SystemAsterisk";
1357  break;
1358  case MB_ICONEXCLAMATION:
1359  EventName = L"SystemExclamation";
1360  break;
1361  case MB_ICONHAND:
1362  EventName = L"SystemHand";
1363  break;
1364  case MB_ICONQUESTION:
1365  EventName = L"SystemQuestion";
1366  break;
1367  default:
1368  WARN("Unhandled type %d\n", uType);
1369  EventName = L"SystemDefault";
1370  }
1371 
1372  return PlaySoundRoutine(EventName, FALSE, SND_ALIAS | SND_NOWAIT | SND_NOSTOP | SND_ASYNC);
1373 }
#define MB_ICONHAND
Definition: winuser.h:782
#define WARN(fmt,...)
Definition: debug.h:111
BOOL PlaySoundRoutine(IN LPCWSTR FileName, IN UINT bLogon, IN UINT Flags)
Definition: sas.c:239
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define SND_NOSTOP
Definition: mmsystem.h:158
smooth NULL
Definition: ftsmooth.c:416
#define SND_ALIAS
Definition: mmsystem.h:160
#define MB_ICONQUESTION
Definition: winuser.h:783
#define SND_ASYNC
Definition: mmsystem.h:154
#define MB_ICONASTERISK
Definition: winuser.h:778
#define SND_NOWAIT
Definition: mmsystem.h:159
static const WCHAR L[]
Definition: oid.c:1250
#define MB_OK
Definition: winuser.h:784
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by SASWindowProc().

◆ HandleShutdown()

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

Definition at line 1039 of file sas.c.

1042 {
1043  PLOGOFF_SHUTDOWN_DATA LSData;
1044  HANDLE hThread;
1045  DWORD exitCode;
1046  BOOLEAN Old;
1047 
1048  // SwitchDesktop(Session->WinlogonDesktop);
1049  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISSHUTTINGDOWN);
1050 
1051  /* Prepare data for shutdown thread */
1052  LSData = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGOFF_SHUTDOWN_DATA));
1053  if (!LSData)
1054  {
1055  ERR("Failed to allocate mem for thread data\n");
1056  return STATUS_NO_MEMORY;
1057  }
1058  if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF)
1059  LSData->Flags = EWX_POWEROFF;
1060  else if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1061  LSData->Flags = EWX_REBOOT;
1062  else
1063  LSData->Flags = EWX_SHUTDOWN;
1064  LSData->Session = Session;
1065 
1066  // FIXME: We may need to specify this flag to really force application kill
1067  // (we are shutting down ReactOS, not just logging off so no hangs, etc...
1068  // should be allowed).
1069  // LSData->Flags |= EWX_FORCE;
1070 
1071  /* Run shutdown thread */
1073  if (!hThread)
1074  {
1075  ERR("Unable to create shutdown thread, error %lu\n", GetLastError());
1076  HeapFree(GetProcessHeap(), 0, LSData);
1077  return STATUS_UNSUCCESSFUL;
1078  }
1080  HeapFree(GetProcessHeap(), 0, LSData);
1081  if (!GetExitCodeThread(hThread, &exitCode))
1082  {
1083  ERR("Unable to get exit code of shutdown thread (error %lu)\n", GetLastError());
1085  return STATUS_UNSUCCESSFUL;
1086  }
1088  if (exitCode == 0)
1089  {
1090  ERR("Shutdown thread returned failure\n");
1091  return STATUS_UNSUCCESSFUL;
1092  }
1093 
1095 
1096  /* Destroy SAS window */
1097  UninitializeSAS(Session);
1098 
1099  /* Now we can shut down NT */
1100  ERR("Shutting down NT...\n");
1102  if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1103  {
1105  }
1106  else
1107  {
1108  if (FALSE)
1109  {
1110  /* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */
1113  }
1115  }
1117  return STATUS_SUCCESS;
1118 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:216
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
PWLSESSION Session
Definition: sas.c:41
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1025
#define EWX_REBOOT
Definition: winuser.h:633
static DWORD WINAPI LogoffShutdownThread(LPVOID Parameter)
Definition: sas.c:694
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:502
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define DialogBox
Definition: winuser.h:5627
static INT_PTR CALLBACK ShutdownComputerWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:993
#define EWX_SHUTDOWN
Definition: winuser.h:634
#define IDS_REACTOSISSHUTTINGDOWN
Definition: resource.h:31
unsigned char BOOLEAN
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:111
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
#define EWX_POWEROFF
Definition: winuser.h:632
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
#define IDD_SHUTDOWNCOMPUTER
Definition: resource.h:7
#define ERR(fmt,...)
Definition: debug.h:109
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:249
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
HANDLE hThread
Definition: wizard.c:27
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define INFINITE
Definition: serial.h:102
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define HeapFree(x, y, z)
Definition: compat.h:394
HINSTANCE hAppInstance
Definition: mmc.c:23

Referenced by DoGenericAction(), and WinMain().

◆ InitializeSAS()

BOOL InitializeSAS ( IN OUT PWLSESSION  Session)

Definition at line 1578 of file sas.c.

1580 {
1581  WNDCLASSEXW swc;
1582  BOOL ret = FALSE;
1583 
1584  if (!SwitchDesktop(Session->WinlogonDesktop))
1585  {
1586  ERR("WL: Failed to switch to winlogon desktop\n");
1587  goto cleanup;
1588  }
1589 
1590  /* Register SAS window class */
1591  swc.cbSize = sizeof(WNDCLASSEXW);
1592  swc.style = CS_SAVEBITS;
1593  swc.lpfnWndProc = SASWindowProc;
1594  swc.cbClsExtra = 0;
1595  swc.cbWndExtra = 0;
1596  swc.hInstance = hAppInstance;
1597  swc.hIcon = NULL;
1598  swc.hCursor = NULL;
1599  swc.hbrBackground = NULL;
1600  swc.lpszMenuName = NULL;
1602  swc.hIconSm = NULL;
1603  if (RegisterClassExW(&swc) == 0)
1604  {
1605  ERR("WL: Failed to register SAS window class\n");
1606  goto cleanup;
1607  }
1608 
1609  /* Create invisible SAS window */
1610  Session->SASWindow = CreateWindowExW(
1611  0,
1614  WS_POPUP,
1615  0, 0, 0, 0, 0, 0,
1616  hAppInstance, Session);
1617  if (!Session->SASWindow)
1618  {
1619  ERR("WL: Failed to create SAS window\n");
1620  goto cleanup;
1621  }
1622 
1623  /* Register SAS window to receive SAS notifications */
1624  if (!SetLogonNotifyWindow(Session->SASWindow))
1625  {
1626  ERR("WL: Failed to register SAS window\n");
1627  goto cleanup;
1628  }
1629 
1630  if (!SetDefaultLanguage(NULL))
1631  return FALSE;
1632 
1633  ret = TRUE;
1634 
1635 cleanup:
1636  if (!ret)
1637  UninitializeSAS(Session);
1638  return ret;
1639 }
#define TRUE
Definition: types.h:120
int cbWndExtra
Definition: winuser.h:3173
BOOL WINAPI SetLogonNotifyWindow(HWND Wnd)
Definition: logon.c:91
static LRESULT CALLBACK SASWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:1378
HICON hIcon
Definition: winuser.h:3175
struct _WNDCLASSEXW WNDCLASSEXW
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1025
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
LPCWSTR lpszMenuName
Definition: winuser.h:3178
#define WINLOGON_SAS_CLASS
Definition: sas.c:25
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
int cbClsExtra
Definition: winuser.h:3172
LPCWSTR lpszClassName
Definition: winuser.h:3179
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
BOOL WINAPI SwitchDesktop(_In_ HDESK)
HINSTANCE hInstance
Definition: winuser.h:3174
#define CS_SAVEBITS
Definition: winuser.h:652
BOOL SetDefaultLanguage(IN PWLSESSION Session)
Definition: sas.c:110
int ret
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)
HCURSOR hCursor
Definition: winuser.h:3176
UINT style
Definition: winuser.h:3170
WNDPROC lpfnWndProc
Definition: winuser.h:3171
#define ERR(fmt,...)
Definition: debug.h:109
#define WS_POPUP
Definition: pedump.c:616
#define WINLOGON_SAS_TITLE
Definition: sas.c:26
HICON hIconSm
Definition: winuser.h:3180
char * cleanup(char *str)
Definition: wpickclick.c:99
HINSTANCE hAppInstance
Definition: mmc.c:23

Referenced by WinMain().

◆ KillComProcesses()

static DWORD WINAPI KillComProcesses ( LPVOID  Parameter)
static

Definition at line 739 of file sas.c.

741 {
742  DWORD ret = 1;
744 
745  TRACE("In KillComProcesses\n");
746 
747  if (LSData->Session->UserToken != NULL &&
749  {
750  ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
751  return 0;
752  }
753 
754  /* Attempt to kill remaining processes. No notifications needed. */
756  {
757  ERR("Unable to kill COM apps, error %lu\n", GetLastError());
758  ret = 0;
759  }
760 
761  if (LSData->Session->UserToken)
762  RevertToSelf();
763 
764  return ret;
765 }
#define EWX_FORCE
Definition: winuser.h:630
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
HANDLE UserToken
Definition: winlogon.h:227
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
PWLSESSION Session
Definition: sas.c:41
_In_ PVOID Parameter
Definition: ldrtypes.h:240
#define EWX_LOGOFF
Definition: winuser.h:631
#define EWX_CALLER_WINLOGON
Definition: undocuser.h:127
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define EWX_NONOTIFY
Definition: undocuser.h:133
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define ERR(fmt,...)
Definition: debug.h:109
struct tagLOGOFF_SHUTDOWN_DATA * PLOGOFF_SHUTDOWN_DATA

Referenced by HandleLogoff().

◆ LogoffShutdownThread()

static DWORD WINAPI LogoffShutdownThread ( LPVOID  Parameter)
static

Definition at line 694 of file sas.c.

696 {
697  DWORD ret = 1;
699  UINT uFlags;
700 
701  if (LSData->Session->UserToken != NULL &&
703  {
704  ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
705  return 0;
706  }
707 
708  // FIXME: To be really fixed: need to check what needs to be kept and what needs to be removed there.
709  //
710  // uFlags = EWX_INTERNAL_KILL_USER_APPS | (LSData->Flags & EWX_FLAGS_MASK) |
711  // ((LSData->Flags & EWX_ACTION_MASK) == EWX_LOGOFF ? EWX_CALLER_WINLOGON_LOGOFF : 0);
712 
713  uFlags = EWX_CALLER_WINLOGON | (LSData->Flags & 0x0F);
714 
715  TRACE("In LogoffShutdownThread with uFlags == 0x%x; exit_in_progress == %s\n",
716  uFlags, ExitReactOSInProgress ? "true" : "false");
717 
719 
720  /* Close processes of the interactive user */
721  if (!ExitWindowsEx(uFlags, 0))
722  {
723  ERR("Unable to kill user apps, error %lu\n", GetLastError());
724  ret = 0;
725  }
726 
727  /* Cancel all the user connections */
729 
730  if (LSData->Session->UserToken)
731  RevertToSelf();
732 
733  return ret;
734 }
#define TRUE
Definition: types.h:120
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
HANDLE UserToken
Definition: winlogon.h:227
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
PWLSESSION Session
Definition: sas.c:41
UINT uFlags
Definition: api.c:60
_In_ PVOID Parameter
Definition: ldrtypes.h:240
#define EWX_CALLER_WINLOGON
Definition: undocuser.h:127
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL ExitReactOSInProgress
Definition: sas.c:44
int ret
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define ERR(fmt,...)
Definition: debug.h:109
struct tagLOGOFF_SHUTDOWN_DATA * PLOGOFF_SHUTDOWN_DATA
unsigned int UINT
Definition: ndis.h:50
DWORD WINAPI WNetClearConnections(HWND owner)
Definition: wnet.c:2686

Referenced by HandleLogoff(), and HandleShutdown().

◆ PlayLogonSound()

static VOID PlayLogonSound ( IN OUT PWLSESSION  Session)
static

Definition at line 420 of file sas.c.

422 {
423  HANDLE hThread;
424 
425  hThread = CreateThread(NULL, 0, PlayLogonSoundThread, (PVOID)Session->UserToken, 0, NULL);
426  if (hThread)
428 }
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI PlayLogonSoundThread(IN LPVOID lpParameter)
Definition: sas.c:283
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:111
smooth NULL
Definition: ftsmooth.c:416
HANDLE hThread
Definition: wizard.c:27

Referenced by HandleLogon().

◆ PlayLogonSoundThread()

DWORD WINAPI PlayLogonSoundThread ( IN LPVOID  lpParameter)

Definition at line 283 of file sas.c.

285 {
286  BYTE TokenUserBuffer[256];
287  PTOKEN_USER pTokenUser = (TOKEN_USER*)TokenUserBuffer;
288  ULONG Length;
289  HKEY hKey;
290  WCHAR wszBuffer[MAX_PATH] = {0};
291  WCHAR wszDest[MAX_PATH];
292  DWORD dwSize = sizeof(wszBuffer), dwType;
294  UNICODE_STRING SidString;
296  ULONG Index = 0;
297  SC_HANDLE hSCManager, hService;
298 
299  //
300  // FIXME: Isn't it possible to *JUST* impersonate the current user
301  // *AND* open its HKCU??
302  //
303 
304  /* Get SID of current user */
306  TokenUser,
307  TokenUserBuffer,
308  sizeof(TokenUserBuffer),
309  &Length);
310  if (!NT_SUCCESS(Status))
311  {
312  ERR("NtQueryInformationToken failed: %x!\n", Status);
313  return 0;
314  }
315 
316  /* Convert SID to string */
317  RtlInitEmptyUnicodeString(&SidString, wszBuffer, sizeof(wszBuffer));
318  Status = RtlConvertSidToUnicodeString(&SidString, pTokenUser->User.Sid, FALSE);
319  if (!NT_SUCCESS(Status))
320  {
321  ERR("RtlConvertSidToUnicodeString failed: %x!\n", Status);
322  return 0;
323  }
324 
325  /* Build path to logon sound registry key.
326  Note: We can't use HKCU here, because Winlogon is owned by SYSTEM user */
327  if (FAILED(StringCbCopyW(wszBuffer + SidString.Length/sizeof(WCHAR),
328  sizeof(wszBuffer) - SidString.Length,
329  L"\\AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current")))
330  {
331  /* SID is too long. Should not happen. */
332  ERR("StringCbCopyW failed!\n");
333  return 0;
334  }
335 
336  /* Open registry key and query sound path */
337  if (RegOpenKeyExW(HKEY_USERS, wszBuffer, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
338  {
339  ERR("RegOpenKeyExW(%ls) failed!\n", wszBuffer);
340  return 0;
341  }
342 
343  if (RegQueryValueExW(hKey, NULL, NULL, &dwType,
344  (LPBYTE)wszBuffer, &dwSize) != ERROR_SUCCESS ||
345  (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
346  {
347  ERR("RegQueryValueExW failed!\n");
348  RegCloseKey(hKey);
349  return 0;
350  }
351 
352  RegCloseKey(hKey);
353 
354  if (!wszBuffer[0])
355  {
356  /* No sound has been set */
357  ERR("No sound has been set\n");
358  return 0;
359  }
360 
361  /* Expand environment variables */
362  if (!ExpandEnvironmentStringsW(wszBuffer, wszDest, MAX_PATH))
363  {
364  ERR("ExpandEnvironmentStringsW failed!\n");
365  return 0;
366  }
367 
368  /* Open the service manager */
370  if (!hSCManager)
371  {
372  ERR("OpenSCManager failed (%x)\n", GetLastError());
373  return 0;
374  }
375 
376  /* Open the wdmaud service */
377  hService = OpenServiceW(hSCManager, L"wdmaud", GENERIC_READ);
378  if (!hService)
379  {
380  /* The service is not installed */
381  TRACE("Failed to open wdmaud service (%x)\n", GetLastError());
383  return 0;
384  }
385 
386  /* Wait for wdmaud to start */
387  do
388  {
390  {
391  TRACE("QueryServiceStatusEx failed (%x)\n", GetLastError());
392  break;
393  }
394 
395  if (Info.dwCurrentState == SERVICE_RUNNING)
396  break;
397 
398  Sleep(1000);
399 
400  } while (Index++ < 20);
401 
402  CloseServiceHandle(hService);
404 
405  /* If wdmaud is not running exit */
406  if (Info.dwCurrentState != SERVICE_RUNNING)
407  {
408  WARN("wdmaud has not started!\n");
409  return 0;
410  }
411 
412  /* Sound subsystem is running. Play logon sound. */
413  TRACE("Playing logon sound: %ls\n", wszDest);
415  return 0;
416 }
#define HKEY_USERS
Definition: winreg.h:13
#define TRUE
Definition: types.h:120
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define KEY_READ
Definition: nt_native.h:1023
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
BOOL PlaySoundRoutine(IN LPCWSTR FileName, IN UINT bLogon, IN UINT Flags)
Definition: sas.c:239
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2830
struct TraceInfo Info
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define SERVICE_RUNNING
Definition: winsvc.h:24
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2103
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Definition: token.c:1839
#define OpenSCManager
Definition: winsvc.h:575
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSYSAPI NTSTATUS NTAPI RtlConvertSidToUnicodeString(OUT PUNICODE_STRING DestinationString, IN PVOID Sid, IN BOOLEAN AllocateDestinationString)
static const WCHAR L[]
Definition: oid.c:1250
LPVOID lpParameter
Definition: kernel32.h:234
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
SC_HANDLE hSCManager
Definition: sc.c:12
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define SND_FILENAME
Definition: mmsystem.h:162
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
SID_AND_ATTRIBUTES User
Definition: setypes.h:956
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define REG_SZ
Definition: layer.c:22

Referenced by PlayLogonSound().

◆ PlaySoundRoutine()

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

Definition at line 239 of file sas.c.

243 {
244  typedef BOOL (WINAPI *PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
245  typedef UINT (WINAPI *WAVEOUTGETNUMDEVS)(VOID);
246  PLAYSOUNDW Play;
247  WAVEOUTGETNUMDEVS waveOutGetNumDevs;
248  UINT NumDevs;
250  BOOL Ret = FALSE;
251 
252  hLibrary = LoadLibraryW(L"winmm.dll");
253  if (hLibrary)
254  {
255  waveOutGetNumDevs = (WAVEOUTGETNUMDEVS)GetProcAddress(hLibrary, "waveOutGetNumDevs");
256  if (waveOutGetNumDevs)
257  {
258  NumDevs = waveOutGetNumDevs();
259  if (!NumDevs)
260  {
261  if (!bLogon)
262  {
263  Beep(500, 500);
264  }
266  return FALSE;
267  }
268  }
269 
270  Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
271  if (Play)
272  {
273  Ret = Play(FileName, NULL, Flags);
274  }
276  }
277 
278  return Ret;
279 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
#define FreeLibrary(x)
Definition: compat.h:405
#define WINAPI
Definition: msvc.h:8
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
HMODULE hLibrary
Definition: odbccp32.c:12
HANDLE HMODULE
Definition: typedefs.h:75
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by HandleMessageBeep(), and PlayLogonSoundThread().

◆ RegisterHotKeys()

static BOOL RegisterHotKeys ( IN PWLSESSION  Session,
IN HWND  hwndSAS 
)
static

Definition at line 1308 of file sas.c.

1311 {
1312  /* Register Ctrl+Alt+Del Hotkey */
1314  {
1315  ERR("WL: Unable to register Ctrl+Alt+Del hotkey!\n");
1316  return FALSE;
1317  }
1318 
1319  /* Register Ctrl+Shift+Esc (optional) */
1320  Session->TaskManHotkey = RegisterHotKey(hwndSAS, HK_CTRL_SHIFT_ESC, MOD_CONTROL | MOD_SHIFT, VK_ESCAPE);
1321  if (!Session->TaskManHotkey)
1322  WARN("WL: Warning: Unable to register Ctrl+Alt+Esc hotkey!\n");
1323  return TRUE;
1324 }
#define HK_CTRL_ALT_DEL
Definition: sas.c:28
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_DELETE
Definition: winuser.h:2187
HWND hwndSAS
Definition: winsta.c:24
#define ERR(fmt,...)
Definition: debug.h:109
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
#define MOD_SHIFT
Definition: imm.h:313
#define HK_CTRL_SHIFT_ESC
Definition: sas.c:29
BOOL WINAPI RegisterHotKey(_In_opt_ HWND, _In_ int, _In_ UINT, _In_ UINT)

Referenced by SASWindowProc().

◆ RestoreAllConnections()

static VOID RestoreAllConnections ( PWLSESSION  Session)
static

Definition at line 513 of file sas.c.

514 {
515  DWORD dRet;
516  HANDLE hEnum;
517  LPNETRESOURCE lpRes;
518  DWORD dSize = 0x1000;
519  DWORD dCount = -1;
520  LPNETRESOURCE lpCur;
521  BOOL UserProfile;
522 
523  UserProfile = (Session && Session->UserToken);
524  if (!UserProfile)
525  {
526  return;
527  }
528 
529  if (!ImpersonateLoggedOnUser(Session->UserToken))
530  {
531  ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
532  return;
533  }
534 
536  if (dRet != WN_SUCCESS)
537  {
538  ERR("Failed to open enumeration: %lu\n", dRet);
539  goto quit;
540  }
541 
542  lpRes = HeapAlloc(GetProcessHeap(), 0, dSize);
543  if (!lpRes)
544  {
545  ERR("Failed to allocate memory\n");
546  WNetCloseEnum(hEnum);
547  goto quit;
548  }
549 
550  do
551  {
552  dSize = 0x1000;
553  dCount = -1;
554 
555  memset(lpRes, 0, dSize);
556  dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
557  if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
558  {
559  lpCur = lpRes;
560  for (; dCount; dCount--)
561  {
563  lpCur++;
564  }
565  }
566  } while (dRet != WN_NO_MORE_ENTRIES);
567 
568  HeapFree(GetProcessHeap(), 0, lpRes);
569  WNetCloseEnum(hEnum);
570 
571 quit:
572  RevertToSelf();
573 }
#define WNetAddConnection
Definition: winnetwk.h:611
#define WN_SUCCESS
Definition: winnetwk.h:111
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
HANDLE UserToken
Definition: winlogon.h:227
LPSTR lpLocalName
Definition: winnetwk.h:171
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define WNetOpenEnum
Definition: winnetwk.h:598
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI WNetCloseEnum(HANDLE hEnum)
Definition: wnet.c:1621
#define WNetEnumResource
Definition: winnetwk.h:599
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define RESOURCE_REMEMBERED
Definition: winnetwk.h:60
#define ERR(fmt,...)
Definition: debug.h:109
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
LPSTR lpRemoteName
Definition: winnetwk.h:172
#define WN_MORE_DATA
Definition: winnetwk.h:117
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by HandleLogon().

◆ SASWindowProc()

static LRESULT CALLBACK SASWindowProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 1378 of file sas.c.

1383 {
1384  PWLSESSION Session = (PWLSESSION)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
1385 
1386  switch (uMsg)
1387  {
1388  case WM_HOTKEY:
1389  {
1390  switch (lParam)
1391  {
1393  {
1394  TRACE("SAS: CONTROL+ALT+DELETE\n");
1395  if (!Session->Gina.UseCtrlAltDelete)
1396  break;
1398  return TRUE;
1399  }
1401  {
1402  TRACE("SAS: CONTROL+SHIFT+ESCAPE\n");
1403  if (Session->LogonState == STATE_LOGGED_ON)
1405  return TRUE;
1406  }
1407  }
1408  break;
1409  }
1410  case WM_CREATE:
1411  {
1412  /* Get the session pointer from the create data */
1413  Session = (PWLSESSION)((LPCREATESTRUCT)lParam)->lpCreateParams;
1414 
1415  /* Save the Session pointer */
1416  SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)Session);
1417  if (GetSetupType())
1418  return TRUE;
1419  return RegisterHotKeys(Session, hwndDlg);
1420  }
1421  case WM_DESTROY:
1422  {
1423  if (!GetSetupType())
1424  UnregisterHotKeys(Session, hwndDlg);
1425  return TRUE;
1426  }
1427  case WM_SETTINGCHANGE:
1428  {
1429  UINT uiAction = (UINT)wParam;
1430  if (uiAction == SPI_SETSCREENSAVETIMEOUT
1431  || uiAction == SPI_SETSCREENSAVEACTIVE)
1432  {
1434  }
1435  return TRUE;
1436  }
1437  case WM_LOGONNOTIFY:
1438  {
1439  switch(wParam)
1440  {
1441  case LN_MESSAGE_BEEP:
1442  {
1443  return HandleMessageBeep(lParam);
1444  }
1445  case LN_SHELL_EXITED:
1446  {
1447  /* lParam is the exit code */
1448  if (lParam != 1 &&
1449  Session->LogonState != STATE_LOGGED_OFF &&
1450  Session->LogonState != STATE_LOGGED_OFF_SAS)
1451  {
1452  SetTimer(hwndDlg, 1, 1000, NULL);
1453  }
1454  break;
1455  }
1456  case LN_START_SCREENSAVE:
1457  {
1459  break;
1460  }
1461  case LN_LOCK_WORKSTATION:
1462  {
1464  break;
1465  }
1466  case LN_LOGOFF:
1467  {
1468  UINT Flags = (UINT)lParam;
1470  DWORD wlxAction;
1471 
1472  TRACE("\tFlags : 0x%lx\n", lParam);
1473 
1474  /*
1475  * Our caller (USERSRV) should have added the shutdown flag
1476  * when setting also poweroff or reboot.
1477  */
1478  if (Action & (EWX_POWEROFF | EWX_REBOOT))
1479  {
1480  if ((Action & EWX_SHUTDOWN) == 0)
1481  {
1482  ERR("Missing EWX_SHUTDOWN flag for poweroff or reboot; action 0x%x\n", Action);
1483  return STATUS_INVALID_PARAMETER;
1484  }
1485 
1486  /* Now we can locally remove it for performing checks */
1487  Action &= ~EWX_SHUTDOWN;
1488  }
1489 
1490  /* Check parameters */
1491  if (Action & EWX_FORCE)
1492  {
1493  // FIXME!
1494  ERR("FIXME: EWX_FORCE present for Winlogon, what to do?\n");
1495  Action &= ~EWX_FORCE;
1496  }
1497  switch (Action)
1498  {
1499  case EWX_LOGOFF:
1500  wlxAction = WLX_SAS_ACTION_LOGOFF;
1501  break;
1502  case EWX_SHUTDOWN:
1503  wlxAction = WLX_SAS_ACTION_SHUTDOWN;
1504  break;
1505  case EWX_REBOOT:
1506  wlxAction = WLX_SAS_ACTION_SHUTDOWN_REBOOT;
1507  break;
1508  case EWX_POWEROFF:
1510  break;
1511 
1512  default:
1513  {
1514  ERR("Invalid ExitWindows action 0x%x\n", Action);
1515  return STATUS_INVALID_PARAMETER;
1516  }
1517  }
1518 
1519  TRACE("In LN_LOGOFF, exit_in_progress == %s\n",
1520  ExitReactOSInProgress ? "true" : "false");
1521 
1522  /*
1523  * In case a parallel shutdown request is done (while we are
1524  * being to shut down) and it was not done by Winlogon itself,
1525  * then just stop here.
1526  */
1527 #if 0
1528 // This code is commented at the moment (even if it's correct) because
1529 // our log-offs do not really work: the shell is restarted, no app is killed
1530 // etc... and as a result you just get explorer opening "My Documents". And
1531 // if you try now a shut down, it won't work because winlogon thinks it is
1532 // still in the middle of a shutdown.
1533 // Maybe we also need to reset ExitReactOSInProgress somewhere else??
1535  {
1536  break;
1537  }
1538 #endif
1539  /* Now do the shutdown action proper */
1540  DoGenericAction(Session, wlxAction);
1541  return 1;
1542  }
1543  case LN_LOGOFF_CANCELED:
1544  {
1545  ERR("Logoff canceled!!, before: exit_in_progress == %s, after will be false\n",
1546  ExitReactOSInProgress ? "true" : "false");
1547 
1549  return 1;
1550  }
1551  default:
1552  {
1553  ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam);
1554  }
1555  }
1556  return 0;
1557  }
1558  case WM_TIMER:
1559  {
1560  if (wParam == 1)
1561  {
1562  KillTimer(hwndDlg, 1);
1563  StartUserShell(Session);
1564  }
1565  break;
1566  }
1567  case WLX_WM_SAS:
1568  {
1569  DispatchSAS(Session, (DWORD)wParam);
1570  return TRUE;
1571  }
1572  }
1573 
1574  return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
1575 }
BOOL UseCtrlAltDelete
Definition: winlogon.h:126
#define EWX_FORCE
Definition: winuser.h:630
#define WLX_SAS_ACTION_SHUTDOWN
Definition: winwlx.h:57
#define WLX_WM_SAS
Definition: winwlx.h:71
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define TRUE
Definition: types.h:120
struct _WLSESSION * PWLSESSION
#define LN_LOGOFF_CANCELED
Definition: undocuser.h:120
HANDLE hScreenSaverParametersChanged
Definition: winlogon.h:238
BOOL WINAPI HandleMessageBeep(UINT uType)
Definition: sas.c:1343
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WM_HOTKEY
Definition: winuser.h:1840
HWND SASWindow
Definition: winlogon.h:220
static BOOL RegisterHotKeys(IN PWLSESSION Session, IN HWND hwndSAS)
Definition: sas.c:1308
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
static BOOL UnregisterHotKeys(IN PWLSESSION Session, IN HWND hwndSAS)
Definition: sas.c:1328
static VOID DoGenericAction(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1122
#define EWX_REBOOT
Definition: winuser.h:633
DWORD GetSetupType(VOID)
Definition: setup.c:16
#define VK_ESCAPE
Definition: winuser.h:2168
WPARAM wParam
Definition: combotst.c:138
#define EWX_LOGOFF
Definition: winuser.h:631
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
#define EWX_CALLER_WINLOGON
Definition: undocuser.h:127
#define WLX_SAS_TYPE_SCRNSVR_TIMEOUT
Definition: winwlx.h:37
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define EWX_SHUTDOWN
Definition: winuser.h:634
#define LN_LOGOFF
Definition: undocuser.h:113
#define GWLP_USERDATA
Definition: treelist.c:63
#define LN_START_SCREENSAVE
Definition: undocuser.h:119
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
smooth NULL
Definition: ftsmooth.c:416
static VOID DispatchSAS(IN OUT PWLSESSION Session, IN DWORD dwSasType)
Definition: sas.c:1212
#define VK_DELETE
Definition: winuser.h:2187
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define EWX_POWEROFF
Definition: winuser.h:632
GINAINSTANCE Gina
Definition: winlogon.h:216
#define LN_LOCK_WORKSTATION
Definition: undocuser.h:116
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_TIMER
Definition: winuser.h:1718
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL ExitReactOSInProgress
Definition: sas.c:44
#define SPI_SETSCREENSAVEACTIVE
Definition: winuser.h:1348
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define WLX_SAS_ACTION_SHUTDOWN_POWER_OFF
Definition: winwlx.h:62
#define WLX_SAS_TYPE_CTRL_ALT_DEL
Definition: winwlx.h:36
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL StartUserShell(IN OUT PWLSESSION Session)
Definition: sas.c:79
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
#define MOD_SHIFT
Definition: imm.h:313
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WLX_SAS_ACTION_TASKLIST
Definition: winwlx.h:59
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1590
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define GetWindowLongPtr
Definition: treelist.c:73
#define LN_MESSAGE_BEEP
Definition: undocuser.h:118
#define EWX_ACTION_MASK
Definition: sas.c:36
LPARAM lParam
Definition: combotst.c:139
#define SPI_SETSCREENSAVETIMEOUT
Definition: winuser.h:1346
#define LN_SHELL_EXITED
Definition: undocuser.h:114
LOGON_STATE LogonState
Definition: winlogon.h:229

Referenced by InitializeSAS().

◆ SetDefaultLanguage()

BOOL SetDefaultLanguage ( IN PWLSESSION  Session)

Definition at line 110 of file sas.c.

112 {
113  BOOL ret = FALSE;
114  BOOL UserProfile;
115  LONG rc;
116  HKEY UserKey, hKey = NULL;
117  LPCWSTR SubKey, ValueName;
118  DWORD dwType, dwSize;
119  LPWSTR Value = NULL;
120  UNICODE_STRING ValueString;
122  LCID Lcid;
123 
124  UserProfile = (Session && Session->UserToken);
125 
126  if (UserProfile && !ImpersonateLoggedOnUser(Session->UserToken))
127  {
128  ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
129  return FALSE;
130  // FIXME: ... or use the default language of the system??
131  // UserProfile = FALSE;
132  }
133 
134  if (UserProfile)
135  {
136  rc = RegOpenCurrentUser(MAXIMUM_ALLOWED, &UserKey);
137  if (rc != ERROR_SUCCESS)
138  {
139  TRACE("RegOpenCurrentUser() failed with error %lu\n", rc);
140  goto cleanup;
141  }
142 
143  SubKey = L"Control Panel\\International";
144  ValueName = L"Locale";
145  }
146  else
147  {
148  UserKey = NULL;
149  SubKey = L"System\\CurrentControlSet\\Control\\Nls\\Language";
150  ValueName = L"Default";
151  }
152 
153  rc = RegOpenKeyExW(UserKey ? UserKey : HKEY_LOCAL_MACHINE,
154  SubKey,
155  0,
156  KEY_READ,
157  &hKey);
158 
159  if (UserKey)
160  RegCloseKey(UserKey);
161 
162  if (rc != ERROR_SUCCESS)
163  {
164  TRACE("RegOpenKeyEx() failed with error %lu\n", rc);
165  goto cleanup;
166  }
167 
168  rc = RegQueryValueExW(hKey,
169  ValueName,
170  NULL,
171  &dwType,
172  NULL,
173  &dwSize);
174  if (rc != ERROR_SUCCESS)
175  {
176  TRACE("RegQueryValueEx() failed with error %lu\n", rc);
177  goto cleanup;
178  }
179  else if (dwType != REG_SZ)
180  {
181  TRACE("Wrong type for %S\\%S registry entry (got 0x%lx, expected 0x%x)\n",
182  SubKey, ValueName, dwType, REG_SZ);
183  goto cleanup;
184  }
185 
187  if (!Value)
188  {
189  TRACE("HeapAlloc() failed\n");
190  goto cleanup;
191  }
192  rc = RegQueryValueExW(hKey,
193  ValueName,
194  NULL,
195  NULL,
196  (LPBYTE)Value,
197  &dwSize);
198  if (rc != ERROR_SUCCESS)
199  {
200  TRACE("RegQueryValueEx() failed with error %lu\n", rc);
201  goto cleanup;
202  }
203 
204  /* Convert Value to a Lcid */
205  ValueString.Length = ValueString.MaximumLength = (USHORT)dwSize;
206  ValueString.Buffer = Value;
207  Status = RtlUnicodeStringToInteger(&ValueString, 16, (PULONG)&Lcid);
208  if (!NT_SUCCESS(Status))
209  {
210  TRACE("RtlUnicodeStringToInteger() failed with status 0x%08lx\n", Status);
211  goto cleanup;
212  }
213 
214  TRACE("%s language is 0x%08lx\n",
215  UserProfile ? "User" : "System", Lcid);
216  Status = NtSetDefaultLocale(UserProfile, Lcid);
217  if (!NT_SUCCESS(Status))
218  {
219  TRACE("NtSetDefaultLocale() failed with status 0x%08lx\n", Status);
220  goto cleanup;
221  }
222 
223  ret = TRUE;
224 
225 cleanup:
226  if (Value)
228 
229  if (hKey)
230  RegCloseKey(hKey);
231 
232  if (UserProfile)
233  RevertToSelf();
234 
235  return ret;
236 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ CONST DEVPROPKEY _In_ LCID Lcid
Definition: iofuncs.h:2408
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define KEY_READ
Definition: nt_native.h:1023
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD LCID
Definition: nls.h:13
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtSetDefaultLocale(IN BOOLEAN UserProfile, IN LCID DefaultLocaleId)
Definition: locale.c:203
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3232
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by HandleLogon(), and InitializeSAS().

◆ ShutdownComputerWindowProc()

static INT_PTR CALLBACK ShutdownComputerWindowProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 993 of file sas.c.

998 {
1000 
1001  switch (uMsg)
1002  {
1003  case WM_COMMAND:
1004  {
1005  switch (LOWORD(wParam))
1006  {
1009  return TRUE;
1010  }
1011  break;
1012  }
1013  case WM_INITDIALOG:
1014  {
1017  return TRUE;
1018  }
1019  }
1020  return FALSE;
1021 }
#define TRUE
Definition: types.h:120
#define MF_BYCOMMAND
Definition: winuser.h:202
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_BTNSHTDOWNCOMPUTER
Definition: resource.h:10
#define WM_COMMAND
Definition: winuser.h:1716
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SC_CLOSE
Definition: winuser.h:2546
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by HandleShutdown().

◆ StartTaskManager()

static BOOL StartTaskManager ( IN OUT PWLSESSION  Session)
static

Definition at line 51 of file sas.c.

53 {
54  LPVOID lpEnvironment;
55  BOOL ret;
56 
57  if (!Session->Gina.Functions.WlxStartApplication)
58  return FALSE;
59 
61  &lpEnvironment,
62  Session->UserToken,
63  TRUE))
64  {
65  return FALSE;
66  }
67 
68  ret = Session->Gina.Functions.WlxStartApplication(
69  Session->Gina.Context,
70  L"Default",
71  lpEnvironment,
72  L"taskmgr.exe");
73 
74  DestroyEnvironmentBlock(lpEnvironment);
75  return ret;
76 }
#define TRUE
Definition: types.h:120
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727

Referenced by DoGenericAction().

◆ StartUserShell()

static BOOL StartUserShell ( IN OUT PWLSESSION  Session)
static

Definition at line 79 of file sas.c.

81 {
82  LPVOID lpEnvironment = NULL;
83  BOOLEAN Old;
84  BOOL ret;
85 
86  /* Create environment block for the user */
87  if (!CreateEnvironmentBlock(&lpEnvironment, Session->UserToken, TRUE))
88  {
89  WARN("WL: CreateEnvironmentBlock() failed\n");
90  return FALSE;
91  }
92 
93  /* Get privilege */
94  /* FIXME: who should do it? winlogon or gina? */
95  /* FIXME: reverting to lower privileges after creating user shell? */
97 
98  ret = Session->Gina.Functions.WlxActivateUserShell(
99  Session->Gina.Context,
100  L"Default",
101  NULL, /* FIXME */
102  lpEnvironment);
103 
104  DestroyEnvironmentBlock(lpEnvironment);
105  return ret;
106 }
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int ret
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727
#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE
Definition: security.c:657

Referenced by HandleLogon(), and SASWindowProc().

◆ UninitializeSAS()

static VOID UninitializeSAS ( IN OUT PWLSESSION  Session)
static

Definition at line 1025 of file sas.c.

1027 {
1028  if (Session->SASWindow)
1029  {
1030  DestroyWindow(Session->SASWindow);
1031  Session->SASWindow = NULL;
1032  }
1033  if (Session->hEndOfScreenSaverThread)
1034  SetEvent(Session->hEndOfScreenSaverThread);
1036 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WINLOGON_SAS_CLASS
Definition: sas.c:25
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE hAppInstance
Definition: mmc.c:23

Referenced by HandleShutdown(), and InitializeSAS().

◆ UnregisterHotKeys()

static BOOL UnregisterHotKeys ( IN PWLSESSION  Session,
IN HWND  hwndSAS 
)
static

Definition at line 1328 of file sas.c.

1331 {
1332  /* Unregister hotkeys */
1334 
1335  if (Session->TaskManHotkey)
1337 
1338  return TRUE;
1339 }
#define HK_CTRL_ALT_DEL
Definition: sas.c:28
#define TRUE
Definition: types.h:120
BOOL WINAPI UnregisterHotKey(_In_opt_ HWND, _In_ int)
HWND hwndSAS
Definition: winsta.c:24
#define HK_CTRL_SHIFT_ESC
Definition: sas.c:29

Referenced by SASWindowProc().

Variable Documentation

◆ ExitReactOSInProgress

BOOL ExitReactOSInProgress = FALSE
static

Definition at line 44 of file sas.c.

Referenced by LogoffShutdownThread(), and SASWindowProc().

◆ LuidNone

LUID LuidNone = {0, 0}