[WIN32SS] Don't trigger ProbeForWrite when retrieving caret size from co_IntDrawCaret...
authorMark Jansen <mark.jansen@reactos.org>
Mon, 9 Jan 2017 21:12:00 +0000 (21:12 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 9 Jan 2017 21:12:00 +0000 (21:12 +0000)
svn path=/trunk/; revision=73517

reactos/win32ss/gdi/ntgdi/bitmaps.c
reactos/win32ss/gdi/ntgdi/bitmaps.h
reactos/win32ss/user/ntuser/caret.c

index 13d5a78..e4639d8 100644 (file)
@@ -430,13 +430,12 @@ NtGdiCreateCompatibleBitmap(
 }
 
 BOOL
-APIENTRY
-NtGdiGetBitmapDimension(
-    HBITMAP hBitmap,
-    LPSIZE psizDim)
+NTAPI
+GreGetBitmapDimension(
+    _In_ HBITMAP hBitmap,
+    _Out_ LPSIZE psizDim)
 {
     PSURFACE psurfBmp;
-    BOOL bResult = TRUE;
 
     if (hBitmap == NULL)
         return FALSE;
@@ -449,22 +448,38 @@ NtGdiGetBitmapDimension(
         return FALSE;
     }
 
+    *psizDim = psurfBmp->sizlDim;
+
+    /* Unlock the bitmap */
+    SURFACE_ShareUnlockSurface(psurfBmp);
+
+    return TRUE;
+}
+
+BOOL
+APIENTRY
+NtGdiGetBitmapDimension(
+    HBITMAP hBitmap,
+    LPSIZE psizDim)
+{
+    SIZE dim;
+
+    if (!GreGetBitmapDimension(hBitmap, &dim))
+        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;
 }
 
 
index 3ef00c2..2f9ac4d 100644 (file)
@@ -50,3 +50,10 @@ UnsafeSetBitmapBits(
     _Inout_ PSURFACE psurf,
     _In_ ULONG cjBits,
     _In_ const VOID *pvBits);
+
+BOOL
+NTAPI
+GreGetBitmapDimension(
+    _In_ HBITMAP hBitmap,
+    _Out_ LPSIZE psizDim);
+
index d415918..a7549e7 100644 (file)
@@ -43,10 +43,10 @@ co_IntDrawCaret(PWND pWnd, PTHRDCARETINFO CaretInfo)
 
     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 @@ co_IntDrawCaret(PWND pWnd, PTHRDCARETINFO CaretInfo)
                     DSTINVERT);
     }
 
+cleanup:
     if (pWnd->hrgnUpdate)
     {
        NtGdiRestoreDC(hdc, -1);