From 786eaea3f022217e2361bd7331b0280bf9f9a4a2 Mon Sep 17 00:00:00 2001 From: David Welch Date: Fri, 1 Aug 2003 20:24:54 +0000 Subject: [PATCH] - Check the validity of the window handle before calling checking for a desktop in NtUserGetAncestor. svn path=/trunk/; revision=5372 --- reactos/subsys/win32k/include/window.h | 2 +- reactos/subsys/win32k/ntuser/callback.c | 7 ++-- reactos/subsys/win32k/ntuser/window.c | 45 ++++++++++--------------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index a1556462967..be5a2ecfcef 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -102,7 +102,7 @@ VOID FASTCALL W32kReleaseWindowObject (PWINDOW_OBJECT Window); HWND STDCALL W32kCreateDesktopWindow (PWINSTATION_OBJECT WindowStation, PWNDCLASS_OBJECT DesktopClass, ULONG Width, ULONG Height); -BOOL FASTCALL W32kIsDesktopWindow (HWND hWnd); +BOOL FASTCALL W32kIsDesktopWindow (PWINDOW_OBJECT Window); HWND FASTCALL W32kGetActiveWindow (VOID); BOOL FASTCALL W32kIsWindowVisible (HWND Wnd); BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child); diff --git a/reactos/subsys/win32k/ntuser/callback.c b/reactos/subsys/win32k/ntuser/callback.c index fa595315a75..b83cc01fdbf 100644 --- a/reactos/subsys/win32k/ntuser/callback.c +++ b/reactos/subsys/win32k/ntuser/callback.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: callback.c,v 1.10 2003/06/05 03:55:36 mdill Exp $ +/* $Id: callback.c,v 1.11 2003/08/01 20:24:54 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -176,11 +176,14 @@ W32kCallWindowProc(WNDPROC Proc, NTSTATUS Status; PVOID ResultPointer; ULONG ResultLength; + PWINDOW_OBJECT WindowObject = W32kGetWindowObject(Wnd); - if (W32kIsDesktopWindow(Wnd)) + if (W32kIsDesktopWindow(WindowObject)) { + W32kReleaseWindowObject(WindowObject); return(W32kDesktopWindowProc(Wnd, Message, wParam, lParam)); } + W32kReleaseWindowObject(WindowObject); Arguments.Proc = Proc; Arguments.Wnd = Wnd; diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 1209f218caa..afd4310a42c 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.73 2003/08/01 14:44:03 dwelch Exp $ +/* $Id: window.c,v 1.74 2003/08/01 20:24:54 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -69,52 +69,44 @@ static LIST_ENTRY RegisteredMessageListHead; HWND STDCALL NtUserGetAncestor(HWND hWnd, UINT Flags) { - if (W32kIsDesktopWindow(hWnd)) + PWINDOW_OBJECT WindowObject; + WindowObject = W32kGetWindowObject(hWnd); + if (WindowObject == NULL) + { + return(NULL); + } + if (W32kIsDesktopWindow(WindowObject)) { return(NULL); } if (Flags & GA_PARENT) - { - PWINDOW_OBJECT Window; + { HWND hParent; - Window = W32kGetWindowObject(hWnd); - if (Window == NULL) + if (WindowObject->Parent == NULL) { - return(NULL); - } - - if (Window->Parent == NULL) - { - W32kReleaseWindowObject(Window); + W32kReleaseWindowObject(WindowObject); } - hParent = Window->Parent->Self; + hParent = WindowObject->Parent->Self; - W32kReleaseWindowObject(Window); + W32kReleaseWindowObject(WindowObject); return(hParent); } else if (Flags & GA_ROOT) { - PWINDOW_OBJECT Window; PWINDOW_OBJECT pChainEnumerator; HWND hRoot; - Window = W32kGetWindowObject(hWnd); - if(Window == NULL) - { - return(NULL); - } - - pChainEnumerator = Window; - while(!W32kIsDesktopWindow(pChainEnumerator->Parent->Self)) + pChainEnumerator = WindowObject; + while(!W32kIsDesktopWindow(pChainEnumerator->Parent)) { pChainEnumerator = pChainEnumerator->Parent; } hRoot = pChainEnumerator->Self; - W32kReleaseWindowObject(Window); + W32kReleaseWindowObject(WindowObject); return(hRoot); } @@ -228,13 +220,10 @@ W32kIsWindowVisible(HWND Wnd) } BOOL FASTCALL -W32kIsDesktopWindow(HWND hWnd) +W32kIsDesktopWindow(PWINDOW_OBJECT WindowObject) { - PWINDOW_OBJECT WindowObject; BOOL IsDesktop; - WindowObject = W32kGetWindowObject(hWnd); IsDesktop = WindowObject->Parent == NULL; - W32kReleaseWindowObject(WindowObject); return(IsDesktop); }