From b41ecb619ad73763c64e22cb6ffe2d805cefdc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sat, 17 May 2003 14:30:28 +0000 Subject: [PATCH] When sending WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages from Win32k, make sure the WINDOWPOS structure referenced by lParam is located in user space svn path=/trunk/; revision=4702 --- reactos/include/user32/callback.h | 32 ++++++++--- reactos/lib/user32/misc/dllmain.c | 4 ++ reactos/subsys/win32k/include/callback.h | 6 ++ reactos/subsys/win32k/ntuser/callback.c | 70 +++++++++++++++++++++--- reactos/subsys/win32k/ntuser/window.c | 6 +- reactos/subsys/win32k/ntuser/winpos.c | 7 +-- 6 files changed, 104 insertions(+), 21 deletions(-) diff --git a/reactos/include/user32/callback.h b/reactos/include/user32/callback.h index e6f2fd55806..05c96d14a81 100644 --- a/reactos/include/user32/callback.h +++ b/reactos/include/user32/callback.h @@ -1,13 +1,15 @@ #ifndef __INCLUDE_USER32_CALLBACK_H #define __INCLUDE_USER32_CALLBACK_H -#define USER32_CALLBACK_WINDOWPROC (0) -#define USER32_CALLBACK_SENDASYNCPROC (1) -#define USER32_CALLBACK_SENDNCCREATE (2) -#define USER32_CALLBACK_SENDNCCALCSIZE (3) -#define USER32_CALLBACK_SENDCREATE (4) -#define USER32_CALLBACK_SENDGETMINMAXINFO (5) -#define USER32_CALLBACK_MAXIMUM (6) +#define USER32_CALLBACK_WINDOWPROC (0) +#define USER32_CALLBACK_SENDASYNCPROC (1) +#define USER32_CALLBACK_SENDNCCREATE (2) +#define USER32_CALLBACK_SENDNCCALCSIZE (3) +#define USER32_CALLBACK_SENDCREATE (4) +#define USER32_CALLBACK_SENDGETMINMAXINFO (5) +#define USER32_CALLBACK_SENDWINDOWPOSCHANGING (6) +#define USER32_CALLBACK_SENDWINDOWPOSCHANGED (7) +#define USER32_CALLBACK_MAXIMUM (7) typedef struct _WINDOWPROC_CALLBACK_ARGUMENTS { @@ -69,6 +71,18 @@ typedef struct _SENDGETMINMAXINFO_CALLBACK_RESULT MINMAXINFO MinMaxInfo; } SENDGETMINMAXINFO_CALLBACK_RESULT, *PSENDGETMINMAXINFO_CALLBACK_RESULT; +typedef struct _SENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS +{ + HWND Wnd; + WINDOWPOS WindowPos; +} SENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS, *PSENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS; + +typedef struct _SENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS +{ + HWND Wnd; + WINDOWPOS WindowPos; +} SENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS, *PSENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS; + NTSTATUS STDCALL User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength); NTSTATUS STDCALL @@ -81,5 +95,9 @@ NTSTATUS STDCALL User32SendGETMINMAXINFOMessageForKernel(PVOID Arguments, ULONG ArgumentLength); NTSTATUS STDCALL User32SendNCCALCSIZEMessageForKernel(PVOID Arguments, ULONG ArgumentLength); +NTSTATUS STDCALL +User32SendWINDOWPOSCHANGINGMessageForKernel(PVOID Arguments, ULONG ArgumentLength); +NTSTATUS STDCALL +User32SendWINDOWPOSCHANGEDMessageForKernel(PVOID Arguments, ULONG ArgumentLength); #endif /* __INCLUDE_USER32_CALLBACK_H */ diff --git a/reactos/lib/user32/misc/dllmain.c b/reactos/lib/user32/misc/dllmain.c index eddbc972e1a..c1ab8d635d0 100644 --- a/reactos/lib/user32/misc/dllmain.c +++ b/reactos/lib/user32/misc/dllmain.c @@ -33,6 +33,10 @@ Init(VOID) (PVOID)User32SendGETMINMAXINFOMessageForKernel; NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_SENDNCCALCSIZE] = (PVOID)User32SendNCCALCSIZEMessageForKernel; + NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_SENDWINDOWPOSCHANGING] = + (PVOID)User32SendWINDOWPOSCHANGINGMessageForKernel; + NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_SENDWINDOWPOSCHANGED] = + (PVOID)User32SendWINDOWPOSCHANGEDMessageForKernel; UserSetupInternalPos(); diff --git a/reactos/subsys/win32k/include/callback.h b/reactos/subsys/win32k/include/callback.h index b620beeb099..528d289ae81 100644 --- a/reactos/subsys/win32k/include/callback.h +++ b/reactos/subsys/win32k/include/callback.h @@ -29,4 +29,10 @@ W32kSendNCCALCSIZEMessage(HWND Wnd, BOOL Validate, PRECT Rect, LRESULT STDCALL W32kSendGETMINMAXINFOMessage(HWND Wnd, MINMAXINFO* MinMaxInfo); +LRESULT STDCALL +W32kSendWINDOWPOSCHANGINGMessage(HWND Wnd, WINDOWPOS* WindowPos); + +LRESULT STDCALL +W32kSendWINDOWPOSCHANGEDMessage(HWND Wnd, WINDOWPOS* WindowPos); + #endif /* __SUBSYS_WIN32K_INCLUDE_CALLBACK_H */ diff --git a/reactos/subsys/win32k/ntuser/callback.c b/reactos/subsys/win32k/ntuser/callback.c index 7d46f62b572..37a4da77e80 100644 --- a/reactos/subsys/win32k/ntuser/callback.c +++ b/reactos/subsys/win32k/ntuser/callback.c @@ -1,4 +1,4 @@ -/* $Id: callback.c,v 1.7 2002/08/31 23:18:46 dwelch Exp $ +/* $Id: callback.c,v 1.8 2003/05/17 14:30:28 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -207,6 +207,56 @@ W32kSendGETMINMAXINFOMessage(HWND Wnd, MINMAXINFO* MinMaxInfo) return(Result.Result); } +LRESULT STDCALL +W32kSendWINDOWPOSCHANGINGMessage(HWND Wnd, WINDOWPOS* WindowPos) +{ + SENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS Arguments; + LRESULT Result; + NTSTATUS Status; + PVOID ResultPointer; + ULONG ResultLength; + + Arguments.Wnd = Wnd; + Arguments.WindowPos = *WindowPos; + ResultPointer = &Result; + ResultLength = sizeof(LRESULT); + Status = NtW32Call(USER32_CALLBACK_SENDWINDOWPOSCHANGING, + &Arguments, + sizeof(SENDWINDOWPOSCHANGING_CALLBACK_ARGUMENTS), + &ResultPointer, + &ResultLength); + if (!NT_SUCCESS(Status)) + { + return(0); + } + return(Result); +} + +LRESULT STDCALL +W32kSendWINDOWPOSCHANGEDMessage(HWND Wnd, WINDOWPOS* WindowPos) +{ + SENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS Arguments; + LRESULT Result; + NTSTATUS Status; + PVOID ResultPointer; + ULONG ResultLength; + + Arguments.Wnd = Wnd; + Arguments.WindowPos = *WindowPos; + ResultPointer = &Result; + ResultLength = sizeof(LRESULT); + Status = NtW32Call(USER32_CALLBACK_SENDWINDOWPOSCHANGED, + &Arguments, + sizeof(SENDWINDOWPOSCHANGED_CALLBACK_ARGUMENTS), + &ResultPointer, + &ResultLength); + if (!NT_SUCCESS(Status)) + { + return(0); + } + return(Result); +} + LRESULT STDCALL W32kCallTrampolineWindowProc(WNDPROC Proc, HWND Wnd, @@ -217,26 +267,32 @@ W32kCallTrampolineWindowProc(WNDPROC Proc, switch (Message) { case WM_NCCREATE: - return(W32kSendNCCREATEMessage(Wnd, (CREATESTRUCTW*)lParam)); + return W32kSendNCCREATEMessage(Wnd, (CREATESTRUCTW*)lParam); case WM_CREATE: - return(W32kSendCREATEMessage(Wnd, (CREATESTRUCTW*)lParam)); + return W32kSendCREATEMessage(Wnd, (CREATESTRUCTW*)lParam); case WM_GETMINMAXINFO: - return(W32kSendGETMINMAXINFOMessage(Wnd, (MINMAXINFO*)lParam)); + return W32kSendGETMINMAXINFOMessage(Wnd, (MINMAXINFO*)lParam); case WM_NCCALCSIZE: { if (wParam) { - return(W32kSendNCCALCSIZEMessage(Wnd, TRUE, NULL, - (NCCALCSIZE_PARAMS*)lParam)); + return W32kSendNCCALCSIZEMessage(Wnd, TRUE, NULL, + (NCCALCSIZE_PARAMS*)lParam); } else { - return(W32kSendNCCALCSIZEMessage(Wnd, FALSE, (RECT*)lParam, NULL)); + return W32kSendNCCALCSIZEMessage(Wnd, FALSE, (RECT*)lParam, NULL); } } + + case WM_WINDOWPOSCHANGING: + return W32kSendWINDOWPOSCHANGINGMessage(Wnd, (WINDOWPOS*) lParam); + + case WM_WINDOWPOSCHANGED: + return W32kSendWINDOWPOSCHANGEDMessage(Wnd, (WINDOWPOS*) lParam); default: return(W32kCallWindowProc(Proc, Wnd, Message, wParam, lParam)); diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index f6a51827edb..b6002405212 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.43 2003/05/17 09:20:23 gvg Exp $ +/* $Id: window.c,v 1.44 2003/05/17 14:30:28 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -879,7 +879,7 @@ NtUserMoveWindow( pWinPos.cy = pWinPos.x + nHeight; else pWinPos.cy = pWinPos.y + NtUserGetSystemMetrics(SM_CYMIN); - NtUserSendMessage(hWnd, WM_WINDOWPOSCHANGING, 0, (LPARAM)&pWinPos); + W32kSendWINDOWPOSCHANGINGMessage(Window->Self, &pWinPos); Window->WindowRect.top = Window->ClientRect.top = pWinPos.y; Window->WindowRect.left = Window->ClientRect.left = pWinPos.x; @@ -908,7 +908,7 @@ NtUserMoveWindow( Window->ClientRect.top += NtUserGetSystemMetrics(SM_CYMENU); } - NtUserSendMessage(hWnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&pWinPos); + W32kSendWINDOWPOSCHANGEDMessage(Window->Self, &pWinPos); NtUserSendMessage(hWnd, WM_MOVE, 0, MAKEWORD(Window->ClientRect.left, Window->ClientRect.top)); diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 357b2994758..2b7c4fb4bcb 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -1,4 +1,4 @@ -/* $Id: winpos.c,v 1.7 2002/11/01 11:29:58 dwelch Exp $ +/* $Id: winpos.c,v 1.8 2003/05/17 14:30:28 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -339,8 +339,7 @@ WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject, { if (!(WinPos->flags & SWP_NOSENDCHANGING)) { - NtUserSendMessage(WindowObject->Self, WM_WINDOWPOSCHANGING, 0, - (LPARAM)WinPos); + W32kSendWINDOWPOSCHANGINGMessage(WindowObject->Self, WinPos); } *WindowRect = WindowObject->WindowRect; @@ -538,7 +537,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, } /* FIXME: Check some conditions before doing this. */ - NtUserSendMessage(WinPos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&WinPos); + W32kSendWINDOWPOSCHANGEDMessage(Window->Self, &WinPos); ObmDereferenceObject(Window); return(TRUE);