ReactOS  0.4.12-dev-914-g71f84a3
desktop.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DESKTOP
 
struct  _SHELL_HOOK_WINDOW
 

Macros

#define DF_TME_HOVER   0x00000400
 
#define DF_TME_LEAVE   0x00000800
 
#define DF_HOTTRACK   0x00004000
 
#define DF_DESTROYED   0x00008000
 
#define DF_DESKWNDDESTROYED   0x00010000
 
#define DF_DYING   0x00020000
 
#define DT_GWL_PROCESSID   0
 
#define DT_GWL_THREADID   4
 
#define DESKTOP_READ
 
#define DESKTOP_WRITE
 
#define DESKTOP_EXECUTE
 
#define DESKTOP_ALL_ACCESS
 
#define IntIsActiveDesktop(Desktop)   ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
 
#define UserIsDesktopWindow(pWnd)   ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP))
 
#define UserIsMessageWindow(pWnd)   ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND))
 

Typedefs

typedef struct _DESKTOP DESKTOP
 
typedef struct _DESKTOPPDESKTOP
 
typedef struct _SHELL_HOOK_WINDOW SHELL_HOOK_WINDOW
 
typedef struct _SHELL_HOOK_WINDOWPSHELL_HOOK_WINDOW
 

Functions

INIT_FUNCTION NTSTATUS NTAPI InitDesktopImpl (VOID)
 
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)
 
NTSTATUS NTAPI IntDesktopObjectDelete (_In_ PVOID Parameters)
 
NTSTATUS NTAPI IntDesktopOkToClose (_In_ PVOID Parameters)
 
NTSTATUS NTAPI IntDesktopObjectOpen (_In_ PVOID Parameters)
 
NTSTATUS NTAPI IntDesktopObjectClose (_In_ PVOID Parameters)
 
HDC FASTCALL IntGetScreenDC (VOID)
 
HWND FASTCALL IntGetDesktopWindow (VOID)
 
PWND FASTCALL UserGetDesktopWindow (VOID)
 
HWND FASTCALL IntGetCurrentThreadDesktopWindow (VOID)
 
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue (VOID)
 
VOID FASTCALL IntSetFocusMessageQueue (PUSER_MESSAGE_QUEUE NewQueue)
 
PDESKTOP FASTCALL IntGetActiveDesktop (VOID)
 
NTSTATUS FASTCALL co_IntShowDesktop (PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL Redraw)
 
NTSTATUS FASTCALL IntHideDesktop (PDESKTOP Desktop)
 
BOOL IntSetThreadDesktop (IN HDESK hDesktop, IN BOOL FreeOnFailure)
 
NTSTATUS FASTCALL IntResolveDesktop (IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
 
NTSTATUS FASTCALL IntValidateDesktopHandle (HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
 
NTSTATUS FASTCALL IntCreateDesktop (OUT HDESK *phDesktop, IN POBJECT_ATTRIBUTES ObjectAttributes, IN KPROCESSOR_MODE AccessMode, IN PUNICODE_STRING lpszDesktopDevice OPTIONAL, IN LPDEVMODEW lpdmw OPTIONAL, IN DWORD dwFlags, IN ACCESS_MASK dwDesiredAccess)
 
VOID APIENTRY UserRedrawDesktop (VOID)
 
BOOL IntRegisterShellHookWindow (HWND hWnd)
 
BOOL IntDeRegisterShellHookWindow (HWND hWnd)
 
VOID co_IntShellHookNotify (WPARAM Message, WPARAM wParam, LPARAM lParam)
 
HDC FASTCALL UserGetDesktopDC (ULONG, BOOL, BOOL)
 
HWND FASTCALL IntGetMessageWindow (VOID)
 
PWND FASTCALL UserGetMessageWindow (VOID)
 
static __inline PVOID DesktopHeapAlloc (IN PDESKTOP Desktop, IN SIZE_T Bytes)
 
static __inline BOOL DesktopHeapFree (IN PDESKTOP Desktop, IN PVOID lpMem)
 
static __inline PVOID DesktopHeapReAlloc (IN PDESKTOP Desktop, IN PVOID lpMem, IN SIZE_T Bytes)
 
static __inline ULONG_PTR DesktopHeapGetUserDelta (VOID)
 
static __inline PVOID DesktopHeapAddressToUser (PVOID lpMem)
 
PWND FASTCALL IntGetThreadDesktopWindow (PTHREADINFO)
 
PWND FASTCALL co_GetDesktopWindow (PWND)
 
BOOL FASTCALL IntPaintDesktop (HDC)
 
BOOL FASTCALL DesktopWindowProc (PWND, UINT, WPARAM, LPARAM, LRESULT *)
 
BOOL FASTCALL UserMessageWindowProc (PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
 
VOID NTAPI DesktopThreadMain (VOID)
 
HDESK UserOpenInputDesktop (DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess)
 

Variables

PDESKTOP gpdeskInputDesktop
 
PCLS DesktopWindowClass
 
HDC ScreenDeviceContext
 
PTHREADINFO gptiForeground
 
PTHREADINFO gptiDesktopThread
 
PKEVENT gpDesktopThreadStartedEvent
 

Macro Definition Documentation

◆ DESKTOP_ALL_ACCESS

#define DESKTOP_ALL_ACCESS
Value:
DESKTOP_CREATEMENU | \
DESKTOP_CREATEWINDOW | \
DESKTOP_ENUMERATE | \
DESKTOP_HOOKCONTROL | \
DESKTOP_JOURNALPLAYBACK | \
DESKTOP_JOURNALRECORD | \
DESKTOP_READOBJECTS | \
DESKTOP_SWITCHDESKTOP | \
DESKTOP_WRITEOBJECTS
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63

Definition at line 73 of file desktop.h.

◆ DESKTOP_EXECUTE

#define DESKTOP_EXECUTE
Value:
DESKTOP_SWITCHDESKTOP
#define STANDARD_RIGHTS_EXECUTE
Definition: nt_native.h:67

Definition at line 70 of file desktop.h.

◆ DESKTOP_READ

#define DESKTOP_READ
Value:
DESKTOP_ENUMERATE | \
DESKTOP_READOBJECTS
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65

Definition at line 58 of file desktop.h.

◆ DESKTOP_WRITE

#define DESKTOP_WRITE
Value:
DESKTOP_CREATEMENU | \
DESKTOP_CREATEWINDOW | \
DESKTOP_HOOKCONTROL | \
DESKTOP_JOURNALPLAYBACK | \
DESKTOP_JOURNALRECORD | \
DESKTOP_WRITEOBJECTS
#define STANDARD_RIGHTS_WRITE
Definition: nt_native.h:66

Definition at line 62 of file desktop.h.

◆ DF_DESKWNDDESTROYED

#define DF_DESKWNDDESTROYED   0x00010000

Definition at line 51 of file desktop.h.

◆ DF_DESTROYED

#define DF_DESTROYED   0x00008000

Definition at line 50 of file desktop.h.

◆ DF_DYING

#define DF_DYING   0x00020000

Definition at line 52 of file desktop.h.

◆ DF_HOTTRACK

#define DF_HOTTRACK   0x00004000

Definition at line 49 of file desktop.h.

◆ DF_TME_HOVER

#define DF_TME_HOVER   0x00000400

Definition at line 47 of file desktop.h.

◆ DF_TME_LEAVE

#define DF_TME_LEAVE   0x00000800

Definition at line 48 of file desktop.h.

◆ DT_GWL_PROCESSID

#define DT_GWL_PROCESSID   0

Definition at line 55 of file desktop.h.

◆ DT_GWL_THREADID

#define DT_GWL_THREADID   4

Definition at line 56 of file desktop.h.

◆ IntIsActiveDesktop

#define IntIsActiveDesktop (   Desktop)    ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))

Definition at line 198 of file desktop.h.

◆ UserIsDesktopWindow

#define UserIsDesktopWindow (   pWnd)    ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP))

Definition at line 220 of file desktop.h.

◆ UserIsMessageWindow

#define UserIsMessageWindow (   pWnd)    ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND))

Definition at line 223 of file desktop.h.

Typedef Documentation

◆ DESKTOP

◆ PDESKTOP

◆ PSHELL_HOOK_WINDOW

◆ SHELL_HOOK_WINDOW

Function Documentation

◆ co_GetDesktopWindow()

PWND FASTCALL co_GetDesktopWindow ( PWND  )

Definition at line 1330 of file desktop.c.

1331 {
1332  if (pWnd->head.rpdesk &&
1333  pWnd->head.rpdesk->pDeskInfo)
1334  return pWnd->head.rpdesk->pDeskInfo->spwnd;
1335  return NULL;
1336 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by co_IntSendActivateMessages(), co_IntSetParent(), co_UserCreateWindowEx(), IntDefWindowProc(), IntIsTopLevelWindow(), and IntWinListOwnedPopups().

◆ co_IntShellHookNotify()

VOID co_IntShellHookNotify ( WPARAM  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1656 of file desktop.c.

1657 {
1659  HWND* HwndList;
1660 
1661  if (!gpsi->uiShellMsg)
1662  {
1663  gpsi->uiShellMsg = IntAddAtom(L"SHELLHOOK");
1664 
1665  TRACE("MsgType = %x\n", gpsi->uiShellMsg);
1666  if (!gpsi->uiShellMsg)
1667  ERR("LastError: %x\n", EngGetLastError());
1668  }
1669 
1670  if (!Desktop)
1671  {
1672  TRACE("IntShellHookNotify: No desktop!\n");
1673  return;
1674  }
1675 
1676  // Allow other devices have a shot at foreground.
1677  if (Message == HSHELL_APPCOMMAND) ptiLastInput = NULL;
1678 
1679  // FIXME: System Tray Support.
1680 
1681  HwndList = UserBuildShellHookHwndList(Desktop);
1682  if (HwndList)
1683  {
1684  HWND* cursor = HwndList;
1685 
1686  for (; *cursor; cursor++)
1687  {
1688  TRACE("Sending notify\n");
1690  gpsi->uiShellMsg,
1691  Message,
1692  (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) );
1693 /* co_IntPostOrSendMessage(*cursor,
1694  gpsi->uiShellMsg,
1695  Message,
1696  (Message == HSHELL_LANGUAGE ? lParam : (LPARAM)wParam) );*/
1697  }
1698 
1700  }
1701 
1702  if (ISITHOOKED(WH_SHELL))
1703  {
1705  }
1706 }
UINT uiShellMsg
Definition: ntuser.h:1016
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
ENGAPI ULONG APIENTRY EngGetLastError(VOID)
Definition: error.c:12
#define WH_SHELL
Definition: winuser.h:40
PSERVERINFO gpsi
Definition: main.c:27
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
PTHREADINFO ptiLastInput
Definition: focus.c:17
#define TRACE(s)
Definition: solgame.cpp:4
#define ISITHOOKED(HookId)
Definition: hook.h:6
CHAR Message[80]
Definition: alive.c:5
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1089
static HWND *FASTCALL UserBuildShellHookHwndList(PDESKTOP Desktop)
Definition: desktop.c:1615
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:109
const char cursor[]
Definition: icontest.c:13
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_WINDOWLIST
Definition: tags.h:297
RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName)
Definition: useratom.c:13
LPARAM lParam
Definition: combotst.c:139

Referenced by co_UserCreateWindowEx(), co_UserDestroyWindow(), co_UserProcessHotKeys(), co_WinPosSetWindowPos(), DefSetText(), IntDefWindowProc(), NtUserActivateKeyboardLayout(), NtUserCallHwndLock(), NtUserDefSetText(), NtUserLoadKeyboardLayoutEx(), and UpdateShellHook().

◆ co_IntShowDesktop()

NTSTATUS FASTCALL co_IntShowDesktop ( PDESKTOP  Desktop,
ULONG  Width,
ULONG  Height,
BOOL  Redraw 
)

Definition at line 1581 of file desktop.c.

1582 {
1583  PWND pwnd = Desktop->pDeskInfo->spwnd;
1585  ASSERT(pwnd);
1586 
1587  if (!bRedraw)
1588  flags |= SWP_NOREDRAW;
1589 
1590  co_WinPosSetWindowPos(pwnd, NULL, 0, 0, Width, Height, flags);
1591 
1592  if (bRedraw)
1594 
1595  return STATUS_SUCCESS;
1596 }
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1651
#define SWP_NOZORDER
Definition: winuser.h:1232
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
GLbitfield flags
Definition: glext.h:7161
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ntuser.h:657
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:876
#define RDW_ALLCHILDREN
Definition: winuser.h:1207
unsigned int UINT
Definition: ndis.h:50
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
#define SWP_NOREDRAW
Definition: winuser.h:1231
#define RDW_UPDATENOW
Definition: winuser.h:1206
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define RDW_INVALIDATE
Definition: winuser.h:1200

Referenced by co_IntInitializeDesktopGraphics(), and NtUserSwitchDesktop().

◆ DesktopHeapAddressToUser()

static __inline PVOID DesktopHeapAddressToUser ( PVOID  lpMem)
static

Definition at line 327 of file desktop.h.

328 {
330  PPROCESSINFO W32Process;
331 
332  W32Process = PsGetCurrentProcessWin32Process();
333 
334  /*
335  * Start the search at the next mapping: skip the first entry
336  * as it must be the global user heap mapping.
337  */
338  Mapping = W32Process->HeapMappings.Next;
339  while (Mapping != NULL)
340  {
341  if ((ULONG_PTR)lpMem >= (ULONG_PTR)Mapping->KernelMapping &&
342  (ULONG_PTR)lpMem < (ULONG_PTR)Mapping->KernelMapping + Mapping->Limit)
343  {
344  return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)Mapping->KernelMapping) +
345  (ULONG_PTR)Mapping->UserMapping);
346  }
347 
348  Mapping = Mapping->Next;
349  }
350 
351  return NULL;
352 }
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:281
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define ULONG_PTR
Definition: config.h:101
struct _W32HEAP_USER_MAPPING * Next
Definition: win32.h:194

