- Check the validity of the window handle before calling checking for

a desktop in NtUserGetAncestor.

svn path=/trunk/; revision=5372
This commit is contained in:
David Welch 2003-08-01 20:24:54 +00:00
parent ec488b1f40
commit 786eaea3f0
3 changed files with 23 additions and 31 deletions

View file

@ -102,7 +102,7 @@ VOID FASTCALL W32kReleaseWindowObject (PWINDOW_OBJECT Window);
HWND STDCALL W32kCreateDesktopWindow (PWINSTATION_OBJECT WindowStation, HWND STDCALL W32kCreateDesktopWindow (PWINSTATION_OBJECT WindowStation,
PWNDCLASS_OBJECT DesktopClass, PWNDCLASS_OBJECT DesktopClass,
ULONG Width, ULONG Height); ULONG Width, ULONG Height);
BOOL FASTCALL W32kIsDesktopWindow (HWND hWnd); BOOL FASTCALL W32kIsDesktopWindow (PWINDOW_OBJECT Window);
HWND FASTCALL W32kGetActiveWindow (VOID); HWND FASTCALL W32kGetActiveWindow (VOID);
BOOL FASTCALL W32kIsWindowVisible (HWND Wnd); BOOL FASTCALL W32kIsWindowVisible (HWND Wnd);
BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child); BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -176,11 +176,14 @@ W32kCallWindowProc(WNDPROC Proc,
NTSTATUS Status; NTSTATUS Status;
PVOID ResultPointer; PVOID ResultPointer;
ULONG ResultLength; ULONG ResultLength;
PWINDOW_OBJECT WindowObject = W32kGetWindowObject(Wnd);
if (W32kIsDesktopWindow(Wnd)) if (W32kIsDesktopWindow(WindowObject))
{ {
W32kReleaseWindowObject(WindowObject);
return(W32kDesktopWindowProc(Wnd, Message, wParam, lParam)); return(W32kDesktopWindowProc(Wnd, Message, wParam, lParam));
} }
W32kReleaseWindowObject(WindowObject);
Arguments.Proc = Proc; Arguments.Proc = Proc;
Arguments.Wnd = Wnd; Arguments.Wnd = Wnd;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -69,52 +69,44 @@ static LIST_ENTRY RegisteredMessageListHead;
HWND STDCALL HWND STDCALL
NtUserGetAncestor(HWND hWnd, UINT Flags) NtUserGetAncestor(HWND hWnd, UINT Flags)
{ {
if (W32kIsDesktopWindow(hWnd)) PWINDOW_OBJECT WindowObject;
WindowObject = W32kGetWindowObject(hWnd);
if (WindowObject == NULL)
{
return(NULL);
}
if (W32kIsDesktopWindow(WindowObject))
{ {
return(NULL); return(NULL);
} }
if (Flags & GA_PARENT) if (Flags & GA_PARENT)
{ {
PWINDOW_OBJECT Window;
HWND hParent; HWND hParent;
Window = W32kGetWindowObject(hWnd); if (WindowObject->Parent == NULL)
if (Window == NULL)
{ {
return(NULL); W32kReleaseWindowObject(WindowObject);
}
if (Window->Parent == NULL)
{
W32kReleaseWindowObject(Window);
} }
hParent = Window->Parent->Self; hParent = WindowObject->Parent->Self;
W32kReleaseWindowObject(Window); W32kReleaseWindowObject(WindowObject);
return(hParent); return(hParent);
} }
else if (Flags & GA_ROOT) else if (Flags & GA_ROOT)
{ {
PWINDOW_OBJECT Window;
PWINDOW_OBJECT pChainEnumerator; PWINDOW_OBJECT pChainEnumerator;
HWND hRoot; HWND hRoot;
Window = W32kGetWindowObject(hWnd); pChainEnumerator = WindowObject;
if(Window == NULL) while(!W32kIsDesktopWindow(pChainEnumerator->Parent))
{
return(NULL);
}
pChainEnumerator = Window;
while(!W32kIsDesktopWindow(pChainEnumerator->Parent->Self))
{ {
pChainEnumerator = pChainEnumerator->Parent; pChainEnumerator = pChainEnumerator->Parent;
} }
hRoot = pChainEnumerator->Self; hRoot = pChainEnumerator->Self;
W32kReleaseWindowObject(Window); W32kReleaseWindowObject(WindowObject);
return(hRoot); return(hRoot);
} }
@ -228,13 +220,10 @@ W32kIsWindowVisible(HWND Wnd)
} }
BOOL FASTCALL BOOL FASTCALL
W32kIsDesktopWindow(HWND hWnd) W32kIsDesktopWindow(PWINDOW_OBJECT WindowObject)
{ {
PWINDOW_OBJECT WindowObject;
BOOL IsDesktop; BOOL IsDesktop;
WindowObject = W32kGetWindowObject(hWnd);
IsDesktop = WindowObject->Parent == NULL; IsDesktop = WindowObject->Parent == NULL;
W32kReleaseWindowObject(WindowObject);
return(IsDesktop); return(IsDesktop);
} }