ReactOS  0.4.15-dev-2534-geba00d1
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 37 of file sas.c.

◆ HK_CTRL_ALT_DEL

#define HK_CTRL_ALT_DEL   0

Definition at line 29 of file sas.c.

◆ HK_CTRL_SHIFT_ESC

#define HK_CTRL_SHIFT_ESC   1

Definition at line 30 of file sas.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 17 of file sas.c.

◆ WINLOGON_SAS_CLASS

#define WINLOGON_SAS_CLASS   L"SAS Window class"

Definition at line 26 of file sas.c.

◆ WINLOGON_SAS_TITLE

#define WINLOGON_SAS_TITLE   L"SAS window"

Definition at line 27 of file sas.c.

Typedef Documentation

◆ LOGOFF_SHUTDOWN_DATA

◆ PLOGOFF_SHUTDOWN_DATA

Function Documentation

◆ AllowWinstaAccess()

static BOOL AllowWinstaAccess ( PWLSESSION  Session)
static

Definition at line 432 of file sas.c.

433 {
434  BOOL bSuccess = FALSE;
435  DWORD dwIndex;
436  DWORD dwLength = 0;
437  PTOKEN_GROUPS ptg = NULL;
438  PSID psid;
439  TOKEN_STATISTICS Stats;
440  DWORD cbStats;
441  DWORD ret;
442 
443  // Get required buffer size and allocate the TOKEN_GROUPS buffer.
444 
445  if (!GetTokenInformation(Session->UserToken,
446  TokenGroups,
447  ptg,
448  0,
449  &dwLength))
450  {
452  return FALSE;
453 
455  if (ptg == NULL)
456  return FALSE;
457  }
458 
459  // Get the token group information from the access token.
460  if (!GetTokenInformation(Session->UserToken,
461  TokenGroups,
462  ptg,
463  dwLength,
464  &dwLength))
465  {
466  goto Cleanup;
467  }
468 
469  // Loop through the groups to find the logon SID.
470 
471  for (dwIndex = 0; dwIndex < ptg->GroupCount; dwIndex++)
472  {
473  if ((ptg->Groups[dwIndex].Attributes & SE_GROUP_LOGON_ID)
475  {
476  psid = ptg->Groups[dwIndex].Sid;
477  break;
478  }
479  }
480 
481  dwLength = GetLengthSid(psid);
482 
483  if (!GetTokenInformation(Session->UserToken,
485  &Stats,
486  sizeof(TOKEN_STATISTICS),
487  &cbStats))
488  {
489  WARN("Couldn't get Authentication id from user token!\n");
490  goto Cleanup;
491  }
492 
494 
496  &Stats.AuthenticationId,
497  psid,
498  dwLength);
499  TRACE("SetWindowStationUser returned 0x%x\n", ret);
500 
501  bSuccess = TRUE;
502 
503 Cleanup:
504 
505  // Free the buffer for the token groups.
506  if (ptg != NULL)
507  HeapFree(GetProcessHeap(), 0, (LPVOID)ptg);
508 
509  return bSuccess;
510 }
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:112
HANDLE UserToken
Definition: winlogon.h:227
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static BOOLEAN bSuccess
Definition: drive.cpp:432
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _TOKEN_GROUPS * PTOKEN_GROUPS
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:85
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 NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
$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:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by HandleLogon().

◆ CreateLogoffSecurityAttributes()

static NTSTATUS CreateLogoffSecurityAttributes ( OUT PSECURITY_ATTRIBUTES ppsa)
static

Definition at line 770 of file sas.c.

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

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

Referenced by HandleLogoff().

◆ DispatchSAS()

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

Definition at line 1218 of file sas.c.

