ReactOS  0.4.14-dev-49-gfb4591c
winsta.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WINSTATION_OBJECT
 

Macros

#define WINSTA_OBJ_DIR   L"\\Windows\\WindowStations"
 
#define SESSION_DIR   L"\\Sessions"
 
#define WSS_LOCKED   (1)
 
#define WSS_NOINTERACTIVE   (2)
 
#define WSS_NOIO   (4)
 
#define WSS_SHUTDOWN   (8)
 
#define WSS_DYING   (16)
 
#define WSS_REALSHUTDOWN   (32)
 
#define WINSTA_READ
 
#define WINSTA_WRITE
 
#define WINSTA_EXECUTE
 
#define WINSTA_ACCESS_ALL
 

Typedefs

typedef struct _WINSTATION_OBJECT WINSTATION_OBJECT
 
typedef struct _WINSTATION_OBJECTPWINSTATION_OBJECT
 

Functions

INIT_FUNCTION NTSTATUS NTAPI InitWindowStationImpl (VOID)
 
NTSTATUS NTAPI UserCreateWinstaDirectory (VOID)
 
NTSTATUS NTAPI IntWinStaObjectDelete (_In_ PVOID Parameters)
 
NTSTATUS NTAPI IntWinStaObjectParse (_In_ PVOID Parameters)
 
NTSTATUS NTAPI IntWinStaOkToClose (_In_ PVOID Parameters)
 