Referenced by IntSetTebWndCallback(), NtUserCallOneParam(), and UserFreeWindowInfo().

◆ DesktopHeapAlloc()

static __inline PVOID DesktopHeapAlloc ( IN PDESKTOP  Desktop,
IN SIZE_T  Bytes 
)
static

Definition at line 230 of file desktop.h.

232 {
233  return RtlAllocateHeap(Desktop->pheapDesktop,
235  Bytes);
236 }
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
_In_ UINT Bytes
Definition: mmcopy.h:9
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585

Referenced by co_IntCreateScrollBars(), DefSetText(), IntCloneMenuItems(), IntCreateClass(), IntCreateWindow(), IntGetClassForDesktop(), IntSetMenuItemInfo(), IntSetThreadDesktop(), MENU_InsertItem(), NtUserDefSetText(), and PopupMenuWndProc().

◆ DesktopHeapFree()

static __inline BOOL DesktopHeapFree ( IN PDESKTOP  Desktop,
IN PVOID  lpMem 
)
static

Definition at line 239 of file desktop.h.

241 {
242  return RtlFreeHeap(Desktop->pheapDesktop,
244  lpMem);
245 }
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603

Referenced by DefSetText(), FreeDeskProcObject(), FreeDeskThreadObject(), IntCloneMenuItems(), IntCreateClass(), IntDestroyClass(), IntDestroyMenu(), IntDestroyScrollBars(), IntRemoveMenuItem(), IntSetThreadDesktop(), MENU_InsertItem(), NtUserDefSetText(), PopupMenuWndProc(), and UserFreeWindowInfo().

◆ DesktopHeapGetUserDelta()

static __inline ULONG_PTR DesktopHeapGetUserDelta ( VOID  )
static

Definition at line 291 of file desktop.h.

292 {
294  PTHREADINFO pti;
295  PPROCESSINFO W32Process;
296  PWIN32HEAP pheapDesktop;
297  ULONG_PTR Delta = 0;
298 
300  if (!pti->rpdesk)
301  return 0;
302 
303  pheapDesktop = pti->rpdesk->pheapDesktop;
304 
305  W32Process = PsGetCurrentProcessWin32Process();
306 
307  /*
308  * Start the search at the next mapping: skip the first entry
309  * as it must be the global user heap mapping.
310  */
311  Mapping = W32Process->HeapMappings.Next;
312  while (Mapping != NULL)
313  {
314  if (Mapping->KernelMapping == (PVOID)pheapDesktop)
315  {
316  Delta = (ULONG_PTR)Mapping->KernelMapping - (ULONG_PTR)Mapping->UserMapping;
317  break;
318  }
319 
320  Mapping = Mapping->Next;
321  }
322 
323  return Delta;
324 }
struct _WIN32HEAP * PWIN32HEAP
Definition: usrheap.h:3
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _DESKTOP * rpdesk
Definition: win32.h:91
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:281
static ULONG Delta
Definition: xboxvideo.c:28
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define ULONG_PTR
Definition: config.h:101
struct _W32HEAP_USER_MAPPING * Next
Definition: win32.h:194

Referenced by IntSetThreadDesktop(), and UserDbgAssertThreadInfo().

◆ DesktopHeapReAlloc()

static __inline PVOID DesktopHeapReAlloc ( IN PDESKTOP  Desktop,
IN PVOID  lpMem,
IN SIZE_T  Bytes 
)
static

Definition at line 248 of file desktop.h.

251 {
252 #if 0
253  /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
254  return RtlReAllocateHeap(Desktop->pheapDesktop,
256  lpMem,
257  Bytes);
258 #else
259  SIZE_T PrevSize;
260  PVOID pNew;
261 
262  PrevSize = RtlSizeHeap(Desktop->pheapDesktop,
264  lpMem);
265 
266  if (PrevSize == Bytes)
267  return lpMem;
268 
269  pNew = RtlAllocateHeap(Desktop->pheapDesktop,
271  Bytes);
272  if (pNew != NULL)
273  {
274  if (PrevSize < Bytes)
275  Bytes = PrevSize;
276 
277  RtlCopyMemory(pNew,
278  lpMem,
279  Bytes);
280 
281  RtlFreeHeap(Desktop->pheapDesktop,
283  lpMem);
284  }
285 
286  return pNew;
287 #endif
288 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_In_ UINT Bytes
Definition: mmcopy.h:9
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2561
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
NTSYSAPI SIZE_T NTAPI RtlSizeHeap(_In_ PVOID HeapHandle, _In_ ULONG Flags, _In_ PVOID MemoryPointer)
ULONG_PTR SIZE_T
Definition: typedefs.h:78

Referenced by IntRemoveMenuItem().

◆ DesktopThreadMain()

VOID NTAPI DesktopThreadMain ( VOID  )

Definition at line 1508 of file desktop.c.

1509 {
1510  BOOL Ret;
1511  MSG Msg;
1512 
1514 
1516 
1517  /* Register system classes. This thread does not belong to any desktop so the
1518  classes will be allocated from the shared heap */
1520 
1522 
1523  while (TRUE)
1524  {
1525  Ret = co_IntGetPeekMessage(&Msg, 0, 0, 0, PM_REMOVE, TRUE);
1526  if (Ret)
1527  {
1529  }
1530  }
1531 
1532  UserLeave();
1533 }
#define TRUE
Definition: types.h:120
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:682
BOOL FASTCALL UserRegisterSystemClasses(VOID)
Definition: class.c:2276
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct @1567 Msg[]
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
PKEVENT gpDesktopThreadStartedEvent
Definition: desktop.c:39
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1020
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define PM_REMOVE
Definition: winuser.h:1182

Referenced by UserSystemThreadProc().

◆ DesktopWindowProc()

BOOL FASTCALL DesktopWindowProc ( PWND  ,
UINT  ,
WPARAM  ,
LPARAM  ,
LRESULT  
)

Definition at line 1401 of file desktop.c.

1402 {
1403  PAINTSTRUCT Ps;
1404  ULONG Value;
1405  //ERR("DesktopWindowProc\n");
1406 
1407  *lResult = 0;
1408 
1409  switch (Msg)
1410  {
1411  case WM_NCCREATE:
1412  if (!Wnd->fnid)
1413  {
1414  Wnd->fnid = FNID_DESKTOP;
1415  }
1416  *lResult = (LRESULT)TRUE;
1417  return TRUE;
1418 
1419  case WM_CREATE:
1421  // Save Process ID
1424  // Save Thread ID
1426  case WM_CLOSE:
1427  return TRUE;
1428 
1429  case WM_DISPLAYCHANGE:
1431  return TRUE;
1432 
1433  case WM_ERASEBKGND:
1435  *lResult = 1;
1436  return TRUE;
1437 
1438  case WM_PAINT:
1439  {
1440  if (IntBeginPaint(Wnd, &Ps))
1441  {
1442  IntEndPaint(Wnd, &Ps);
1443  }
1444  return TRUE;
1445  }
1446  case WM_SYSCOLORCHANGE:
1448  return TRUE;
1449 
1450  case WM_SETCURSOR:
1451  {
1452  PCURICON_OBJECT pcurOld, pcurNew;
1454  if (!pcurNew)
1455  {
1456  return TRUE;
1457  }
1458 
1459  pcurNew->CURSORF_flags |= CURSORF_CURRENT;
1460  pcurOld = UserSetCursor(pcurNew, FALSE);
1461  if (pcurOld)
1462  {
1463  pcurOld->CURSORF_flags &= ~CURSORF_CURRENT;
1464  UserDereferenceObject(pcurOld);
1465  }
1466  return TRUE;
1467  }
1468 
1469  case WM_WINDOWPOSCHANGING:
1470  {
1471  PWINDOWPOS pWindowPos = (PWINDOWPOS)lParam;
1472  if ((pWindowPos->flags & SWP_SHOWWINDOW) != 0)
1473  {
1474  HDESK hdesk = UserOpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS);
1475  IntSetThreadDesktop(hdesk, FALSE);
1476  }
1477  break;
1478  }
1479  default:
1480  TRACE("DWP calling IDWP Msg %d\n",Msg);
1481  //*lResult = IntDefWindowProc(Wnd, Msg, wParam, lParam, FALSE);
1482  }
1483  return TRUE; /* We are done. Do not do any callbacks to user mode */
1484 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define CURSORF_CURRENT
Definition: ntuser.h:1156
#define TRUE
Definition: types.h:120
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1651
static HDC
Definition: imagelist.c:92
#define HandleToULong(h)
Definition: basetsd.h:95
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
struct @1567 Msg[]
#define SWP_NOZORDER
Definition: winuser.h:1232
#define DT_GWL_THREADID
Definition: desktop.h:56
HCURSOR gDesktopCursor
Definition: desktop.c:38
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define DT_GWL_PROCESSID
Definition: desktop.h:55
#define FNID_DESKTOP
Definition: ntuser.h:824
#define WM_SETCURSOR
Definition: winuser.h:1618
smooth NULL
Definition: ftsmooth.c:416
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1791
PsGetCurrentThreadId
Definition: CrNtStubs.h:7
UINT flags
Definition: winuser.h:3536
HDESK UserOpenInputDesktop(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess)
Definition: desktop.c:2572
struct _WINDOWPOS * PWINDOWPOS
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
LONG FASTCALL co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
Definition: window.c:3815
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define RDW_ERASE
Definition: winuser.h:1197
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
#define WM_CLOSE
Definition: winuser.h:1603
HDC FASTCALL IntBeginPaint(PWND Window, PPAINTSTRUCT Ps)
Definition: painting.c:1422
#define WM_PAINT
Definition: winuser.h:1602
ULONG CURSORF_flags
Definition: cursoricon.h:16
#define LRESULT
Definition: ole.h:14
#define DESKTOP_ALL_ACCESS
Definition: precomp.h:20
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:876
#define RDW_ALLCHILDREN
Definition: winuser.h:1207
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3181
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1518
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define WM_ERASEBKGND
Definition: winuser.h:1607
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define RDW_INVALIDATE
Definition: winuser.h:1200

Referenced by co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), IntDispatchMessage(), and NtUserMessageCall().

◆ InitDesktopImpl()

INIT_FUNCTION NTSTATUS NTAPI InitDesktopImpl ( VOID  )

Definition at line 236 of file desktop.c.

237 {
238  GENERIC_MAPPING IntDesktopMapping = { DESKTOP_READ,
242 
243  /* Set Desktop Object Attributes */
245  ExDesktopObjectType->TypeInfo.GenericMapping = IntDesktopMapping;
247 
248  /* Allocate memory for the event structure */
250  sizeof(KEVENT),
251  USERTAG_EVENT);
253  {
254  ERR("Failed to allocate event!\n");
255  return STATUS_NO_MEMORY;
256  }
257 
258  /* Initialize the kernel event */
261  FALSE);
262 
263  return STATUS_SUCCESS;
264 }
#define DESKTOP_EXECUTE
Definition: desktop.h:70
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
#define USERTAG_EVENT
Definition: tags.h:229
PKEVENT gpDesktopThreadStartedEvent
Definition: desktop.c:39
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DESKTOP_WRITE
Definition: desktop.h:62
OBJECT_TYPE_INITIALIZER TypeInfo
Definition: obtypes.h:390
#define DESKTOP_ALL_ACCESS
Definition: precomp.h:20
#define ERR(fmt,...)
Definition: debug.h:109
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
struct _DESKTOP DESKTOP
#define DESKTOP_READ
Definition: desktop.h:58
return STATUS_SUCCESS
Definition: btrfs.c:2725
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by DriverEntry().

◆ IntCreateDesktop()

NTSTATUS FASTCALL IntCreateDesktop ( OUT HDESK *  phDesktop,
IN POBJECT_ATTRIBUTES  ObjectAttributes,
IN KPROCESSOR_MODE  AccessMode,
IN PUNICODE_STRING lpszDesktopDevice  OPTIONAL,
IN LPDEVMODEW lpdmw  OPTIONAL,
IN DWORD  dwFlags,
IN ACCESS_MASK  dwDesiredAccess 
)

Definition at line 2308 of file desktop.c.