1221 {
1222  DWORD wlxAction = WLX_SAS_ACTION_NONE;
1223  PSID LogonSid = NULL; /* FIXME */
1224  BOOL bSecure = TRUE;
1225 
1226  switch (dwSasType)
1227  {
1229  switch (Session->LogonState)
1230  {
1231  case STATE_INIT:
1232  Session->LogonState = STATE_LOGGED_OFF;
1233  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1234  return;
1235 
1236  case STATE_LOGGED_OFF:
1237  Session->LogonState = STATE_LOGGED_OFF_SAS;
1238 
1240 
1241  Session->Options = 0;
1242 
1243  wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS(
1244  Session->Gina.Context,
1245  Session->SASAction,
1246  &Session->LogonId,
1247  LogonSid,
1248  &Session->Options,
1249  &Session->UserToken,
1250  &Session->MprNotifyInfo,
1251  (PVOID*)&Session->Profile);
1252  break;
1253 
1254  case STATE_LOGGED_OFF_SAS:
1255  /* Ignore SAS if we are already in an SAS state */
1256  return;
1257 
1258  case STATE_LOGGED_ON:
1259  Session->LogonState = STATE_LOGGED_ON_SAS;
1260  wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOnSAS(Session->Gina.Context, dwSasType, NULL);
1261  break;
1262 
1263  case STATE_LOGGED_ON_SAS:
1264  /* Ignore SAS if we are already in an SAS state */
1265  return;
1266 
1267  case STATE_LOCKED:
1268  Session->LogonState = STATE_LOCKED_SAS;
1269 
1271 
1272  wlxAction = (DWORD)Session->Gina.Functions.WlxWkstaLockedSAS(Session->Gina.Context, dwSasType);
1273  break;
1274 
1275  case STATE_LOCKED_SAS:
1276  /* Ignore SAS if we are already in an SAS state */
1277  return;
1278 
1279  default:
1280  return;
1281  }
1282  break;
1283 
1284  case WLX_SAS_TYPE_TIMEOUT:
1285  return;
1286 
1288  if (!Session->Gina.Functions.WlxScreenSaverNotify(Session->Gina.Context, &bSecure))
1289  {
1290  /* Skip start of screen saver */
1291  SetEvent(Session->hEndOfScreenSaver);
1292  }
1293  else
1294  {
1295  StartScreenSaver(Session);
1296  if (bSecure)
1297  {
1298  wlxAction = WLX_SAS_ACTION_LOCK_WKSTA;
1299 // DoGenericAction(Session, WLX_SAS_ACTION_LOCK_WKSTA);
1300  }
1301  }
1302  break;
1303 
1305  SetEvent(Session->hUserActivity);
1306  break;
1307  }
1308 
1309  DoGenericAction(Session, wlxAction);
1310 }
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define WLX_SAS_TYPE_SCRNSVR_ACTIVITY
Definition: winwlx.h:38
#define TRUE
Definition: types.h:120
VOID StartScreenSaver(IN PWLSESSION Session)
Definition: screensaver.c:257
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define WLX_SAS_TYPE_TIMEOUT
Definition: winwlx.h:35
static VOID DoGenericAction(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1128
#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
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
#define NULL
Definition: types.h:112

Referenced by SASWindowProc().

◆ DoGenericAction()

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

Definition at line 1128 of file sas.c.

1131 {
1132  switch (wlxAction)
1133  {
1134  case WLX_SAS_ACTION_LOGON: /* 0x01 */
1135  if (Session->LogonState == STATE_LOGGED_OFF_SAS)
1136  {
1137  if (!HandleLogon(Session))
1138  {
1139  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1141  }
1142  }
1143  break;
1144  case WLX_SAS_ACTION_NONE: /* 0x02 */
1145  if (Session->LogonState == STATE_LOGGED_OFF_SAS)
1146  {
1147  Session->LogonState = STATE_LOGGED_OFF;
1148  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1149  }
1150  else if (Session->LogonState == STATE_LOGGED_ON_SAS)
1151  {
1152  Session->LogonState = STATE_LOGGED_ON;
1153  }
1154  else if (Session->LogonState == STATE_LOCKED_SAS)
1155  {
1156  Session->LogonState = STATE_LOCKED;
1157  Session->Gina.Functions.WlxDisplayLockedNotice(Session->Gina.Context);
1158  }
1159  break;
1160  case WLX_SAS_ACTION_LOCK_WKSTA: /* 0x03 */
1161  if (Session->Gina.Functions.WlxIsLockOk(Session->Gina.Context))
1162  {
1163  SwitchDesktop(Session->WinlogonDesktop);
1164  Session->LogonState = STATE_LOCKED;
1165  Session->Gina.Functions.WlxDisplayLockedNotice(Session->Gina.Context);
1167  }
1168  break;
1169  case WLX_SAS_ACTION_LOGOFF: /* 0x04 */
1170  case WLX_SAS_ACTION_SHUTDOWN: /* 0x05 */
1171  case WLX_SAS_ACTION_SHUTDOWN_POWER_OFF: /* 0x0a */
1172  case WLX_SAS_ACTION_SHUTDOWN_REBOOT: /* 0x0b */
1173  if (Session->LogonState != STATE_LOGGED_OFF)
1174  {
1175  if (!Session->Gina.Functions.WlxIsLogoffOk(Session->Gina.Context))
1176  break;
1177  if (!NT_SUCCESS(HandleLogoff(Session, EWX_LOGOFF)))
1178  {
1179  RemoveStatusMessage(Session);
1180  break;
1181  }
1182  Session->Gina.Functions.WlxLogoff(Session->Gina.Context);
1183  }
1184  if (WLX_SHUTTINGDOWN(wlxAction))
1185  {
1186  // FIXME: WlxShutdown should be done from inside HandleShutdown,
1187  // after having displayed "ReactOS is shutting down" message.
1188  Session->Gina.Functions.WlxShutdown(Session->Gina.Context, wlxAction);
1189  if (!NT_SUCCESS(HandleShutdown(Session, wlxAction)))
1190  {
1191  RemoveStatusMessage(Session);
1192  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1193  }
1194  }
1195  else
1196  {
1197  RemoveStatusMessage(Session);
1198  Session->Gina.Functions.WlxDisplaySASNotice(Session->Gina.Context);
1199  }
1200  break;
1201  case WLX_SAS_ACTION_TASKLIST: /* 0x07 */
1202  SwitchDesktop(Session->ApplicationDesktop);
1203  Session->LogonState = STATE_LOGGED_ON;
1204  StartTaskManager(Session);
1205  break;
1206  case WLX_SAS_ACTION_UNLOCK_WKSTA: /* 0x08 */
1207  SwitchDesktop(Session->ApplicationDesktop);
1208  Session->LogonState = STATE_LOGGED_ON;
1210  break;
1211  default:
1212  WARN("Unknown SAS action 0x%lx\n", wlxAction);
1213  }
1214 }
#define WLX_SAS_ACTION_SHUTDOWN
Definition: winwlx.h:57
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:370
#define WLX_SAS_ACTION_LOCK_WKSTA
Definition: winwlx.h:55
#define WARN(fmt,...)
Definition: debug.h:112
static BOOL StartTaskManager(IN OUT PWLSESSION Session)
Definition: sas.c:52
NTSTATUS HandleShutdown(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1040
#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:578
#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:380
#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:896

Referenced by DispatchSAS(), and SASWindowProc().

◆ HandleLogoff()

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

Definition at line 896 of file sas.c.

899 {
900  PLOGOFF_SHUTDOWN_DATA LSData;
902  HANDLE hThread;
903  DWORD exitCode;
905 
906  /* Prepare data for logoff thread */
907  LSData = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGOFF_SHUTDOWN_DATA));
908  if (!LSData)
909  {
910  ERR("Failed to allocate mem for thread data\n");
911  return STATUS_NO_MEMORY;
912  }
913  LSData->Flags = Flags;
914  LSData->Session = Session;
915 
917  if (!NT_SUCCESS(Status))
918  {
919  ERR("Failed to create a required security descriptor. Status 0x%08lx\n", Status);
920  HeapFree(GetProcessHeap(), 0, LSData);
921  return Status;
922  }
923 
924  /* Run logoff thread */
926  if (!hThread)
927  {
928  ERR("Unable to create logoff thread, error %lu\n", GetLastError());
930  HeapFree(GetProcessHeap(), 0, LSData);
931  return STATUS_UNSUCCESSFUL;
932  }
934  if (!GetExitCodeThread(hThread, &exitCode))
935  {
936  ERR("Unable to get exit code of logoff thread (error %lu)\n", GetLastError());
939  HeapFree(GetProcessHeap(), 0, LSData);
940  return STATUS_UNSUCCESSFUL;
941  }
943  if (exitCode == 0)
944  {
945  ERR("Logoff thread returned failure\n");
947  HeapFree(GetProcessHeap(), 0, LSData);
948  return STATUS_UNSUCCESSFUL;
949  }
950 
951  SwitchDesktop(Session->WinlogonDesktop);
952 
953  // TODO: Play logoff sound!
954 
955  SetWindowStationUser(Session->InteractiveWindowStation,
956  &LuidNone, NULL, 0);
957 
958  // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOGGINGOFF);
959 
960  // FIXME: Closing network connections!
961  // DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_CLOSINGNETWORKCONNECTIONS);
962 
963  /* Kill remaining COM apps. Only at logoff! */
964  hThread = CreateThread(psa, 0, KillComProcesses, (LPVOID)LSData, 0, NULL);
965  if (hThread)
966  {
969  }
970 
971  /* We're done with the SECURITY_DESCRIPTOR */
973  psa = NULL;
974 
975  HeapFree(GetProcessHeap(), 0, LSData);
976 
977  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_SAVEYOURSETTINGS);
978 
979  UnloadUserProfile(Session->UserToken, Session->hProfileInfo);
980 
982 
983  CloseHandle(Session->UserToken);
985  Session->LogonState = STATE_LOGGED_OFF;
986  Session->UserToken = NULL;
987 
988  return STATUS_SUCCESS;
989 }
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:349
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:598
static DWORD WINAPI KillComProcesses(LPVOID Parameter)
Definition: sas.c:740
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
PWLSESSION Session
Definition: sas.c:42
static VOID DestroyLogoffSecurityAttributes(IN PSECURITY_ATTRIBUTES psa)
Definition: sas.c:884
LUID LuidNone
Definition: sas.c:47
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
Definition: profile.c:2184
static DWORD WINAPI LogoffShutdownThread(LPVOID Parameter)
Definition: sas.c:695
static NTSTATUS CreateLogoffSecurityAttributes(OUT PSECURITY_ATTRIBUTES *ppsa)
Definition: sas.c:770
#define IDS_SAVEYOURSETTINGS
Definition: resource.h:34
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:540
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
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:136
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define GetProcessHeap()
Definition: compat.h:595
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
#define ERR(fmt,...)
Definition: debug.h:110
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:380
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
HANDLE hThread
Definition: wizard.c:28
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
DWORD WINAPI UpdatePerUserSystemParameters(DWORD dw1, DWORD dw2)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define INFINITE
Definition: serial.h:102
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DoGenericAction().