NTSTATUS FASTCALL IntValidateWindowStationHandle (HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
 
NTSTATUS FASTCALL IntCreateWindowStation (OUT HWINSTA *phWinSta, IN POBJECT_ATTRIBUTES ObjectAttributes, IN KPROCESSOR_MODE AccessMode, IN KPROCESSOR_MODE OwnerMode, IN ACCESS_MASK dwDesiredAccess, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4, DWORD Unknown5, DWORD Unknown6)
 
BOOL FASTCALL UserSetProcessWindowStation (HWINSTA hWindowStation)
 
BOOL FASTCALL co_IntInitializeDesktopGraphics (VOID)
 
VOID FASTCALL IntEndDesktopGraphics (VOID)
 
BOOL FASTCALL CheckWinstaAttributeAccess (ACCESS_MASK)
 

Variables

WINSTATION_OBJECTInputWindowStation
 
HANDLE gpidLogon
 
HWND hwndSAS
 
UNICODE_STRING gustrWindowStationsDir
 

Macro Definition Documentation

◆ SESSION_DIR

#define SESSION_DIR   L"\\Sessions"

Definition at line 4 of file winsta.h.

◆ WINSTA_ACCESS_ALL

#define WINSTA_ACCESS_ALL
Value:
WINSTA_ACCESSCLIPBOARD | \
WINSTA_ACCESSGLOBALATOMS | \
WINSTA_CREATEDESKTOP | \
WINSTA_ENUMDESKTOPS | \
WINSTA_ENUMERATE | \
WINSTA_EXITWINDOWS | \
WINSTA_READATTRIBUTES | \
WINSTA_READSCREEN | \
WINSTA_WRITEATTRIBUTES
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63

Definition at line 65 of file winsta.h.

◆ WINSTA_EXECUTE

#define WINSTA_EXECUTE
Value:
WINSTA_ACCESSGLOBALATOMS | \
WINSTA_EXITWINDOWS
#define STANDARD_RIGHTS_EXECUTE
Definition: nt_native.h:67

Definition at line 61 of file winsta.h.

◆ WINSTA_OBJ_DIR

#define WINSTA_OBJ_DIR   L"\\Windows\\WindowStations"

Definition at line 3 of file winsta.h.

◆ WINSTA_READ

#define WINSTA_READ
Value:
WINSTA_ENUMDESKTOPS | \
WINSTA_ENUMERATE | \
WINSTA_READATTRIBUTES | \
WINSTA_READSCREEN
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65

Definition at line 50 of file winsta.h.

◆ WINSTA_WRITE

#define WINSTA_WRITE
Value:
WINSTA_ACCESSCLIPBOARD | \
WINSTA_CREATEDESKTOP | \
WINSTA_WRITEATTRIBUTES
#define STANDARD_RIGHTS_WRITE
Definition: nt_native.h:66

Definition at line 56 of file winsta.h.

◆ WSS_DYING

#define WSS_DYING   (16)

Definition at line 11 of file winsta.h.

◆ WSS_LOCKED

#define WSS_LOCKED   (1)

Definition at line 7 of file winsta.h.

◆ WSS_NOINTERACTIVE

#define WSS_NOINTERACTIVE   (2)

Definition at line 8 of file winsta.h.

◆ WSS_NOIO

#define WSS_NOIO   (4)

Definition at line 9 of file winsta.h.

◆ WSS_REALSHUTDOWN

#define WSS_REALSHUTDOWN   (32)

Definition at line 12 of file winsta.h.

◆ WSS_SHUTDOWN

#define WSS_SHUTDOWN   (8)

Definition at line 10 of file winsta.h.

Typedef Documentation

◆ PWINSTATION_OBJECT

◆ WINSTATION_OBJECT

Function Documentation

◆ CheckWinstaAttributeAccess()

BOOL FASTCALL CheckWinstaAttributeAccess ( ACCESS_MASK  )

Definition at line 353 of file winsta.c.

354 {
356  if ( gpidLogon != PsGetCurrentProcessId() )
357  {
358  if (!(ppi->W32PF_flags & W32PF_IOWINSTA))
359  {
360  ERR("Requires Interactive Window Station\n");
362  return FALSE;
363  }
365  {
366  ERR("Access Denied\n");
368  return FALSE;
369  }
370  }
371  return TRUE;
372 }
#define TRUE
Definition: types.h:120
#define W32PF_IOWINSTA
Definition: win32.h:23
#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
Definition: winerror.h:940
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define ERR(fmt,...)
Definition: debug.h:109
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
NTSYSAPI BOOLEAN NTAPI RtlAreAllAccessesGranted(ACCESS_MASK GrantedAccess, ACCESS_MASK DesiredAccess)
ACCESS_MASK amwinsta
Definition: win32.h:259
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
HANDLE gpidLogon
Definition: simplecall.c:15

Referenced by NtUserGetClipCursor(), NtUserSetSystemCursor(), and UserClipCursor().

◆ co_IntInitializeDesktopGraphics()

BOOL FASTCALL co_IntInitializeDesktopGraphics ( VOID  )

Definition at line 260 of file winsta.c.

261 {
262  TEXTMETRICW tmw;
263  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
264  PDESKTOP pdesk;
265 
267  if (NULL == ScreenDeviceContext)
268  {
270  return FALSE;
271  }
273 
275  {
276  return FALSE;
277  }
278 
280 
283 
284  /* Update the system metrics */
285  InitMetrics();
286 
287  /* Set new size of the monitor */
289 
290  /* Update the SERVERINFO */
295  gpsi->BitCount = gpsi->Planes * gpsi->BitsPixel;
298  {
299  gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
300  }
301  else
302  {
303  gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
304  }
305  // Font is realized and this dc was previously set to internal DC_ATTR.
306  gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
307  gpsi->tmSysFont = tmw;
308 
309  /* Put the pointer in the center of the screen */
310  gpsi->ptCursor.x = gpsi->aiSysMet[SM_CXSCREEN] / 2;
311  gpsi->ptCursor.y = gpsi->aiSysMet[SM_CYSCREEN] / 2;
312 
313  /* Attach monitor */
315 
316  /* Setup the cursor */
318 
319  /* Setup the icons */
321 
322  /* Setup Menu */
323  MenuInit();
324 
325  /* Show the desktop */
326  pdesk = IntGetActiveDesktop();
327  ASSERT(pdesk);
328  co_IntShowDesktop(pdesk, gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN], TRUE);
329 
330  return TRUE;
331 }
BOOL MenuInit(VOID)
Definition: menu.c:359
#define BITSPIXEL
Definition: wingdi.h:719
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI UserUpdateMonitorSize(IN HDEV hDev)
Definition: monitor.c:225
GDIINFO gdiinfo
Definition: pdevobj.h:124
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
#define RASTERCAPS
Definition: wingdi.h:744
PSERVERINFO gpsi
Definition: main.c:27
NTSTATUS NTAPI UserAttachMonitor(IN HDEV hDev)
Definition: monitor.c:129
#define SM_CXSCREEN
Definition: winuser.h:949
BOOL FASTCALL co_IntSetWndIcons(VOID)
Definition: callback.c:1090
DWORD FASTCALL IntGetCharDimensions(HDC hdc, PTEXTMETRICW ptm, PDWORD height)
Definition: font.c:329
ULONG ulHorzRes
Definition: winddi.h:882
smooth NULL
Definition: ftsmooth.c:416
#define SYSTEM_FONT
Definition: wingdi.h:910
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
#define SM_CYSCREEN
Definition: winuser.h:950
HDC hSystemBM
Definition: stockobj.c:52
#define RC_PALETTE
Definition: wingdi.h:789
BOOL NTAPI InitMetrics(VOID)
Definition: metric.c:19
BOOL APIENTRY co_IntLoadDefaultCursors(VOID)
Definition: callback.c:478
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL FASTCALL IntCreatePrimarySurface(VOID)
Definition: device.c:29
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS FASTCALL co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL bRedraw)
Definition: desktop.c:1581
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1043
BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner)
Definition: dclife.c:455
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define PUSIF_PALETTEDISPLAY
Definition: ntuser.h:954
#define LOGPIXELSY
Definition: wingdi.h:718
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226
__kernel_entry W32KAPI INT APIENTRY NtGdiGetDeviceCaps(_In_ HDC hdc, _In_ INT i)
HDC ScreenDeviceContext
Definition: desktop.c:36
ULONG ulVertRes
Definition: winddi.h:883
VOID FASTCALL IntDestroyPrimarySurface(VOID)
Definition: device.c:44
#define PLANES
Definition: wingdi.h:720
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by co_AddGuiApp().

