Author: jgardou
Date: Thu Jun 10 11:36:20 2010
New Revision: 47733
URL:
http://svn.reactos.org/svn/reactos?rev=47733&view=rev
Log:
[WIN32K]
- Split NtGdiCreateDIBitmapInternal with its Gre Counterpart
- Set bV5ImageSize if it was not already set
- Probe bits we're given in NtGdiSetDIBits
- SEHize clipboard image data access
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h
branches/reactos-yarotows/subsystems/win32/win32k/ntuser/clipboard.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1] Thu
Jun 10 11:36:20 2010
@@ -36,3 +36,15 @@
IN ULONG cjBits,
IN OPTIONAL PVOID pvBits);
+HBITMAP
+FASTCALL
+GreCreateDIBitmapInternal(
+ IN HDC hDc,
+ IN INT cx,
+ IN INT cy,
+ IN DWORD fInit,
+ IN OPTIONAL LPBYTE pjInit,
+ IN OPTIONAL PBITMAPV5INFO pbmi,
+ IN DWORD iUsage,
+ IN FLONG fl,
+ IN HANDLE hcmXform);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/ntuser/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] Thu
Jun 10 11:36:20 2010
@@ -243,31 +243,45 @@
/*==============================================================*/
HANDLE FASTCALL
-renderBITMAPfromDIB(LPBYTE hDIB)
+renderBITMAPfromDIB(LPBYTE pDIB)
{
HDC hdc;
HBITMAP hbitmap;
unsigned int offset;
- BITMAPINFOHEADER *ih;
+ BITMAPV5INFO bmi;
+ NTSTATUS Status ;
//hdc = UserGetDCEx(NULL, NULL, DCX_USESTYLE);
hdc = UserGetDCEx(ClipboardWindow, NULL, DCX_USESTYLE);
- ih = (BITMAPINFOHEADER *)hDIB;
-
- offset = sizeof(BITMAPINFOHEADER) + ((ih->biBitCount <= 8) ? (sizeof(RGBQUAD) *
(1 << ih->biBitCount)) : 0);
-
- hbitmap = NtGdiCreateDIBitmapInternal(hdc,
- ih->biWidth,
- ih->biHeight,
- CBM_INIT,
- (LPBYTE)ih+offset,
- (LPBITMAPINFO)ih,
- DIB_RGB_COLORS,
- ih->biBitCount,
- ih->biSizeImage,
- 0,
- 0);
+ /* Probe it */
+ _SEH2_TRY
+ {
+ Status = ProbeAndConvertToBitmapV5Info(&bmi, (BITMAPINFO*)pDIB,
DIB_RGB_COLORS, 0);
+ offset = DIB_BitmapInfoSize((BITMAPINFO*)pDIB, DIB_RGB_COLORS);
+ ProbeForRead(pDIB + offset, bmi.bmiHeader.bV5SizeImage, 1);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+
+ if(!NT_SUCCESS(Status))
+ {
+ UserReleaseDC(ClipboardWindow, hdc, FALSE);
+ return NULL;
+ }
+
+ hbitmap = GreCreateDIBitmapInternal(hdc,
+ bmi.bmiHeader.bV5Width,
+ bmi.bmiHeader.bV5Height,
+ CBM_INIT,
+ pDIB+offset,
+ &bmi,
+ DIB_RGB_COLORS,
+ 0,
+ 0);
//UserReleaseDC(NULL, hdc, FALSE);
UserReleaseDC(ClipboardWindow, hdc, FALSE);
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu
Jun 10 11:36:20 2010
@@ -355,7 +355,7 @@
_SEH2_TRY
{
Status = ProbeAndConvertToBitmapV5Info(&bmiLocal, bmi, ColorUse, 0);
- /* Don't check Bits and hope we won't die */
+ ProbeForRead(Bits, bmiLocal.bmiHeader.bV5SizeImage, 1);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -1130,28 +1130,53 @@
IN FLONG fl,
IN HANDLE hcmXform)
{
+ BITMAPV5INFO bmiLocal ;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ _SEH2_TRY
+ {
+ if(pbmi) Status = ProbeAndConvertToBitmapV5Info(&bmiLocal, pbmi, iUsage,
cjMaxInitInfo);
+ if(pjInit && (fInit == CBM_INIT)) ProbeForRead(pjInit, cjMaxBits, 1);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ return NULL;
+ }
+
+ return GreCreateDIBitmapInternal(hDc,
+ cx,
+ cy,
+ fInit,
+ pjInit,
+ pbmi ? &bmiLocal : NULL,
+ iUsage,
+ fl,
+ hcmXform);
+}
+
+HBITMAP
+FASTCALL
+GreCreateDIBitmapInternal(
+ IN HDC hDc,
+ IN INT cx,
+ IN INT cy,
+ IN DWORD fInit,
+ IN OPTIONAL LPBYTE pjInit,
+ IN OPTIONAL PBITMAPV5INFO pbmi,
+ IN DWORD iUsage,
+ IN FLONG fl,
+ IN HANDLE hcmXform)
+{
PDC Dc;
HBITMAP Bmp;
- UINT bpp;
- BITMAPV5INFO bmiLocal ;
- NTSTATUS Status = STATUS_SUCCESS;
-
- _SEH2_TRY
- {
- if(pbmi) Status = ProbeAndConvertToBitmapV5Info(&bmiLocal, pbmi, iUsage,
cjMaxInitInfo);
- if(pjInit && (fInit == CBM_INIT)) ProbeForRead(pjInit, cjMaxBits, 1);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Status = _SEH2_GetExceptionCode();
- }
- _SEH2_END
-
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- return NULL;
- }
+ WORD bpp;
if (!hDc) // CreateBitmap
{ // Should use System Bitmap DC hSystemBM, with CreateCompatibleDC for this.
@@ -1170,7 +1195,7 @@
return NULL;
}
bpp = 1;
- Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi ? &bmiLocal :
NULL, iUsage);
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
DC_UnlockDc(Dc);
NtGdiDeleteObjectApp(hDc);
@@ -1188,7 +1213,7 @@
should match that of the hdc and not that supplied in bmih.
*/
if (pbmi)
- bpp = bmiLocal.bmiHeader.bV5BitCount;
+ bpp = pbmi->bmiHeader.bV5BitCount;
else
{
if (Dc->dctype != DC_TYPE_MEMORY)
@@ -1212,7 +1237,7 @@
}
}
}
- Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi ? &bmiLocal :
NULL, iUsage);
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
DC_UnlockDc(Dc);
}
return Bmp;
@@ -1800,7 +1825,9 @@
/* Set some default values */
pbmhDst->bV5Compression = BI_RGB;
- pbmhDst->bV5SizeImage = 0;
+ pbmhDst->bV5SizeImage = DIB_GetDIBImageBytes(pbch->bcWidth,
+ pbch->bcHeight,
+
pbch->bcPlanes*pbch->bcBitCount) ;
pbmhDst->bV5XPelsPerMeter = 72;
pbmhDst->bV5YPelsPerMeter = 72;
pbmhDst->bV5ClrUsed = 0;
@@ -1810,6 +1837,10 @@
{
/* Copy valid fields */
memcpy(pbmiDst, pbmiUnsafe, dwSize);
+ if(!pbmhDst->bV5SizeImage)
+ pbmhDst->bV5SizeImage = DIB_GetDIBImageBytes(pbmhDst->bV5Width,
+ pbmhDst->bV5Height,
+
pbmhDst->bV5Planes*pbmhDst->bV5BitCount) ;
if(dwSize < sizeof(BITMAPV5HEADER))
{
@@ -1939,7 +1970,7 @@
else
{
/* Copy valid Fields, keep bmiHeader.biSize safe */
- RtlCopyMemory(&pbmiDst->bmiHeader.biWidth,
+ RtlCopyMemory(&pbmiDst->bmiHeader.biWidth,
&pbmiSrc->bmiHeader.bV5Width,
pbmiDst->bmiHeader.biSize - sizeof(DWORD));
}
@@ -1957,7 +1988,7 @@
ULONG cColorsUsed;
cColorsUsed = pbmiSrc->bmiHeader.bV5ClrUsed;
- if (cColorsUsed == 0 && pbmiSrc->bmiHeader.bV5BitCount <= 8)
+ if (cColorsUsed == 0 && pbmiSrc->bmiHeader.bV5BitCount <= 8)
cColorsUsed = (1 << pbmiSrc->bmiHeader.bV5BitCount);
if(dwColorUse == DIB_PAL_COLORS)