2316 {
2317  NTSTATUS Status;
2318  PDESKTOP pdesk = NULL;
2319  HDESK hDesk;
2320  BOOLEAN Context = FALSE;
2321  UNICODE_STRING ClassName;
2322  LARGE_STRING WindowName;
2323  BOOL NoHooks = FALSE;
2324  PWND pWnd = NULL;
2325  CREATESTRUCTW Cs;
2326  PTHREADINFO ptiCurrent;
2327  PCLS pcls;
2328 
2329  TRACE("Enter IntCreateDesktop\n");
2330 
2331  ASSERT(phDesktop);
2332  *phDesktop = NULL;
2333 
2334  ptiCurrent = PsGetCurrentThreadWin32Thread();
2335  ASSERT(ptiCurrent);
2337 
2338  /* Turn off hooks when calling any CreateWindowEx from inside win32k */
2339  NoHooks = (ptiCurrent->TIF_flags & TIF_DISABLEHOOKS);
2340  ptiCurrent->TIF_flags |= TIF_DISABLEHOOKS;
2341  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
2342 
2343  /*
2344  * Try to open already existing desktop
2345  */
2348  AccessMode,
2349  NULL,
2350  dwDesiredAccess,
2351  (PVOID)&Context,
2352  (PHANDLE)&hDesk);
2353  if (!NT_SUCCESS(Status))
2354  {
2355  ERR("ObOpenObjectByName failed to open/create desktop\n");
2356  goto Quit;
2357  }
2358 
2359  /* In case the object was not created (eg if it existed), return now */
2360  if (Context == FALSE)
2361  {
2362  TRACE("IntCreateDesktop opened desktop '%wZ'\n", ObjectAttributes->ObjectName);
2364  goto Quit;
2365  }
2366 
2367  /* Reference the desktop */
2369  0,
2371  KernelMode,
2372  (PVOID*)&pdesk,
2373  NULL);
2374  if (!NT_SUCCESS(Status))
2375  {
2376  ERR("Failed to reference desktop object\n");
2377  goto Quit;
2378  }
2379 
2380  /* Get the desktop window class. The thread desktop does not belong to any desktop
2381  * so the classes created there (including the desktop class) are allocated in the shared heap
2382  * It would cause problems if we used a class that belongs to the caller
2383  */
2384  ClassName.Buffer = WC_DESKTOP;
2385  ClassName.Length = 0;
2386  pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE);
2387  if (pcls == NULL)
2388  {
2389  ASSERT(FALSE);
2391  goto Quit;
2392  }
2393 
2394  RtlZeroMemory(&WindowName, sizeof(WindowName));
2395  RtlZeroMemory(&Cs, sizeof(Cs));
2401  Cs.hInstance = hModClient; // hModuleWin; // Server side winproc!
2402  Cs.lpszName = (LPCWSTR) &WindowName;
2403  Cs.lpszClass = (LPCWSTR) &ClassName;
2404 
2405  /* Use IntCreateWindow instead of co_UserCreateWindowEx because the later expects a thread with a desktop */
2406  pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk);
2407  if (pWnd == NULL)
2408  {
2409  ERR("Failed to create desktop window for the new desktop\n");
2411  goto Quit;
2412  }
2413 
2415  pdesk->DesktopWindow = pWnd->head.h;
2416  pdesk->pDeskInfo->spwnd = pWnd;
2417  pWnd->fnid = FNID_DESKTOP;
2418 
2419  ClassName.Buffer = MAKEINTATOM(gpsi->atomSysClass[ICLS_HWNDMESSAGE]);
2420  ClassName.Length = 0;
2421  pcls = IntGetAndReferenceClass(&ClassName, 0, TRUE);
2422  if (pcls == NULL)
2423  {
2424  ASSERT(FALSE);
2426  goto Quit;
2427  }
2428 
2429  RtlZeroMemory(&WindowName, sizeof(WindowName));
2430  RtlZeroMemory(&Cs, sizeof(Cs));
2431  Cs.cx = Cs.cy = 100;
2433  Cs.hInstance = hModClient; // hModuleWin; // Server side winproc!
2434  Cs.lpszName = (LPCWSTR)&WindowName;
2435  Cs.lpszClass = (LPCWSTR)&ClassName;
2436  pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk);
2437  if (pWnd == NULL)
2438  {
2439  ERR("Failed to create message window for the new desktop\n");
2441  goto Quit;
2442  }
2443 
2444  pdesk->spwndMessage = pWnd;
2445  pWnd->fnid = FNID_MESSAGEWND;
2446 
2447  /* Now,,,
2448  if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki)
2449  Create Tooltip. Saved in DesktopObject->spwndTooltip.
2450  Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST
2451  hWndParent are spwndMessage. Use hModuleWin for server side winproc!
2452  The rest is same as message window.
2453  http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx
2454  */
2456 
2457 Quit:
2458  if (pdesk != NULL)
2459  {
2460  ObDereferenceObject(pdesk);
2461  }
2462  if (!NT_SUCCESS(Status) && hDesk != NULL)
2463  {
2464  ObCloseHandle(hDesk, AccessMode);
2465  hDesk = NULL;
2466  }
2467  if (!NoHooks)
2468  {
2469  ptiCurrent->TIF_flags &= ~TIF_DISABLEHOOKS;
2470  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
2471  }
2472 
2473  TRACE("Leave IntCreateDesktop, Status 0x%08lx\n", Status);
2474 
2475  if (NT_SUCCESS(Status))
2476  *phDesktop = hDesk;
2477  else
2479  return Status;
2480 }
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
#define TRUE
Definition: types.h:120
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
FLONG TIF_flags
Definition: win32.h:94
DWORD dwSessionId
Definition: desktop.h:6
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define WS_CLIPCHILDREN
Definition: pedump.c:619
PSERVERINFO gpsi
Definition: main.c:27
#define FNID_MESSAGEWND
Definition: ntuser.h:826
#define WC_DESKTOP
Definition: undocuser.h:10
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
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
DWORD fnid
Definition: ntuser.h:673
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FNID_DESKTOP
Definition: ntuser.h:824
HWND DesktopWindow
Definition: desktop.h:40
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
THRDESKHEAD head
Definition: ntuser.h:659
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: ntuser.h:533
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
HINSTANCE hInstance
Definition: winuser.h:2909
PWND FASTCALL IntCreateWindow(CREATESTRUCTW *Cs, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, PDESKTOP pdeskCreated)
Definition: window.c:1612
ULONG NTAPI PsGetCurrentProcessSessionId(VOID)
Definition: process.c:1133
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCLS IntGetAndReferenceClass(PUNICODE_STRING ClassName, HINSTANCE hInstance, BOOL bDesktopThread)
Definition: class.c:1407
PWND spwndMessage
Definition: desktop.h:20
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
LPCWSTR lpszName
Definition: winuser.h:2917
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
struct _WND * spwnd
Definition: ntuser.h:136
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
#define WS_POPUP
Definition: pedump.c:616
LPCWSTR lpszClass
Definition: winuser.h:2918
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define TIF_DISABLEHOOKS
Definition: ntuser.h:268
HINSTANCE hModClient
Definition: ntuser.c:25
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define MAKEINTATOM(i)
Definition: winbase.h:1416
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1013

Referenced by IntResolveDesktop(), and NtUserCreateDesktop().

◆ IntDeRegisterShellHookWindow()

BOOL IntDeRegisterShellHookWindow ( HWND  hWnd)

Definition at line 1748 of file desktop.c.

1749 {
1751  PDESKTOP Desktop = pti->rpdesk;
1752  PLIST_ENTRY ListEntry;
1753  PSHELL_HOOK_WINDOW Current;
1754 
1755  ListEntry = Desktop->ShellHookWindows.Flink;
1756  while (ListEntry != &Desktop->ShellHookWindows)
1757  {
1758  Current = CONTAINING_RECORD(ListEntry, SHELL_HOOK_WINDOW, ListEntry);
1759  ListEntry = ListEntry->Flink;
1760  if (Current->hWnd == hWnd)
1761  {
1762  RemoveEntryList(&Current->ListEntry);
1763  ExFreePoolWithTag(Current, TAG_WINSTA);
1764  return TRUE;
1765  }
1766  }
1767 
1768  return FALSE;
1769 }
#define TRUE
Definition: types.h:120
#define TAG_WINSTA
Definition: tags.h:11
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LIST_ENTRY ListEntry
Definition: desktop.h:93
HWND hWnd
Definition: settings.c:17
struct _DESKTOP * rpdesk
Definition: win32.h:91
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by co_UserFreeWindow(), IntRegisterShellHookWindow(), and NtUserCallHwnd().

◆ IntDesktopObjectClose()

NTSTATUS NTAPI IntDesktopObjectClose ( _In_ PVOID  Parameters)

Definition at line 215 of file desktop.c.

217 {
218  PWIN32_CLOSEMETHOD_PARAMETERS CloseParameters = Parameters;
219  PPROCESSINFO ppi = PsGetProcessWin32Process(CloseParameters->Process);
220  if (ppi == NULL)
221  {
222  /* This happens when the process leaks desktop handles.
223  * At this point the PPROCESSINFO is already destroyed */
224  return STATUS_SUCCESS;
225  }
226 
227  return IntUnmapDesktopView((PDESKTOP)CloseParameters->Object);
228 }
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
static NTSTATUS IntUnmapDesktopView(IN PDESKTOP pdesk)
Definition: desktop.c:3063
smooth NULL
Definition: ftsmooth.c:416
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ IntDesktopObjectDelete()

NTSTATUS NTAPI IntDesktopObjectDelete ( _In_ PVOID  Parameters)

Definition at line 147 of file desktop.c.

149 {
150  PWIN32_DELETEMETHOD_PARAMETERS DeleteParameters = Parameters;
151  PDESKTOP pdesk = (PDESKTOP)DeleteParameters->Object;
152 
153  TRACE("Deleting desktop object 0x%p\n", pdesk);
154 
155  if (pdesk->pDeskInfo &&
156  pdesk->pDeskInfo->spwnd)
157  {
158  ASSERT(pdesk->pDeskInfo->spwnd->spwndChild == NULL);
160  }
161 
162  if (pdesk->spwndMessage)
164 
165  /* Remove the desktop from the window station's list of associcated desktops */
166  RemoveEntryList(&pdesk->ListEntry);
167 
168  /* Free the heap */
169  IntFreeDesktopHeap(pdesk);
170 
172 
173  return STATUS_SUCCESS;
174 }
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
static VOID IntFreeDesktopHeap(IN PDESKTOP pdesk)
struct _DESKTOP * PDESKTOP
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2629
struct _WINSTATION_OBJECT * rpwinstaParent
Definition: desktop.h:11
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PWND spwndMessage
Definition: desktop.h:20
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
struct _WND * spwnd
Definition: ntuser.h:136
return STATUS_SUCCESS
Definition: btrfs.c:2725
LIST_ENTRY ListEntry
Definition: desktop.h:9

Referenced by DriverEntry().

◆ IntDesktopObjectOpen()

NTSTATUS NTAPI IntDesktopObjectOpen ( _In_ PVOID  Parameters)

Definition at line 202 of file desktop.c.

204 {
205  PWIN32_OPENMETHOD_PARAMETERS OpenParameters = Parameters;
206  PPROCESSINFO ppi = PsGetProcessWin32Process(OpenParameters->Process);
207  if (ppi == NULL)
208  return STATUS_SUCCESS;
209 
210  return IntMapDesktopView((PDESKTOP)OpenParameters->Object);
211 }
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
smooth NULL
Definition: ftsmooth.c:416
static NTSTATUS IntMapDesktopView(IN PDESKTOP pdesk)
Definition: desktop.c:3107
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ IntDesktopObjectParse()

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 at line 45 of file desktop.c.

55 {
59  PLIST_ENTRY NextEntry, ListHead;
60  PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)ParseObject;
61  UNICODE_STRING DesktopName;
62  PBOOLEAN pContext = (PBOOLEAN) Context;
63 
64  if (pContext)
65  *pContext = FALSE;
66 
67  /* Set the list pointers and loop the window station */
68  ListHead = &WinStaObject->DesktopListHead;
69  NextEntry = ListHead->Flink;
70  while (NextEntry != ListHead)
71  {
72  /* Get the current desktop */
73  Desktop = CONTAINING_RECORD(NextEntry, DESKTOP, ListEntry);
74 
75  /* Get the desktop name */
76  ASSERT(Desktop->pDeskInfo != NULL);
77  RtlInitUnicodeString(&DesktopName, Desktop->pDeskInfo->szDesktopName);
78 
79  /* Compare the name */
81  &DesktopName,
83  {
84  /* We found a match. Did this come from a create? */
85  if (Context)
86  {
87  /* Unless OPEN_IF was given, fail with an error */
88  if (!(Attributes & OBJ_OPENIF))
89  {
90  /* Name collision */
92  }
93  else
94  {
95  /* Otherwise, return with a warning only */
97  }
98  }
99  else
100  {
101  /* This was a real open, so this is OK */
103  }
104 
105  /* Reference the desktop and return it */
107  *Object = Desktop;
108  return Status;
109  }
110 
111  /* Go to the next desktop */
112  NextEntry = NextEntry->Flink;
113  }
114 
115  /* If we got here but this isn't a create, just fail */
117 
118  /* Create the desktop object */
123  KernelMode,
124  NULL,
125  sizeof(DESKTOP),
126  0,
127  0,
128  (PVOID*)&Desktop);
129  if (!NT_SUCCESS(Status)) return Status;
130 
131  /* Initialize the desktop */
133  if (!NT_SUCCESS(Status))
134  {
136  return Status;
137  }
138 
139  /* Set the desktop object and return success */
140  *Object = Desktop;
141  *pContext = TRUE;
142  return STATUS_SUCCESS;
143 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:114
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LIST_ENTRY DesktopListHead
Definition: winsta.h:18
#define OBJ_OPENIF
Definition: winternl.h:229
smooth NULL
Definition: ftsmooth.c:416
static CHAR Desktop[MAX_PATH]
Definition: dem.c:256
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _WINSTATION_OBJECT * PWINSTATION_OBJECT
static IUnknown Object
Definition: main.c:512
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
char * PBOOLEAN
Definition: retypes.h:11
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
static NTSTATUS UserInitializeDesktop(PDESKTOP pdesk, PUNICODE_STRING DesktopName, PWINSTATION_OBJECT pwinsta)
Definition: desktop.c:2216
#define ObReferenceObject
Definition: obfuncs.h:204
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
return STATUS_SUCCESS
Definition: btrfs.c:2725
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:806

Referenced by IntWinStaObjectParse().

◆ IntDesktopOkToClose()

NTSTATUS NTAPI IntDesktopOkToClose ( _In_ PVOID  Parameters)

Definition at line 178 of file desktop.c.

