From 5ec99910727cf57d55a1757a5bd2cc5c1fe6c6fc Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Thu, 3 Jun 2010 16:12:43 +0000 Subject: [PATCH] [user32] - Remove a reactos only export (PrivateCsrssInitialized) - Don't call NtUserGetClassLong - Move implementation of AnyPopup to user mode - Fix a small bug in GetParent and in IsChild [csrss] - Don't call PrivateCsrssInitialized [win32k] - Call CsrInit in NtUserInitialize so we can remove PrivateCsrssInitialized - Romove a reactos only syscall (NtUserGetClassLong) - Remove UserGetClassLongPtr, UserGetWindow, UserGetWindowLong, IntGetOwner. Instead access objects directly - In WINDOW_OBJECT store pointer to the ownder window instead of a handle svn path=/trunk/; revision=47544 --- reactos/dll/win32/user32/include/user32p.h | 3 - reactos/dll/win32/user32/misc/misc.c | 7 - reactos/dll/win32/user32/user32.pspec | 1 - reactos/dll/win32/user32/windows/class.c | 43 ++- reactos/dll/win32/user32/windows/window.c | 35 ++- reactos/include/reactos/win32k/ntuser.h | 1 - .../subsystems/win32/csrss/win32csr/dllmain.c | 3 - .../subsystems/win32/win32k/include/class.h | 5 - .../win32/win32k/include/userfuncs.h | 4 - .../subsystems/win32/win32k/include/window.h | 12 +- .../subsystems/win32/win32k/ntuser/callproc.c | 4 +- .../subsystems/win32/win32k/ntuser/class.c | 129 --------- .../subsystems/win32/win32k/ntuser/defwnd.c | 2 +- .../subsystems/win32/win32k/ntuser/desktop.c | 2 +- .../subsystems/win32/win32k/ntuser/focus.c | 16 +- .../subsystems/win32/win32k/ntuser/ntuser.c | 2 + .../win32/win32k/ntuser/simplecall.c | 10 +- .../subsystems/win32/win32k/ntuser/window.c | 264 ++---------------- .../subsystems/win32/win32k/ntuser/winpos.c | 17 +- reactos/subsystems/win32/win32k/w32ksvc.db | 1 - 20 files changed, 102 insertions(+), 459 deletions(-) diff --git a/reactos/dll/win32/user32/include/user32p.h b/reactos/dll/win32/user32/include/user32p.h index 31f38a1a7db..1ab637eeea0 100644 --- a/reactos/dll/win32/user32/include/user32p.h +++ b/reactos/dll/win32/user32/include/user32p.h @@ -33,9 +33,6 @@ #define NtUserMsqClearWakeMask() \ NtUserCallNoParam(NOPARAM_ROUTINE_MSQCLEARWAKEMASK) -#define NtUserAnyPopup() \ - (BOOL)NtUserCallNoParam(NOPARAM_ROUTINE_ANYPOPUP) - #define NtUserValidateRgn(hWnd, hRgn) \ (BOOL)NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)hRgn, TWOPARAM_ROUTINE_VALIDATERGN) diff --git a/reactos/dll/win32/user32/misc/misc.c b/reactos/dll/win32/user32/misc/misc.c index 4d786c51e52..32438366a5e 100644 --- a/reactos/dll/win32/user32/misc/misc.c +++ b/reactos/dll/win32/user32/misc/misc.c @@ -45,13 +45,6 @@ PrivateCsrssManualGuiCheck(LONG Check) NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK); } -VOID -WINAPI -PrivateCsrssInitialized(VOID) -{ - NtUserCallNoParam(NOPARAM_ROUTINE_CSRSS_INITIALIZED); -} - /* * @implemented diff --git a/reactos/dll/win32/user32/user32.pspec b/reactos/dll/win32/user32/user32.pspec index 45eb26b2b64..d58fb951d1b 100644 --- a/reactos/dll/win32/user32/user32.pspec +++ b/reactos/dll/win32/user32/user32.pspec @@ -750,7 +750,6 @@ ; ROS specific exports @ stdcall PrivateCsrssManualGuiCheck(long) -@ stdcall PrivateCsrssInitialized() ; Functions exported by Win Vista @ stdcall SetProcessDPIAware() diff --git a/reactos/dll/win32/user32/windows/class.c b/reactos/dll/win32/user32/windows/class.c index f546aa45952..1c66fd7606f 100644 --- a/reactos/dll/win32/user32/windows/class.c +++ b/reactos/dll/win32/user32/windows/class.c @@ -423,22 +423,15 @@ GetClassLongA(HWND hWnd, int nIndex) } else { - /* This is a race condition! Call win32k to make sure we're getting - the correct result */ - Wnd = NULL; /* Make sure we call NtUserGetClassLong */ - WARN("Invalid class for hwnd 0x%p!\n", hWnd); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Wnd = NULL; /* Make sure we call NtUserGetClassLong */ + Ret = 0; } _SEH2_END; - if (Wnd == NULL) - Ret = NtUserGetClassLong(hWnd, nIndex, TRUE); - return Ret; } @@ -534,22 +527,14 @@ GetClassLongW ( HWND hWnd, int nIndex ) } else { - /* This is a race condition! Call win32k to make sure we're getting - the correct result */ - Wnd = NULL; /* Make sure we call NtUserGetClassLong */ - WARN("Invalid class for hwnd 0x%p!\n", hWnd); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Wnd = NULL; /* Make sure we call NtUserGetClassLong */ } _SEH2_END; - if (Wnd == NULL) - Ret = NtUserGetClassLong(hWnd, nIndex, FALSE); - return Ret; } @@ -617,18 +602,28 @@ GetClassNameW( WORD WINAPI GetClassWord( - HWND hWnd, - int nIndex) -/* - * NOTE: Obsoleted in 32-bit windows - */ + HWND hwnd, + int offset) { - TRACE("%p %x\n", hWnd, nIndex); + PWND Wnd; + PCLS class; + WORD retvalue = 0; - if ((nIndex < 0) && (nIndex != GCW_ATOM)) + if (offset < 0) return GetClassLongA( hwnd, offset ); + + Wnd = ValidateHwnd(hwnd); + if (!Wnd) return 0; - return (WORD) NtUserGetClassLong ( hWnd, nIndex, TRUE ); + class = DesktopPtrToUser(Wnd->pcls); + if (class == NULL) return 0; + + if (offset <= class->cbclsExtra - sizeof(WORD)) + memcpy( &retvalue, (char *)(class + 1) + offset, sizeof(retvalue) ); + else + SetLastError( ERROR_INVALID_INDEX ); + + return retvalue; } diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index e0c657cdfa9..04533ff0aa1 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1030,16 +1030,16 @@ GetParent(HWND hWnd) _SEH2_TRY { WndParent = NULL; - if (Wnd->style & WS_CHILD) - { - if (Wnd->spwndParent != NULL) - WndParent = DesktopPtrToUser(Wnd->spwndParent); - } - else if (Wnd->style & WS_POPUP) + if (Wnd->style & WS_POPUP) { if (Wnd->spwndOwner != NULL) WndParent = DesktopPtrToUser(Wnd->spwndOwner); } + else if (Wnd->style & WS_CHILD) + { + if (Wnd->spwndParent != NULL) + WndParent = DesktopPtrToUser(Wnd->spwndParent); + } if (WndParent != NULL) Ret = UserHMGetHandle(WndParent); @@ -1464,7 +1464,7 @@ BOOL WINAPI IsChild(HWND hWndParent, HWND hWnd) { - PWND WndParent, Wnd; + PWND WndParent, DesktopWnd, Wnd; BOOL Ret = FALSE; WndParent = ValidateHwnd(hWndParent); @@ -1474,6 +1474,10 @@ IsChild(HWND hWndParent, if (!Wnd) return FALSE; + DesktopWnd = GetThreadDesktopWnd(); + if (!DesktopWnd) + return FALSE; + _SEH2_TRY { while (Wnd != NULL) @@ -1481,6 +1485,10 @@ IsChild(HWND hWndParent, if (Wnd->spwndParent != NULL) { Wnd = DesktopPtrToUser(Wnd->spwndParent); + + if(Wnd == DesktopWnd) + Wnd = NULL; + if (Wnd == WndParent) { Ret = TRUE; @@ -2062,7 +2070,18 @@ ScrollWindowEx(HWND hWnd, BOOL WINAPI AnyPopup(VOID) { - return NtUserAnyPopup(); + int i; + BOOL retvalue; + HWND *list = WIN_ListChildren( GetDesktopWindow() ); + + if (!list) return FALSE; + for (i = 0; list[i]; i++) + { + if (IsWindowVisible( list[i] ) && GetWindow( list[i], GW_OWNER )) break; + } + retvalue = (list[i] != 0); + HeapFree( GetProcessHeap(), 0, list ); + return retvalue; } /* diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 0d6d7811db7..007fa887200 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -3135,7 +3135,6 @@ typedef struct tagKMDDELPARAM #define NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO 0xffff0005 #define NOPARAM_ROUTINE_ANYPOPUP 0xffff0006 -#define NOPARAM_ROUTINE_CSRSS_INITIALIZED 0xffff0007 #define ONEPARAM_ROUTINE_CSRSS_GUICHECK 0xffff0008 #define ONEPARAM_ROUTINE_SWITCHCARETSHOWING 0xfffe0008 #define ONEPARAM_ROUTINE_ISWINDOWINDESTROY 0xfffe000c diff --git a/reactos/subsystems/win32/csrss/win32csr/dllmain.c b/reactos/subsystems/win32/csrss/win32csr/dllmain.c index 7d8b7e2aaf8..640f0fb163e 100644 --- a/reactos/subsystems/win32/csrss/win32csr/dllmain.c +++ b/reactos/subsystems/win32/csrss/win32csr/dllmain.c @@ -13,7 +13,6 @@ /* Not defined in any header file */ extern VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check); -extern VOID WINAPI PrivateCsrssInitialized(); extern VOID WINAPI InitializeAppSwitchHook(); /* GLOBALS *******************************************************************/ @@ -111,8 +110,6 @@ Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, static BOOL WINAPI Win32CsrInitComplete(void) { - PrivateCsrssInitialized(); - return TRUE; } diff --git a/reactos/subsystems/win32/win32k/include/class.h b/reactos/subsystems/win32/win32k/include/class.h index 2c8d0b0d0c1..27b3baf1f83 100644 --- a/reactos/subsystems/win32/win32k/include/class.h +++ b/reactos/subsystems/win32/win32k/include/class.h @@ -65,11 +65,6 @@ UserUnregisterClass(IN PUNICODE_STRING ClassName, IN HINSTANCE hInstance, OUT PCLSMENUNAME pClassMenuName); -ULONG_PTR -UserGetClassLongPtr(IN PCLS Class, - IN INT Index, - IN BOOL Ansi); - RTL_ATOM IntGetClassAtom(IN PUNICODE_STRING ClassName, IN HINSTANCE hInstance OPTIONAL, diff --git a/reactos/subsystems/win32/win32k/include/userfuncs.h b/reactos/subsystems/win32/win32k/include/userfuncs.h index 7ad47e625bc..d31e66faea9 100644 --- a/reactos/subsystems/win32/win32k/include/userfuncs.h +++ b/reactos/subsystems/win32/win32k/include/userfuncs.h @@ -122,15 +122,11 @@ co_DestroyThreadWindows(struct _ETHREAD *Thread); HWND FASTCALL UserGetShellWindow(VOID); -HWND FASTCALL UserGetWindow(HWND hWnd, UINT Relationship); - HDC FASTCALL UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags); BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Wnd); -LONG FASTCALL UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi); - PWINDOW_OBJECT FASTCALL UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type); /*************** MENU.C ***************/ diff --git a/reactos/subsystems/win32/win32k/include/window.h b/reactos/subsystems/win32/win32k/include/window.h index 14cac125fef..79a8df2d003 100644 --- a/reactos/subsystems/win32/win32k/include/window.h +++ b/reactos/subsystems/win32/win32k/include/window.h @@ -37,11 +37,8 @@ typedef struct _WINDOW_OBJECT struct _WINDOW_OBJECT* spwndChild; struct _WINDOW_OBJECT* spwndNext; struct _WINDOW_OBJECT* spwndPrev; - /* Handle to the parent window. */ struct _WINDOW_OBJECT* spwndParent; - /* Handle to the owner window. */ - HWND hOwner; // Use spwndOwner - + struct _WINDOW_OBJECT* spwndOwner; /* Scrollbar info */ PSBINFOEX pSBInfo; // convert to PSBINFO @@ -125,10 +122,6 @@ IntGetAncestor(PWINDOW_OBJECT Wnd, UINT Type); PWINDOW_OBJECT FASTCALL IntGetParent(PWINDOW_OBJECT Wnd); -PWINDOW_OBJECT FASTCALL -IntGetOwner(PWINDOW_OBJECT Wnd); - - INT FASTCALL IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn); @@ -141,9 +134,6 @@ IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi); VOID FASTCALL IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, UINT *cx, UINT *cy); -BOOL FASTCALL -IntAnyPopup(VOID); - BOOL FASTCALL IntIsWindowInDestroy(PWINDOW_OBJECT Window); diff --git a/reactos/subsystems/win32/win32k/ntuser/callproc.c b/reactos/subsystems/win32/win32k/ntuser/callproc.c index dc8496dd431..f2298256d08 100644 --- a/reactos/subsystems/win32/win32k/ntuser/callproc.c +++ b/reactos/subsystems/win32/win32k/ntuser/callproc.c @@ -185,9 +185,7 @@ UserGetCPD( Example: If pWnd is created from Ansi and lpfnXxyz is assumed to be Ansi, caller will ask for Unicode Proc return Proc or CallProcData handle. - - This function should replaced NtUserGetClassLong and NtUserGetWindowLong. - */ +*/ ULONG_PTR APIENTRY NtUserGetCPD( diff --git a/reactos/subsystems/win32/win32k/ntuser/class.c b/reactos/subsystems/win32/win32k/ntuser/class.c index c1726a69d8c..814aadb67dc 100644 --- a/reactos/subsystems/win32/win32k/ntuser/class.c +++ b/reactos/subsystems/win32/win32k/ntuser/class.c @@ -1515,96 +1515,6 @@ UserGetClassName(IN PCLS Class, return Ret; } -ULONG_PTR -UserGetClassLongPtr(IN PCLS Class, - IN INT Index, - IN BOOL Ansi) -{ - ULONG_PTR Ret = 0; - - if (Index >= 0) - { - PULONG_PTR Data; - - TRACE("GetClassLong(%d)\n", Index); - if (Index + sizeof(ULONG_PTR) < Index || - Index + sizeof(ULONG_PTR) > Class->cbclsExtra) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - - Data = (PULONG_PTR)((ULONG_PTR)(Class + 1) + Index); - - /* FIXME - Data might be a unaligned pointer! Might be a problem on - certain architectures, maybe using RtlCopyMemory is a - better choice for those architectures! */ - - TRACE("Result: %x\n", Ret); - return *Data; - } - - switch (Index) - { - case GCL_CBWNDEXTRA: - Ret = (ULONG_PTR)Class->cbwndExtra; - break; - - case GCL_CBCLSEXTRA: - Ret = (ULONG_PTR)Class->cbclsExtra; - break; - - case GCLP_HBRBACKGROUND: - Ret = (ULONG_PTR)Class->hbrBackground; - break; - - case GCLP_HCURSOR: - /* FIXME - get handle from pointer to CURSOR object */ - Ret = (ULONG_PTR)Class->hCursor; - break; - - case GCLP_HICON: - /* FIXME - get handle from pointer to ICON object */ - Ret = (ULONG_PTR)Class->hIcon; - break; - - case GCLP_HICONSM: - /* FIXME - get handle from pointer to ICON object */ - Ret = (ULONG_PTR)Class->hIconSm; - break; - - case GCLP_HMODULE: - Ret = (ULONG_PTR)Class->hModule; - break; - - case GCLP_MENUNAME: - /* NOTE: Returns pointer in kernel heap! */ - if (Ansi) - Ret = (ULONG_PTR)Class->lpszClientAnsiMenuName; - else - Ret = (ULONG_PTR)Class->lpszClientUnicodeMenuName; - break; - - case GCL_STYLE: - Ret = (ULONG_PTR)Class->style; - break; - - case GCLP_WNDPROC: - Ret = (ULONG_PTR)IntGetClassWndProc(Class, Ansi); - break; - - case GCW_ATOM: - Ret = (ULONG_PTR)Class->atomClassName; - break; - - default: - SetLastWin32Error(ERROR_INVALID_INDEX); - break; - } - - return Ret; -} - static BOOL IntSetClassMenuName(IN PCLS Class, IN PUNICODE_STRING MenuName) @@ -2190,45 +2100,6 @@ InvalidParameter: return Ret; } -ULONG_PTR APIENTRY -NtUserGetClassLong(IN HWND hWnd, - IN INT Offset, - IN BOOL Ansi) -{ - PWINDOW_OBJECT Window; - ULONG_PTR Ret = 0; - - if (Offset != GCLP_WNDPROC) - { - UserEnterShared(); - } - else - { - UserEnterExclusive(); - } - - Window = UserGetWindowObject(hWnd); - if (Window != NULL) - { - Ret = UserGetClassLongPtr(Window->Wnd->pcls, - Offset, - Ansi); - - if ( Ret != 0 && - Offset == GCLP_MENUNAME && - Window->Wnd->pcls->MenuNameIsString) - { - Ret = (ULONG_PTR)UserHeapAddressToUser((PVOID)Ret); - } - } - - UserLeave(); - - return Ret; -} - - - ULONG_PTR APIENTRY NtUserSetClassLong(HWND hWnd, INT Offset, diff --git a/reactos/subsystems/win32/win32k/ntuser/defwnd.c b/reactos/subsystems/win32/win32k/ntuser/defwnd.c index 6cf4fd010c6..afc60e852ae 100644 --- a/reactos/subsystems/win32/win32k/ntuser/defwnd.c +++ b/reactos/subsystems/win32/win32k/ntuser/defwnd.c @@ -129,7 +129,7 @@ IntDefWindowProc( { if ((Wnd->style & WS_VISIBLE) && wParam) break; if (!(Wnd->style & WS_VISIBLE) && !wParam) break; - if (!Window->hOwner) break; + if (!Window->spwndOwner) break; if (LOWORD(lParam)) { if (wParam) diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 6bfe10b0239..57a5be135e7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1423,7 +1423,7 @@ NtUserPaintDesktop(HDC hDC) RETURN(FALSE); } - DesktopBrush = (HBRUSH)UserGetClassLongPtr(WndDesktop->Wnd->pcls, GCL_HBRBACKGROUND, FALSE); + DesktopBrush = (HBRUSH)WndDesktop->Wnd->pcls->hbrBackground; /* diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index ee9c2ff93ad..59f364ed548 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -51,12 +51,14 @@ IntGetThreadFocusWindow(VOID) VOID FASTCALL co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd) { - if (hWndPrev) + PWINDOW_OBJECT WndPrev ; + + if (hWndPrev && (WndPrev = UserGetWindowObject(hWndPrev))) { co_IntSendMessageNoWait(hWndPrev, WM_NCACTIVATE, FALSE, 0); co_IntSendMessageNoWait(hWndPrev, WM_ACTIVATE, - MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE), - (LPARAM)hWnd); + MAKEWPARAM(WA_INACTIVE, WndPrev->Wnd->style & WS_MINIMIZE), + (LPARAM)hWnd); } } @@ -83,11 +85,11 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) 0); } - if (UserGetWindow(hWnd, GW_HWNDPREV) != NULL) + if (Window->spwndPrev != NULL) co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); - if (!IntGetOwner(Window) && !IntGetParent(Window)) + if (!Window->spwndOwner && !IntGetParent(Window)) { co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd); } @@ -153,7 +155,7 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) /* FIXME: WA_CLICKACTIVE */ co_IntSendMessageNoWait(hWnd, WM_ACTIVATE, MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, - UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), + Window->Wnd->style & WS_MINIMIZE), (LPARAM)hWndPrev); } } @@ -184,7 +186,7 @@ IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner) for(Child = Root->spwndChild; Child; Child = Child->spwndNext) { - OwnerWnd = UserGetWindowObject(Child->hOwner); + OwnerWnd = Child->spwndOwner; if(!OwnerWnd) continue; diff --git a/reactos/subsystems/win32/win32k/ntuser/ntuser.c b/reactos/subsystems/win32/win32k/ntuser/ntuser.c index 569acfdc54c..b8f17849195 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntuser.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntuser.c @@ -124,6 +124,8 @@ UserInitialize( NtUserUpdatePerUserSystemParameters(0, TRUE); + CsrInit(); + return STATUS_SUCCESS; } diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index cdd4a22a6b1..f46a75da2aa 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -110,14 +110,6 @@ NtUserCallNoParam(DWORD Routine) Result = (DWORD_PTR)MsqGetMessageExtraInfo(); break; - case NOPARAM_ROUTINE_ANYPOPUP: - Result = (DWORD_PTR)IntAnyPopup(); - break; - - case NOPARAM_ROUTINE_CSRSS_INITIALIZED: - Result = (DWORD_PTR)CsrInit(); - break; - case NOPARAM_ROUTINE_MSQCLEARWAKEMASK: RETURN( (DWORD_PTR)IntMsqClearWakeMask()); @@ -525,7 +517,7 @@ NtUserCallHwndLock( SWP_NOZORDER| SWP_NOACTIVATE| SWP_FRAMECHANGED ); - if (!IntGetOwner(Window) && !IntGetParent(Window)) + if (!Window->spwndOwner && !IntGetParent(Window)) { co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) hWnd); } diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index e1965d8c02d..ee1f7aea849 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -96,6 +96,8 @@ PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd) ASSERT(Window->head.cLockObj >= 0); Window->head.cLockObj++; + + ASSERT(Window->Wnd); } return Window; } @@ -130,6 +132,9 @@ PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd) } ASSERT(Window->head.cLockObj >= 0); + + ASSERT(Window->Wnd); + return Window; } @@ -163,20 +168,12 @@ IntIsWindow(HWND hWnd) -/* - Caller must NOT dereference retval! - But if caller want the returned value to persist spanning a co_ call, - it must reference the value (because the owner is not garanteed to - exist just because the owned window exist)! -*/ PWINDOW_OBJECT FASTCALL IntGetParent(PWINDOW_OBJECT Wnd) { - if (!Wnd->Wnd) return NULL; - if (Wnd->Wnd->style & WS_POPUP) { - return UserGetWindowObject(Wnd->hOwner); + return Wnd->spwndOwner; } else if (Wnd->Wnd->style & WS_CHILD) { @@ -187,20 +184,6 @@ IntGetParent(PWINDOW_OBJECT Wnd) } -/* - Caller must NOT dereference retval! - But if caller want the returned value to persist spanning a co_ call, - it must reference the value (because the owner is not garanteed to - exist just because the owned window exist)! -*/ -PWINDOW_OBJECT FASTCALL -IntGetOwner(PWINDOW_OBJECT Wnd) -{ - return UserGetWindowObject(Wnd->hOwner); -} - - - /* * IntWinListChildren * @@ -265,7 +248,7 @@ static void IntSendDestroyMsg(HWND hWnd) // USER_REFERENCE_ENTRY Ref; // UserRefObjectCo(Window, &Ref); - if (!IntGetOwner(Window) && !IntGetParent(Window)) + if (!Window->spwndOwner && !IntGetParent(Window)) { co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM) hWnd); } @@ -1091,26 +1074,19 @@ IntSetOwner(HWND hWnd, HWND hWndNewOwner) if(!Wnd) return NULL; - WndOldOwner = IntGetWindowObject(Wnd->hOwner); - if (WndOldOwner) - { - ret = WndOldOwner->hSelf; - UserDereferenceObject(WndOldOwner); - } - else - { - ret = 0; - } + WndOldOwner = Wnd->spwndOwner; + + ret = WndOldOwner ? WndOldOwner->hSelf : 0; if((WndNewOwner = UserGetWindowObject(hWndNewOwner))) { - Wnd->hOwner = hWndNewOwner; - Wnd->Wnd->spwndOwner = WndNewOwner->Wnd; + Wnd->spwndOwner= WndNewOwner; + Wnd->Wnd->spwndOwner = WndNewOwner->Wnd; } else { - Wnd->hOwner = NULL; - Wnd->Wnd->spwndOwner = NULL; + Wnd->spwndOwner = NULL; + Wnd->Wnd->spwndOwner = NULL; } UserDereferenceObject(Wnd); @@ -1279,31 +1255,6 @@ IntUnlinkWindow(PWINDOW_OBJECT Wnd) Wnd->spwndPrev = Wnd->spwndNext = Wnd->spwndParent = NULL; } -BOOL FASTCALL -IntAnyPopup(VOID) -{ - PWINDOW_OBJECT Window, Child; - - if(!(Window = UserGetWindowObject(IntGetDesktopWindow()))) - { - return FALSE; - } - - for(Child = Window->spwndChild; Child; Child = Child->spwndNext) - { - if(Child->hOwner && Child->Wnd->style & WS_VISIBLE) - { - /* - * The desktop has a popup window if one of them has - * an owner window and is visible - */ - return TRUE; - } - } - - return FALSE; -} - BOOL FASTCALL IntIsWindowInDestroy(PWINDOW_OBJECT Window) { @@ -1511,7 +1462,7 @@ NtUserBuildHwndList( Window = CONTAINING_RECORD(Current, WINDOW_OBJECT, ThreadListEntry); ASSERT(Window); - if(bChildren || Window->hOwner != NULL) + if(bChildren || Window->spwndOwner != NULL) { if(dwCount < *pBufSize && pWnd) { @@ -1737,7 +1688,7 @@ PWINDOW_OBJECT FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, Window->pti = pti; Window->hSelf = hWnd; Window->spwndParent = ParentWindow; - Window->hOwner = OwnerWindow ? OwnerWindow->hSelf : NULL; + Window->spwndOwner = OwnerWindow; Wnd->head.h = hWnd; Wnd->head.pti = pti; @@ -2560,7 +2511,7 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window) Child = UserGetWindowObject(*ChildHandle); if (Child == NULL) continue; - if (Child->hOwner != Window->hSelf) + if (Child->spwndOwner != Window) { continue; } @@ -2576,9 +2527,9 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window) continue; } - if (Child->hOwner != NULL) + if (Child->spwndOwner != NULL) { - Child->hOwner = NULL; + Child->spwndOwner = NULL; Child->Wnd->spwndOwner = NULL; } @@ -3041,9 +2992,6 @@ PWINDOW_OBJECT FASTCALL UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type) break; } - //temp hack -// UserDereferenceObject(Parent); - WndAncestor = Parent; } break; @@ -3374,7 +3322,7 @@ BOOL APIENTRY NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) { PWINSTATION_OBJECT WinStaObject; - PWINDOW_OBJECT WndShell; + PWINDOW_OBJECT WndShell, WndListView; DECLARE_RETURN(BOOL); USER_REFERENCE_ENTRY Ref; NTSTATUS Status; @@ -3388,6 +3336,11 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) RETURN(FALSE); } + if(!(WndListView = UserGetWindowObject(hwndListView))) + { + RETURN(FALSE); + } + Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, 0, @@ -3421,14 +3374,14 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) co_WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); #endif - if (UserGetWindowLong(hwndListView, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) + if (WndListView->Wnd->ExStyle & WS_EX_TOPMOST) { ObDereferenceObject(WinStaObject); RETURN( FALSE); } } - if (UserGetWindowLong(hwndShell, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) + if (WndShell->Wnd->ExStyle & WS_EX_TOPMOST) { ObDereferenceObject(WinStaObject); RETURN( FALSE); @@ -3553,162 +3506,6 @@ CLEANUP: END_CLEANUP; } -HWND FASTCALL -UserGetWindow(HWND hWnd, UINT Relationship) -{ - PWINDOW_OBJECT Parent, Window; - HWND hWndResult = NULL; - - if (!(Window = UserGetWindowObject(hWnd))) - return NULL; - - switch (Relationship) - { - case GW_HWNDFIRST: - if((Parent = Window->spwndParent)) - { - if (Parent->spwndChild) - hWndResult = Parent->spwndChild->hSelf; - } - break; - - case GW_HWNDLAST: - if((Parent = Window->spwndParent)) - { - if (Parent->spwndChild) - { - Window = Parent->spwndChild; - if(Window) - { - while(Window->spwndNext) - Window = Window->spwndNext; - } - hWndResult = Window->hSelf; - } - } - break; - - case GW_HWNDNEXT: - if (Window->spwndNext) - hWndResult = Window->spwndNext->hSelf; - break; - - case GW_HWNDPREV: - if (Window->spwndPrev) - hWndResult = Window->spwndPrev->hSelf; - break; - - case GW_OWNER: - if((Parent = UserGetWindowObject(Window->hOwner))) - { - hWndResult = Parent->hSelf; - } - break; - case GW_CHILD: - if (Window->spwndChild) - hWndResult = Window->spwndChild->hSelf; - break; - } - - return hWndResult; -} - -/* - * NtUserGetWindowLong - * - * The NtUserGetWindowLong function retrieves information about the specified - * window. The function also retrieves the 32-bit (long) value at the - * specified offset into the extra window memory. - * - * Status - * @implemented - */ - -LONG FASTCALL -UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) -{ - PWINDOW_OBJECT Window, Parent; - PWND Wnd; - LONG Result = 0; - - DPRINT("NtUserGetWindowLong(%x,%d,%d)\n", hWnd, (INT)Index, Ansi); - - if (!(Window = UserGetWindowObject(hWnd)) || !Window->Wnd) - { - return 0; - } - - Wnd = Window->Wnd; - - /* - * WndProc is only available to the owner process - */ - if (GWL_WNDPROC == Index - && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess()) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return 0; - } - - if ((INT)Index >= 0) - { - if ((Index + sizeof(LONG)) > Window->Wnd->cbwndExtra) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - Result = *((LONG *)((PCHAR)(Window->Wnd + 1) + Index)); - } - else - { - switch (Index) - { - case GWL_EXSTYLE: - Result = Wnd->ExStyle; - break; - - case GWL_STYLE: - Result = Wnd->style; - break; - - case GWL_WNDPROC: - Result = (LONG)IntGetWindowProc(Wnd, Ansi); - break; - - case GWL_HINSTANCE: - Result = (LONG) Wnd->hModule; - break; - - case GWL_HWNDPARENT: - Parent = Window->spwndParent; - if(Parent) - { - if (Parent && Parent->hSelf == IntGetDesktopWindow()) - Result = (LONG) UserGetWindow(Window->hSelf, GW_OWNER); - else - Result = (LONG) Parent->hSelf; - } - break; - - case GWL_ID: - Result = (LONG) Wnd->IDMenu; - break; - - case GWL_USERDATA: - Result = Wnd->dwUserData; - break; - - default: - DPRINT1("NtUserGetWindowLong(): Unsupported index %d\n", Index); - SetLastWin32Error(ERROR_INVALID_PARAMETER); - Result = 0; - break; - } - } - - return Result; -} - LONG FASTCALL co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { @@ -4807,7 +4604,7 @@ NtUserDefSetText(HWND hWnd, PLARGE_STRING WindowText) // In User32, these are called after: NotifyWinEvent EVENT_OBJECT_NAMECHANGE than // RepaintButton, StaticRepaint, NtUserCallHwndLock HWNDLOCK_ROUTINE_REDRAWFRAMEANDHOOK, etc. /* Send shell notifications */ - if (!IntGetOwner(Window) && !IntGetParent(Window)) + if (!Window->spwndOwner && !IntGetParent(Window)) { co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) hWnd); } @@ -4908,11 +4705,10 @@ IntShowOwnedPopups(PWINDOW_OBJECT OwnerWnd, BOOL fShow ) count++; while (--count >= 0) { - if (UserGetWindow( win_array[count], GW_OWNER ) != OwnerWnd->hSelf) - continue; if (!(pWnd = UserGetWindowObject( win_array[count] ))) continue; - // if (pWnd == WND_OTHER_PROCESS) continue; + if (pWnd->spwndOwner != OwnerWnd) + continue; if (fShow) { diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index 6a04e8c05c8..8bdd29969a3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -151,7 +151,7 @@ co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window) } /* If this is popup window, try to activate the owner first. */ - if ((Wnd->style & WS_POPUP) && (WndTo = IntGetOwner(Window))) + if ((Wnd->style & WS_POPUP) && (WndTo = Window->spwndOwner)) { WndTo = UserGetAncestor( WndTo, GA_ROOT ); if (can_activate_window(WndTo)) goto done; @@ -741,11 +741,15 @@ HWND FASTCALL WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter) { HWND *List = NULL; - HWND Owner = UserGetWindow(hWnd, GW_OWNER); - LONG Style = UserGetWindowLong(hWnd, GWL_STYLE, FALSE); - PWINDOW_OBJECT DesktopWindow, ChildObject; + HWND Owner; + LONG Style; + PWINDOW_OBJECT Window ,DesktopWindow, ChildObject; int i; + Window = UserGetWindowObject(hWnd); + Owner = Window->spwndOwner ? Window->spwndOwner->hSelf : NULL; + Style = Window->Wnd->style; + if ((Style & WS_POPUP) && Owner) { /* Make sure this popup stays above the owner */ @@ -804,8 +808,7 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter) if (!(Wnd = UserGetWindowObject(List[i]))) continue; - if ((Wnd->Wnd->style & WS_POPUP) && - UserGetWindow(List[i], GW_OWNER) == hWnd) + if (Wnd->Wnd->style & WS_POPUP && Wnd->spwndOwner == Window) { USER_REFERENCE_ENTRY Ref; UserRefObjectCo(Wnd, &Ref); @@ -958,7 +961,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window) * itself. */ if ((WinPos->hwnd == WinPos->hwndInsertAfter) || - (WinPos->hwnd == UserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT))) + (WinPos->hwnd == InsAfterWnd->spwndNext->hSelf)) { WinPos->flags |= SWP_NOZORDER; } diff --git a/reactos/subsystems/win32/win32k/w32ksvc.db b/reactos/subsystems/win32/win32k/w32ksvc.db index acce60122d2..0b90145a90f 100644 --- a/reactos/subsystems/win32/win32k/w32ksvc.db +++ b/reactos/subsystems/win32/win32k/w32ksvc.db @@ -684,7 +684,6 @@ NtGdiOffsetWindowOrgEx 4 # NtUserBuildMenuItemList 4 NtUserCreateCursorIconHandle 2 -NtUserGetClassLong 3 NtUserGetMenuDefaultItem 3 NtUserGetLastInputInfo 1 NtUserGetMinMaxInfo 3 -- 2.17.1