◆ HandleLogon()

static BOOL HandleLogon ( IN OUT PWLSESSION  Session)
static

Definition at line 578 of file sas.c.

580 {
581  PROFILEINFOW ProfileInfo;
582  BOOL ret = FALSE;
583 
584  /* Loading personal settings */
585  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS);
586  ProfileInfo.hProfile = INVALID_HANDLE_VALUE;
587  if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
588  {
589  if (Session->Profile == NULL
590  || (Session->Profile->dwType != WLX_PROFILE_TYPE_V1_0
591  && Session->Profile->dwType != WLX_PROFILE_TYPE_V2_0))
592  {
593  ERR("WL: Wrong profile\n");
594  goto cleanup;
595  }
596 
597  /* Load the user profile */
598  ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW));
599  ProfileInfo.dwSize = sizeof(PROFILEINFOW);
600  ProfileInfo.dwFlags = 0;
601  ProfileInfo.lpUserName = Session->MprNotifyInfo.pszUserName;
602  ProfileInfo.lpProfilePath = Session->Profile->pszProfile;
603  if (Session->Profile->dwType >= WLX_PROFILE_TYPE_V2_0)
604  {
605  ProfileInfo.lpDefaultPath = Session->Profile->pszNetworkDefaultUserProfile;
606  ProfileInfo.lpServerName = Session->Profile->pszServerName;
607  ProfileInfo.lpPolicyPath = Session->Profile->pszPolicy;
608  }
609 
610  if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
611  {
612  ERR("WL: LoadUserProfileW() failed\n");
613  goto cleanup;
614  }
615  }
616 
617  /* Create environment block for the user */
618  if (!CreateUserEnvironment(Session))
619  {
620  WARN("WL: SetUserEnvironment() failed\n");
621  goto cleanup;
622  }
623 
625 
626  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
628 
629  /* Set default user language */
630  if (!SetDefaultLanguage(Session))
631  {
632  WARN("WL: SetDefaultLanguage() failed\n");
633  goto cleanup;
634  }
635 
636  AllowWinstaAccess(Session);
637 
638  /* Connect remote resources */
639  RestoreAllConnections(Session);
640 
641  if (!StartUserShell(Session))
642  {
643  //WCHAR StatusMsg[256];
644  WARN("WL: WlxActivateUserShell() failed\n");
645  //LoadStringW(hAppInstance, IDS_FAILEDACTIVATEUSERSHELL, StatusMsg, sizeof(StatusMsg) / sizeof(StatusMsg[0]));
646  //MessageBoxW(0, StatusMsg, NULL, MB_ICONERROR);
647  goto cleanup;
648  }
649 
651 
652  if (!InitializeScreenSaver(Session))
653  WARN("WL: Failed to initialize screen saver\n");
654 
655  Session->hProfileInfo = ProfileInfo.hProfile;
656 
657  /* Logon has succeeded. Play sound. */
658  PlayLogonSound(Session);
659 
660  ret = TRUE;
661 
662 cleanup:
663  if (Session->Profile)
664  {
665  HeapFree(GetProcessHeap(), 0, Session->Profile->pszProfile);
666  HeapFree(GetProcessHeap(), 0, Session->Profile);
667  }
668  Session->Profile = NULL;
669  if (!ret && ProfileInfo.hProfile != INVALID_HANDLE_VALUE)
670  {
671  UnloadUserProfile(Session->UserToken, ProfileInfo.hProfile);
672  }
673  RemoveStatusMessage(Session);
674  if (!ret)
675  {
676  SetWindowStationUser(Session->InteractiveWindowStation,
677  &LuidNone, NULL, 0);
678  CloseHandle(Session->UserToken);
679  Session->UserToken = NULL;
680  }
681 
682  if (ret)
683  {
684  SwitchDesktop(Session->ApplicationDesktop);
685  Session->LogonState = STATE_LOGGED_ON;
686  }
687 
688  return ret;
689 }
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:349
BOOL RemoveStatusMessage(IN PWLSESSION Session)
Definition: winlogon.c:370
#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 CloseHandle
Definition: compat.h:598
HANDLE hProfile
Definition: userenv.h:43
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define ZeroMemory
Definition: winbase.h:1664
BOOL CreateUserEnvironment(IN PWLSESSION Session)
Definition: environment.c:128
LUID LuidNone
Definition: sas.c:47
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
Definition: profile.c:2184
LPWSTR lpDefaultPath
Definition: userenv.h:40
LPWSTR lpUserName
Definition: userenv.h:38
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR lpServerName
Definition: userenv.h:41
static VOID RestoreAllConnections(PWLSESSION Session)
Definition: sas.c:514
LPWSTR lpPolicyPath
Definition: userenv.h:42
#define GetProcessHeap()
Definition: compat.h:595
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:111
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:110
static BOOL StartUserShell(IN OUT PWLSESSION Session)
Definition: sas.c:80
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:380
static VOID PlayLogonSound(IN OUT PWLSESSION Session)
Definition: sas.c:421
LPWSTR lpProfilePath
Definition: userenv.h:39
static BOOL AllowWinstaAccess(PWLSESSION Session)
Definition: sas.c:432
#define NULL
Definition: types.h:112
BOOL WINAPI LoadUserProfileW(_In_ HANDLE hToken, _Inout_ LPPROFILEINFOW lpProfileInfo)
Definition: profile.c:2005
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:594
#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 1349 of file sas.c.

