From c4e75c424ff8da5d554b1c0adfad4caf6c13a72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 23 Mar 2004 11:20:58 +0000 Subject: [PATCH] Implement GetUpdateRect() and harden NtUserGetUpdateRect() svn path=/trunk/; revision=8846 --- reactos/lib/user32/windows/paint.c | 15 ++++---- reactos/subsys/win32k/ntuser/painting.c | 47 +++++++++++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/reactos/lib/user32/windows/paint.c b/reactos/lib/user32/windows/paint.c index ada6e1be3f0..31f793a4d8b 100644 --- a/reactos/lib/user32/windows/paint.c +++ b/reactos/lib/user32/windows/paint.c @@ -16,10 +16,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: paint.c,v 1.22 2004/01/26 08:44:51 weiden Exp $ +/* $Id: paint.c,v 1.23 2004/03/23 11:20:58 gvg Exp $ * * PROJECT: ReactOS user32.dll - * FILE: lib/user32/windows/input.c + * FILE: lib/user32/windows/paint.c * PURPOSE: Input * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * UPDATE HISTORY: @@ -120,17 +120,16 @@ ExcludeUpdateRgn( /* - * @unimplemented + * @implemented */ BOOL STDCALL GetUpdateRect( - HWND hWnd, - LPRECT lpRect, - BOOL bErase) + HWND Wnd, + LPRECT Rect, + BOOL Erase) { - UNIMPLEMENTED; - return FALSE; + return NtUserGetUpdateRect(Wnd, Rect, Erase); } diff --git a/reactos/subsys/win32k/ntuser/painting.c b/reactos/subsys/win32k/ntuser/painting.c index 910fb6940e8..091ecd3d4e2 100644 --- a/reactos/subsys/win32k/ntuser/painting.c +++ b/reactos/subsys/win32k/ntuser/painting.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: painting.c,v 1.77 2004/03/22 20:14:29 weiden Exp $ + * $Id: painting.c,v 1.78 2004/03/23 11:20:58 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -892,21 +892,46 @@ NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) */ BOOL STDCALL -NtUserGetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL fErase) +NtUserGetUpdateRect(HWND Wnd, LPRECT UnsafeRect, BOOL Erase) { - HRGN hRgn = NtGdiCreateRectRgn(0, 0, 0, 0); + RECT Rect; + HRGN Rgn; + PROSRGNDATA RgnData; + NTSTATUS Status; - if (!lpRect) - { + Rgn = NtGdiCreateRectRgn(0, 0, 0, 0); + if (NULL == Rgn) + { + NtGdiDeleteObject(Rgn); + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + return FALSE; + } + NtUserGetUpdateRgn(Wnd, Rgn, Erase); + RgnData = RGNDATA_LockRgn(Rgn); + if (NULL == RgnData) + { + NtGdiDeleteObject(Rgn); + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + return FALSE; + } + if (ERROR == UnsafeIntGetRgnBox(RgnData, &Rect)) + { + RGNDATA_UnlockRgn(Rgn); + NtGdiDeleteObject(Rgn); + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + return FALSE; + } + RGNDATA_UnlockRgn(Rgn); + NtGdiDeleteObject(Rgn); + + Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECT)); + if (! NT_SUCCESS(Status)) + { SetLastWin32Error(ERROR_INVALID_PARAMETER); return FALSE; - } + } - NtUserGetUpdateRgn(hWnd, hRgn, fErase); - NtGdiGetRgnBox(hRgn, lpRect); - NtGdiDeleteObject(hRgn); - - return lpRect->left < lpRect->right && lpRect->top < lpRect->bottom; + return Rect.left < Rect.right && Rect.top < Rect.bottom; } /*