From afd39cbc06bcd2af34fedc581978398f9f236ddb Mon Sep 17 00:00:00 2001 From: Doug Lyons Date: Tue, 12 Mar 2024 02:45:22 -0500 Subject: [PATCH] [USER32] Show Debug Log Message when unhandled PNG found in ICO file. (#5566) Detect the PNG data in ICO files and print an appropriate message to the debug log. JIRA issue: CORE-19107 --- win32ss/user/user32/windows/cursoricon.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/win32ss/user/user32/windows/cursoricon.c b/win32ss/user/user32/windows/cursoricon.c index a3f8a48602e..eb160a88c13 100644 --- a/win32ss/user/user32/windows/cursoricon.c +++ b/win32ss/user/user32/windows/cursoricon.c @@ -179,6 +179,12 @@ static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, LONG *height, WORD *bpp, DWORD *compr ) { + #define CR 13 + #define LF 10 + #define EOFM 26 // DOS End Of File Marker + #define HighBitDetect 0x89 // Byte with high bit set to test if not 7-bit + /* wine's definition */ + static const BYTE png_sig_pattern[] = { HighBitDetect, 'P', 'N', 'G', CR, LF, EOFM, LF }; if (header->biSize == sizeof(BITMAPCOREHEADER)) { const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header; @@ -198,7 +204,15 @@ static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, *compr = header->biCompression; return 1; } - ERR("(%d): unknown/wrong size for header\n", header->biSize ); + if (memcmp(&header->biSize, png_sig_pattern, sizeof(png_sig_pattern)) == 0) + { + ERR("Cannot yet display PNG icons\n"); + /* for PNG format details see https://en.wikipedia.org/wiki/PNG */ + } + else + { + ERR("Unknown/wrong size for header of 0x%x\n", header->biSize ); + } return -1; } @@ -1377,7 +1391,10 @@ CURSORICON_LoadFromFileW( /* Do the dance */ if(!CURSORICON_GetCursorDataFromBMI(&cursorData, (BITMAPINFO*)(&bits[entry->dwDIBOffset]))) - goto end; + { + ERR("Failing File is \n '%S'.\n", lpszName); + goto end; + } hCurIcon = NtUserxCreateEmptyCurObject(FALSE); if(!hCurIcon)