3 typedef struct _DESKTOP
5 PDESKTOPINFO pDeskInfo
;
7 /* Pointer to the associated window station. */
8 struct _WINSTATION_OBJECT
*rpwinstaParent
;
14 PSECTION_OBJECT hsectionDesktop
;
15 PWIN32HEAP pheapDesktop
;
18 /* Use for tracking mouse moves. */
22 DWORD dwMouseHoverTime
;
25 /* Pointer to the active queue. */
26 struct _USER_MESSAGE_QUEUE
*ActiveMessageQueue
;
27 /* Handle of the desktop window. */
29 /* Thread blocking input */
30 PVOID BlockInputThread
;
31 LIST_ENTRY ShellHookWindows
;
35 #define DF_TME_HOVER 0x00000400
36 #define DF_TME_LEAVE 0x00000800
37 #define DF_HOTTRACK 0x00004000
38 #define DF_DESTROYED 0x00008000
39 #define DF_DESKWNDDESTROYED 0x00010000
40 #define DF_DYING 0x00020000
42 #define DESKTOP_READ STANDARD_RIGHTS_READ | \
46 #define DESKTOP_WRITE STANDARD_RIGHTS_WRITE | \
47 DESKTOP_CREATEMENU | \
48 DESKTOP_CREATEWINDOW | \
49 DESKTOP_HOOKCONTROL | \
50 DESKTOP_JOURNALPLAYBACK | \
51 DESKTOP_JOURNALRECORD | \
54 #define DESKTOP_EXECUTE STANDARD_RIGHTS_EXECUTE | \
57 #define DESKTOP_ALL_ACCESS STANDARD_RIGHTS_REQUIRED | \
58 DESKTOP_CREATEMENU | \
59 DESKTOP_CREATEWINDOW | \
61 DESKTOP_HOOKCONTROL | \
62 DESKTOP_JOURNALPLAYBACK | \
63 DESKTOP_JOURNALRECORD | \
64 DESKTOP_READOBJECTS | \
65 DESKTOP_SWITCHDESKTOP | \
68 extern PDESKTOP InputDesktop
;
69 extern HDESK InputDesktopHandle
;
70 extern PCLS DesktopWindowClass
;
71 extern HDC ScreenDeviceContext
;
73 typedef struct _SHELL_HOOK_WINDOW
77 } SHELL_HOOK_WINDOW
, *PSHELL_HOOK_WINDOW
;
82 InitDesktopImpl(VOID
);
86 IntDesktopObjectParse(IN PVOID ParseObject
,
88 IN OUT PACCESS_STATE AccessState
,
89 IN KPROCESSOR_MODE AccessMode
,
91 IN OUT PUNICODE_STRING CompleteName
,
92 IN OUT PUNICODE_STRING RemainingName
,
93 IN OUT PVOID Context OPTIONAL
,
94 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL
,
98 IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters
);
101 IntDesktopOkToClose(PWIN32_OKAYTOCLOSEMETHOD_PARAMETERS Parameters
);
104 IntGetScreenDC(VOID
);
107 IntGetDesktopWindow (VOID
);
110 UserGetDesktopWindow(VOID
);
113 IntGetCurrentThreadDesktopWindow(VOID
);
115 PUSER_MESSAGE_QUEUE FASTCALL
116 IntGetFocusMessageQueue(VOID
);
119 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue
);
122 IntGetActiveDesktop(VOID
);
125 co_IntShowDesktop(PDESKTOP Desktop
, ULONG Width
, ULONG Height
);
128 IntHideDesktop(PDESKTOP Desktop
);
130 BOOL
IntSetThreadDesktop(IN HDESK hDesktop
,
131 IN BOOL FreeOnFailure
);
134 IntValidateDesktopHandle(
136 KPROCESSOR_MODE AccessMode
,
137 ACCESS_MASK DesiredAccess
,
141 IntParseDesktopPath(PEPROCESS Process
,
142 PUNICODE_STRING DesktopPath
,
146 VOID APIENTRY
UserRedrawDesktop(VOID
);
147 BOOL
IntRegisterShellHookWindow(HWND hWnd
);
148 BOOL
IntDeRegisterShellHookWindow(HWND hWnd
);
149 VOID
co_IntShellHookNotify(WPARAM Message
, LPARAM lParam
);
150 HDC FASTCALL
UserGetDesktopDC(ULONG
,BOOL
,BOOL
);
152 #define IntIsActiveDesktop(Desktop) \
153 ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
155 #define GET_DESKTOP_NAME(d) \
156 OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d)) ? \
157 &(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d))->Name) : \
160 HWND FASTCALL
IntGetMessageWindow(VOID
);
161 PWND FASTCALL
UserGetMessageWindow(VOID
);
163 static __inline PVOID
164 DesktopHeapAlloc(IN PDESKTOP Desktop
,
167 return RtlAllocateHeap(Desktop
->pheapDesktop
,
173 DesktopHeapFree(IN PDESKTOP Desktop
,
176 return RtlFreeHeap(Desktop
->pheapDesktop
,
181 static __inline PVOID
182 DesktopHeapReAlloc(IN PDESKTOP Desktop
,
187 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
188 return RtlReAllocateHeap(Desktop
->pheapDesktop
,
196 PrevSize
= RtlSizeHeap(Desktop
->pheapDesktop
,
200 if (PrevSize
== Bytes
)
203 pNew
= RtlAllocateHeap(Desktop
->pheapDesktop
,
208 if (PrevSize
< Bytes
)
215 RtlFreeHeap(Desktop
->pheapDesktop
,
224 static __inline ULONG_PTR
225 DesktopHeapGetUserDelta(VOID
)
227 PW32HEAP_USER_MAPPING Mapping
;
229 PPROCESSINFO W32Process
;
230 PWIN32HEAP pheapDesktop
;
233 pti
= PsGetCurrentThreadWin32Thread();
237 pheapDesktop
= pti
->rpdesk
->pheapDesktop
;
239 W32Process
= PsGetCurrentProcessWin32Process();
240 Mapping
= W32Process
->HeapMappings
.Next
;
241 while (Mapping
!= NULL
)
243 if (Mapping
->KernelMapping
== (PVOID
)pheapDesktop
)
245 Delta
= (ULONG_PTR
)Mapping
->KernelMapping
- (ULONG_PTR
)Mapping
->UserMapping
;
249 Mapping
= Mapping
->Next
;
255 static __inline PVOID
256 DesktopHeapAddressToUser(PVOID lpMem
)
258 PW32HEAP_USER_MAPPING Mapping
;
259 PPROCESSINFO W32Process
;
261 W32Process
= PsGetCurrentProcessWin32Process();
262 Mapping
= W32Process
->HeapMappings
.Next
;
263 while (Mapping
!= NULL
)
265 if ((ULONG_PTR
)lpMem
>= (ULONG_PTR
)Mapping
->KernelMapping
&&
266 (ULONG_PTR
)lpMem
< (ULONG_PTR
)Mapping
->KernelMapping
+ Mapping
->Limit
)
268 return (PVOID
)(((ULONG_PTR
)lpMem
- (ULONG_PTR
)Mapping
->KernelMapping
) +
269 (ULONG_PTR
)Mapping
->UserMapping
);
272 Mapping
= Mapping
->Next
;