From 7581cc7fb97b97fcc35b8a50142d590de26f256d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 2 Jan 2005 18:04:59 +0000 Subject: [PATCH] Implement ExtCreateRegion. svn path=/trunk/; revision=12730 --- reactos/include/win32k/region.h | 6 +-- reactos/lib/gdi32/gdi32.def | 4 +- reactos/subsys/win32k/objects/region.c | 57 +++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/reactos/include/win32k/region.h b/reactos/include/win32k/region.h index c2812115e2a..0925b9f50ce 100644 --- a/reactos/include/win32k/region.h +++ b/reactos/include/win32k/region.h @@ -79,9 +79,9 @@ NtGdiEqualRgn(HRGN hSrcRgn1, HRGN STDCALL -NtGdiExtCreateRegion(CONST PXFORM Xform, - DWORD Count, - CONST PROSRGNDATA RgnData); +NtGdiExtCreateRegion(CONST XFORM *Xform, + DWORD Count, + CONST RGNDATA *RgnData); BOOL STDCALL diff --git a/reactos/lib/gdi32/gdi32.def b/reactos/lib/gdi32/gdi32.def index 26c1278eba9..dd78ff6da07 100644 --- a/reactos/lib/gdi32/gdi32.def +++ b/reactos/lib/gdi32/gdi32.def @@ -1,4 +1,4 @@ -; $Id: gdi32.def,v 1.13 2004/12/30 02:32:23 navaraf Exp $ +; $Id$ ; ; gdi32.def ; @@ -168,7 +168,7 @@ EudcLoadLinkW@16 EudcUnloadLinkW@8 ExcludeClipRect@20=NtGdiExcludeClipRect@20 ExtCreatePen@20=NtGdiExtCreatePen@20 -ExtCreateRegion@12 +ExtCreateRegion@12=NtGdiExtCreateRegion@12 ExtEscape@24=NtGdiExtEscape@24 ExtFloodFill@20=NtGdiExtFloodFill@20 ExtSelectClipRgn@12=NtGdiExtSelectClipRgn@12 diff --git a/reactos/subsys/win32k/objects/region.c b/reactos/subsys/win32k/objects/region.c index 72f495d044f..2feb5a31a7b 100644 --- a/reactos/subsys/win32k/objects/region.c +++ b/reactos/subsys/win32k/objects/region.c @@ -113,7 +113,7 @@ SOFTWARE. * the y-x-banding that's so nice to have... */ -/* $Id: region.c,v 1.64 2004/12/12 01:40:38 weiden Exp $ */ +/* $Id$ */ #include #include @@ -2224,12 +2224,57 @@ exit: HRGN STDCALL -NtGdiExtCreateRegion(CONST PXFORM Xform, - DWORD Count, - CONST PROSRGNDATA RgnData) +NtGdiExtCreateRegion(CONST XFORM *Xform, + DWORD Count, + CONST RGNDATA *RgnData) { - UNIMPLEMENTED; - return 0; + HRGN hRgn; + RGNDATA SafeRgnData; + PROSRGNDATA Region; + NTSTATUS Status; + + if (Count < FIELD_OFFSET(RGNDATA, Buffer)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return NULL; + } + + Status = MmCopyFromCaller(&SafeRgnData, RgnData, min(Count, sizeof(RGNDATA))); + if (!NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return NULL; + } + + hRgn = RGNDATA_AllocRgn(SafeRgnData.rdh.nCount); + if (hRgn == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + Region = RGNDATA_LockRgn(hRgn); + if (Region == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + RtlCopyMemory(&Region->rdh, &SafeRgnData, FIELD_OFFSET(RGNDATA, Buffer)); + + Status = MmCopyFromCaller(Region->Buffer, RgnData->Buffer, + Count - FIELD_OFFSET(RGNDATA, Buffer)); + if (!NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + RGNDATA_UnlockRgn(hRgn); + NtGdiDeleteObject(hRgn); + return NULL; + } + + RGNDATA_UnlockRgn(hRgn); + + return hRgn; } BOOL