180 {
181  PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS OkToCloseParameters = Parameters;
183 
184  if (pti == NULL)
185  {
186  /* This happens when we leak desktop handles */
187  return STATUS_SUCCESS;
188  }
189 
190  /* Do not allow the current desktop or the initial desktop to be closed */
191  if (OkToCloseParameters->Handle == pti->ppi->hdeskStartup ||
192  OkToCloseParameters->Handle == pti->hdesk)
193  {
194  return STATUS_ACCESS_DENIED;
195  }
196 
197  return STATUS_SUCCESS;
198 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PPROCESSINFO ppi
Definition: win32.h:87
HDESK hdesk
Definition: win32.h:107
HDESK hdeskStartup
Definition: win32.h:254
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:871
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ IntGetActiveDesktop()

◆ IntGetCurrentThreadDesktopWindow()

HWND FASTCALL IntGetCurrentThreadDesktopWindow ( VOID  )

Definition at line 1386 of file desktop.c.

1387 {
1389  PDESKTOP pdo = pti->rpdesk;
1390  if (NULL == pdo)
1391  {
1392  ERR("Thread doesn't have a desktop\n");
1393  return NULL;
1394  }
1395  return pdo->DesktopWindow;
1396 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
struct _DESKTOP * rpdesk
Definition: win32.h:91
HWND DesktopWindow
Definition: desktop.h:40
smooth NULL
Definition: ftsmooth.c:416
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by NtUserFindWindowEx().

◆ IntGetDesktopWindow()

HWND FASTCALL IntGetDesktopWindow ( VOID  )

Definition at line 1338 of file desktop.c.

1339 {
1340  PDESKTOP pdo = IntGetActiveDesktop();
1341  if (!pdo)
1342  {
1343  TRACE("No active desktop\n");
1344  return NULL;
1345  }
1346  return pdo->DesktopWindow;
1347 }
HWND DesktopWindow
Definition: desktop.h:40
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226

Referenced by co_IntProcessKeyboardMessage(), co_IntSetWindowLongPtr(), co_UserSetParent(), co_WinPosSetWindowPos(), DceUpdateVisRgn(), IntPaintDesktop(), NtUserAlterWindowStyle(), NtUserRedrawWindow(), NtUserSetParent(), NtUserSetWindowLong(), NtUserSetWindowWord(), NtUserWindowFromPoint(), SnapWindow(), UserGetAncestor(), UserRealizePalette(), and UserRegisterUserApiHook().

◆ IntGetFocusMessageQueue()

PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue ( VOID  )

Definition at line 1271 of file desktop.c.

1272 {
1273  PDESKTOP pdo = IntGetActiveDesktop();
1274  if (!pdo)
1275  {
1276  TRACE("No active desktop\n");
1277  return(NULL);
1278  }
1280 }
struct _USER_MESSAGE_QUEUE * ActiveMessageQueue
Definition: desktop.h:38
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226

Referenced by co_IntSetForegroundAndFocusWindow(), co_UserSetFocus(), co_WinPosShowWindow(), DoTheScreenSaver(), IntGetCaptureWindow(), IntSendDestroyMsg(), NtUserGetGUIThreadInfo(), ProcessKeyEvent(), UserGetForegroundWindow(), UserProcessKeyboardInput(), and UserSendKeyboardInput().

◆ IntGetMessageWindow()

HWND FASTCALL IntGetMessageWindow ( VOID  )

Definition at line 1362 of file desktop.c.

1363 {
1364  PDESKTOP pdo = IntGetActiveDesktop();
1365 
1366  if (!pdo)
1367  {
1368  TRACE("No active desktop\n");
1369  return NULL;
1370  }
1371  return pdo->spwndMessage->head.h;
1372 }
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PWND spwndMessage
Definition: desktop.h:20
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226

Referenced by NtUserFindWindowEx(), and NtUserSetParent().

◆ IntGetScreenDC()

HDC FASTCALL IntGetScreenDC ( VOID  )

Definition at line 347 of file winsta.c.

348 {
349  return ScreenDeviceContext;
350 }
HDC ScreenDeviceContext
Definition: desktop.c:36

Referenced by co_MsqInsertMouseMessage(), MsqCleanupMessageQueue(), UserSetCursor(), and UserShowCursor().

◆ IntGetThreadDesktopWindow()

PWND FASTCALL IntGetThreadDesktopWindow ( PTHREADINFO  )

Definition at line 1323 of file desktop.c.

1324 {
1325  if (!pti) pti = PsGetCurrentThreadWin32Thread();
1326  if (pti->pDeskInfo) return pti->pDeskInfo->spwnd;
1327  return NULL;
1328 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
smooth NULL
Definition: ftsmooth.c:416

Referenced by ActivateOtherWindowMin().

◆ IntHideDesktop()

NTSTATUS FASTCALL IntHideDesktop ( PDESKTOP  Desktop)

Definition at line 1599 of file desktop.c.

1600 {
1601  PWND DesktopWnd;
1602 
1603  DesktopWnd = IntGetWindowObject(Desktop->DesktopWindow);
1604  if (! DesktopWnd)
1605  {
1607  }
1608  DesktopWnd->style &= ~WS_VISIBLE;
1609 
1610  return STATUS_SUCCESS;
1611 }
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
Definition: ntuser.h:657
PWND FASTCALL IntGetWindowObject(HWND hWnd)
Definition: window.c:51
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define WS_VISIBLE
Definition: pedump.c:620
DWORD style
Definition: ntuser.h:670

Referenced by IntEndDesktopGraphics(), and NtUserSwitchDesktop().

◆ IntPaintDesktop()

BOOL FASTCALL IntPaintDesktop ( HDC  )

Definition at line 1791 of file desktop.c.

1792 {
1793  static WCHAR s_wszSafeMode[] = L"Safe Mode"; // FIXME: Localize!
1794 
1795  RECTL Rect;
1796  HBRUSH DesktopBrush, PreviousBrush;
1797  HWND hWndDesktop;
1798  BOOL doPatBlt = TRUE;
1799  PWND WndDesktop;
1800  BOOLEAN InSafeMode;
1801 
1802  if (GdiGetClipBox(hDC, &Rect) == ERROR)
1803  return FALSE;
1804 
1805  hWndDesktop = IntGetDesktopWindow(); // rpdesk->DesktopWindow;
1806 
1807  WndDesktop = UserGetWindowObject(hWndDesktop); // rpdesk->pDeskInfo->spwnd;
1808  if (!WndDesktop)
1809  return FALSE;
1810 
1811  /* Retrieve the current SafeMode state */
1812  InSafeMode = (UserGetSystemMetrics(SM_CLEANBOOT) != 0); // gpsi->aiSysMet[SM_CLEANBOOT];
1813 
1814  if (!InSafeMode)
1815  {
1816  DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground;
1817 
1818  /*
1819  * Paint desktop background
1820  */
1821  if (gspv.hbmWallpaper != NULL)
1822  {
1823  SIZE sz;
1824  int x, y;
1825  int scaledWidth, scaledHeight;
1826  int wallpaperX, wallpaperY, wallpaperWidth, wallpaperHeight;
1827  HDC hWallpaperDC;
1828 
1829  sz.cx = WndDesktop->rcWindow.right - WndDesktop->rcWindow.left;
1830  sz.cy = WndDesktop->rcWindow.bottom - WndDesktop->rcWindow.top;
1831 
1832  if (gspv.WallpaperMode == wmFit ||
1834  {
1835  int scaleNum, scaleDen;
1836 
1837  // Precision improvement over ((sz.cx / gspv.cxWallpaper) > (sz.cy / gspv.cyWallpaper))
1838  if ((sz.cx * gspv.cyWallpaper) > (sz.cy * gspv.cxWallpaper))
1839  {
1840  if (gspv.WallpaperMode == wmFit)
1841  {
1842  scaleNum = sz.cy;
1843  scaleDen = gspv.cyWallpaper;
1844  }
1845  else
1846  {
1847  scaleNum = sz.cx;
1848  scaleDen = gspv.cxWallpaper;
1849  }
1850  }
1851  else
1852  {
1853  if (gspv.WallpaperMode == wmFit)
1854  {
1855  scaleNum = sz.cx;
1856  scaleDen = gspv.cxWallpaper;
1857  }
1858  else
1859  {
1860  scaleNum = sz.cy;
1861  scaleDen = gspv.cyWallpaper;
1862  }
1863  }
1864 
1865  scaledWidth = EngMulDiv(gspv.cxWallpaper, scaleNum, scaleDen);
1866  scaledHeight = EngMulDiv(gspv.cyWallpaper, scaleNum, scaleDen);
1867 
1868  if (gspv.WallpaperMode == wmFill)
1869  {
1870  wallpaperX = (((scaledWidth - sz.cx) * gspv.cxWallpaper) / (2 * scaledWidth));
1871  wallpaperY = (((scaledHeight - sz.cy) * gspv.cyWallpaper) / (2 * scaledHeight));
1872 
1873  wallpaperWidth = (sz.cx * gspv.cxWallpaper) / scaledWidth;
1874  wallpaperHeight = (sz.cy * gspv.cyWallpaper) / scaledHeight;
1875  }
1876  }
1877 
1878  if (gspv.WallpaperMode == wmStretch ||
1879  gspv.WallpaperMode == wmTile ||
1881  {
1882  x = 0;
1883  y = 0;
1884  }
1885  else if (gspv.WallpaperMode == wmFit)
1886  {
1887  x = (sz.cx - scaledWidth) / 2;
1888  y = (sz.cy - scaledHeight) / 2;
1889  }
1890  else
1891  {
1892  /* Find the upper left corner, can be negative if the bitmap is bigger than the screen */
1893  x = (sz.cx / 2) - (gspv.cxWallpaper / 2);
1894  y = (sz.cy / 2) - (gspv.cyWallpaper / 2);
1895  }
1896 
1897  hWallpaperDC = NtGdiCreateCompatibleDC(hDC);
1898  if (hWallpaperDC != NULL)
1899  {
1900  HBITMAP hOldBitmap;
1901 
1902  /* Fill in the area that the bitmap is not going to cover */
1903  if (x > 0 || y > 0)
1904  {
1905  /* FIXME: Clip out the bitmap
1906  can be replaced with "NtGdiPatBlt(hDC, x, y, gspv.cxWallpaper, gspv.cyWallpaper, PATCOPY | DSTINVERT);"
1907  once we support DSTINVERT */
1908  PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush);
1909  NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
1910  NtGdiSelectBrush(hDC, PreviousBrush);
1911  }
1912 
1913  /* Do not fill the background after it is painted no matter the size of the picture */
1914  doPatBlt = FALSE;
1915 
1916  hOldBitmap = NtGdiSelectBitmap(hWallpaperDC, gspv.hbmWallpaper);
1917 
1918  if (gspv.WallpaperMode == wmStretch)
1919  {
1920  if (Rect.right && Rect.bottom)
1922  x,
1923  y,
1924  sz.cx,
1925  sz.cy,
1926  hWallpaperDC,
1927  0,
1928  0,
1929  gspv.cxWallpaper,
1930  gspv.cyWallpaper,
1931  SRCCOPY,
1932  0);
1933  }
1934  else if (gspv.WallpaperMode == wmTile)
1935  {
1936  /* Paint the bitmap across the screen then down */
1937  for (y = 0; y < Rect.bottom; y += gspv.cyWallpaper)
1938  {
1939  for (x = 0; x < Rect.right; x += gspv.cxWallpaper)
1940  {
1941  NtGdiBitBlt(hDC,
1942  x,
1943  y,
1944  gspv.cxWallpaper,
1945  gspv.cyWallpaper,
1946  hWallpaperDC,
1947  0,
1948  0,
1949  SRCCOPY,
1950  0,
1951  0);
1952  }
1953  }
1954  }
1955  else if (gspv.WallpaperMode == wmFit)
1956  {
1957  if (Rect.right && Rect.bottom)
1958  {
1960  x,
1961  y,
1962  scaledWidth,
1963  scaledHeight,
1964  hWallpaperDC,
1965  0,
1966  0,
1967  gspv.cxWallpaper,
1968  gspv.cyWallpaper,
1969  SRCCOPY,
1970  0);
1971  }
1972  }
1973  else if (gspv.WallpaperMode == wmFill)
1974  {
1975  if (Rect.right && Rect.bottom)
1976  {
1978  x,
1979  y,
1980  sz.cx,
1981  sz.cy,
1982  hWallpaperDC,
1983  wallpaperX,
1984  wallpaperY,
1985  wallpaperWidth,
1986  wallpaperHeight,
1987  SRCCOPY,
1988  0);
1989  }
1990  }
1991  else
1992  {
1993  NtGdiBitBlt(hDC,
1994  x,
1995  y,
1996  gspv.cxWallpaper,
1997  gspv.cyWallpaper,
1998  hWallpaperDC,
1999  0,
2000  0,
2001  SRCCOPY,
2002  0,
2003  0);
2004  }
2005  NtGdiSelectBitmap(hWallpaperDC, hOldBitmap);
2006  NtGdiDeleteObjectApp(hWallpaperDC);
2007  }
2008  }
2009  }
2010  else
2011  {
2012  /* Black desktop background in Safe Mode */
2013  DesktopBrush = StockObjects[BLACK_BRUSH];
2014  }
2015 
2016  /* Background is set to none, clear the screen */
2017  if (doPatBlt)
2018  {
2019  PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush);
2020  NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
2021  NtGdiSelectBrush(hDC, PreviousBrush);
2022  }
2023 
2024  /*
2025  * Display the system version on the desktop background
2026  */
2027  if (InSafeMode || g_AlwaysDisplayVersion || g_PaintDesktopVersion)
2028  {
2029  NTSTATUS Status;
2030  static WCHAR wszzVersion[1024] = L"\0";
2031 
2032  /* Only used in normal mode */
2033  // We expect at most 4 strings (3 for version, 1 for optional NtSystemRoot)
2034  static POLYTEXTW VerStrs[4] = {{0},{0},{0},{0}};
2035  INT i = 0;
2036  SIZE_T len;
2037 
2038  HFONT hFont1 = NULL, hFont2 = NULL, hOldFont = NULL;
2039  COLORREF crText, color_old;
2040  UINT align_old;
2041  INT mode_old;
2042  PDC pdc;
2043 
2044  if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &Rect, 0))
2045  {
2046  Rect.left = Rect.top = 0;
2049  }
2050  else
2051  {
2052  RECTL_vOffsetRect(&Rect, -Rect.left, -Rect.top);
2053  }
2054 
2055  /*
2056  * Set up the fonts (otherwise use default ones)
2057  */
2058 
2059  /* Font for the principal version string */
2060  hFont1 = GreCreateFontIndirectW(&gspv.ncm.lfCaptionFont);
2061  /* Font for the secondary version strings */
2062  hFont2 = GreCreateFontIndirectW(&gspv.ncm.lfMenuFont);
2063 
2064  if (hFont1)
2065  hOldFont = NtGdiSelectFont(hDC, hFont1);
2066 
2067  if (gspv.hbmWallpaper == NULL)
2068  {
2069  /* Retrieve the brush fill colour */
2070  // TODO: The following code constitutes "GreGetBrushColor".
2071  PreviousBrush = NtGdiSelectBrush(hDC, DesktopBrush);
2072  pdc = DC_LockDc(hDC);
2073  if (pdc)
2074  {
2075  crText = pdc->eboFill.ulRGBColor;
2076  DC_UnlockDc(pdc);
2077  }
2078  else
2079  {
2080  crText = RGB(0, 0, 0);
2081  }
2082  NtGdiSelectBrush(hDC, PreviousBrush);
2083 
2084  /* Adjust text colour according to the brush */
2085  if (GetRValue(crText) + GetGValue(crText) + GetBValue(crText) > 128 * 3)
2086  crText = RGB(0, 0, 0);
2087  else
2088  crText = RGB(255, 255, 255);
2089  }
2090  else
2091  {
2092  /* Always use white when the text is displayed on top of a wallpaper */
2093  crText = RGB(255, 255, 255);
2094  }
2095 
2096  color_old = IntGdiSetTextColor(hDC, crText);
2097  align_old = IntGdiSetTextAlign(hDC, TA_RIGHT);
2098  mode_old = IntGdiSetBkMode(hDC, TRANSPARENT);
2099 
2100  /* Display the system version information */
2101  if (!*wszzVersion)
2102  {
2103  Status = GetSystemVersionString(wszzVersion,
2104  ARRAYSIZE(wszzVersion),
2105  InSafeMode,
2107  if (!InSafeMode && NT_SUCCESS(Status) && *wszzVersion)
2108  {
2109  PWCHAR pstr = wszzVersion;
2110  for (i = 0; (i < ARRAYSIZE(VerStrs)) && *pstr; ++i)
2111  {
2112  VerStrs[i].n = lstrlenW(pstr);
2113  VerStrs[i].lpstr = pstr;
2114  pstr += (VerStrs[i].n + 1);
2115  }
2116  }
2117  }
2118  else
2119  {
2121  }
2122  if (NT_SUCCESS(Status) && *wszzVersion)
2123  {
2124  if (!InSafeMode)
2125  {
2126  SIZE Size = {0, 0};
2127  LONG TotalHeight = 0;
2128 
2129  /* Normal Mode: multiple version information text separated by newlines */
2131 
2132  /* Compute the heights of the strings */
2133  if (hFont1) NtGdiSelectFont(hDC, hFont1);
2134  for (i = 0; i < ARRAYSIZE(VerStrs); ++i)
2135  {
2136  if (!VerStrs[i].lpstr || !*VerStrs[i].lpstr || (VerStrs[i].n == 0))
2137  break;
2138 
2139  GreGetTextExtentW(hDC, VerStrs[i].lpstr, VerStrs[i].n, &Size, 1);
2140  VerStrs[i].y = Size.cy; // Store the string height
2141  TotalHeight += Size.cy;
2142 
2143  /* While the first string was using hFont1, all the others use hFont2 */
2144  if (hFont2) NtGdiSelectFont(hDC, hFont2);
2145  }
2146  /* The total height must not exceed the screen height */
2147  TotalHeight = min(TotalHeight, Rect.bottom);
2148 
2149  /* Display the strings */
2150  if (hFont1) NtGdiSelectFont(hDC, hFont1);
2151  for (i = 0; i < ARRAYSIZE(VerStrs); ++i)
2152  {
2153  if (!VerStrs[i].lpstr || !*VerStrs[i].lpstr || (VerStrs[i].n == 0))
2154  break;
2155 
2156  TotalHeight -= VerStrs[i].y;
2158  Rect.right - 5,
2159  Rect.bottom - TotalHeight - 5,
2160  0, NULL,
2161  VerStrs[i].lpstr,
2162  VerStrs[i].n,
2163  NULL, 0);
2164 
2165  /* While the first string was using hFont1, all the others use hFont2 */
2166  if (hFont2) NtGdiSelectFont(hDC, hFont2);
2167  }
2168  }
2169  else
2170  {
2171  if (hFont1) NtGdiSelectFont(hDC, hFont1);
2172 
2173  /* Safe Mode: single version information text in top center */
2174  len = wcslen(wszzVersion);
2175 
2177  GreExtTextOutW(hDC, (Rect.right + Rect.left)/2, Rect.top + 3, 0, NULL, wszzVersion, len, NULL, 0);
2178  }
2179  }
2180 
2181  if (InSafeMode)
2182  {
2183  if (hFont1) NtGdiSelectFont(hDC, hFont1);
2184 
2185  /* Print Safe Mode text in corners */
2186  len = wcslen(s_wszSafeMode);
2187 
2189  GreExtTextOutW(hDC, Rect.left, Rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
2191  GreExtTextOutW(hDC, Rect.right, Rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
2193  GreExtTextOutW(hDC, Rect.left, Rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
2195  GreExtTextOutW(hDC, Rect.right, Rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
2196  }
2197 
2198  IntGdiSetBkMode(hDC, mode_old);
2199  IntGdiSetTextAlign(hDC, align_old);
2200  IntGdiSetTextColor(hDC, color_old);
2201 
2202  if (hFont2)
2203  GreDeleteObject(hFont2);
2204 
2205  if (hFont1)
2206  {
2207  NtGdiSelectFont(hDC, hOldFont);
2208  GreDeleteObject(hFont1);
2209  }
2210  }
2211 
2212  return TRUE;
2213 }
HANDLE hbmWallpaper
Definition: sysparams.h:142
ULONG cyWallpaper
Definition: sysparams.h:143
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define TRUE
Definition: types.h:120
UINT n
Definition: wingdi.h:2541
LPCWSTR lpstr
Definition: wingdi.h:2542
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
__kernel_entry W32KAPI BOOL APIENTRY NtGdiPatBlt(_In_ HDC hdcDest, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_ DWORD dwRop)
Definition: bitblt.c:924
#define ERROR(name)
Definition: error_private.h:53
UINT FASTCALL IntGdiSetTextAlign(HDC hDC, UINT Mode)
Definition: dcutil.c:145
BOOL FASTCALL GreGetTextExtentW(HDC hDC, LPCWSTR lpwsz, INT cwc, LPSIZE psize, UINT flOpts)
Definition: text.c:36
LONG NTSTATUS
Definition: precomp.h:26
static HDC
Definition: imagelist.c:92
#define GetRValue(rgb)
Definition: wingdi.h:2913
NONCLIENTMETRICSW ncm
Definition: sysparams.h:51
GLdouble n
Definition: glext.h:7729
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
LONG top
Definition: windef.h:292
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode)
Definition: dcutil.c:124
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static NTSTATUS GetSystemVersionString(OUT PWSTR pwszzVersion, IN SIZE_T cchDest, IN BOOLEAN InSafeMode, IN BOOLEAN AppendNtSystemRoot)
Definition: desktop.c:267
#define TA_LEFT
Definition: wingdi.h:931
uint16_t * PWCHAR
Definition: typedefs.h:54
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define lstrlenW
Definition: compat.h:407
int32_t INT
Definition: typedefs.h:56
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
#define GetGValue(rgb)
Definition: wingdi.h:2914
#define TA_TOP
Definition: wingdi.h:929
#define SM_CXSCREEN
Definition: winuser.h:949
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HGDIOBJ StockObjects[]
Definition: stockobj.c:100
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL g_AlwaysDisplayVersion
Definition: ntuser.c:17
#define TRANSPARENT
Definition: wingdi.h:949
unsigned char BOOLEAN
#define TA_BOTTOM
Definition: wingdi.h:928
smooth NULL
Definition: ftsmooth.c:416
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
LONG cx
Definition: windef.h:319
COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color)
Definition: dcutil.c:172
HFONT FASTCALL GreCreateFontIndirectW(LOGFONTW *lplf)
Definition: font.c:23
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define SM_CLEANBOOT
Definition: winuser.h:1017
#define BLACK_BRUSH
Definition: wingdi.h:895
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
#define TA_RIGHT
Definition: wingdi.h:932
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
#define SM_CYSCREEN
Definition: winuser.h:950
Definition: polytest.cpp:40
if(!(yy_init))
Definition: macro.lex.yy.c:714
HBRUSH hbrBackground
Definition: ntuser.h:555
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2918
BOOL APIENTRY GreExtTextOutW(IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
Definition: freetype.c:6249
SPIVALUES gspv
Definition: sysparams.c:17
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
RECT rcWindow
Definition: ntuser.h:680
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
#define PATCOPY
Definition: wingdi.h:334
Status
Definition: gdiplustypes.h:24
Definition: ntuser.h:657
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1338
static HDC hDC
Definition: 3dtext.c:33
ULONG_PTR SIZE_T
Definition: typedefs.h:78
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
ENGAPI INT APIENTRY EngMulDiv(_In_ INT a, _In_ INT b, _In_ INT c)
Definition: math.c:26
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
__kernel_entry W32KAPI BOOL APIENTRY NtGdiStretchBlt(_In_ HDC hdcDst, _In_ INT xDst, _In_ INT yDst, _In_ INT cxDst, _In_ INT cyDst, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ INT cxSrc, _In_ INT cySrc, _In_ DWORD dwRop, _In_ DWORD dwBackColor)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG bottom
Definition: windef.h:294
#define GetBValue(rgb)
Definition: wingdi.h:2915
static LPCSTR lpstr
Definition: font.c:51
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2059
static HBITMAP
Definition: button.c:44
#define TA_CENTER
Definition: wingdi.h:930
return STATUS_SUCCESS
Definition: btrfs.c:2725
LONG cy
Definition: windef.h:320
ULONG cxWallpaper
Definition: sysparams.h:143
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SRCCOPY
Definition: wingdi.h:332
struct Rect Rect
WALLPAPER_MODE WallpaperMode
Definition: sysparams.h:144
BOOL g_PaintDesktopVersion
Definition: sysparams.c:19
PCLS pcls
Definition: ntuser.h:684

Referenced by DesktopWindowProc(), NtUserPaintDesktop(), and UserRealizePalette().

◆ IntRegisterShellHookWindow()

BOOL IntRegisterShellHookWindow ( HWND  hWnd)

Definition at line 1716 of file desktop.c.

1717 {
1719  PDESKTOP Desktop = pti->rpdesk;
1721 
1722  TRACE("IntRegisterShellHookWindow\n");
1723 
1724  /* First deregister the window, so we can be sure it's never twice in the
1725  * list.
1726  */
1728 
1730  sizeof(SHELL_HOOK_WINDOW),
1731  TAG_WINSTA);
1732 
1733  if (!Entry)
1734  return FALSE;
1735 
1736  Entry->hWnd = hWnd;
1737 
1738  InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry);
1739 
1740  return TRUE;
1741 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
#define TAG_WINSTA
Definition: tags.h:11
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
#define InsertTailList(ListHead, Entry)
struct _DESKTOP * rpdesk
Definition: win32.h:91
#define TRACE(s)
Definition: solgame.cpp:4
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1748
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
base of all file and directory entries
Definition: entries.h:82