1350 {
1351  LPWSTR EventName;
1352 
1353  switch(uType)
1354  {
1355  case 0xFFFFFFFF:
1356  EventName = NULL;
1357  break;
1358  case MB_OK:
1359  EventName = L"SystemDefault";
1360  break;
1361  case MB_ICONASTERISK:
1362  EventName = L"SystemAsterisk";
1363  break;
1364  case MB_ICONEXCLAMATION:
1365  EventName = L"SystemExclamation";
1366  break;
1367  case MB_ICONHAND:
1368  EventName = L"SystemHand";
1369  break;
1370  case MB_ICONQUESTION:
1371  EventName = L"SystemQuestion";
1372  break;
1373  default:
1374  WARN("Unhandled type %d\n", uType);
1375  EventName = L"SystemDefault";
1376  }
1377 
1378  return PlaySoundRoutine(EventName, FALSE, SND_ALIAS | SND_NOWAIT | SND_NOSTOP | SND_ASYNC);
1379 }
#define MB_ICONHAND
Definition: winuser.h:782
#define WARN(fmt,...)
Definition: debug.h:112
BOOL PlaySoundRoutine(IN LPCWSTR FileName, IN UINT bLogon, IN UINT Flags)
Definition: sas.c:240
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define FALSE
Definition: types.h:117
#define SND_NOSTOP
Definition: mmsystem.h:158
#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 NULL
Definition: types.h:112
#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 1040 of file sas.c.

1043 {
1044  PLOGOFF_SHUTDOWN_DATA LSData;
1045  HANDLE hThread;
1046  DWORD exitCode;
1047  BOOLEAN Old;
1048 
1049  // SwitchDesktop(Session->WinlogonDesktop);
1050 
1051  /* If the system is rebooting, show the appropriate string */
1052  if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1053  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISRESTARTING);
1054  else
1055  DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_REACTOSISSHUTTINGDOWN);
1056 
1057  /* Prepare data for shutdown thread */
1058  LSData = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGOFF_SHUTDOWN_DATA));
1059  if (!LSData)
1060  {
1061  ERR("Failed to allocate mem for thread data\n");
1062  return STATUS_NO_MEMORY;
1063  }
1064  if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_POWER_OFF)
1065  LSData->Flags = EWX_POWEROFF;
1066  else if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1067  LSData->Flags = EWX_REBOOT;
1068  else
1069  LSData->Flags = EWX_SHUTDOWN;
1070  LSData->Session = Session;
1071 
1072  // FIXME: We may need to specify this flag to really force application kill
1073  // (we are shutting down ReactOS, not just logging off so no hangs, etc...
1074  // should be allowed).
1075  // LSData->Flags |= EWX_FORCE;
1076 
1077  /* Run shutdown thread */
1079  if (!hThread)
1080  {
1081  ERR("Unable to create shutdown thread, error %lu\n", GetLastError());
1082  HeapFree(GetProcessHeap(), 0, LSData);
1083  return STATUS_UNSUCCESSFUL;
1084  }
1086  HeapFree(GetProcessHeap(), 0, LSData);
1087  if (!GetExitCodeThread(hThread, &exitCode))
1088  {
1089  ERR("Unable to get exit code of shutdown thread (error %lu)\n", GetLastError());
1091  return STATUS_UNSUCCESSFUL;
1092  }
1094  if (exitCode == 0)
1095  {
1096  ERR("Shutdown thread returned failure\n");
1097  return STATUS_UNSUCCESSFUL;
1098  }
1099 
1101 
1102  /* Destroy SAS window */
1103  UninitializeSAS(Session);
1104 
1105  /* Now we can shut down NT */
1106  ERR("Shutting down NT...\n");
1108  if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
1109  {
1111  }
1112  else
1113  {
1114  if (FALSE)
1115  {
1116  /* FIXME - only show this dialog if it's a shutdown and the computer doesn't support APM */
1119  }
1121  }
1123  return STATUS_SUCCESS;
1124 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL DisplayStatusMessage(IN PWLSESSION Session, IN HDESK hDesktop, IN UINT ResourceId)
Definition: winlogon.c:349
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
PWLSESSION Session
Definition: sas.c:42
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1026
#define EWX_REBOOT
Definition: winuser.h:633
static DWORD WINAPI LogoffShutdownThread(LPVOID Parameter)
Definition: sas.c:695
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:540
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define DialogBox
Definition: winuser.h:5736
static INT_PTR CALLBACK ShutdownComputerWindowProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sas.c:994
#define FALSE
Definition: types.h:117
#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:136
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
#define EWX_POWEROFF
Definition: winuser.h:632
#define GetProcessHeap()
Definition: compat.h:595
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:110
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
Definition: notify.c:380
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
HANDLE hThread
Definition: wizard.c:28
#define WLX_SAS_ACTION_SHUTDOWN_REBOOT
Definition: winwlx.h:63
#define IDS_REACTOSISRESTARTING
Definition: resource.h:38
#define STATUS_SUCCESS
Definition: shellext.h:65
#define INFINITE
Definition: serial.h:102
#define HeapFree(x, y, z)
Definition: compat.h:594
HINSTANCE hAppInstance
Definition: mmc.c:23

Referenced by DoGenericAction(), and WinMain().

◆ InitializeSAS()

BOOL InitializeSAS ( IN OUT PWLSESSION  Session)

Definition at line 1584 of file sas.c.

