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
;
90 typedef struct _SHELL_HOOK_WINDOW
94 } SHELL_HOOK_WINDOW
, *PSHELL_HOOK_WINDOW
;
99 InitDesktopImpl(VOID
);
103 IntDesktopObjectParse(IN PVOID ParseObject
,
105 IN OUT PACCESS_STATE AccessState
,
106 IN KPROCESSOR_MODE AccessMode
,
108 IN OUT PUNICODE_STRING CompleteName
,
109 IN OUT PUNICODE_STRING RemainingName
,
110 IN OUT PVOID Context OPTIONAL
,
111 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL
,
116 IntDesktopObjectDelete(
117 _In_ PVOID Parameters
);
122 _In_ PVOID Parameters
);
126 IntDesktopObjectOpen(
127 _In_ PVOID Parameters
);
131 IntDesktopObjectClose(
132 _In_ PVOID Parameters
);
135 IntGetScreenDC(VOID
);
138 IntGetDesktopWindow (VOID
);
141 UserGetDesktopWindow(VOID
);
144 IntGetCurrentThreadDesktopWindow(VOID
);
146 PUSER_MESSAGE_QUEUE FASTCALL
147 IntGetFocusMessageQueue(VOID
);
150 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue
);
153 IntGetActiveDesktop(VOID
);
156 co_IntShowDesktop(PDESKTOP Desktop
, ULONG Width
, ULONG Height
, BOOL Redraw
);
159 IntHideDesktop(PDESKTOP Desktop
);
161 BOOL
IntSetThreadDesktop(IN HDESK hDesktop
,
162 IN BOOL FreeOnFailure
);
165 IntValidateDesktopHandle(
167 KPROCESSOR_MODE AccessMode
,
168 ACCESS_MASK DesiredAccess
,
174 OUT HDESK
* phDesktop
,
175 IN POBJECT_ATTRIBUTES ObjectAttributes
,
176 IN KPROCESSOR_MODE AccessMode
,
177 IN PUNICODE_STRING lpszDesktopDevice OPTIONAL
,
178 IN LPDEVMODEW lpdmw OPTIONAL
,
180 IN ACCESS_MASK dwDesiredAccess
);
183 IntParseDesktopPath(PEPROCESS Process
,
184 PUNICODE_STRING DesktopPath
,
188 VOID APIENTRY
UserRedrawDesktop(VOID
);
189 BOOL
IntRegisterShellHookWindow(HWND hWnd
);
190 BOOL
IntDeRegisterShellHookWindow(HWND hWnd
);
191 VOID
co_IntShellHookNotify(WPARAM Message
, WPARAM wParam
, LPARAM lParam
);
192 HDC FASTCALL
UserGetDesktopDC(ULONG
,BOOL
,BOOL
);
194 #define IntIsActiveDesktop(Desktop) \
195 ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
197 HWND FASTCALL
IntGetMessageWindow(VOID
);
198 PWND FASTCALL
UserGetMessageWindow(VOID
);
202 UserIsDesktopWindow(IN PWND pWnd
)
204 // return (pWnd == UserGetDesktopWindow());
205 return (pWnd
&& (pWnd
->fnid
== FNID_DESKTOP
));
209 UserIsMessageWindow(IN PWND pWnd
)
211 // return (pWnd == UserGetMessageWindow());
212 return (pWnd
&& (pWnd
->fnid
== FNID_MESSAGEWND
));
216 #define UserIsDesktopWindow(pWnd) \
217 ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP))
219 #define UserIsMessageWindow(pWnd) \
220 ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND))
225 static __inline PVOID
226 DesktopHeapAlloc(IN PDESKTOP Desktop
,
229 return RtlAllocateHeap(Desktop
->pheapDesktop
,
235 DesktopHeapFree(IN PDESKTOP Desktop
,
238 return RtlFreeHeap(Desktop
->pheapDesktop
,
243 static __inline PVOID
244 DesktopHeapReAlloc(IN PDESKTOP Desktop
,
249 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
250 return RtlReAllocateHeap(Desktop
->pheapDesktop
,
258 PrevSize
= RtlSizeHeap(Desktop
->pheapDesktop
,
262 if (PrevSize
== Bytes
)
265 pNew
= RtlAllocateHeap(Desktop
->pheapDesktop
,
270 if (PrevSize
< Bytes
)
277 RtlFreeHeap(Desktop
->pheapDesktop
,
286 static __inline ULONG_PTR
287 DesktopHeapGetUserDelta(VOID
)
289 PW32HEAP_USER_MAPPING Mapping
;
291 PPROCESSINFO W32Process
;
292 PWIN32HEAP pheapDesktop
;
295 pti
= PsGetCurrentThreadWin32Thread();
299 pheapDesktop
= pti
->rpdesk
->pheapDesktop
;
301 W32Process
= PsGetCurrentProcessWin32Process();
304 * Start the search at the next mapping: skip the first entry
305 * as it must be the global user heap mapping.
307 Mapping
= W32Process
->HeapMappings
.Next
;
308 while (Mapping
!= NULL
)
310 if (Mapping
->KernelMapping
== (PVOID
)pheapDesktop
)
312 Delta
= (ULONG_PTR
)Mapping
->KernelMapping
- (ULONG_PTR
)Mapping
->UserMapping
;
316 Mapping
= Mapping
->Next
;
322 static __inline PVOID
323 DesktopHeapAddressToUser(PVOID lpMem
)
325 PW32HEAP_USER_MAPPING Mapping
;
326 PPROCESSINFO W32Process
;
328 W32Process
= PsGetCurrentProcessWin32Process();
331 * Start the search at the next mapping: skip the first entry
332 * as it must be the global user heap mapping.
334 Mapping
= W32Process
->HeapMappings
.Next
;
335 while (Mapping
!= NULL
)
337 if ((ULONG_PTR
)lpMem
>= (ULONG_PTR
)Mapping
->KernelMapping
&&
338 (ULONG_PTR
)lpMem
< (ULONG_PTR
)Mapping
->KernelMapping
+ Mapping
->Limit
)
340 return (PVOID
)(((ULONG_PTR
)lpMem
- (ULONG_PTR
)Mapping
->KernelMapping
) +
341 (ULONG_PTR
)Mapping
->UserMapping
);
344 Mapping
= Mapping
->Next
;
350 PWND FASTCALL
IntGetThreadDesktopWindow(PTHREADINFO
);
351 PWND FASTCALL
co_GetDesktopWindow(PWND
);
352 BOOL FASTCALL
IntPaintDesktop(HDC
);
353 BOOL FASTCALL
DesktopWindowProc(PWND
, UINT
, WPARAM
, LPARAM
, LRESULT
*);
354 BOOL FASTCALL
UserMessageWindowProc(PWND pwnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*lResult
);
355 VOID NTAPI
DesktopThreadMain(VOID
);