2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2003-12-07 19:29:33 +00:00
|
|
|
|
|
|
|
#include "msgqueue.h"
|
|
|
|
#include "window.h"
|
|
|
|
|
2008-10-17 13:09:56 +00:00
|
|
|
typedef struct _DESKTOP
|
2005-06-25 20:05:56 +00:00
|
|
|
{
|
2010-01-14 00:43:54 +00:00
|
|
|
PDESKTOPINFO pDeskInfo;
|
2005-06-25 20:05:56 +00:00
|
|
|
LIST_ENTRY ListEntry;
|
2010-01-14 02:52:12 +00:00
|
|
|
/* Pointer to the associated window station. */
|
|
|
|
struct _WINSTATION_OBJECT *rpwinstaParent;
|
2010-01-14 00:43:54 +00:00
|
|
|
PWND spwndForeground;
|
|
|
|
PWND spwndTray;
|
|
|
|
PWND spwndMessage;
|
|
|
|
PWND spwndTooltip;
|
|
|
|
PSECTION_OBJECT hsectionDesktop;
|
|
|
|
PWIN32HEAP pheapDesktop;
|
|
|
|
ULONG_PTR ulHeapSize;
|
2008-10-17 21:07:24 +00:00
|
|
|
LIST_ENTRY PtiList;
|
2010-01-14 00:43:54 +00:00
|
|
|
/* use for tracking mouse moves. */
|
|
|
|
PWND spwndTrack;
|
|
|
|
DWORD htEx;
|
|
|
|
RECT rcMouseHover;
|
|
|
|
DWORD dwMouseHoverTime;
|
2008-10-17 21:07:24 +00:00
|
|
|
|
2010-01-14 00:43:54 +00:00
|
|
|
/* ReactOS */
|
2005-06-25 20:05:56 +00:00
|
|
|
/* Pointer to the active queue. */
|
|
|
|
PVOID ActiveMessageQueue;
|
|
|
|
/* Handle of the desktop window. */
|
|
|
|
HANDLE DesktopWindow;
|
|
|
|
/* Thread blocking input */
|
|
|
|
PVOID BlockInputThread;
|
|
|
|
LIST_ENTRY ShellHookWindows;
|
2008-10-17 13:09:56 +00:00
|
|
|
} DESKTOP, *PDESKTOP;
|
2005-06-25 20:05:56 +00:00
|
|
|
|
2008-10-17 13:09:56 +00:00
|
|
|
extern PDESKTOP InputDesktop;
|
2005-05-08 02:11:54 +00:00
|
|
|
extern HDESK InputDesktopHandle;
|
2009-07-22 05:23:08 +00:00
|
|
|
extern PCLS DesktopWindowClass;
|
2003-12-07 19:29:33 +00:00
|
|
|
extern HDC ScreenDeviceContext;
|
2004-12-06 02:23:05 +00:00
|
|
|
extern BOOL g_PaintDesktopVersion;
|
2003-12-07 19:29:33 +00:00
|
|
|
|
2005-03-13 23:08:51 +00:00
|
|
|
typedef struct _SHELL_HOOK_WINDOW
|
|
|
|
{
|
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
HWND hWnd;
|
|
|
|
} SHELL_HOOK_WINDOW, *PSHELL_HOOK_WINDOW;
|
|
|
|
|
2010-11-03 00:51:19 +00:00
|
|
|
INIT_FUNCTION
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2003-12-07 19:29:33 +00:00
|
|
|
InitDesktopImpl(VOID);
|
|
|
|
|
|
|
|
NTSTATUS FASTCALL
|
|
|
|
CleanupDesktopImpl(VOID);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-05-25 19:30:09 +00:00
|
|
|
NTSTATUS
|
2008-11-29 22:48:58 +00:00
|
|
|
APIENTRY
|
2006-05-25 19:30:09 +00:00
|
|
|
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);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
VOID APIENTRY
|
2006-05-25 20:03:13 +00:00
|
|
|
IntDesktopObjectDelete(PWIN32_DELETEMETHOD_PARAMETERS Parameters);
|
2005-03-12 14:15:49 +00:00
|
|
|
|
2003-12-07 19:29:33 +00:00
|
|
|
LRESULT CALLBACK
|
|
|
|
IntDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
|
|
|
HDC FASTCALL
|
|
|
|
IntGetScreenDC(VOID);
|
|
|
|
|
2003-12-12 18:18:21 +00:00
|
|
|
HWND FASTCALL
|
|
|
|
IntGetDesktopWindow (VOID);
|
|
|
|
|
2010-10-11 03:41:41 +00:00
|
|
|
PWND FASTCALL
|
2005-09-05 21:19:23 +00:00
|
|
|
UserGetDesktopWindow(VOID);
|
|
|
|
|
2004-07-09 20:57:38 +00:00
|
|
|
HWND FASTCALL
|
|
|
|
IntGetCurrentThreadDesktopWindow(VOID);
|
|
|
|
|
2003-12-07 19:29:33 +00:00
|
|
|
PUSER_MESSAGE_QUEUE FASTCALL
|
|
|
|
IntGetFocusMessageQueue(VOID);
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue);
|
|
|
|
|
2008-10-17 13:09:56 +00:00
|
|
|
PDESKTOP FASTCALL
|
2003-12-07 19:29:33 +00:00
|
|
|
IntGetActiveDesktop(VOID);
|
|
|
|
|
2003-12-07 23:02:57 +00:00
|
|
|
NTSTATUS FASTCALL
|
2008-10-17 13:09:56 +00:00
|
|
|
co_IntShowDesktop(PDESKTOP Desktop, ULONG Width, ULONG Height);
|
2003-12-07 23:02:57 +00:00
|
|
|
|
|
|
|
NTSTATUS FASTCALL
|
2008-10-17 13:09:56 +00:00
|
|
|
IntHideDesktop(PDESKTOP Desktop);
|
2003-12-07 23:02:57 +00:00
|
|
|
|
2004-05-05 22:47:06 +00:00
|
|
|
HDESK FASTCALL
|
2008-10-17 13:09:56 +00:00
|
|
|
IntGetDesktopObjectHandle(PDESKTOP DesktopObject);
|
2004-05-05 22:47:06 +00:00
|
|
|
|
2008-10-17 13:09:56 +00:00
|
|
|
BOOL IntSetThreadDesktop(IN PDESKTOP DesktopObject,
|
2006-04-15 10:41:58 +00:00
|
|
|
IN BOOL FreeOnFailure);
|
2006-04-05 08:05:55 +00:00
|
|
|
|
2004-05-05 22:47:06 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
IntValidateDesktopHandle(
|
|
|
|
HDESK Desktop,
|
|
|
|
KPROCESSOR_MODE AccessMode,
|
|
|
|
ACCESS_MASK DesiredAccess,
|
2008-10-17 13:09:56 +00:00
|
|
|
PDESKTOP *Object);
|
2004-11-20 16:46:06 +00:00
|
|
|
NTSTATUS FASTCALL
|
|
|
|
IntParseDesktopPath(PEPROCESS Process,
|
|
|
|
PUNICODE_STRING DesktopPath,
|
|
|
|
HWINSTA *hWinSta,
|
|
|
|
HDESK *hDesktop);
|
2009-07-02 19:09:32 +00:00
|
|
|
BOOL FASTCALL IntDesktopUpdatePerUserSettings(BOOL bEnable);
|
2008-05-05 17:45:20 +00:00
|
|
|
VOID APIENTRY UserRedrawDesktop(VOID);
|
2005-03-13 23:08:51 +00:00
|
|
|
BOOL IntRegisterShellHookWindow(HWND hWnd);
|
|
|
|
BOOL IntDeRegisterShellHookWindow(HWND hWnd);
|
2005-09-05 21:19:23 +00:00
|
|
|
VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam);
|
2009-07-02 19:09:32 +00:00
|
|
|
HDC FASTCALL UserGetDesktopDC(ULONG,BOOL,BOOL);
|
2005-03-13 23:08:51 +00:00
|
|
|
|
2004-04-29 20:26:35 +00:00
|
|
|
#define IntIsActiveDesktop(Desktop) \
|
2010-01-14 02:52:12 +00:00
|
|
|
((Desktop)->rpwinstaParent->ActiveDesktop == (Desktop))
|
2004-04-29 20:26:35 +00:00
|
|
|
|
2006-05-25 19:30:09 +00:00
|
|
|
#define GET_DESKTOP_NAME(d) \
|
|
|
|
OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d)) ? \
|
|
|
|
&(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d))->Name) : \
|
|
|
|
NULL
|
|
|
|
|
2009-07-01 17:19:16 +00:00
|
|
|
HWND FASTCALL IntGetMessageWindow(VOID);
|
2006-05-25 19:30:09 +00:00
|
|
|
|
2006-04-05 08:05:55 +00:00
|
|
|
static __inline PVOID
|
2008-10-19 01:06:30 +00:00
|
|
|
DesktopHeapAlloc(IN PDESKTOP Desktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
IN SIZE_T Bytes)
|
|
|
|
{
|
2008-10-19 02:05:41 +00:00
|
|
|
return RtlAllocateHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
Bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline BOOL
|
2008-10-19 01:06:30 +00:00
|
|
|
DesktopHeapFree(IN PDESKTOP Desktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
IN PVOID lpMem)
|
|
|
|
{
|
2008-10-19 02:05:41 +00:00
|
|
|
return RtlFreeHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
lpMem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline PVOID
|
2008-10-19 01:06:30 +00:00
|
|
|
DesktopHeapReAlloc(IN PDESKTOP Desktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
IN PVOID lpMem,
|
|
|
|
IN SIZE_T Bytes)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
/* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
|
2008-10-19 02:05:41 +00:00
|
|
|
return RtlReAllocateHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
lpMem,
|
|
|
|
Bytes);
|
|
|
|
#else
|
|
|
|
SIZE_T PrevSize;
|
|
|
|
PVOID pNew;
|
|
|
|
|
2008-10-19 02:05:41 +00:00
|
|
|
PrevSize = RtlSizeHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
lpMem);
|
|
|
|
|
|
|
|
if (PrevSize == Bytes)
|
|
|
|
return lpMem;
|
|
|
|
|
2008-10-19 02:05:41 +00:00
|
|
|
pNew = RtlAllocateHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
Bytes);
|
|
|
|
if (pNew != NULL)
|
|
|
|
{
|
|
|
|
if (PrevSize < Bytes)
|
|
|
|
Bytes = PrevSize;
|
|
|
|
|
|
|
|
RtlCopyMemory(pNew,
|
|
|
|
lpMem,
|
|
|
|
Bytes);
|
|
|
|
|
2008-10-19 02:05:41 +00:00
|
|
|
RtlFreeHeap(Desktop->pheapDesktop,
|
2006-04-05 08:05:55 +00:00
|
|
|
HEAP_NO_SERIALIZE,
|
|
|
|
lpMem);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pNew;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline ULONG_PTR
|
|
|
|
DesktopHeapGetUserDelta(VOID)
|
|
|
|
{
|
|
|
|
PW32HEAP_USER_MAPPING Mapping;
|
2008-10-16 17:52:38 +00:00
|
|
|
PTHREADINFO pti;
|
2009-07-26 16:17:50 +00:00
|
|
|
PPROCESSINFO W32Process;
|
2008-10-19 02:05:41 +00:00
|
|
|
PWIN32HEAP pheapDesktop;
|
2006-04-05 08:05:55 +00:00
|
|
|
ULONG_PTR Delta = 0;
|
|
|
|
|
2008-10-16 17:52:38 +00:00
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
2010-01-14 02:52:12 +00:00
|
|
|
if (!pti->rpdesk)
|
2008-10-17 21:07:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-01-14 02:52:12 +00:00
|
|
|
pheapDesktop = pti->rpdesk->pheapDesktop;
|
2006-04-05 08:05:55 +00:00
|
|
|
|
2008-10-18 20:34:36 +00:00
|
|
|
W32Process = PsGetCurrentProcessWin32Process();
|
|
|
|
Mapping = W32Process->HeapMappings.Next;
|
2006-04-05 08:05:55 +00:00
|
|
|
while (Mapping != NULL)
|
|
|
|
{
|
2008-10-19 02:05:41 +00:00
|
|
|
if (Mapping->KernelMapping == (PVOID)pheapDesktop)
|
2006-04-05 08:05:55 +00:00
|
|
|
{
|
|
|
|
Delta = (ULONG_PTR)Mapping->KernelMapping - (ULONG_PTR)Mapping->UserMapping;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mapping = Mapping->Next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline PVOID
|
2007-11-15 19:42:41 +00:00
|
|
|
DesktopHeapAddressToUser(PVOID lpMem)
|
2006-04-05 08:05:55 +00:00
|
|
|
{
|
|
|
|
PW32HEAP_USER_MAPPING Mapping;
|
2009-07-26 16:17:50 +00:00
|
|
|
PPROCESSINFO W32Process;
|
2006-04-05 08:05:55 +00:00
|
|
|
|
2008-10-18 20:34:36 +00:00
|
|
|
W32Process = PsGetCurrentProcessWin32Process();
|
|
|
|
Mapping = W32Process->HeapMappings.Next;
|
2006-04-05 08:05:55 +00:00
|
|
|
while (Mapping != NULL)
|
|
|
|
{
|
2007-11-15 19:42:41 +00:00
|
|
|
if ((ULONG_PTR)lpMem >= (ULONG_PTR)Mapping->KernelMapping &&
|
|
|
|
(ULONG_PTR)lpMem < (ULONG_PTR)Mapping->KernelMapping + Mapping->Limit)
|
2006-04-05 08:05:55 +00:00
|
|
|
{
|
2007-11-15 19:42:41 +00:00
|
|
|
return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)Mapping->KernelMapping) +
|
2006-04-05 08:05:55 +00:00
|
|
|
(ULONG_PTR)Mapping->UserMapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
Mapping = Mapping->Next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-07 19:29:33 +00:00
|
|
|
/* EOF */
|