◆ InitWindowStationImpl()

INIT_FUNCTION NTSTATUS NTAPI InitWindowStationImpl ( VOID  )

Definition at line 34 of file winsta.c.

35 {
36  GENERIC_MAPPING IntWindowStationMapping = { WINSTA_READ,
40 
41  /* Set Winsta Object Attributes */
43  ExWindowStationObjectType->TypeInfo.GenericMapping = IntWindowStationMapping;
45 
46  return STATUS_SUCCESS;
47 }
#define WINSTA_READ
Definition: winsta.h:50
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
#define WINSTA_EXECUTE
Definition: winsta.h:61
struct _WINSTATION_OBJECT WINSTATION_OBJECT
OBJECT_TYPE_INITIALIZER TypeInfo
Definition: obtypes.h:390
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define WINSTA_ACCESS_ALL
Definition: winsta.h:65
#define WINSTA_WRITE
Definition: winsta.h:56
return STATUS_SUCCESS
Definition: btrfs.c:2966
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by DriverEntry().

◆ IntCreateWindowStation()

NTSTATUS FASTCALL IntCreateWindowStation ( OUT HWINSTA *  phWinSta,
IN POBJECT_ATTRIBUTES  ObjectAttributes,
IN KPROCESSOR_MODE  AccessMode,
IN KPROCESSOR_MODE  OwnerMode,
IN ACCESS_MASK  dwDesiredAccess,
DWORD  Unknown2,
DWORD  Unknown3,
DWORD  Unknown4,
DWORD  Unknown5,
DWORD  Unknown6 
)

Definition at line 411 of file winsta.c.

422 {
424  HWINSTA hWinSta;
425  PWINSTATION_OBJECT WindowStation;
426 
427  TRACE("IntCreateWindowStation called\n");
428 
429  ASSERT(phWinSta);
430  *phWinSta = NULL;
431 
434  AccessMode,
435  NULL,
436  dwDesiredAccess,
437  NULL,
438  (PVOID*)&hWinSta);
439  if (NT_SUCCESS(Status))
440  {
441  TRACE("IntCreateWindowStation opened window station '%wZ'\n",
442  ObjectAttributes->ObjectName);
443  *phWinSta = hWinSta;
444  return Status;
445  }
446 
447  /*
448  * No existing window station found, try to create a new one.
449  */
450 
451  /* Create the window station object */
455  OwnerMode,
456  NULL,
457  sizeof(WINSTATION_OBJECT),
458  0,
459  0,
460  (PVOID*)&WindowStation);
461  if (!NT_SUCCESS(Status))
462  {
463  ERR("ObCreateObject failed for window station '%wZ', Status 0x%08lx\n",
464  ObjectAttributes->ObjectName, Status);
466  return Status;
467  }
468 
469  /* Initialize the window station */
470  RtlZeroMemory(WindowStation, sizeof(WINSTATION_OBJECT));
471 
472  InitializeListHead(&WindowStation->DesktopListHead);
473  WindowStation->dwSessionId = NtCurrentPeb()->SessionId;
474  Status = RtlCreateAtomTable(37, &WindowStation->AtomTable);
475  if (!NT_SUCCESS(Status))
476  {
477  ERR("RtlCreateAtomTable failed for window station '%wZ', Status 0x%08lx\n",
478  ObjectAttributes->ObjectName, Status);
479  ObDereferenceObject(WindowStation);
481  return Status;
482  }
483 
484  Status = ObInsertObject(WindowStation,
485  NULL,
486  dwDesiredAccess,
487  0,
488  NULL,
489  (PVOID*)&hWinSta);
490  if (!NT_SUCCESS(Status))
491  {
492  ERR("ObInsertObject failed for window station, Status 0x%08lx\n", Status);
494  return Status;
495  }
496 
497  // FIXME! TODO: Add this new window station to a linked list
498 
499  if (InputWindowStation == NULL)
500  {
501  ERR("Initializing input window station\n");
502 
503  /* Only Winlogon can create the interactive window station */
505 
506  InputWindowStation = WindowStation;
507  WindowStation->Flags &= ~WSS_NOIO;
508 
509  InitCursorImpl();
510 
513 
514  /* Desktop functions require the desktop thread running so wait for it to initialize */
515  UserLeaveCo();
517  UserRequest,
518  UserMode,
519  FALSE,
520  NULL);
521  UserEnterCo();
522  }
523  else
524  {
525  WindowStation->Flags |= WSS_NOIO;
526  }
527 
528  TRACE("IntCreateWindowStation created window station '%wZ' object 0x%p handle 0x%p\n",
529  ObjectAttributes->ObjectName, WindowStation, hWinSta);
530 
531  *phWinSta = hWinSta;
533 
534  return STATUS_SUCCESS;
535 }
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2529
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
BOOL UserCreateSystemThread(DWORD Type)
Definition: csr.c:247
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
#define ERROR_SUCCESS
Definition: deptool.c:10
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LIST_ENTRY DesktopListHead
Definition: winsta.h:18
NTSYSAPI NTSTATUS NTAPI RtlCreateAtomTable(_In_ ULONG TableSize, _Inout_ PRTL_ATOM_TABLE *AtomTable)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
BOOL InitCursorImpl(VOID)
Definition: cursoricon.c:64
#define UserLeaveCo
Definition: ntuser.h:10
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
#define WSS_NOIO
Definition: winsta.h:9
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DWORD dwSessionId
Definition: winsta.h:16
PKEVENT gpDesktopThreadStartedEvent
Definition: desktop.c:39
#define UserEnterCo
Definition: ntuser.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ST_RIT
Definition: csr.h:35
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
PRTL_ATOM_TABLE AtomTable
Definition: winsta.h:19
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
#define NtCurrentPeb()
Definition: FLS.c:20
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
#define ST_DESKTOP_THREAD
Definition: csr.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
HANDLE gpidLogon
Definition: simplecall.c:15

