ReactOS 0.4.15-dev-8227-g32d615f
desktop.h
Go to the documentation of this file.
1#pragma once
2
3typedef struct _DESKTOP
4{
5 /* Must be the first member */
7
10 /* Pointer to the associated window station. */
26
27 /* One console input thread per desktop, maintained by CONSRV */
29
30 /* Use for tracking mouse moves. */
35
36 /* ReactOS */
37 /* Pointer to the active queue. */
39 /* Handle of the desktop window. */
41 /* Thread blocking input */
45
46// Desktop flags
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
53
54// Index offset for Desktop data. Should these be global?
55#define DT_GWL_PROCESSID 0
56#define DT_GWL_THREADID 4
57
64
65typedef struct _SHELL_HOOK_WINDOW
66{
70
71CODE_SEG("INIT")
75
83 IN OUT PUNICODE_STRING CompleteName,
88
93
98
100NTAPI
103
105NTAPI
108
111
114
117
120
123
126
129
132
135
136BOOL IntSetThreadDesktop(IN HDESK hDesktop,
137 IN BOOL FreeOnFailure);
138
143 IN PUNICODE_STRING DesktopPath,
144 IN BOOL bInherit,
145 OUT HWINSTA* phWinSta,
146 OUT HDESK* phDesktop);
147
150 HDESK Desktop,
154
158 OUT HDESK* phDesktop,
161 IN PUNICODE_STRING lpszDesktopDevice OPTIONAL,
162 IN LPDEVMODEW lpdmw OPTIONAL,
164 IN ACCESS_MASK dwDesiredAccess);
165
171
172#define IntIsActiveDesktop(Desktop) \
173 ((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
174
177
178#if 0
179static __inline BOOL
181{
182 // return (pWnd == UserGetDesktopWindow());
183 return (pWnd && (pWnd->fnid == FNID_DESKTOP));
184}
185
186static __inline BOOL
188{
189 // return (pWnd == UserGetMessageWindow());
190 return (pWnd && (pWnd->fnid == FNID_MESSAGEWND));
191}
192#else
193
194#define UserIsDesktopWindow(pWnd) \
195 ((pWnd) && ((pWnd)->fnid == FNID_DESKTOP))
196
197#define UserIsMessageWindow(pWnd) \
198 ((pWnd) && ((pWnd)->fnid == FNID_MESSAGEWND))
199
200#endif
201
202
203static __inline PVOID
206{
207 /* Desktop heap has no lock, using global user lock instead. */
209 return RtlAllocateHeap(Desktop->pheapDesktop,
211 Bytes);
212}
213
214static __inline BOOL
216 IN PVOID lpMem)
217{
218 /* Desktop heap has no lock, using global user lock instead. */
220 return RtlFreeHeap(Desktop->pheapDesktop,
222 lpMem);
223}
224
225static __inline PVOID
227 IN PVOID lpMem,
229{
230#if 0
231 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
232 return RtlReAllocateHeap(Desktop->pheapDesktop,
234 lpMem,
235 Bytes);
236#else
237 SIZE_T PrevSize;
238 PVOID pNew;
239
240 /* Desktop heap has no lock, using global user lock instead. */
242
243 PrevSize = RtlSizeHeap(Desktop->pheapDesktop,
245 lpMem);
246
247 if (PrevSize == Bytes)
248 return lpMem;
249
250 pNew = RtlAllocateHeap(Desktop->pheapDesktop,
252 Bytes);
253 if (pNew != NULL)
254 {
255 if (PrevSize < Bytes)
256 Bytes = PrevSize;
257
258 RtlCopyMemory(pNew,
259 lpMem,
260 Bytes);
261
262 RtlFreeHeap(Desktop->pheapDesktop,
264 lpMem);
265 }
266
267 return pNew;
268#endif
269}
270
271static __inline ULONG_PTR
273{
275 PTHREADINFO pti;
276 PPROCESSINFO W32Process;
277 PWIN32HEAP pheapDesktop;
278 ULONG_PTR Delta = 0;
279
281 if (!pti->rpdesk)
282 return 0;
283
284 pheapDesktop = pti->rpdesk->pheapDesktop;
285
286 W32Process = PsGetCurrentProcessWin32Process();
287
288 /*
289 * Start the search at the next mapping: skip the first entry
290 * as it must be the global user heap mapping.
291 */
292 Mapping = W32Process->HeapMappings.Next;
293 while (Mapping != NULL)
294 {
295 if (Mapping->KernelMapping == (PVOID)pheapDesktop)
296 {
297 Delta = (ULONG_PTR)Mapping->KernelMapping - (ULONG_PTR)Mapping->UserMapping;
298 break;
299 }
300
301 Mapping = Mapping->Next;
302 }
303
304 return Delta;
305}
306
307static __inline PVOID
309{
311 PPROCESSINFO W32Process;
312
313 W32Process = PsGetCurrentProcessWin32Process();
314
315 /*
316 * Start the search at the next mapping: skip the first entry
317 * as it must be the global user heap mapping.
318 */
319 Mapping = W32Process->HeapMappings.Next;
320 while (Mapping != NULL)
321 {
322 if ((ULONG_PTR)lpMem >= (ULONG_PTR)Mapping->KernelMapping &&
323 (ULONG_PTR)lpMem < (ULONG_PTR)Mapping->KernelMapping + Mapping->Limit)
324 {
325 return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)Mapping->KernelMapping) +
326 (ULONG_PTR)Mapping->UserMapping);
327 }
328
329 Mapping = Mapping->Next;
330 }
331
332 return NULL;
333}
334
341HDESK UserOpenInputDesktop(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess);
342
343/* EOF */
#define CODE_SEG(...)
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:802
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct @1643 Msg[]
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define APIENTRY
Definition: api.h:79
static const WCHAR Message[]
Definition: register.c:74
#define ULONG_PTR
Definition: config.h:101
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define FNID_DESKTOP
Definition: ntuser.h:862
#define FNID_MESSAGEWND
Definition: ntuser.h:864
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2667
_In_ UINT Bytes
Definition: mmcopy.h:9
#define ASSERT(a)
Definition: mode.c:44
static HDC
Definition: imagelist.c:92
ObjectType
Definition: metafile.c:81
#define _In_
Definition: ms_sal.h:308
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI SIZE_T NTAPI RtlSizeHeap(_In_ PVOID HeapHandle, _In_ ULONG Flags, _In_ PVOID MemoryPointer)
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FASTCALL
Definition: nt_native.h:50
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:224
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: ntuser.h:566
PVOID hsectionDesktop
Definition: desktop.h:22
DWORD_PTR dwDesktopId
Definition: desktop.h:13
PVOID BlockInputThread
Definition: desktop.h:42
DWORD dwMouseHoverTime
Definition: desktop.h:34
struct _USER_MESSAGE_QUEUE * ActiveMessageQueue
Definition: desktop.h:38
LIST_ENTRY PtiList
Definition: desktop.h:25
LIST_ENTRY ListEntry
Definition: desktop.h:9
ULONG_PTR ulHeapSize
Definition: desktop.h:24
struct _WINSTATION_OBJECT * rpwinstaParent
Definition: desktop.h:11
LIST_ENTRY ShellHookWindows
Definition: desktop.h:43
PWND spwndTrack
Definition: desktop.h:31
PWIN32HEAP pheapDesktop
Definition: desktop.h:23
DWORD dwConsoleThreadId
Definition: desktop.h:28
PWND spwndForeground
Definition: desktop.h:18
PWND spwndTray
Definition: desktop.h:19
PMENU spmenuSys
Definition: desktop.h:14
PMENU spmenuDialogSys
Definition: desktop.h:15
PWND spwndMessage
Definition: desktop.h:20
PWND spwndTooltip
Definition: desktop.h:21
PMENU spmenuVScroll
Definition: desktop.h:17
DWORD htEx
Definition: desktop.h:32
HWND DesktopWindow
Definition: desktop.h:40
RECT rcMouseHover
Definition: desktop.h:33
PMENU spmenuHScroll
Definition: desktop.h:16
DWORD dwDTFlags
Definition: desktop.h:12
PDESKTOPINFO pDeskInfo
Definition: desktop.h:8
DWORD dwSessionId
Definition: desktop.h:6
Definition: typedefs.h:120
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:290
LIST_ENTRY ListEntry
Definition: desktop.h:67
struct _DESKTOP * rpdesk
Definition: win32.h:92
struct _W32HEAP_USER_MAPPING * Next
Definition: win32.h:198
Definition: ntuser.h:694
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
struct _WIN32HEAP * PWIN32HEAP
Definition: usrheap.h:3
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
PDESKTOP FASTCALL IntGetActiveDesktop(VOID)
Definition: desktop.c:1262
PTHREADINFO gptiDesktopThread
Definition: desktop.c:37
struct _DESKTOP * PDESKTOP
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:2352
PWND FASTCALL IntGetThreadDesktopWindow(PTHREADINFO)
Definition: desktop.c:1359
struct _DESKTOP DESKTOP
HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
Definition: desktop.c:1424
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
Definition: desktop.c:186
NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:252
VOID APIENTRY UserRedrawDesktop(VOID)
Definition: desktop.c:1599
PKEVENT gpDesktopThreadStartedEvent
Definition: desktop.c:39
static __inline ULONG_PTR DesktopHeapGetUserDelta(VOID)
Definition: desktop.h:272
HDC ScreenDeviceContext
Definition: desktop.c:36
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
BOOL IntDeRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1784
HWND FASTCALL IntGetMessageWindow(VOID)
Definition: desktop.c:1399
NTSTATUS FASTCALL IntHideDesktop(PDESKTOP Desktop)
Definition: desktop.c:1635
struct _SHELL_HOOK_WINDOW SHELL_HOOK_WINDOW
VOID NTAPI DesktopThreadMain(VOID)
Definition: desktop.c:1546
HDESK UserOpenInputDesktop(DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess)
Definition: desktop.c:2617
VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
Definition: desktop.c:1319
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1374
NTSTATUS FASTCALL co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height, BOOL Redraw)
Definition: desktop.c:1617
PTHREADINFO gptiForeground
Definition: focus.c:15
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:227
BOOL IntRegisterShellHookWindow(HWND hWnd)
Definition: desktop.c:1752
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1237
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1307
struct _SHELL_HOOK_WINDOW * PSHELL_HOOK_WINDOW
HDC FASTCALL UserGetDesktopDC(ULONG, BOOL, BOOL)
Definition: desktop.c:1574
NTSTATUS APIENTRY IntDesktopObjectParse(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: desktop.c:45
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1692
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:551
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
PCLS DesktopWindowClass
PWND FASTCALL co_GetDesktopWindow(PWND)
Definition: desktop.c:1366
static __inline PVOID DesktopHeapReAlloc(IN PDESKTOP Desktop, IN PVOID lpMem, IN SIZE_T Bytes)
Definition: desktop.h:226
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
Definition: desktop.c:1525
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:210
BOOL FASTCALL IntPaintDesktop(HDC)
Definition: desktop.c:1835
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:155
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
PDESKTOP gpdeskInputDesktop
Definition: desktop.c:35
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3260
HDC FASTCALL IntGetScreenDC(VOID)
Definition: winsta.c:371
PWND FASTCALL UserGetMessageWindow(VOID)
Definition: desktop.c:1412
static __inline PVOID DesktopHeapAddressToUser(PVOID lpMem)
Definition: desktop.h:308
BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *)
Definition: desktop.c:1439
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
static ULONG Delta
Definition: xboxvideo.c:33
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
_In_opt_ PVOID _In_opt_ PUNICODE_STRING _In_ PSECURITY_DESCRIPTOR _In_ PACCESS_STATE AccessState
Definition: sefuncs.h:417