[PATCH 0/1] MR10036: winemac.drv: Attempt to correct the size of icon resources.
It seems that some apps have different sizes in the GRPICONDIR and the IMAGE_RESOURCE_DATA_ENTRY. winemenubuilder has had the same workaround since 2014 - see c205e6800a63a5df9960d8484a2e67687d53bc50. --- The size difference is great enough in some situations (e.g. Brotato) that the attempt read the resource may fault. The original mailing list discussion about the winemenubuilder patch is [here](https://marc.info/?l=wine-patches&m=140903555724711&w=2). Huge thanks to @bshanks for spotting that patch. This has apparently always been faulting for some apps, but only became an issue after !10032. The subsequent syscall fault unwinds out of the pthread_once that !10032 added, so future threads that wind up there will hang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10036
From: Tim Clem <tclem@codeweavers.com> It seems that some apps have different sizes in the GRPICONDIR and the IMAGE_RESOURCE_DATA_ENTRY. winemenubuilder has had the same workaround since 2014 - see c205e6800a63a5df9960d8484a2e67687d53bc50. --- dlls/winemac.drv/dllmain.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 7ece4dc99a3..7106038560f 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -290,6 +290,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) LPCWSTR name; HGLOBAL icon_res_data; BYTE *icon_bits; + DWORD actual_size; if (!width) width = 256; if (!height) height = 256; @@ -324,6 +325,9 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) continue; } + /* Some apps have inaccurate sizes in the GRPICONDIR. */ + actual_size = min(icon_dir->idEntries[i].dwBytesInRes, ((IMAGE_RESOURCE_DATA_ENTRY *)res_info)->Size); + icon_res_data = LoadResource(NULL, res_info); if (!icon_res_data) { @@ -338,7 +342,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) entry->width = width; entry->height = height; - entry->size = icon_dir->idEntries[i].dwBytesInRes; + entry->size = actual_size; if (!memcmp(icon_bits, png_magic, sizeof(png_magic))) { @@ -348,7 +352,7 @@ static NTSTATUS WINAPI macdrv_app_icon(void *arg, ULONG size) } else { - HICON icon = CreateIconFromResourceEx(icon_bits, icon_dir->idEntries[i].dwBytesInRes, + HICON icon = CreateIconFromResourceEx(icon_bits, actual_size, TRUE, 0x00030000, width, height, 0); if (icon) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10036
Brendan Shanks (@bshanks) commented about dlls/winemac.drv/dllmain.c:
continue; }
+ /* Some apps have inaccurate sizes in the GRPICONDIR. */ + actual_size = min(icon_dir->idEntries[i].dwBytesInRes, ((IMAGE_RESOURCE_DATA_ENTRY *)res_info)->Size);
It does the same thing, but `SizeofResource(NULL, res_info)` would be a bit cleaner? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10036#note_128896
participants (3)
-
Brendan Shanks (@bshanks) -
Tim Clem -
Tim Clem (@tclem)