1586 {
1587  WNDCLASSEXW swc;
1588  BOOL ret = FALSE;
1589 
1590  if (!SwitchDesktop(Session->WinlogonDesktop))
1591  {
1592  ERR("WL: Failed to switch to winlogon desktop\n");
1593  goto cleanup;
1594  }
1595 
1596  /* Register SAS window class */
1597  swc.cbSize = sizeof(WNDCLASSEXW);
1598  swc.style = CS_SAVEBITS;
1599  swc.lpfnWndProc = SASWindowProc;
1600  swc.cbClsExtra = 0;
1601  swc.cbWndExtra = 0;
1602  swc.hInstance = hAppInstance;
1603  swc.hIcon = NULL;
1604  swc.hCursor = NULL;
1605  swc.hbrBackground = NULL;
1606  swc.lpszMenuName = NULL;
1608  swc.hIconSm = NULL;
1609  if (RegisterClassExW(&swc) == 0)
1610  {
1611  ERR("WL: Failed to register SAS window class\n");
1612  goto cleanup;
1613  }
1614 
1615  /* Create invisible SAS window */
1616  Session->SASWindow = CreateWindowExW(
1617  0,
1620  WS_POPUP,
1621  0, 0, 0, 0, 0, 0,
1622  hAppInstance, Session);
1623  if (!Session->SASWindow)
1624  {
1625  ERR("WL: Failed to create SAS window\n");
1626  goto cleanup;
1627  }
1628 
1629  /* Register SAS window to receive SAS notifications */
1630  if (!SetLogonNotifyWindow(Session->SASWindow))
1631  {
1632  ERR("WL: Failed to register SAS window\n");
1633  goto cleanup;
1634  }
1635 
1636  if (!SetDefaultLanguage(NULL))
1637  return FALSE;
1638 
1639  ret = TRUE;
1640 
1641 cleanup:
1642  if (!ret)
1643  UninitializeSAS(Session);
1644  return ret;
1645 }
int cbWndExtra
Definition: winuser.h:3195
#define TRUE
Definition: types.h:120
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:1384
HICON hIcon
Definition: winuser.h:3197
struct _WNDCLASSEXW WNDCLASSEXW
static VOID UninitializeSAS(IN OUT PWLSESSION Session)
Definition: sas.c:1026
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
LPCWSTR lpszMenuName
Definition: winuser.h:3200
#define WINLOGON_SAS_CLASS
Definition: sas.c:26
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
int cbClsExtra
Definition: winuser.h:3194
LPCWSTR lpszClassName
Definition: winuser.h:3201
HBRUSH hbrBackground
Definition: winuser.h:3199
UINT cbSize
Definition: winuser.h:3191
BOOL WINAPI SwitchDesktop(_In_ HDESK)
HINSTANCE hInstance
Definition: winuser.h:3196
#define CS_SAVEBITS
Definition: winuser.h:652
BOOL SetDefaultLanguage(IN PWLSESSION Session)
Definition: sas.c:111
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:3198
UINT style
Definition: winuser.h:3192
WNDPROC lpfnWndProc
Definition: winuser.h:3193
#define ERR(fmt,...)
Definition: debug.h:110
#define WS_POPUP
Definition: pedump.c:616
#define WINLOGON_SAS_TITLE
Definition: sas.c:27
#define NULL
Definition: types.h:112
HICON hIconSm
Definition: winuser.h:3202
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 740 of file sas.c.