Referenced by NtUserCallHwnd().

◆ IntResolveDesktop()

NTSTATUS FASTCALL IntResolveDesktop ( IN PEPROCESS  Process,
IN PUNICODE_STRING  DesktopPath,
IN BOOL  bInherit,
OUT HWINSTA *  phWinSta,
OUT HDESK *  phDesktop 
)

Definition at line 535 of file desktop.c.

541 {
543  HWINSTA hWinSta = NULL, hWinStaDup = NULL;
544  HDESK hDesktop = NULL, hDesktopDup = NULL;
545  PPROCESSINFO ppi;
546  HANDLE hProcess = NULL;
547  LUID ProcessLuid;
548  USHORT StrSize;
549  SIZE_T MemSize;
552  UNICODE_STRING WinStaName, DesktopName;
553  const UNICODE_STRING WinSta0Name = RTL_CONSTANT_STRING(L"WinSta0");
554  PWINSTATION_OBJECT WinStaObject;
555  HWINSTA hTempWinSta = NULL;
556  BOOLEAN bUseDefaultWinSta = FALSE;
557  BOOLEAN bInteractive = FALSE;
558  BOOLEAN bAccessAllowed = FALSE;
559 
560  ASSERT(phWinSta);
561  ASSERT(phDesktop);
562  ASSERT(DesktopPath);
563 
564  *phWinSta = NULL;
565  *phDesktop = NULL;
566 
568  /* ppi is typically NULL for console applications that connect to Win32 USER */
569  if (!ppi) TRACE("IntResolveDesktop: ppi is NULL!\n");
570 
571  if (ppi && ppi->hwinsta != NULL && ppi->hdeskStartup != NULL)
572  {
573  /*
574  * If this process is the current one, just return the cached handles.
575  * Otherwise, open the window station and desktop objects.
576  */
577  if (Process == PsGetCurrentProcess())
578  {
579  hWinSta = ppi->hwinsta;
580  hDesktop = ppi->hdeskStartup;
581  }
582  else
583  {
585  0,
586  NULL,
589  UserMode,
590  (PHANDLE)&hWinSta);
591  if (!NT_SUCCESS(Status))
592  {
593  ERR("IntResolveDesktop: Could not reference window station 0x%p\n", ppi->prpwinsta);
595  return Status;
596  }
597 
599  0,
600  NULL,
603  UserMode,
604  (PHANDLE)&hDesktop);
605  if (!NT_SUCCESS(Status))
606  {
607  ERR("IntResolveDesktop: Could not reference desktop 0x%p\n", ppi->rpdeskStartup);
608  ObCloseHandle(hWinSta, UserMode);
610  return Status;
611  }
612  }
613 
614  *phWinSta = hWinSta;
615  *phDesktop = hDesktop;
616  return STATUS_SUCCESS;
617  }
618 
619  /* We will by default use the default window station and desktop */
620  RtlInitEmptyUnicodeString(&WinStaName, NULL, 0);
621  RtlInitEmptyUnicodeString(&DesktopName, NULL, 0);
622 
623  /*
624  * Parse the desktop path string which can be of the form "WinSta\Desktop"
625  * or just "Desktop". In the latter case we use the default window station
626  * on which the process is attached to (or if none, "WinSta0").
627  */
628  if (DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR))
629  {
630  DesktopName = *DesktopPath;
631 
632  /* Find the separator */
633  while (DesktopName.Length > 0 && *DesktopName.Buffer &&
634  *DesktopName.Buffer != OBJ_NAME_PATH_SEPARATOR)
635  {
636  DesktopName.Buffer++;
637  DesktopName.Length -= sizeof(WCHAR);
638  DesktopName.MaximumLength -= sizeof(WCHAR);
639  }
640  if (DesktopName.Length > 0)
641  {
642  RtlInitEmptyUnicodeString(&WinStaName, DesktopPath->Buffer,
643  DesktopPath->Length - DesktopName.Length);
644  // (USHORT)((ULONG_PTR)DesktopName.Buffer - (ULONG_PTR)DesktopPath->Buffer);
645  WinStaName.Length = WinStaName.MaximumLength;
646 
647  /* Skip the separator */
648  DesktopName.Buffer++;
649  DesktopName.Length -= sizeof(WCHAR);
650  DesktopName.MaximumLength -= sizeof(WCHAR);
651  }
652  else
653  {
654  RtlInitEmptyUnicodeString(&WinStaName, NULL, 0);
655  DesktopName = *DesktopPath;
656  }
657  }
658 
659  TRACE("IntResolveDesktop: WinStaName:'%wZ' ; DesktopName:'%wZ'\n", &WinStaName, &DesktopName);
660 
661  /* Retrieve the process LUID */
662  Status = GetProcessLuid(NULL, Process, &ProcessLuid);
663  if (!NT_SUCCESS(Status))
664  {
665  ERR("IntResolveDesktop: Failed to retrieve the process LUID, Status 0x%08lx\n", Status);
667  return Status;
668  }
669 
670  /*
671  * If this process is not the current one, obtain a temporary handle
672  * to it so that we can perform handles duplication later.
673  */
674  if (Process != PsGetCurrentProcess())
675  {
678  NULL,
679  0,
680  *PsProcessType,
681  KernelMode,
682  &hProcess);
683  if (!NT_SUCCESS(Status))
684  {
685  ERR("IntResolveDesktop: Failed to obtain a handle to process 0x%p, Status 0x%08lx\n", Process, Status);
687  return Status;
688  }
689  ASSERT(hProcess);
690  }
691 
692  /*
693  * If no window station has been specified, search the process handle table
694  * for inherited window station handles, otherwise use a default one.
695  */
696  if (WinStaName.Buffer == NULL)
697  {
698  /*
699  * We want to find a suitable default window station.
700  * For applications that can be interactive, i.e. that have allowed
701  * access to the single interactive window station on the system,
702  * the default window station is 'WinSta0'.
703  * For applications that cannot be interactive, i.e. that do not have
704  * access to 'WinSta0' (e.g. non-interactive services), the default
705  * window station is 'Service-0xXXXX-YYYY$' (created if needed).
706  * Precedence will however be taken by any inherited window station
707  * that possesses the required interactivity property.
708  */
709  bUseDefaultWinSta = TRUE;
710 
711  /*
712  * Use the default 'WinSta0' window station. Whether we should
713  * use 'Service-0xXXXX-YYYY$' instead will be determined later.
714  */
715  // RtlInitUnicodeString(&WinStaName, L"WinSta0");
716  WinStaName = WinSta0Name;
717 
719  NULL,
721  NULL,
722  (PHANDLE)&hWinSta))
723  {
724  TRACE("IntResolveDesktop: Inherited window station is: 0x%p\n", hWinSta);
725  }
726  }
727 
728  /*
729  * If no desktop has been specified, search the process handle table
730  * for inherited desktop handles, otherwise use the Default desktop.
731  * Note that the inherited desktop that we may use, may not belong
732  * to the window station we will connect to.
733  */
734  if (DesktopName.Buffer == NULL)
735  {
736  /* Use a default desktop name */
737  RtlInitUnicodeString(&DesktopName, L"Default");
738 
740  NULL,
742  NULL,
743  (PHANDLE)&hDesktop))
744  {
745  TRACE("IntResolveDesktop: Inherited desktop is: 0x%p\n", hDesktop);
746  }
747  }
748 
749 
750  /*
751  * We are going to open either a window station or a desktop.
752  * Even if this operation is done from kernel-mode, we should
753  * "emulate" an opening from user-mode (i.e. using an ObjectAttributes
754  * allocated in user-mode, with AccessMode == UserMode) for the
755  * Object Manager to perform proper access validation to the
756  * window station or desktop.
757  */
758 
759  /*
760  * Estimate the maximum size needed for the window station name
761  * and desktop name to be given to ObjectAttributes->ObjectName.
762  */
763  StrSize = 0;
764 
765  /* Window station name */
766  MemSize = _scwprintf(L"Service-0x%x-%x$", MAXULONG, MAXULONG) * sizeof(WCHAR);
768  + max(WinStaName.Length, MemSize) + sizeof(UNICODE_NULL);
769  if (MemSize > MAXUSHORT)
770  {
771  ERR("IntResolveDesktop: Window station name length is too long.\n");
773  goto Quit;
774  }
775  StrSize = max(StrSize, (USHORT)MemSize);
776 
777  /* Desktop name */
778  MemSize = max(DesktopName.Length + sizeof(UNICODE_NULL), sizeof(L"Default"));
779  StrSize = max(StrSize, (USHORT)MemSize);
780 
781  /* Size for the OBJECT_ATTRIBUTES */
782  MemSize = ALIGN_UP(sizeof(OBJECT_ATTRIBUTES), sizeof(PVOID));
783 
784  /* Add the string size */
785  MemSize += ALIGN_UP(sizeof(UNICODE_STRING), sizeof(PVOID));
786  MemSize += StrSize;
787 
788  /* Allocate the memory in user-mode */
789  Status = ZwAllocateVirtualMemory(ZwCurrentProcess(),
791  0,
792  &MemSize,
793  MEM_COMMIT,
795  if (!NT_SUCCESS(Status))
796  {
797  ERR("ZwAllocateVirtualMemory() failed, Status 0x%08lx\n", Status);
798  goto Quit;
799  }
800 
802  ALIGN_UP(sizeof(OBJECT_ATTRIBUTES), sizeof(PVOID)));
803 
804  RtlInitEmptyUnicodeString(ObjectName,
806  ALIGN_UP(sizeof(UNICODE_STRING), sizeof(PVOID))),
807  StrSize);
808 
809 
810  /* If we got an inherited window station handle, duplicate and use it */
811  if (hWinSta)
812  {
813  ASSERT(bUseDefaultWinSta);
814 
815  /* Duplicate the handle if it belongs to another process than the current one */
816  if (Process != PsGetCurrentProcess())
817  {
818  ASSERT(hProcess);
819  Status = ZwDuplicateObject(hProcess,
820  hWinSta,
822  (PHANDLE)&hWinStaDup,
823  0,
824  0,
826  if (!NT_SUCCESS(Status))
827  {
828  ERR("IntResolveDesktop: Failed to duplicate the window station handle, Status 0x%08lx\n", Status);
829  /* We will use a default window station */
830  hWinSta = NULL;
831  }
832  else
833  {
834  hWinSta = hWinStaDup;
835  }
836  }
837  }
838 
839  /*
840  * If we have an inherited window station, check whether
841  * it is interactive and remember that for later.
842  */
843  if (hWinSta)
844  {
845  ASSERT(bUseDefaultWinSta);
846 
847  /* Reference the inherited window station */
849  0,
851  KernelMode,
852  (PVOID*)&WinStaObject,
853  NULL);
854  if (!NT_SUCCESS(Status))
855  {
856  ERR("Failed to reference the inherited window station, Status 0x%08lx\n", Status);
857  /* We will use a default window station */
858  if (hWinStaDup)
859  {
860  ASSERT(hWinSta == hWinStaDup);
861  ObCloseHandle(hWinStaDup, UserMode);
862  hWinStaDup = NULL;
863  }
864  hWinSta = NULL;
865  }
866  else
867  {
868  ERR("Process LUID is: 0x%x-%x, inherited window station LUID is: 0x%x-%x\n",
869  ProcessLuid.HighPart, ProcessLuid.LowPart,
870  WinStaObject->luidUser.HighPart, WinStaObject->luidUser.LowPart);
871 
872  /* Check whether this window station is interactive, and remember it for later */
873  bInteractive = !(WinStaObject->Flags & WSS_NOIO);
874 
875  /* Dereference the window station */
876  ObDereferenceObject(WinStaObject);
877  }
878  }
879 
880  /* Build a valid window station name */
882  ObjectName->MaximumLength,
883  L"%wZ\\%wZ",
885  &WinStaName);
886  if (!NT_SUCCESS(Status))
887  {
888  ERR("Impossible to build a valid window station name, Status 0x%08lx\n", Status);
889  goto Quit;
890  }
891  ObjectName->Length = (USHORT)(wcslen(ObjectName->Buffer) * sizeof(WCHAR));
892 
893  TRACE("Parsed initial window station: '%wZ'\n", ObjectName);
894 
895  /* Try to open the window station */
897  ObjectName,
899  NULL,
900  NULL);
901  if (bInherit)
902  ObjectAttributes->Attributes |= OBJ_INHERIT;
903 
906  UserMode,
907  NULL,
909  NULL,
910  (PHANDLE)&hTempWinSta);
911  if (!NT_SUCCESS(Status))
912  {
913  ERR("Failed to open the window station '%wZ', Status 0x%08lx\n", ObjectName, Status);
914  }
915  else
916  {
917  //
918  // FIXME TODO: Perform a window station access check!!
919  // If we fail AND bUseDefaultWinSta == FALSE we just quit.
920  //
921 
922  /*
923  * Check whether we are opening the (single) interactive
924  * window station, and if so, perform an access check.
925  */
926  /* Check whether we are allowed to perform interactions */
927  if (RtlEqualUnicodeString(&WinStaName, &WinSta0Name, TRUE))
928  {
929  LUID SystemLuid = SYSTEM_LUID;
930 
931  /* Interactive window station: check for user LUID */
932  WinStaObject = InputWindowStation;
933 
935 
936  // TODO: Check also that we compare wrt. window station WinSta0
937  // which is the only one that can be interactive on the system.
938  if (((!bUseDefaultWinSta || bInherit) && RtlEqualLuid(&ProcessLuid, &SystemLuid)) ||
939  RtlEqualLuid(&ProcessLuid, &WinStaObject->luidUser))
940  {
941  /* We are interactive on this window station */
942  bAccessAllowed = TRUE;
944  }
945  }
946  else
947  {
948  /* Non-interactive window station: we have access since we were able to open it */
949  bAccessAllowed = TRUE;
951  }
952  }
953 
954  /* If we failed, bail out if we were not trying to open the default window station */
955  if (!NT_SUCCESS(Status) && !bUseDefaultWinSta) // if (!bAccessAllowed)
956  goto Quit;
957 
958  if (/* bAccessAllowed && */ bInteractive || !bAccessAllowed)
959  {
960  /*
961  * Close WinSta0 if the inherited window station is interactive so that
962  * we can use it, or we do not have access to the interactive WinSta0.
963  */
964  ObCloseHandle(hTempWinSta, UserMode);
965  hTempWinSta = NULL;
966  }
967  if (bInteractive == bAccessAllowed)
968  {
969  /* Keep using the inherited window station */
970  NOTHING;
971  }
972  else // if (bInteractive != bAccessAllowed)
973  {
974  /*
975  * Close the inherited window station, we will either keep using
976  * the interactive WinSta0, or use Service-0xXXXX-YYYY$.
977  */
978  if (hWinStaDup)
979  {
980  ASSERT(hWinSta == hWinStaDup);
981  ObCloseHandle(hWinStaDup, UserMode);
982  hWinStaDup = NULL;
983  }
984  hWinSta = hTempWinSta; // hTempWinSta is NULL in case bAccessAllowed == FALSE
985  }
986 
987  if (bUseDefaultWinSta)
988  {
989  if (hWinSta == NULL && !bInteractive)
990  {
991  /* Build a valid window station name from the LUID */
993  ObjectName->MaximumLength,
994  L"%wZ\\Service-0x%x-%x$",
996  ProcessLuid.HighPart,
997  ProcessLuid.LowPart);
998  if (!NT_SUCCESS(Status))
999  {
1000  ERR("Impossible to build a valid window station name, Status 0x%08lx\n", Status);
1001  goto Quit;
1002  }
1003  ObjectName->Length = (USHORT)(wcslen(ObjectName->Buffer) * sizeof(WCHAR));
1004 
1005  /*
1006  * Create or open the non-interactive window station.
1007  * NOTE: The non-interactive window station handle is never inheritable.
1008  */
1009  // FIXME: Set security!
1011  ObjectName,
1013  NULL,
1014  NULL);
1015 
1016  Status = IntCreateWindowStation(&hWinSta,
1018  UserMode,
1019  KernelMode,
1021  0, 0, 0, 0, 0);
1022  if (!NT_SUCCESS(Status))
1023  {
1024  ASSERT(hWinSta == NULL);
1025  ERR("Failed to create or open the non-interactive window station '%wZ', Status 0x%08lx\n",
1026  ObjectName, Status);
1027  goto Quit;
1028  }
1029 
1030  //
1031  // FIXME: We might not need to always create or open the "Default"
1032  // desktop on the Service-0xXXXX-YYYY$ window station; we may need
1033  // to use another one....
1034  //
1035 
1036  /* Create or open the Default desktop on the window station */
1038  ObjectName->MaximumLength,
1039  L"Default");
1040  if (!NT_SUCCESS(Status))
1041  {
1042  ERR("Impossible to build a valid desktop name, Status 0x%08lx\n", Status);
1043  goto Quit;
1044  }
1045  ObjectName->Length = (USHORT)(wcslen(ObjectName->Buffer) * sizeof(WCHAR));
1046 
1047  /* NOTE: The non-interactive desktop handle is never inheritable. */
1048  // FIXME: Set security!
1050  ObjectName,
1052  hWinSta,
1053  NULL);
1054 
1055  Status = IntCreateDesktop(&hDesktop,
1057  UserMode,
1058  NULL,
1059  NULL,
1060  0,
1061  MAXIMUM_ALLOWED);
1062  if (!NT_SUCCESS(Status))
1063  {
1064  ASSERT(hDesktop == NULL);
1065  ERR("Failed to create or open the desktop '%wZ' on window station 0x%p, Status 0x%08lx\n",
1066  ObjectName, hWinSta, Status);
1067  }
1068 
1069  goto Quit;
1070  }
1071 /*
1072  if (hWinSta == NULL)
1073  {
1074  Status = STATUS_UNSUCCESSFUL;
1075  goto Quit;
1076  }
1077 */
1078  }
1079 
1080  /*
1081  * If we got an inherited desktop handle, duplicate and use it,
1082  * otherwise open a new desktop.
1083  */
1084  if (hDesktop != NULL)
1085  {
1086  /* Duplicate the handle if it belongs to another process than the current one */
1087  if (Process != PsGetCurrentProcess())
1088  {
1089  ASSERT(hProcess);
1090  Status = ZwDuplicateObject(hProcess,
1091  hDesktop,
1092  ZwCurrentProcess(),
1093  (PHANDLE)&hDesktopDup,
1094  0,
1095  0,
1097  if (!NT_SUCCESS(Status))
1098  {
1099  ERR("IntResolveDesktop: Failed to duplicate the desktop handle, Status 0x%08lx\n", Status);
1100  /* We will use a default desktop */
1101  hDesktop = NULL;
1102  }
1103  else
1104  {
1105  hDesktop = hDesktopDup;
1106  }
1107  }
1108  }
1109 
1110  if ((hWinSta != NULL) && (hDesktop == NULL))
1111  {
1113  ObjectName->MaximumLength,
1114  DesktopName.Buffer,
1115  DesktopName.Length);
1116  if (!NT_SUCCESS(Status))
1117  {
1118  ERR("Impossible to build a valid desktop name, Status 0x%08lx\n", Status);
1119  goto Quit;
1120  }
1121  ObjectName->Length = (USHORT)(wcslen(ObjectName->Buffer) * sizeof(WCHAR));
1122 
1123  TRACE("Parsed initial desktop: '%wZ'\n", ObjectName);
1124 
1125  /* Open the desktop object */
1127  ObjectName,
1129  hWinSta,
1130  NULL);
1131  if (bInherit)
1132  ObjectAttributes->Attributes |= OBJ_INHERIT;
1133 
1136  UserMode,
1137  NULL,
1139  NULL,
1140  (PHANDLE)&hDesktop);
1141  if (!NT_SUCCESS(Status))
1142  {
1143  ERR("Failed to open the desktop '%wZ' on window station 0x%p, Status 0x%08lx\n",
1144  ObjectName, hWinSta, Status);
1145  goto Quit;
1146  }
1147  }
1148 
1149 Quit:
1150  /* Release the object attributes */
1151  if (ObjectAttributes)
1152  {
1153  MemSize = 0;
1154  ZwFreeVirtualMemory(ZwCurrentProcess(),
1156  &MemSize,
1157  MEM_RELEASE);
1158  }
1159 
1160  /* Close the temporary process handle */
1161  if (hProcess) // if (Process != PsGetCurrentProcess())
1163 
1164  if (NT_SUCCESS(Status))
1165  {
1166  *phWinSta = hWinSta;
1167  *phDesktop = hDesktop;
1168  return STATUS_SUCCESS;
1169  }
1170  else
1171  {
1172  ERR("IntResolveDesktop(%wZ) failed, Status 0x%08lx\n", DesktopPath, Status);
1173 
1174  if (hDesktopDup)
1175  ObCloseHandle(hDesktopDup, UserMode);
1176  if (hWinStaDup)
1177  ObCloseHandle(hWinStaDup, UserMode);
1178 
1179  if (hDesktop)
1180  ObCloseHandle(hDesktop, UserMode);
1181  if (hWinSta)
1182  ObCloseHandle(hWinSta, UserMode);
1183 
1185  return Status;
1186  }
1187 }
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
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
#define ALIGN_UP(size, type)
Definition: umtypes.h:91
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOLEAN NTAPI ObFindHandleForObject(IN PEPROCESS Process, IN PVOID Object, IN POBJECT_TYPE ObjectType, IN POBJECT_HANDLE_INFORMATION HandleInformation, OUT PHANDLE Handle)
Definition: obhandle.c:2853
#define ZwCurrentProcess()
UNICODE_STRING gustrWindowStationsDir
Definition: winsta.c:27
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
uint16_t * PWCHAR
Definition: typedefs.h:54
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2739
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:257
#define MEM_COMMIT
Definition: nt_native.h:1313
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define OBJ_OPENIF
Definition: winternl.h:229
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: winsta.c:411
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
HDESK hdeskStartup
Definition: win32.h:254
#define DUPLICATE_SAME_ACCESS
#define UNICODE_NULL
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:411
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define WSS_NOIO
Definition: winsta.h:9
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:484
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DWORD LowPart
struct _DESKTOP * rpdeskStartup
Definition: win32.h:249
#define OBJ_INHERIT
Definition: winternl.h:225
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
LONG HighPart
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define NOTHING
Definition: env_spec_w32.h:461
static __inline NTSTATUS 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:1120
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define SYSTEM_LUID
Definition: setypes.h:672
#define DESKTOP_ALL_ACCESS
Definition: precomp.h:20
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSTATUS FASTCALL IntCreateDesktop(OUT HDESK *phDesktop, IN POBJECT_ATTRIBUTES ObjectAttributes, IN KPROCESSOR_MODE AccessMode, IN PUNICODE_STRING lpszDesktopDevice OPTIONAL, IN LPDEVMODEW lpdmw OPTIONAL, IN DWORD dwFlags, IN ACCESS_MASK dwDesiredAccess)
Definition: desktop.c:2308
HWINSTA hwinsta
Definition: win32.h:258
#define WINSTA_ACCESS_ALL
Definition: winsta.h:65
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS GetProcessLuid(IN PETHREAD Thread OPTIONAL, IN PEPROCESS Process OPTIONAL, OUT PLUID Luid)
Definition: misc.c:791
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define MAXUSHORT
Definition: typedefs.h:81
#define MEM_RELEASE
Definition: nt_native.h:1316
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Check_return_ _CRTIMP int __cdecl _scwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format,...)
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
POBJECT_TYPE PsProcessType
Definition: process.c:20
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by InitThreadCallback(), and NtUserResolveDesktop().

