3 typedef struct _DESKTOP
5 /* Must be the first member */
8 PDESKTOPINFO pDeskInfo
;
10 /* Pointer to the associated window station. */
11 struct _WINSTATION_OBJECT
*rpwinstaParent
;
13 DWORD_PTR dwDesktopId
;
15 PMENU spmenuDialogSys
;
22 PVOID hsectionDesktop
;
23 PWIN32HEAP pheapDesktop
;
27 /* One console input thread per desktop, maintained by CONSRV */
28 DWORD dwConsoleThreadId
;
30 /* Use for tracking mouse moves. */
34 DWORD dwMouseHoverTime
;
37 /* Pointer to the active queue. */
38 struct _USER_MESSAGE_QUEUE
*ActiveMessageQueue
;
39 /* Handle of the desktop window. */
41 /* Thread blocking input */
42 PVOID BlockInputThread
;
43 LIST_ENTRY ShellHookWindows
;
47 #define DF_TME_HOVER 0x00000400
48 #define DF_TME_LEAVE 0x00000800
49 #define DF_HOTTRACK 0x00004000
50 #define DF_DESTROYED 0x00008000
51 #define DF_DESKWNDDESTROYED 0x00010000
52 #define DF_DYING 0x00020000
54 // Index offset for Desktop data. Should these be global?
55 #define DT_GWL_PROCESSID 0
56 #define DT_GWL_THREADID 4
58 #define DESKTOP_READ STANDARD_RIGHTS_READ | \
62 #define DESKTOP_WRITE STANDARD_RIGHTS_WRITE | \
63 DESKTOP_CREATEMENU | \
64 DESKTOP_CREATEWINDOW | \
65 DESKTOP_HOOKCONTROL | \
66 DESKTOP_JOURNALPLAYBACK | \
67 DESKTOP_JOURNALRECORD | \
70 #define DESKTOP_EXECUTE STANDARD_RIGHTS_EXECUTE | \
73 #define DESKTOP_ALL_ACCESS STANDARD_RIGHTS_REQUIRED | \
74 DESKTOP_CREATEMENU | \
75 DESKTOP_CREATEWINDOW | \
77 DESKTOP_HOOKCONTROL | \
78 DESKTOP_JOURNALPLAYBACK | \
79 DESKTOP_JOURNALRECORD | \
80 DESKTOP_READOBJECTS | \
81 DESKTOP_SWITCHDESKTOP | \
84 extern PDESKTOP gpdeskInputDesktop
;
85 extern PCLS DesktopWindowClass
;
86 extern HDC ScreenDeviceContext
;
87 extern PTHREADINFO gptiForeground
;
88 extern PTHREADINFO gptiDesktopThread
;
89 extern PKEVENT gpDesktopThreadStartedEvent
;
91 typedef struct _SHELL_HOOK_WINDOW
95 } SHELL_HOOK_WINDOW
, *PSHELL_HOOK_WINDOW
;
100 InitDesktopImpl(VOID
);
104 IntDesktopObjectParse(IN PVOID ParseObject
,
106 IN OUT PACCESS_STATE AccessState
,
107 IN KPROCESSOR_MODE AccessMode
,
109 IN OUT PUNICODE_STRING CompleteName
,
110 IN OUT PUNICODE_STRING RemainingName
,
111 IN OUT PVOID Context OPTIONAL
,
112 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL
,
117 IntDesktopObjectDelete(
118 _In_ PVOID Parameters
);
123 _In_ PVOID Parameters
);
127 IntDesktopObjectOpen(
128 _In_ PVOID Parameters
);
132 IntDesktopObjectClose(
133 _In_ PVOID Parameters
);
136 IntGetScreenDC(VOID
);
139 IntGetDesktopWindow (VOID
);
142 UserGetDesktopWindow(VOID
);
145 IntGetCurrentThreadDesktopWindow(VOID
);
147 PUSER_MESSAGE_QUEUE FASTCALL
148 IntGetFocusMessageQueue(VOID
);
151 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue
);
154 IntGetActiveDesktop(VOID
);
157 co_IntShowDesktop(PDESKTOP Desktop
, ULONG Width
, ULONG Height
, BOOL Redraw
);
160 IntHideDesktop(PDESKTOP Desktop
);
162 BOOL
IntSetThreadDesktop(IN HDESK hDesktop
,
163 IN BOOL FreeOnFailure
);
168 IN PEPROCESS Process
,
169 IN PUNICODE_STRING DesktopPath
,
171 OUT HWINSTA
* phWinSta
,
172 OUT HDESK
* phDesktop
);
175 IntValidateDesktopHandle(
177 KPROCESSOR_MODE AccessMode
,
178 ACCESS_MASK DesiredAccess
,
184 OUT HDESK
* phDesktop
,
185 IN POBJECT_ATTRIBUTES ObjectAttributes
,
186 IN KPROCESSOR_MODE AccessMode
,
187 IN PUNICODE_STRING lpszDesktopDevice OPTIONAL
,
188 IN LPDEVMODEW lpdmw OPTIONAL
,
190 IN ACCESS_MASK dwDesiredAccess
);
192 VOID APIENTRY
UserRedrawDesktop(VOID
);
193 BOOL
IntRegisterShellHookWindow(HWND hWnd
);
194 BOOL
IntDeRegisterShellHookWindow(HWND hWnd
);
195 VOID
co_IntShellHookNotify(WPARAM Message
, WPARAM wParam
, LPARAM lParam
);
196 HDC FASTCALL
UserGetDesktopDC(ULONG
,BOOL
,BOOL
);
198 #define IntIsActiveDesktop(Desktop) \
199 ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
201 HWND FASTCALL
IntGetMessageWindow(VOID
);
202 PWND FASTCALL
UserGetMessageWindow(VOID
);
206 UserIsDesktopWindow(IN PWND pWnd
)
208 // return (pWnd == UserGetDesktopWindow());
209 return (pWnd
&& (pWnd
->fnid
== FNID_DESKTOP
));
213 UserIsMessageWindow(IN PWND pWnd
)
215 // return (pWnd == UserGetMessageWindow());
216 return (pWnd
&& (pWnd
->fnid
== FNID_MESSAGEWND
));
220 #define UserIsDesktopWindow(pWnd) \
221 ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP))
223 #define UserIsMessageWindow(pWnd) \
224 ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND))
229 static __inline PVOID
230 DesktopHeapAlloc(IN PDESKTOP Desktop
,
233 return RtlAllocateHeap(Desktop
->pheapDesktop
,
239 DesktopHeapFree(IN PDESKTOP Desktop
,
242 return RtlFreeHeap(Desktop
->pheapDesktop
,
247 static __inline PVOID
248 DesktopHeapReAlloc(IN PDESKTOP Desktop
,
253 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
254 return RtlReAllocateHeap(Desktop
->pheapDesktop
,
262 PrevSize
= RtlSizeHeap(Desktop
->pheapDesktop
,
266 if (PrevSize
== Bytes
)
269 pNew
= RtlAllocateHeap(Desktop
->pheapDesktop
,
274 if (PrevSize
< Bytes
)
281 RtlFreeHeap(Desktop
->pheapDesktop
,
290 static __inline ULONG_PTR
291 DesktopHeapGetUserDelta(VOID
)
293 PW32HEAP_USER_MAPPING Mapping
;
295 PPROCESSINFO W32Process
;
296 PWIN32HEAP pheapDesktop
;
299 pti
= PsGetCurrentThreadWin32Thread();
303 pheapDesktop
= pti
->rpdesk
->pheapDesktop
;
305 W32Process
= PsGetCurrentProcessWin32Process();
308 * Start the search at the next mapping: skip the first entry
309 * as it must be the global user heap mapping.
311 Mapping
= W32Process
->HeapMappings
.Next
;
312 while (Mapping
!= NULL
)
314 if (Mapping
->KernelMapping
== (PVOID
)pheapDesktop
)
316 Delta
= (ULONG_PTR
)Mapping
->KernelMapping
- (ULONG_PTR
)Mapping
->UserMapping
;
320 Mapping
= Mapping
->Next
;
326 static __inline PVOID
327 DesktopHeapAddressToUser(PVOID lpMem
)
329 PW32HEAP_USER_MAPPING Mapping
;
330 PPROCESSINFO W32Process
;
332 W32Process
= PsGetCurrentProcessWin32Process();
335 * Start the search at the next mapping: skip the first entry
336 * as it must be the global user heap mapping.
338 Mapping
= W32Process
->HeapMappings
.Next
;
339 while (Mapping
!= NULL
)
341 if ((ULONG_PTR
)lpMem
>= (ULONG_PTR
)Mapping
->KernelMapping
&&
342 (ULONG_PTR
)lpMem
< (ULONG_PTR
)Mapping
->KernelMapping
+ Mapping
->Limit
)
344 return (PVOID
)(((ULONG_PTR
)lpMem
- (ULONG_PTR
)Mapping
->KernelMapping
) +
345 (ULONG_PTR
)Mapping
->UserMapping
);
348 Mapping
= Mapping
->Next
;
354 PWND FASTCALL
IntGetThreadDesktopWindow(PTHREADINFO
);
355 PWND FASTCALL
co_GetDesktopWindow(PWND
);
356 BOOL FASTCALL
IntPaintDesktop(HDC
);
357 BOOL FASTCALL
DesktopWindowProc(PWND
, UINT
, WPARAM
, LPARAM
, LRESULT
*);
358 BOOL FASTCALL
UserMessageWindowProc(PWND pwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*lResult
);
359 VOID NTAPI
DesktopThreadMain(VOID
);