diff --git "a/win32ss/user/user32/misc/exticon.c" "b/win32ss/user/user32/misc/exticon.c" index 33f8f19b15f..a3441225366 100644 --- "a/win32ss/user/user32/misc/exticon.c" +++ "b/win32ss/user/user32/misc/exticon.c" @@ -714,9 +714,69 @@ static UINT ICO_ExtractIconExW( xresdir = find_entry_by_id(iconresdir, LOWORD(pIconId[i]), rootresdir); if( !xresdir ) { + const IMAGE_RESOURCE_DIRECTORY *resdir; WARN("icon entry %d not found\n", LOWORD(pIconId[i])); - RetPtr[i]=0; - continue; + + /* Try to get an icon by walking the files Resource Section */ + if (iconresdir->NumberOfIdEntries > 0) + { + xresent = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*) + (ULONG_PTR)(iconresdir + 1); + } + else + { + RetPtr[i]=0; + continue; + } + + /* Get the Resource Directory */ + resdir = (const IMAGE_RESOURCE_DIRECTORY *) + ((const char *)rootresdir + xresent->OffsetToDirectory); + + if (resdir->NumberOfIdEntries > 0) // Do we have entries + { + xresent = (const IMAGE_RESOURCE_DIRECTORY_ENTRY*) + (ULONG_PTR)(resdir + 1); + } + else + { + RetPtr[i]=0; + continue; + } + + /* Retreive the data entry and find its address */ + igdataent = (const IMAGE_RESOURCE_DATA_ENTRY*) + ((const char *)rootresdir + xresent->OffsetToData); + idata = RtlImageRvaToVa(RtlImageNtHeader((HMODULE)peimage), + (HMODULE)peimage, igdataent->OffsetToData, NULL); + if (!idata) + { + RetPtr[i]=0; + continue; + } + + /* Check to see if this looks like an icon bitmap */ + if (idata[0] == sizeof(BITMAPINFOHEADER)) + { + BITMAPINFOHEADER bmih; + RtlCopyMemory(&bmih, idata, sizeof(BITMAPINFOHEADER)); + /* Do the Width and Height look correct for an icon */ + if (bmih.biWidth == 32 && bmih.biHeight == 64) + { + RetPtr[0] = CreateIconFromResourceEx(idata, igdataent->Size, + TRUE, 0x00030000, cx1, cy1, flags); + if (cx2 && cy2) + RetPtr[1] = CreateIconFromResourceEx(idata, idataent->Size, + TRUE, 0x00030000, cx2, cy2, flags); + ret = 1; // Set number of icons found + goto end; // Success so Exit + } + } + else + { + RetPtr[i]=0; + continue; + } } xresdir = find_entry_default(xresdir, rootresdir); idataent = (const IMAGE_RESOURCE_DATA_ENTRY*)xresdir;