◆ IntSetFocusMessageQueue()

VOID FASTCALL IntSetFocusMessageQueue ( PUSER_MESSAGE_QUEUE  NewQueue)

Definition at line 1283 of file desktop.c.

1284 {
1285  PUSER_MESSAGE_QUEUE Old;
1286  PDESKTOP pdo = IntGetActiveDesktop();
1287  if (!pdo)
1288  {
1289  TRACE("No active desktop\n");
1290  return;
1291  }
1292  if (NewQueue != NULL)
1293  {
1294  if (NewQueue->Desktop != NULL)
1295  {
1296  TRACE("Message Queue already attached to another desktop!\n");
1297  return;
1298  }
1299  IntReferenceMessageQueue(NewQueue);
1300  (void)InterlockedExchangePointer((PVOID*)&NewQueue->Desktop, pdo);
1301  }
1303  if (Old != NULL)
1304  {
1306  gpqForegroundPrev = Old;
1308  }
1309  // Only one Q can have active foreground even when there are more than one desktop.
1310  if (NewQueue)
1311  {
1313  }
1314  else
1315  {
1316  gpqForeground = NULL;
1317  ERR("ptiLastInput is CLEARED!!\n");
1318  ptiLastInput = NULL; // ReactOS hacks,,,, should check for process death.
1319  }
1320 }
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:12
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define IntReferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:217
struct _USER_MESSAGE_QUEUE * ActiveMessageQueue
Definition: desktop.h:38
smooth NULL
Definition: ftsmooth.c:416
struct _USER_MESSAGE_QUEUE * PUSER_MESSAGE_QUEUE
PTHREADINFO ptiLastInput
Definition: focus.c:17
#define IntDereferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:220
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define ERR(fmt,...)
Definition: debug.h:109
PUSER_MESSAGE_QUEUE gpqForegroundPrev
Definition: focus.c:13
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226
struct _DESKTOP * Desktop
Definition: msgqueue.h:50

