Author: fireball Date: Thu Sep 16 20:04:53 2010 New Revision: 48784
URL: http://svn.reactos.org/svn/reactos?rev=48784&view=rev Log: - Always capture unsafe bits buffer in SetDIBits to a safe one allocated from heap (by analogy from trunk's gdi32). - Cleanup winent.rbuild, add PSEH library. See issue #5509 for more details.
Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c branches/arwinss/reactos/dll/win32/winent.drv/winent.h branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild
Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] Thu Sep 16 20:04:53 2010 @@ -18,6 +18,7 @@ #include <win32k/ntgdityp.h> #include "ntrosgdi.h" #include "winent.h" +#include <pseh/pseh2.h> #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(rosgdidrv); @@ -732,6 +733,8 @@ { LONG height, width, tmpheight; WORD infoBpp, compression; + PVOID safeBits = NULL; + INT result, bitsSize;
/* Perform extensive parameter checking */ if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, @@ -745,8 +748,34 @@
if (startscan + lines > height) lines = height - startscan;
- return RosGdiSetDIBits(physDev->hKernelDC, hbitmap, startscan, - tmpheight >= 0 ? lines : -lines, bits, info, coloruse); + /* Create a safe copy of bits */ + bitsSize = DIB_GetDIBWidthBytes( width, infoBpp ) * height; + + if ( bits ) + { + safeBits = HeapAlloc( GetProcessHeap(), 0, bitsSize ); + if (safeBits) + { + _SEH2_TRY + { + RtlCopyMemory( safeBits, bits, bitsSize ); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ERR("StretchDIBits failed to read bits 0x%p, size: %d\n", bits, bitsSize); + } + _SEH2_END + } + } + + result = RosGdiSetDIBits(physDev->hKernelDC, hbitmap, startscan, + lines, safeBits, info, coloruse); + + /* Free safe copy of bits */ + if ( safeBits ) + HeapFree( GetProcessHeap(), 0, safeBits ); + + return result; }
INT CDECL RosDrv_SetDIBitsToDevice( NTDRV_PDEVICE *physDev, INT xDest, INT yDest, DWORD cx, @@ -960,4 +989,9 @@ return DIB_GetBitmapInfoEx( header, width, height, &planes, bpp, compr, &size); }
+INT DIB_GetDIBWidthBytes(INT width, INT depth) +{ + return ((width * depth + 31) & ~31) >> 3; +} + /* EOF */
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] Thu Sep 16 20:04:53 2010 @@ -49,6 +49,8 @@ int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, LONG *height, WORD *bpp, WORD *compr );
+INT DIB_GetDIBWidthBytes(INT width, INT depth); + void CDECL RosDrv_SetDeviceClipping( NTDRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn );
/* font.c */
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/winent.rbuild [iso-8859-1] Thu Sep 16 20:04:53 2010 @@ -21,7 +21,7 @@ <library>imm32</library> <library>gdi32</library> <library>user32</library> - <library>kernel32</library> <library>ntdll</library> + <library>pseh</library> <library>win32ksys</library> </module>