[WIN32SS] Don't trigger ProbeForWrite when retrieving caret size from co_IntDrawCaret, fix unlocking in failure path. CORE-10308

svn path=/trunk/; revision=73517
This commit is contained in:
Mark Jansen 2017-01-09 21:12:00 +00:00
parent 657d78a387
commit e8801e23b6
3 changed files with 42 additions and 19 deletions

View 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;
}
/* Use SEH to copy the data to the caller */
_SEH2_TRY
{
ProbeForWrite(psizDim, sizeof(SIZE), 1);
*psizDim = psurfBmp->sizlDim;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
bResult = FALSE;
}
_SEH2_END
*psizDim = psurfBmp->sizlDim;
/* Unlock the bitmap */
SURFACE_ShareUnlockSurface(psurfBmp);
return bResult;
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(*psizDim), 1);
*psizDim = dim;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
_SEH2_YIELD(return FALSE);
}
_SEH2_END
return TRUE;
}

View 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);

View 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);