Referenced by co_IntSetForegroundMessageQueue(), co_WinPosActivateOtherWindow(), IntSetThreadDesktop(), MsqCleanupMessageQueue(), and UserAttachThreadInput().

◆ IntSetThreadDesktop()

BOOL IntSetThreadDesktop ( IN HDESK  hDesktop,
IN BOOL  FreeOnFailure 
)

Definition at line 3181 of file desktop.c.

3183 {
3184  PDESKTOP pdesk = NULL, pdeskOld;
3185  PTHREADINFO pti;
3186  NTSTATUS Status;
3187  PCLIENTTHREADINFO pctiOld, pctiNew = NULL;
3188  PCLIENTINFO pci;
3189 
3190  ASSERT(NtCurrentTeb());
3191 
3192  TRACE("IntSetThreadDesktop hDesktop:0x%p, FOF:%i\n",hDesktop, FreeOnFailure);
3193 
3195  pci = pti->pClientInfo;
3196 
3197  /* If the caller gave us a desktop, ensure it is valid */
3198  if (hDesktop != NULL)
3199  {
3200  /* Validate the new desktop. */
3201  Status = IntValidateDesktopHandle(hDesktop, UserMode, 0, &pdesk);
3202  if (!NT_SUCCESS(Status))
3203  {
3204  ERR("Validation of desktop handle 0x%p failed\n", hDesktop);
3205  return FALSE;
3206  }
3207 
3208  if (pti->rpdesk == pdesk)
3209  {
3210  /* Nothing to do */
3211  ObDereferenceObject(pdesk);
3212  return TRUE;
3213  }
3214  }
3215 
3216  /* Make sure that we don't own any window in the current desktop */
3217  if (!IsListEmpty(&pti->WindowListHead))
3218  {
3219  if (pdesk)
3220  ObDereferenceObject(pdesk);
3221  ERR("Attempted to change thread desktop although the thread has windows!\n");
3223  return FALSE;
3224  }
3225 
3226  /* Desktop is being re-set so clear out foreground. */
3227  if (pti->rpdesk != pdesk && pti->MessageQueue == gpqForeground)
3228  {
3229  // Like above, there shouldn't be any windows, hooks or anything active on this threads desktop!
3231  }
3232 
3233  /* Before doing the switch, map the new desktop heap and allocate the new pcti */
3234  if (pdesk != NULL)
3235  {
3236  Status = IntMapDesktopView(pdesk);
3237  if (!NT_SUCCESS(Status))
3238  {
3239  ERR("Failed to map desktop heap!\n");
3240  ObDereferenceObject(pdesk);
3242  return FALSE;
3243  }
3244 
3245  pctiNew = DesktopHeapAlloc(pdesk, sizeof(CLIENTTHREADINFO));
3246  if (pctiNew == NULL)
3247  {
3248  ERR("Failed to allocate new pcti\n");
3249  IntUnmapDesktopView(pdesk);
3250  ObDereferenceObject(pdesk);
3252  return FALSE;
3253  }
3254  }
3255 
3256  /*
3257  * Processes, in particular Winlogon.exe, that manage window stations
3258  * (especially the interactive WinSta0 window station) and desktops,
3259  * may not be able to connect at startup to a window station and have
3260  * an associated desktop as well, if none exists on the system already.
3261  * Because creating a new window station does not affect the window station
3262  * associated to the process, and because neither by associating a window
3263  * station to the process nor creating a new desktop on it does associate
3264  * a startup desktop to that process, the process has to actually assigns
3265  * one of its threads to a desktop so that it gets automatically an assigned
3266  * startup desktop.
3267  *
3268  * This is what actually happens for Winlogon.exe, which is started without
3269  * any window station and desktop. By creating the first (and therefore
3270  * interactive) WinSta0 window station, then assigning WinSta0 to itself
3271  * and creating the Default desktop on it, and then assigning this desktop
3272  * to its main thread, Winlogon.exe basically does the similar steps that
3273  * would have been done automatically at its startup if there were already
3274  * an existing WinSta0 window station and Default desktop.
3275  *
3276  * Of course all this must not be done if we are a SYSTEM or CSRSS thread.
3277  */
3278  // if (pti->ppi->peProcess != gpepCSRSS)
3279  if (!(pti->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
3280  pti->ppi->rpdeskStartup == NULL && hDesktop != NULL)
3281  {
3282  ERR("The process 0x%p '%s' didn't have an assigned startup desktop before, assigning it now!\n",
3283  pti->ppi->peProcess, pti->ppi->peProcess->ImageFileName);
3284 
3285  pti->ppi->hdeskStartup = hDesktop;
3286  pti->ppi->rpdeskStartup = pdesk;
3287  }
3288 
3289  /* free all classes or move them to the shared heap */
3290  if (pti->rpdesk != NULL)
3291  {
3292  if (!IntCheckProcessDesktopClasses(pti->rpdesk, FreeOnFailure))
3293  {
3294  ERR("Failed to move process classes to shared heap!\n");
3295  if (pdesk)
3296  {
3297  DesktopHeapFree(pdesk, pctiNew);
3298  IntUnmapDesktopView(pdesk);
3299  ObDereferenceObject(pdesk);
3300  }
3301  return FALSE;
3302  }
3303  }
3304 
3305  pdeskOld = pti->rpdesk;
3306  if (pti->pcti != &pti->cti)
3307  pctiOld = pti->pcti;
3308  else
3309  pctiOld = NULL;
3310 
3311  /* do the switch */
3312  if (pdesk != NULL)
3313  {
3314  pti->rpdesk = pdesk;
3315  pti->hdesk = hDesktop;
3316  pti->pDeskInfo = pti->rpdesk->pDeskInfo;
3317  pti->pcti = pctiNew;
3318 
3320  pci->pDeskInfo = (PVOID)((ULONG_PTR)pti->pDeskInfo - pci->ulClientDelta);
3321  pci->pClientThreadInfo = (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta);
3322 
3323  /* initialize the new pcti */
3324  if (pctiOld != NULL)
3325  {
3326  RtlCopyMemory(pctiNew, pctiOld, sizeof(CLIENTTHREADINFO));
3327  }
3328  else
3329  {
3330  RtlZeroMemory(pctiNew, sizeof(CLIENTTHREADINFO));
3331  pci->fsHooks = pti->fsHooks;
3332  pci->dwTIFlags = pti->TIF_flags;
3333  }
3334  }
3335  else
3336  {
3337  pti->rpdesk = NULL;
3338  pti->hdesk = NULL;
3339  pti->pDeskInfo = NULL;
3340  pti->pcti = &pti->cti; // Always point inside so there will be no crash when posting or sending msg's!
3341  pci->ulClientDelta = 0;
3342  pci->pDeskInfo = NULL;
3343  pci->pClientThreadInfo = NULL;
3344  }
3345 
3346  /* clean up the old desktop */
3347  if (pdeskOld != NULL)
3348  {
3349  RemoveEntryList(&pti->PtiLink);
3350  if (pctiOld) DesktopHeapFree(pdeskOld, pctiOld);
3351  IntUnmapDesktopView(pdeskOld);
3352  ObDereferenceObject(pdeskOld);
3353  }
3354 
3355  if (pdesk)
3356  {
3357  InsertTailList(&pdesk->PtiList, &pti->PtiLink);
3358  }
3359 
3360  TRACE("IntSetThreadDesktop: pti 0x%p ppi 0x%p switched from object 0x%p to 0x%p\n", pti, pti->ppi, pdeskOld, pdesk);
3361 
3362  return TRUE;
3363 }
BOOL IntCheckProcessDesktopClasses(IN PDESKTOP Desktop, IN BOOL FreeOnFailure)
Definition: class.c:989
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:12
ULONG fsHooks
Definition: ntuser.h:296
LIST_ENTRY PtiList
Definition: desktop.h:25
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LIST_ENTRY WindowListHead
Definition: win32.h:149
FLONG TIF_flags
Definition: win32.h:94
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LIST_ENTRY PtiLink
Definition: win32.h:125
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define InsertTailList(ListHead, Entry)
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:242
struct _DESKTOP * rpdesk
Definition: win32.h:91
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define ERROR_BUSY
Definition: dderror.h:12
PCLIENTTHREADINFO pClientThreadInfo
Definition: ntuser.h:300
PPROCESSINFO ppi
Definition: win32.h:87
uint32_t ULONG_PTR
Definition: typedefs.h:63
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
HDESK hdesk
Definition: win32.h:107
HDESK hdeskStartup
Definition: win32.h:254
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:230
#define TIF_CSRSSTHREAD
Definition: ntuser.h:243
static NTSTATUS IntUnmapDesktopView(IN PDESKTOP pdesk)
Definition: desktop.c:3063
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
ULONG_PTR ulClientDelta
Definition: ntuser.h:294
#define TRACE(s)
Definition: solgame.cpp:4
ULONG fsHooks
Definition: win32.h:116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static NTSTATUS IntMapDesktopView(IN PDESKTOP pdesk)
Definition: desktop.c:3107
struct _DESKTOP * rpdeskStartup
Definition: win32.h:249
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CLIENTTHREADINFO cti
Definition: win32.h:138
PDESKTOPINFO pDeskInfo
Definition: ntuser.h:293
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
Definition: desktop.c:1283
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
static __inline ULONG_PTR DesktopHeapGetUserDelta(VOID)
Definition: desktop.h:291
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1200
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:239
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
DWORD dwTIFlags
Definition: ntuser.h:292
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DesktopWindowProc(), ExitThreadCallback(), InitThreadCallback(), NtUserSetInformationThread(), and NtUserSetThreadDesktop().

◆ IntValidateDesktopHandle()

NTSTATUS FASTCALL IntValidateDesktopHandle ( HDESK  Desktop,
KPROCESSOR_MODE  AccessMode,
ACCESS_MASK  DesiredAccess,
PDESKTOP Object 
)

Definition at line 1200 of file desktop.c.

1205 {
1206  NTSTATUS Status;
1207 
1209  Desktop,
1210  DesiredAccess,
1212  AccessMode,
1213  (PVOID*)Object,
1214  NULL);
1215 
1216  TRACE("IntValidateDesktopHandle: handle:0x%p obj:0x%p access:0x%x Status:0x%lx\n",
1218 
1219  if (!NT_SUCCESS(Status))
1221 
1222  return Status;
1223 }
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
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 TRACE(s)
Definition: solgame.cpp:4
#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
_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

Referenced by InitThreadCallback(), IntSetThreadDesktop(), NtUserBuildHwndList(), NtUserCloseDesktop(), NtUserGetObjectInformation(), and NtUserSwitchDesktop().

◆ UserGetDesktopDC()

HDC FASTCALL UserGetDesktopDC ( ULONG  ,
BOOL  ,
BOOL   
)

Definition at line 1536 of file desktop.c.

1537 {
1538  PWND DesktopObject = 0;
1539  HDC DesktopHDC = 0;
1540 
1541  /* This can be called from GDI/DX, so acquire the USER lock */
1543 
1544  if (DcType == DC_TYPE_DIRECT)
1545  {
1546  DesktopObject = UserGetDesktopWindow();
1547  DesktopHDC = (HDC)UserGetWindowDC(DesktopObject);
1548  }
1549  else
1550  {
1551  PMONITOR pMonitor = UserGetPrimaryMonitor();
1552  DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC);
1553  }
1554 
1555  UserLeave();
1556 
1557  return DesktopHDC;
1558 }
HDEV hDev
Definition: monitor.h:23
static HDC
Definition: imagelist.c:92
HDC FASTCALL UserGetWindowDC(PWND Wnd)
Definition: windc.c:946
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC)
Definition: dclife.c:1055
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define DC_TYPE_DIRECT
Definition: ntgdihdl.h:123