Referenced by IntResolveDesktop(), and NtUserCreateWindowStation().

◆ IntEndDesktopGraphics()

VOID FASTCALL IntEndDesktopGraphics ( VOID  )

Definition at line 334 of file winsta.c.

335 {
336  if (NULL != ScreenDeviceContext)
337  { // No need to allocate a new dcattr.
341  }
344 }
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1155
smooth NULL
Definition: ftsmooth.c:416
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner)
Definition: dclife.c:455
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226
HDC ScreenDeviceContext
Definition: desktop.c:36
VOID FASTCALL IntDestroyPrimarySurface(VOID)
Definition: device.c:44
NTSTATUS FASTCALL IntHideDesktop(PDESKTOP Desktop)
Definition: desktop.c:1599

Referenced by RemoveGuiApp().

◆ IntValidateWindowStationHandle()

NTSTATUS FASTCALL IntValidateWindowStationHandle ( HWINSTA  WindowStation,
KPROCESSOR_MODE  AccessMode,
ACCESS_MASK  DesiredAccess,
PWINSTATION_OBJECT Object,
POBJECT_HANDLE_INFORMATION  pObjectHandleInfo 
)

Definition at line 230 of file winsta.c.

236 {
238 
239  if (WindowStation == NULL)
240  {
241  ERR("Invalid window station handle\n");
243  return STATUS_INVALID_HANDLE;
244  }
245 
246  Status = ObReferenceObjectByHandle(WindowStation,
249  AccessMode,
250  (PVOID*)Object,
251  pObjectHandleInfo);
252 
253  if (!NT_SUCCESS(Status))
255 
256  return Status;
257 }
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static IUnknown Object
Definition: main.c:512
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by BuildDesktopNameList(), IntGetWinStaForCbAccess(), NtUserCloseWindowStation(), NtUserLockWindowStation(), NtUserSetShellWindowEx(), NtUserSetWindowsHookEx(), NtUserSetWindowStationUser(), NtUserUnlockWindowStation(), UserCreateMenu(), UserGetShellWindow(), and UserSetProcessWindowStation().

