Author: jimtabor
Date: Wed Jul 4 22:59:27 2012
New Revision: 56832
URL:
http://svn.reactos.org/svn/reactos?rev=56832&view=rev
Log:
[Win32k]
- Fix assert with WinSnap. Added support functions to be used later.
Modified:
trunk/reactos/win32ss/user/ntuser/desktop.c
trunk/reactos/win32ss/user/ntuser/desktop.h
trunk/reactos/win32ss/user/ntuser/hook.c
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Wed Jul 4 22:59:27 2012
@@ -466,6 +466,23 @@
}
// Only one Q can have active foreground even when there are more than one desktop.
if (NewQueue) gpqForeground = pdo->ActiveMessageQueue;
+ else gpqForeground = NULL;
+}
+
+PWND FASTCALL
+IntGetThreadDesktopWindow(PTHREADINFO pti)
+{
+ if (!pti) pti = PsGetCurrentThreadWin32Thread();
+ if (pti->pDeskInfo) return pti->pDeskInfo->spwnd;
+ return NULL;
+}
+
+PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
+{
+ if (pWnd->head.rpdesk &&
+ pWnd->head.rpdesk->pDeskInfo)
+ return pWnd->head.rpdesk->pDeskInfo->spwnd;
+ return NULL;
}
HWND FASTCALL IntGetDesktopWindow(VOID)
@@ -529,6 +546,21 @@
}
/* PUBLIC FUNCTIONS ***********************************************************/
+
+LRESULT FASTCALL
+DesktopWindowProc(PWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (Msg)
+ {
+ case WM_NCCREATE:
+ if (!Wnd->fnid)
+ {
+ Wnd->fnid = FNID_DESKTOP;
+ }
+ return (LRESULT)TRUE;
+ }
+ return 0;
+}
HDC FASTCALL
UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
@@ -1335,16 +1367,17 @@
{
PDESKTOP pdesk;
NTSTATUS Status;
- HDESK hdesk;
-
- TRACE("Enter NtUserOpenInputDesktop\n");
+ HDESK hdesk = NULL;
+
+ UserEnterExclusive();
+ TRACE("Enter NtUserOpenInputDesktop InputDesktopHandle
0x%x\n",InputDesktopHandle);
/* Get a pointer to the desktop object */
Status = IntValidateDesktopHandle(InputDesktopHandle, UserMode, 0, &pdesk);
if (!NT_SUCCESS(Status))
{
- TRACE("Validation of input desktop handle (0x%X) failed\n",
InputDesktop);
- return NULL;
+ ERR("Validation of input desktop handle (0x%X) failed\n",
InputDesktopHandle);
+ goto Exit;
}
/* Create a new handle to the object */
@@ -1363,10 +1396,11 @@
{
ERR("Failed to open input desktop object\n");
SetLastNtError(Status);
- return NULL;
- }
-
+ goto Exit;
+ }
+Exit:
TRACE("NtUserOpenInputDesktop returning 0x%x\n",hdesk);
+ UserLeave();
return hdesk;
}
@@ -1397,15 +1431,12 @@
{
PDESKTOP pdesk;
NTSTATUS Status;
- PTHREADINFO pti;
DECLARE_RETURN(BOOL);
-
- pti = PsGetCurrentThreadWin32Thread();
TRACE("NtUserCloseDesktop called (0x%x)\n", hDesktop);
UserEnterExclusive();
- if( hDesktop == pti->hdesk || hDesktop == pti->ppi->hdeskStartup)
+ if( hDesktop == gptiCurrent->hdesk || hDesktop ==
gptiCurrent->ppi->hdeskStartup)
{
ERR("Attempted to close thread desktop\n");
EngSetLastError(ERROR_BUSY);
@@ -1526,7 +1557,7 @@
/* Set the global state. */
InputDesktop = pdesk;
InputDesktopHandle = hdesk;
-
+ TRACE("SwitchDesktop InputDesktopHandle 0x%x\n",InputDesktopHandle);
ObDereferenceObject(pdesk);
RETURN(TRUE);
@@ -1780,6 +1811,13 @@
return FALSE;
}
+ /* Desktop is being re-set so clear out foreground. */
+ if (pti->rpdesk != pdesk && pti->MessageQueue == gpqForeground)
+ {
+ // Like above, there shouldn't be any windows, hooks or anything active on
this threads desktop!
+ IntSetFocusMessageQueue(NULL);
+ }
+
/* Before doing the switch, map the new desktop heap and allocate the new pcti */
if(pdesk != NULL)
{
@@ -1846,6 +1884,8 @@
else
{
RtlZeroMemory(pctiNew, sizeof(CLIENTTHREADINFO));
+ pci->fsHooks = pti->fsHooks;
+ pci->dwTIFlags = pti->TIF_flags;
}
}
else
Modified: trunk/reactos/win32ss/user/ntuser/desktop.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] Wed Jul 4 22:59:27 2012
@@ -275,4 +275,8 @@
return NULL;
}
+PWND FASTCALL IntGetThreadDesktopWindow(PTHREADINFO);
+PWND FASTCALL co_GetDesktopWindow(PWND);
+
+LRESULT FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM);
/* EOF */
Modified: trunk/reactos/win32ss/user/ntuser/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/hook.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] Wed Jul 4 22:59:27 2012
@@ -1048,7 +1048,7 @@
pti->fsHooks &= ~HOOKID_TO_FLAG(HookId);
_SEH2_TRY
{
- GetWin32ClientInfo()->fsHooks = pti->fsHooks;
+ pti->pClientInfo->fsHooks = pti->fsHooks;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -1106,6 +1106,7 @@
}
}
pti->fsHooks = 0;
+ pti->pClientInfo->fsHooks = 0;
}
// Global search based on Thread and cleanup.
if (pdo->pDeskInfo->fsHooks)