Author: mjansen
Date: Mon Jan 9 21:12:00 2017
New Revision: 73517
URL:
http://svn.reactos.org/svn/reactos?rev=73517&view=rev
Log:
[WIN32SS] Don't trigger ProbeForWrite when retrieving caret size from co_IntDrawCaret,
fix unlocking in failure path. CORE-10308
Modified:
trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c
trunk/reactos/win32ss/gdi/ntgdi/bitmaps.h
trunk/reactos/win32ss/user/ntuser/caret.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitmaps.…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] Mon Jan 9 21:12:00 2017
@@ -430,41 +430,56 @@
}
BOOL
+NTAPI
+GreGetBitmapDimension(
+ _In_ HBITMAP hBitmap,
+ _Out_ LPSIZE psizDim)
+{
+ PSURFACE psurfBmp;
+
+ if (hBitmap == NULL)
+ return FALSE;
+
+ /* Lock the bitmap */
+ psurfBmp = SURFACE_ShareLockSurface(hBitmap);
+ if (psurfBmp == NULL)
+ {
+ EngSetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ *psizDim = psurfBmp->sizlDim;
+
+ /* Unlock the bitmap */
+ SURFACE_ShareUnlockSurface(psurfBmp);
+
+ return TRUE;
+}
+
+BOOL
APIENTRY
NtGdiGetBitmapDimension(
HBITMAP hBitmap,
LPSIZE psizDim)
{
- PSURFACE psurfBmp;
- BOOL bResult = TRUE;
-
- if (hBitmap == NULL)
+ SIZE dim;
+
+ if (!GreGetBitmapDimension(hBitmap, &dim))
return FALSE;
-
- /* Lock the bitmap */
- psurfBmp = SURFACE_ShareLockSurface(hBitmap);
- if (psurfBmp == NULL)
- {
- EngSetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
/* Use SEH to copy the data to the caller */
_SEH2_TRY
{
- ProbeForWrite(psizDim, sizeof(SIZE), 1);
- *psizDim = psurfBmp->sizlDim;
+ ProbeForWrite(psizDim, sizeof(*psizDim), 1);
+ *psizDim = dim;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- bResult = FALSE;
+ _SEH2_YIELD(return FALSE);
}
_SEH2_END
- /* Unlock the bitmap */
- SURFACE_ShareUnlockSurface(psurfBmp);
-
- return bResult;
+ return TRUE;
}
Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitmaps.…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/bitmaps.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/bitmaps.h [iso-8859-1] Mon Jan 9 21:12:00 2017
@@ -50,3 +50,10 @@
_Inout_ PSURFACE psurf,
_In_ ULONG cjBits,
_In_ const VOID *pvBits);
+
+BOOL
+NTAPI
+GreGetBitmapDimension(
+ _In_ HBITMAP hBitmap,
+ _Out_ LPSIZE psizDim);
+
Modified: trunk/reactos/win32ss/user/ntuser/caret.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/caret.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/caret.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/caret.c [iso-8859-1] Mon Jan 9 21:12:00 2017
@@ -43,10 +43,10 @@
if (CaretInfo->Bitmap)
{
- if (!NtGdiGetBitmapDimension(CaretInfo->Bitmap, &CaretInfo->Size))
+ if (!GreGetBitmapDimension(CaretInfo->Bitmap, &CaretInfo->Size))
{
ERR("Failed to get bitmap dimensions\n");
- return;
+ goto cleanup;
}
hdcMem = NtGdiCreateCompatibleDC(hdc);
@@ -79,6 +79,7 @@
DSTINVERT);
}
+cleanup:
if (pWnd->hrgnUpdate)
{
NtGdiRestoreDC(hdc, -1);