Referenced by DxEngGetDesktopDC().

◆ UserGetDesktopWindow()

◆ UserGetMessageWindow()

PWND FASTCALL UserGetMessageWindow ( VOID  )

Definition at line 1374 of file desktop.c.

1375 {
1376  PDESKTOP pdo = IntGetActiveDesktop();
1377 
1378  if (!pdo)
1379  {
1380  TRACE("No active desktop\n");
1381  return NULL;
1382  }
1383  return pdo->spwndMessage;
1384 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PWND spwndMessage
Definition: desktop.h:20
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1226

◆ UserMessageWindowProc()

BOOL FASTCALL UserMessageWindowProc ( PWND  pwnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT lResult 
)

Definition at line 1487 of file desktop.c.

1488 {
1489  *lResult = 0;
1490 
1491  switch(Msg)
1492  {
1493  case WM_NCCREATE:
1494  pwnd->fnid |= FNID_MESSAGEWND;
1495  *lResult = (LRESULT)TRUE;
1496  break;
1497  case WM_DESTROY:
1498  pwnd->fnid |= FNID_DESTROY;
1499  break;
1500  default:
1501  ERR("UMWP calling IDWP\n");
1502  *lResult = IntDefWindowProc(pwnd, Msg, wParam, lParam, FALSE);
1503  }
1504 
1505  return TRUE; /* We are done. Do not do any callbacks to user mode */
1506 }
LRESULT FASTCALL IntDefWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi)
Definition: defwnd.c:532
#define TRUE
Definition: types.h:120
struct @1567 Msg[]
#define FNID_DESTROY
Definition: ntuser.h:859
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define FNID_MESSAGEWND
Definition: ntuser.h:826
DWORD fnid
Definition: ntuser.h:673
#define WM_DESTROY
Definition: winuser.h:1591
#define LRESULT
Definition: ole.h:14
#define ERR(fmt,...)
Definition: debug.h:109
LPARAM lParam
Definition: combotst.c:139

Referenced by co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), IntDispatchMessage(), and NtUserMessageCall().

◆ UserOpenInputDesktop()

HDESK UserOpenInputDesktop ( DWORD  dwFlags,
BOOL  fInherit,
ACCESS_MASK  dwDesiredAccess 
)

Definition at line 2572 of file desktop.c.

2575 {
2577  NTSTATUS Status;
2578  ULONG HandleAttributes = 0;
2579  HDESK hdesk = NULL;
2580 
2581  if (!gpdeskInputDesktop)
2582  {
2583  return NULL;
2584  }
2585 
2586  if (pti->ppi->prpwinsta != InputWindowStation)
2587  {
2588  ERR("Tried to open input desktop from non interactive winsta!\n");
2590  return NULL;
2591  }
2592 
2593  if (fInherit) HandleAttributes = OBJ_INHERIT;
2594 
2595  /* Create a new handle to the object */
2599  NULL,
2600  dwDesiredAccess,
2602  UserMode,
2603  (PHANDLE)&hdesk);
2604 
2605  if (!NT_SUCCESS(Status))
2606  {
2607  ERR("Failed to open input desktop object\n");
2609  }
2610 
2611  return hdesk;
2612 }
_In_ HANDLE _In_opt_ HANDLE _Out_opt_ PHANDLE _In_ ACCESS_MASK _In_ ULONG HandleAttributes
Definition: obfuncs.h:429
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
PDESKTOP gpdeskInputDesktop
Definition: desktop.c:35
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2739
struct _WINSTATION_OBJECT * prpwinsta
Definition: win32.h:257
PPROCESSINFO ppi
Definition: win32.h:87
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_INHERIT
Definition: winternl.h:225
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int ULONG
Definition: retypes.h:1
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DesktopWindowProc(), and NtUserOpenInputDesktop().

◆ UserRedrawDesktop()

VOID APIENTRY UserRedrawDesktop ( VOID  )

Definition at line 1561 of file desktop.c.

1562 {
1563  PWND Window = NULL;
1564  PREGION Rgn;
1565 
1567  Rgn = IntSysCreateRectpRgnIndirect(&Window->rcWindow);
1568 
1570  Rgn,
1571  RDW_FRAME |
1572  RDW_ERASE |
1573  RDW_INVALIDATE |
1574  RDW_ALLCHILDREN);
1575 
1576  REGION_Delete(Rgn);
1577 }
#define RDW_FRAME
Definition: winuser.h:1198
Definition: window.c:29
smooth NULL
Definition: ftsmooth.c:416
Definition: region.h:7
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
#define RDW_ERASE
Definition: winuser.h:1197
VOID FASTCALL IntInvalidateWindows(PWND Wnd, PREGION Rgn, ULONG Flags)
Definition: painting.c:630
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1349
Definition: ntuser.h:657
#define RDW_ALLCHILDREN
Definition: winuser.h:1207
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2428
#define RDW_INVALIDATE
Definition: winuser.h:1200

Referenced by DxEngRedrawDesktop(), NtUserSetSysColors(), and UserChangeDisplaySettings().

Variable Documentation

◆ DesktopWindowClass

PCLS DesktopWindowClass

◆ gpdeskInputDesktop

◆ gpDesktopThreadStartedEvent

PKEVENT gpDesktopThreadStartedEvent

Definition at line 39 of file desktop.c.

Referenced by DesktopThreadMain(), InitDesktopImpl(), and IntCreateWindowStation().

◆ gptiDesktopThread

◆ gptiForeground

◆ ScreenDeviceContext

HDC ScreenDeviceContext