Index: win32ss/gdi/gdi32/objects/bitmap.c =================================================================== --- win32ss/gdi/gdi32/objects/bitmap.c (revision 56551) +++ win32ss/gdi/gdi32/objects/bitmap.c (working copy) @@ -448,15 +448,32 @@ UINT cjBmpScanSize = 0; HBITMAP hBmp; NTSTATUS Status = STATUS_SUCCESS; - - if (!Header) return 0; - +//No Header, No life + if (!Header) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } +//Let's check if the Header has an appropiate Size. if (DIB_GetBitmapInfo(Header, &width, &height, &planes, &bpp, &compr, &dibsize) == -1) { GdiSetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + // +//Checking if the Compr is incompatible. + if(compr==BI_JPEG||compr==BI_PNG||compr==BI_BITFIELDS) return 0; +//Just DIB_RGB_COLORS(0),DIB_PAL_COLORS(1) and "2" are valid. + if(ColorUse>DIB_PAL_COLORS+1) + { + GdiSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + +//Negative width?No way. + if(width<0) return 0; +//Negative height?Yes. Top-down DIBs have a negative height!So Abs it. + height= abs(height); // For Icm support. // GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))