742 {
743  DWORD ret = 1;
745 
746  TRACE("In KillComProcesses\n");
747 
748  if (LSData->Session->UserToken != NULL &&
750  {
751  ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
752  return 0;
753  }
754 
755  /* Attempt to kill remaining processes. No notifications needed. */
757  {
758  ERR("Unable to kill COM apps, error %lu\n", GetLastError());
759  ret = 0;
760  }
761 
762  if (LSData->Session->UserToken)
763  RevertToSelf();
764 
765  return ret;
766 }
#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:1044
PWLSESSION Session
Definition: sas.c:42
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define EWX_LOGOFF
Definition: winuser.h:631
#define EWX_CALLER_WINLOGON
Definition: undocuser.h:127
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:110
struct tagLOGOFF_SHUTDOWN_DATA * PLOGOFF_SHUTDOWN_DATA
#define NULL
Definition: types.h:112

Referenced by HandleLogoff().

◆ LogoffShutdownThread()

static DWORD WINAPI LogoffShutdownThread ( LPVOID  Parameter)
static

Definition at line 695 of file sas.c.

697 {
698  DWORD ret = 1;
700  UINT uFlags;
701 
702  if (LSData->Session->UserToken != NULL &&
704  {
705  ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
706  return 0;
707  }
708 
709  // FIXME: To be really fixed: need to check what needs to be kept and what needs to be removed there.
710  //
711  // uFlags = EWX_INTERNAL_KILL_USER_APPS | (LSData->Flags & EWX_FLAGS_MASK) |
712  // ((LSData->Flags & EWX_ACTION_MASK) == EWX_LOGOFF ? EWX_CALLER_WINLOGON_LOGOFF : 0);
713 
714  uFlags = EWX_CALLER_WINLOGON | (LSData->Flags & 0x0F);
715 
716  TRACE("In LogoffShutdownThread with uFlags == 0x%x; exit_in_progress == %s\n",
717  uFlags, ExitReactOSInProgress ? "true" : "false");
718 
720 
721  /* Close processes of the interactive user */
722  if (!ExitWindowsEx(uFlags, 0))
723  {
724  ERR("Unable to kill user apps, error %lu\n", GetLastError());
725  ret = 0;
726  }
727 
728  /* Cancel all the user connections */
730 
731  if (LSData->Session->UserToken)
732  RevertToSelf();
733 
734  return ret;
735 }
#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:1044
PWLSESSION Session
Definition: sas.c:42
UINT uFlags
Definition: api.c:59
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define EWX_CALLER_WINLOGON
Definition: undocuser.h:127
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:45
int ret
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define ERR(fmt,...)
Definition: debug.h:110
struct tagLOGOFF_SHUTDOWN_DATA * PLOGOFF_SHUTDOWN_DATA
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD WINAPI WNetClearConnections(HWND owner)
Definition: wnet.c:2825

Referenced by HandleLogoff(), and HandleShutdown().

◆ PlayLogonSound()

static VOID PlayLogonSound ( IN OUT PWLSESSION  Session)
static

Definition at line 421 of file sas.c.

423 {
424  HANDLE hThread;
425 
426  hThread = CreateThread(NULL, 0, PlayLogonSoundThread, (PVOID)Session->UserToken, 0, NULL);
427  if (hThread)
429 }
#define CloseHandle
Definition: compat.h:598
DWORD WINAPI PlayLogonSoundThread(IN LPVOID lpParameter)
Definition: sas.c:284
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:136
#define NULL
Definition: types.h:112
HANDLE hThread
Definition: wizard.c:28

Referenced by HandleLogon().

◆ PlayLogonSoundThread()

DWORD WINAPI PlayLogonSoundThread ( IN LPVOID  lpParameter)

Definition at line 284 of file sas.c.

286 {
287  BYTE TokenUserBuffer[256];
288  PTOKEN_USER pTokenUser = (TOKEN_USER*)TokenUserBuffer;
289  ULONG Length;
290  HKEY hKey;
291  WCHAR wszBuffer[MAX_PATH] = {0};
292  WCHAR wszDest[MAX_PATH];
293  DWORD dwSize = sizeof(wszBuffer), dwType;
295  UNICODE_STRING SidString;
297  ULONG Index = 0;
298  SC_HANDLE hSCManager, hService;
299 
300  //
301  // FIXME: Isn't it possible to *JUST* impersonate the current user
302  // *AND* open its HKCU??
303  //
304 
305  /* Get SID of current user */
307  TokenUser,
308  TokenUserBuffer,
309  sizeof(TokenUserBuffer),
310  &Length);
311  if (!NT_SUCCESS(Status))
312  {
313  ERR("NtQueryInformationToken failed: %x!\n", Status);
314  return 0;
315  }
316 
317  /* Convert SID to string */
318  RtlInitEmptyUnicodeString(&SidString, wszBuffer, sizeof(wszBuffer));
319  Status = RtlConvertSidToUnicodeString(&SidString, pTokenUser->User.Sid, FALSE);
320  if (!NT_SUCCESS(Status))
321  {
322  ERR("RtlConvertSidToUnicodeString failed: %x!\n", Status);
323  return 0;
324  }
325 
326  /* Build path to logon sound registry key.
327  Note: We can't use HKCU here, because Winlogon is owned by SYSTEM user */
328  if (FAILED(StringCbCopyW(wszBuffer + SidString.Length/sizeof(WCHAR),
329  sizeof(wszBuffer) - SidString.Length,
330  L"\\AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current")))
331  {
332  /* SID is too long. Should not happen. */
333  ERR("StringCbCopyW failed!\n");
334  return 0;
335  }
336 
337  /* Open registry key and query sound path */
338  if (RegOpenKeyExW(HKEY_USERS, wszBuffer, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
339  {
340  ERR("RegOpenKeyExW(%ls) failed!\n", wszBuffer);
341  return 0;
342  }
343 
344  if (RegQueryValueExW(hKey, NULL, NULL, &dwType,
345  (LPBYTE)wszBuffer, &dwSize) != ERROR_SUCCESS ||
346  (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
347  {
348  ERR("RegQueryValueExW failed!\n");
349  RegCloseKey(hKey);
350  return 0;
351  }
352 
353  RegCloseKey(hKey);
354 
355  if (!wszBuffer[0])
356  {
357  /* No sound has been set */
358  ERR("No sound has been set\n");
359  return 0;
360  }
361 
362  /* Expand environment variables */
363  if (!ExpandEnvironmentStringsW(wszBuffer, wszDest, MAX_PATH))
364  {
365  ERR("ExpandEnvironmentStringsW failed!\n");
366  return 0;
367  }
368 
369  /* Open the service manager */
371  if (!hSCManager)
372  {
373  ERR("OpenSCManager failed (%x)\n", GetLastError());
374  return 0;
375  }
376 
377  /* Open the wdmaud service */
378  hService = OpenServiceW(hSCManager, L"wdmaud", GENERIC_READ);
379  if (!hService)
380  {
381  /* The service is not installed */
382  TRACE("Failed to open wdmaud service (%x)\n", GetLastError());
384  return 0;
385  }
386 
387  /* Wait for wdmaud to start */
388  do
389  {
391  {
392  TRACE("QueryServiceStatusEx failed (%x)\n", GetLastError());
393  break;
394  }
395 
396  if (Info.dwCurrentState == SERVICE_RUNNING)
397  break;
398 
399  Sleep(1000);
400 
401  } while (Index++ < 20);
402 
403  CloseServiceHandle(hService);
405 
406  /* If wdmaud is not running exit */
407  if (Info.dwCurrentState != SERVICE_RUNNING)
408  {
409  WARN("wdmaud has not started!\n");
410  return 0;
411  }
412 
413  /* Sound subsystem is running. Play logon sound. */
414  TRACE("Playing logon sound: %ls\n", wszDest);
416  return 0;
417 }
#define HKEY_USERS
Definition: winreg.h:13
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
BOOL PlaySoundRoutine(IN LPCWSTR FileName, IN UINT bLogon, IN UINT Flags)
Definition: sas.c:240
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2830
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#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
_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:2383
Status
Definition: gdiplustypes.h:24
#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
_In_ WDFCOLLECTION _In_ ULONG Index
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
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:241
#define GENERIC_READ
Definition: compat.h:135
SC_HANDLE hSCManager
Definition: sc.c:12
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
#define SND_FILENAME
Definition: mmsystem.h:162
FxAutoRegKey hKey
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
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:56
#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 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  {
256  waveOutGetNumDevs = (WAVEOUTGETNUMDEVS)GetProcAddress(hLibrary, "waveOutGetNumDevs");
257  if (waveOutGetNumDevs)
258  {
259  NumDevs = waveOutGetNumDevs();
260  if (!NumDevs)
261  {
262  if (!bLogon)
263  {
264  Beep(500, 500);
265  }
267  return FALSE;
268  }
269  }
270 
271  Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
272  if (Play)
273  {
274  Ret = Play(FileName, NULL, Flags);
275  }
277  }
278 
279  return Ret;
280 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:606
UINT WINAPI waveOutGetNumDevs(void)
Definition: winmm.c:2140
#define FreeLibrary(x)
Definition: compat.h:607
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define WINAPI
Definition: msvc.h:6
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:77
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by HandleMessageBeep(), and PlayLogonSoundThread().

◆ RegisterHotKeys()

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

Definition at line 1314 of file sas.c.

1317 {
1318  /* Register Ctrl+Alt+Del Hotkey */
1320  {
1321  ERR("WL: Unable to register Ctrl+Alt+Del hotkey!\n");
1322  return FALSE;
1323  }
1324 
1325  /* Register Ctrl+Shift+Esc (optional) */
1326  Session->TaskManHotkey = RegisterHotKey(hwndSAS, HK_CTRL_SHIFT_ESC, MOD_CONTROL | MOD_SHIFT, VK_ESCAPE);
1327  if (!Session->TaskManHotkey)
1328  WARN("WL: Warning: Unable to register Ctrl+Alt+Esc hotkey!\n");
1329  return TRUE;
1330 }
#define HK_CTRL_ALT_DEL
Definition: sas.c:29
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define VK_ESCAPE
Definition: winuser.h:2189
#define FALSE
Definition: types.h:117
#define VK_DELETE
Definition: winuser.h:2208
HWND hwndSAS
Definition: winsta.c:24
#define ERR(fmt,...)
Definition: debug.h:110
#define MOD_ALT
Definition: imm.h:314
#define MOD_CONTROL
Definition: imm.h:315
#define MOD_SHIFT
Definition: imm.h:316
#define HK_CTRL_SHIFT_ESC
Definition: sas.c:30
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 514 of file sas.c.

515 {
516  DWORD dRet;
517  HANDLE hEnum;
518  LPNETRESOURCE lpRes;
519  DWORD dSize = 0x1000;
520  DWORD dCount = -1;
521  LPNETRESOURCE lpCur;
522  BOOL UserProfile;
523 
524  UserProfile = (Session && Session->UserToken);
525  if (!UserProfile)
526  {
527  return;
528  }
529 
530  if (!ImpersonateLoggedOnUser(Session->UserToken))
531  {
532  ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
533  return;
534  }
535 
537  if (dRet != WN_SUCCESS)
538  {
539  ERR("Failed to open enumeration: %lu\n", dRet);
540  goto quit;
541  }
542 
543  lpRes = HeapAlloc(GetProcessHeap(), 0, dSize);
544  if (!lpRes)
545  {
546  ERR("Failed to allocate memory\n");
547  WNetCloseEnum(hEnum);
548  goto quit;
549  }
550 
551  do
552  {
553  dSize = 0x1000;
554  dCount = -1;
555 
556  memset(lpRes, 0, dSize);
557  dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
558  if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
559  {
560  lpCur = lpRes;
561  for (; dCount; dCount--)
562  {
564  lpCur++;
565  }
566  }
567  } while (dRet != WN_NO_MORE_ENTRIES);
568 
569  HeapFree(GetProcessHeap(), 0, lpRes);
570  WNetCloseEnum(hEnum);
571 
572 quit:
573  RevertToSelf();
574 }
#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:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
#define WNetOpenEnum
Definition: winnetwk.h:598
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI WNetCloseEnum(HANDLE hEnum)
Definition: wnet.c:1760
#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:110
#define NULL
Definition: types.h:112
#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:594

Referenced by HandleLogon().

◆ SASWindowProc()

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

Definition at line 1384 of file sas.c.

1389 {
1390  PWLSESSION Session = (PWLSESSION)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
1391 
1392  switch (uMsg)
1393  {
1394  case WM_HOTKEY:
1395  {
1396  switch (lParam)
1397  {
1399  {
1400  TRACE("SAS: CONTROL+ALT+DELETE\n");
1401  if (!Session->Gina.UseCtrlAltDelete)
1402  break;
1404  return TRUE;
1405  }
1407  {
1408  TRACE("SAS: CONTROL+SHIFT+ESCAPE\n");
1409  if (Session->LogonState == STATE_LOGGED_ON)
1411  return TRUE;
1412  }
1413  }
1414  break;
1415  }
1416  case WM_CREATE:
1417  {
1418  /* Get the session pointer from the create data */
1419  Session = (PWLSESSION)((LPCREATESTRUCT)lParam)->lpCreateParams;
1420 
1421  /* Save the Session pointer */
1422  SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (LONG_PTR)Session);
1423  if (GetSetupType())
1424  return TRUE;
1425  return RegisterHotKeys(Session, hwndDlg);
1426  }
1427  case WM_DESTROY:
1428  {
1429  if (!GetSetupType())
1430  UnregisterHotKeys(Session, hwndDlg);
1431  return TRUE;
1432  }
1433  case WM_SETTINGCHANGE:
1434  {
1435  UINT uiAction = (UINT)wParam;
1436  if (uiAction == SPI_SETSCREENSAVETIMEOUT
1437  || uiAction == SPI_SETSCREENSAVEACTIVE)
1438  {
1440  }
1441  return TRUE;
1442  }
1443  case WM_LOGONNOTIFY:
1444  {
1445  switch(wParam)
1446  {
1447  case LN_MESSAGE_BEEP:
1448  {
1449  return HandleMessageBeep(lParam);
1450  }
1451  case LN_SHELL_EXITED:
1452  {
1453  /* lParam is the exit code */
1454  if (lParam != 1 &&
1455  Session->LogonState != STATE_LOGGED_OFF &&
1456  Session->LogonState != STATE_LOGGED_OFF_SAS)
1457  {
1458  SetTimer(hwndDlg, 1, 1000, NULL);
1459  }
1460  break;
1461  }
1462  case LN_START_SCREENSAVE:
1463  {
1465  break;
1466  }
1467  case LN_LOCK_WORKSTATION:
1468  {
1470  break;
1471  }
1472  case LN_LOGOFF:
1473  {
1474  UINT Flags = (UINT)lParam;
1476  DWORD wlxAction;
1477 
1478  TRACE("\tFlags : 0x%lx\n", lParam);
1479 
1480  /*
1481  * Our caller (USERSRV) should have added the shutdown flag
1482  * when setting also poweroff or reboot.
1483  */
1484  if (Action & (EWX_POWEROFF | EWX_REBOOT))
1485  {
1486  if ((Action & EWX_SHUTDOWN) == 0)
1487  {
1488  ERR("Missing EWX_SHUTDOWN flag for poweroff or reboot; action 0x%x\n", Action);
1489  return STATUS_INVALID_PARAMETER;
1490  }
1491 
1492  /* Now we can locally remove it for performing checks */
1493  Action &= ~EWX_SHUTDOWN;
1494  }
1495 
1496  /* Check parameters */
1497  if (Action & EWX_FORCE)
1498  {
1499  // FIXME!
1500  ERR("FIXME: EWX_FORCE present for Winlogon, what to do?\n");
1501  Action &= ~EWX_FORCE;
1502  }
1503  switch (Action)
1504  {
1505  case EWX_LOGOFF:
1506  wlxAction = WLX_SAS_ACTION_LOGOFF;
1507  break;
1508  case EWX_SHUTDOWN:
1509  wlxAction = WLX_SAS_ACTION_SHUTDOWN;
1510  break;
1511  case EWX_REBOOT:
1512  wlxAction = WLX_SAS_ACTION_SHUTDOWN_REBOOT;
1513  break;
1514  case EWX_POWEROFF:
1516  break;
1517 
1518  default:
1519  {
1520  ERR("Invalid ExitWindows action 0x%x\n", Action);
1521  return STATUS_INVALID_PARAMETER;
1522  }
1523  }
1524 
1525  TRACE("In LN_LOGOFF, exit_in_progress == %s\n",
1526  ExitReactOSInProgress ? "true" : "false");
1527 
1528  /*
1529  * In case a parallel shutdown request is done (while we are
1530  * being to shut down) and it was not done by Winlogon itself,
1531  * then just stop here.
1532  */
1533 #if 0
1534 // This code is commented at the moment (even if it's correct) because
1535 // our log-offs do not really work: the shell is restarted, no app is killed
1536 // etc... and as a result you just get explorer opening "My Documents". And
1537 // if you try now a shut down, it won't work because winlogon thinks it is
1538 // still in the middle of a shutdown.
1539 // Maybe we also need to reset ExitReactOSInProgress somewhere else??
1541  {
1542  break;
1543  }
1544 #endif
1545  /* Now do the shutdown action proper */
1546  DoGenericAction(Session, wlxAction);
1547  return 1;
1548  }
1549  case LN_LOGOFF_CANCELED:
1550  {
1551  ERR("Logoff canceled!!, before: exit_in_progress == %s, after will be false\n",
1552  ExitReactOSInProgress ? "true" : "false");
1553 
1555  return 1;
1556  }
1557  default:
1558  {
1559  ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam);
1560  }
1561  }
1562  return 0;
1563  }
1564  case WM_TIMER:
1565  {
1566  if (wParam == 1)
1567  {
1568  KillTimer(hwndDlg, 1);
1569  StartUserShell(Session);
1570  }
1571  break;
1572  }
1573  case WLX_WM_SAS:
1574  {
1575  DispatchSAS(Session, (DWORD)wParam);
1576  return TRUE;
1577  }
1578  }
1579 
1580  return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
1581 }
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
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:1349
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WM_HOTKEY
Definition: winuser.h:1861
HWND SASWindow
Definition: winlogon.h:220
static BOOL RegisterHotKeys(IN PWLSESSION Session, IN HWND hwndSAS)
Definition: sas.c:1314
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
static BOOL UnregisterHotKeys(IN PWLSESSION Session, IN HWND hwndSAS)
Definition: sas.c:1334
static VOID DoGenericAction(IN OUT PWLSESSION Session, IN DWORD wlxAction)
Definition: sas.c:1128
#define EWX_REBOOT
Definition: winuser.h:633
DWORD GetSetupType(VOID)
Definition: setup.c:16
#define VK_ESCAPE
Definition: winuser.h:2189
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
#define FALSE
Definition: types.h:117
#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:249
#define WLX_SAS_ACTION_LOGOFF
Definition: winwlx.h:56
static VOID DispatchSAS(IN OUT PWLSESSION Session, IN DWORD dwSasType)
Definition: sas.c:1218
#define VK_DELETE
Definition: winuser.h:2208
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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define WM_TIMER
Definition: winuser.h:1724
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL ExitReactOSInProgress
Definition: sas.c:45
#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:110
static BOOL StartUserShell(IN OUT PWLSESSION Session)
Definition: sas.c:80
#define MOD_ALT
Definition: imm.h:314
#define MOD_CONTROL
Definition: imm.h:315
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
#define MOD_SHIFT
Definition: imm.h:316
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#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:5321
#define GetWindowLongPtr
Definition: treelist.c:73
#define LN_MESSAGE_BEEP
Definition: undocuser.h:118
#define EWX_ACTION_MASK
Definition: sas.c:37
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 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 
169  rc = RegQueryValueExW(hKey,
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  }
193  rc = RegQueryValueExW(hKey,
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 
226 cleanup:
227  if (Value)
229 
230  if (hKey)
231  RegCloseKey(hKey);
232 
233  if (UserProfile)
234  RevertToSelf();
235 
236  return ret;
237 }
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ CONST DEVPROPKEY _In_ LCID Lcid
Definition: iofuncs.h:2414
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD LCID
Definition: nls.h:13
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
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
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
unsigned short USHORT
Definition: pedump.c:61
FxAutoRegKey hKey
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
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:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#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 994 of file sas.c.

999 {
1001 
1002  switch (uMsg)
1003  {
1004  case WM_COMMAND:
1005  {
1006  switch (LOWORD(wParam))
1007  {
1010  return TRUE;
1011  }
1012  break;
1013  }
1014  case WM_INITDIALOG:
1015  {
1018  return TRUE;
1019  }
1020  }
1021  return FALSE;
1022 }
#define MF_BYCOMMAND
Definition: winuser.h:202
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
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:1722
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SC_CLOSE
Definition: winuser.h:2567
#define WM_INITDIALOG
Definition: winuser.h:1721
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 52 of file sas.c.

54 {
55  LPVOID lpEnvironment;
56  BOOL ret;
57 
58  if (!Session->Gina.Functions.WlxStartApplication)
59  return FALSE;
60 
62  &lpEnvironment,
63  Session->UserToken,
64  TRUE))
65  {
66  return FALSE;
67  }
68 
69  ret = Session->Gina.Functions.WlxStartApplication(
70  Session->Gina.Context,
71  L"Default",
72  lpEnvironment,
73  L"taskmgr.exe");
74 
75  DestroyEnvironmentBlock(lpEnvironment);
76  return ret;
77 }
#define TRUE
Definition: types.h:120
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
#define FALSE
Definition: types.h:117
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 80 of file sas.c.