◆ IntWinStaObjectDelete()

NTSTATUS NTAPI IntWinStaObjectDelete ( _In_ PVOID  Parameters)

Definition at line 106 of file winsta.c.

108 {
109  PWIN32_DELETEMETHOD_PARAMETERS DeleteParameters = Parameters;
110  PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeleteParameters->Object;
111 
112  TRACE("Deleting window station 0x%p\n", WinSta);
113 
114  if (WinSta == InputWindowStation)
115  {
116  ERR("WARNING: Deleting the interactive window station '%wZ'!\n",
118 
119  /* Only Winlogon can close and delete the interactive window station */
121 
123  }
124 
125  WinSta->Flags |= WSS_DYING;
126 
127  UserEmptyClipboardData(WinSta);
128 
130 
131  return STATUS_SUCCESS;
132 }
VOID NTAPI UserEmptyClipboardData(PWINSTATION_OBJECT pWinSta)
Definition: clipboard.c:354
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define WSS_DYING
Definition: winsta.h:11
#define OBJECT_HEADER_TO_NAME_INFO(h)
Definition: obtypes.h:114
#define OBJECT_TO_OBJECT_HEADER(o)
Definition: obtypes.h:111
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
struct _WINSTATION_OBJECT * PWINSTATION_OBJECT
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
#define ERR(fmt,...)
Definition: debug.h:109
PRTL_ATOM_TABLE AtomTable
Definition: winsta.h:19
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
NTSYSAPI NTSTATUS NTAPI RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable)
Definition: atom.c:203
return STATUS_SUCCESS
Definition: btrfs.c:2966
HANDLE gpidLogon
Definition: simplecall.c:15

