diff --git a/win32ss/user/user32/misc/exticon.c b/win32ss/user/user32/misc/exticon.c index ba2bd6d6b2c..8b22f5b14aa 100644 --- a/win32ss/user/user32/misc/exticon.c +++ b/win32ss/user/user32/misc/exticon.c @@ -439,7 +439,9 @@ static UINT ICO_ExtractIconExW( DWORD dataOffset; LPBYTE imageData; POINT hotSpot; +#ifndef __REACTOS__ LPICONIMAGE entry; +#endif dataOffset = get_best_icon_file_offset(peimage, fsizel, cx[index], cy[index], sig == 1, flags, sig == 1 ? NULL : &hotSpot); @@ -447,14 +449,36 @@ static UINT ICO_ExtractIconExW( { HICON icon; WORD *cursorData = NULL; +#ifdef __REACTOS__ + BITMAPINFOHEADER bmih; +#endif imageData = peimage + dataOffset; +#ifdef __REACTOS__ + memcpy(&bmih, imageData, sizeof(BITMAPINFOHEADER)); +#else entry = (LPICONIMAGE)(imageData); +#endif if(sig == 2) { +#ifdef __REACTOS__ + /* biSizeImage is the size of the raw bitmap data. + * A dummy 0 can be given for BI_RGB bitmaps. + * https://en.wikipedia.org/wiki/BMP_file_format */ + if ((bmih.biCompression == BI_RGB) && + (bmih.biSizeImage == 0)) + { + bmih.biSizeImage = bmih.biWidth * + bmih.biHeight / 2 * bmih.biBitCount / 8; + } +#endif /* we need to prepend the bitmap data with hot spots for CreateIconFromResourceEx */ +#ifdef __REACTOS__ + cursorData = HeapAlloc(GetProcessHeap(), 0, bmih.biSizeImage + 2 * sizeof(WORD)); +#else cursorData = HeapAlloc(GetProcessHeap(), 0, entry->icHeader.biSizeImage + 2 * sizeof(WORD)); +#endif if(!cursorData) continue; @@ -462,12 +486,20 @@ static UINT ICO_ExtractIconExW( cursorData[0] = hotSpot.x; cursorData[1] = hotSpot.y; +#ifdef __REACTOS__ + memcpy(cursorData + 2, imageData, bmih.biSizeImage); +#else memcpy(cursorData + 2, imageData, entry->icHeader.biSizeImage); +#endif imageData = (LPBYTE)cursorData; } +#ifdef __REACTOS__ + icon = CreateIconFromResourceEx(imageData, bmih.biSizeImage, sig == 1, 0x00030000, cx[index], cy[index], flags); +#else icon = CreateIconFromResourceEx(imageData, entry->icHeader.biSizeImage, sig == 1, 0x00030000, cx[index], cy[index], flags); +#endif HeapFree(GetProcessHeap(), 0, cursorData);