82 {
83  LPVOID lpEnvironment = NULL;
84  BOOLEAN Old;
85  BOOL ret;
86 
87  /* Create environment block for the user */
88  if (!CreateEnvironmentBlock(&lpEnvironment, Session->UserToken, TRUE))
89  {
90  WARN("WL: CreateEnvironmentBlock() failed\n");
91  return FALSE;
92  }
93 
94  /* Get privilege */
95  /* FIXME: who should do it? winlogon or gina? */
96  /* FIXME: reverting to lower privileges after creating user shell? */
98 
99  ret = Session->Gina.Functions.WlxActivateUserShell(
100  Session->Gina.Context,
101  L"Default",
102  NULL, /* FIXME */
103  lpEnvironment);
104 
105  DestroyEnvironmentBlock(lpEnvironment);
106  return ret;
107 }
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char BOOLEAN
int ret
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727
#define NULL
Definition: types.h:112
#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 1026 of file sas.c.

1028 {
1029  if (Session->SASWindow)
1030  {
1031  DestroyWindow(Session->SASWindow);
1032  Session->SASWindow = NULL;
1033  }
1034  if (Session->hEndOfScreenSaverThread)
1035  SetEvent(Session->hEndOfScreenSaverThread);
1037 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WINLOGON_SAS_CLASS
Definition: sas.c:26
#define NULL
Definition: types.h:112
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 1334 of file sas.c.

1337 {
1338  /* Unregister hotkeys */
1340 
1341  if (Session->TaskManHotkey)
1343 
1344  return TRUE;
1345 }
#define HK_CTRL_ALT_DEL
Definition: sas.c:29
#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:30

Referenced by SASWindowProc().

Variable Documentation

◆ ExitReactOSInProgress

BOOL ExitReactOSInProgress = FALSE
static

Definition at line 45 of file sas.c.

Referenced by LogoffShutdownThread(), and SASWindowProc().

◆ LuidNone

LUID LuidNone = {0, 0}