Referenced by DriverEntry().

◆ IntWinStaObjectParse()

NTSTATUS NTAPI IntWinStaObjectParse ( _In_ PVOID  Parameters)

Definition at line 136 of file winsta.c.

138 {
139  PWIN32_PARSEMETHOD_PARAMETERS ParseParameters = Parameters;
140  PUNICODE_STRING RemainingName = ParseParameters->RemainingName;
141 
142  /* Assume we don't find anything */
143  *ParseParameters->Object = NULL;
144 
145  /* Check for an empty name */
146  if (!RemainingName->Length)
147  {
148  /* Make sure this is a window station, can't parse a desktop now */
149  if (ParseParameters->ObjectType != ExWindowStationObjectType)
150  {
151  /* Fail */
153  }
154 
155  /* Reference the window station and return */
156  ObReferenceObject(ParseParameters->ParseObject);
157  *ParseParameters->Object = ParseParameters->ParseObject;
158  return STATUS_SUCCESS;
159  }
160 
161  /* Check for leading slash */
162  if (RemainingName->Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
163  {
164  /* Skip it */
165  RemainingName->Buffer++;
166  RemainingName->Length -= sizeof(WCHAR);
167  RemainingName->MaximumLength -= sizeof(WCHAR);
168  }
169 
170  /* Check if there is still a slash */
172  {
173  /* In this case, fail */
175  }
176 
177  /*
178  * Check if we are parsing a desktop.
179  */
180  if (ParseParameters->ObjectType == ExDesktopObjectType)
181  {
182  /* Then call the desktop parse routine */
183  return IntDesktopObjectParse(ParseParameters->ParseObject,
184  ParseParameters->ObjectType,
185  ParseParameters->AccessState,
186  ParseParameters->AccessMode,
187  ParseParameters->Attributes,
188  ParseParameters->CompleteName,
190  ParseParameters->Context,
191  ParseParameters->SecurityQos,
192  ParseParameters->Object);
193  }
194 
195  /* Should hopefully never get here */
197 }
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
NTSTATUS APIENTRY IntDesktopObjectParse(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: desktop.c:45
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
KPROCESSOR_MODE AccessMode
Definition: pstypes.h:1603
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:259
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
PSECURITY_QUALITY_OF_SERVICE SecurityQos
Definition: pstypes.h:1608
#define STATUS_OBJECT_PATH_INVALID
Definition: ntstatus.h:279
#define ObReferenceObject
Definition: obfuncs.h:204
PUNICODE_STRING RemainingName
Definition: pstypes.h:1606
return STATUS_SUCCESS
Definition: btrfs.c:2966
_Out_ PUNICODE_STRING CompleteName
Definition: pstypes.h:1605
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:806

Referenced by DriverEntry().

◆ IntWinStaOkToClose()

NTSTATUS NTAPI IntWinStaOkToClose ( _In_ PVOID  Parameters)

Definition at line 201 of file winsta.c.

203 {
204  PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS OkToCloseParameters = Parameters;
205  PPROCESSINFO ppi;
206 
208 
209  if (ppi && (OkToCloseParameters->Handle == ppi->hwinsta))
210  {
211  return STATUS_ACCESS_DENIED;
212  }
213 
214  return STATUS_SUCCESS;
215 }
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
HWINSTA hwinsta
Definition: win32.h:258
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by DriverEntry().

◆ UserCreateWinstaDirectory()

NTSTATUS NTAPI UserCreateWinstaDirectory ( VOID  )

Definition at line 51 of file winsta.c.

52 {
54  PPEB Peb;
56  HANDLE hWinstaDir;
57  WCHAR wstrWindowStationsDir[MAX_PATH];
58 
59  /* Create the WindowStations directory and cache its path for later use */
60  Peb = NtCurrentPeb();
61  if(Peb->SessionId == 0)
62  {
64  {
66  }
67  }
68  else
69  {
70  Status = RtlStringCbPrintfW(wstrWindowStationsDir,
71  sizeof(wstrWindowStationsDir),
72  L"%ws\\%lu%ws",
74  Peb->SessionId,
76  if (!NT_SUCCESS(Status))
77  return Status;
78 
79  if (!RtlCreateUnicodeString(&gustrWindowStationsDir, wstrWindowStationsDir))
80  {
82  }
83  }
84 
88  NULL,
89  NULL);
91  if (!NT_SUCCESS(Status))
92  {
93  ERR("Could not create %wZ directory (Status 0x%X)\n", &gustrWindowStationsDir, Status);
94  return Status;
95  }
96 
97  TRACE("Created directory %wZ for session %lu\n", &gustrWindowStationsDir, Peb->SessionId);
98 
99  return Status;
100 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PPEB Peb
Definition: dllmain.c:27
#define DIRECTORY_CREATE_OBJECT
Definition: nt_native.h:1256
UNICODE_STRING gustrWindowStationsDir
Definition: winsta.c:27
LONG NTSTATUS
Definition: precomp.h:26
#define SESSION_DIR
Definition: dllmain.c:38
#define WINSTA_OBJ_DIR
Definition: winsta.h:3
NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject(_Out_ PHANDLE DirectoryHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define MAX_PATH
Definition: compat.h:26
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ULONG SessionId
Definition: btrfs_drv.h:1823
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define NtCurrentPeb()
Definition: FLS.c:20
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231

Referenced by UserInitialize().

◆ UserSetProcessWindowStation()

BOOL FASTCALL UserSetProcessWindowStation ( HWINSTA  hWindowStation)

Definition at line 1346 of file winsta.c.

1347 {
1348  NTSTATUS Status;
1349  PPROCESSINFO ppi;
1350  OBJECT_HANDLE_INFORMATION ObjectHandleInfo;
1351  PWINSTATION_OBJECT NewWinSta = NULL, OldWinSta;
1352  HWINSTA hCacheWinSta;
1353 
1355 
1356  /* Reference the new window station */
1357  if (hWindowStation != NULL)
1358  {
1359  Status = IntValidateWindowStationHandle(hWindowStation,
1360  UserMode,
1361  0,
1362  &NewWinSta,
1363  &ObjectHandleInfo);
1364  if (!NT_SUCCESS(Status))
1365  {
1366  TRACE("Validation of window station handle 0x%p failed\n", hWindowStation);
1368  return FALSE;
1369  }
1370  }
1371 
1372  OldWinSta = ppi->prpwinsta;
1373  hCacheWinSta = PsGetProcessWin32WindowStation(ppi->peProcess);
1374 
1375  /* Dereference the previous window station */
1376  if (OldWinSta != NULL)
1377  {
1378  ObDereferenceObject(OldWinSta);
1379  }
1380 
1381  /*
1382  * FIXME: Don't allow changing the window station if there are threads that are attached to desktops and own GUI objects?
1383  */
1384 
1385  /* Close the cached EPROCESS window station handle if needed */
1386  if (hCacheWinSta != NULL)
1387  {
1388  /* Reference the window station */
1389  Status = ObReferenceObjectByHandle(hCacheWinSta,
1390  0,
1392  UserMode,
1393  (PVOID*)&OldWinSta,
1394  NULL);
1395  if (!NT_SUCCESS(Status))
1396  {
1397  ERR("Failed to reference the inherited window station, Status 0x%08lx\n", Status);
1398  /* We failed, reset the cache */
1399  hCacheWinSta = NULL;
1400  PsSetProcessWindowStation(ppi->peProcess, hCacheWinSta);
1401  }
1402  else
1403  {
1404  /*
1405  * Close the old handle and reset the cache only
1406  * if we are setting a different window station.
1407  */
1408  if (NewWinSta != OldWinSta)
1409  {
1410  ObCloseHandle(hCacheWinSta, UserMode);
1411  hCacheWinSta = NULL;
1412  PsSetProcessWindowStation(ppi->peProcess, hCacheWinSta);
1413  }
1414 
1415  /* Dereference the window station */
1416  ObDereferenceObject(OldWinSta);
1417  }
1418  }
1419 
1420  /* Duplicate and save a new cached EPROCESS window station handle */
1421  if ((hCacheWinSta == NULL) && (hWindowStation != NULL))
1422  {
1423  Status = ZwDuplicateObject(ZwCurrentProcess(),
1424  hWindowStation,
1425  ZwCurrentProcess(),
1426  (PHANDLE)&hCacheWinSta,
1427  0,
1428  0,
1430  if (!NT_SUCCESS(Status))
1431  {
1432  ERR("UserSetProcessWindowStation: Failed to duplicate the window station handle, Status 0x%08lx\n", Status);
1433  }
1434  else
1435  {
1436  PsSetProcessWindowStation(ppi->peProcess, hCacheWinSta);
1437  }
1438  }
1439 
1440  ppi->prpwinsta = NewWinSta;
1441  ppi->hwinsta = hWindowStation;
1442  ppi->amwinsta = hWindowStation != NULL ? ObjectHandleInfo.GrantedAccess : 0;
1443  TRACE("WS : Granted Access 0x%08lx\n",ppi->amwinsta);
1444 
1446  {
1447  ppi->W32PF_flags |= W32PF_READSCREENACCESSGRANTED;
1448  }
1449  else
1450  {
1451  ppi->W32PF_flags &= ~W32PF_READSCREENACCESSGRANTED;
1452  }
1453 
1454  if (NewWinSta && !(NewWinSta->Flags & WSS_NOIO))
1455  {
1456  ppi->W32PF_flags |= W32PF_IOWINSTA;
1457  }
1458  else /* Might be closed if the handle is NULL */
1459  {
1460  ppi->W32PF_flags &= ~W32PF_IOWINSTA;
1461  }
1462  return TRUE;
1463 }
#define TRUE
Definition: types.h:120
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
#define ZwCurrentProcess()
#define W32PF_IOWINSTA
Definition: win32.h:23
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:257
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define DUPLICATE_SAME_ACCESS
ACCESS_MASK GrantedAccess
Definition: iotypes.h:158
#define WSS_NOIO
Definition: winsta.h:9
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS FASTCALL IntValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PWINSTATION_OBJECT *Object, POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
Definition: winsta.c:230
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI PsSetProcessWindowStation(PEPROCESS Process, PVOID WindowStation)
Definition: process.c:1314
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
PVOID NTAPI PsGetProcessWin32WindowStation(PEPROCESS Process)
Definition: process.c:1203
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
HWINSTA hwinsta
Definition: win32.h:258
#define W32PF_READSCREENACCESSGRANTED
Definition: win32.h:8
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
NTSYSAPI BOOLEAN NTAPI RtlAreAllAccessesGranted(ACCESS_MASK GrantedAccess, ACCESS_MASK DesiredAccess)
ACCESS_MASK amwinsta
Definition: win32.h:259
#define WINSTA_READSCREEN
Definition: winuser.h:415

Referenced by InitThreadCallback(), NtUserSetProcessWindowStation(), RawInputThreadMain(), and UserProcessDestroy().

Variable Documentation

◆ gpidLogon

◆ gustrWindowStationsDir

◆ hwndSAS

◆ InputWindowStation