aloneguid/win-shim

Generated shim has an ugly icon

Opened this issue · 1 comments

  1. Make a shim pointing to any app with icon, say Notepad:
shmake.exe -i notepad.exe -o sample.exe
  1. Open Explorer and check the mirrored icon of the generated shim. It looks much worse compared to the original one.

icons

I suspect this happens because shmake doesn't copy icon groups from the input executable. According to docs, Windows chooses the most appropriate icon to display based on icon groups but not plain icon resources.

Let's inspect the resources of Notepad app:

notepad

As we see, Notepad has an icon group with ID 2 containing thirteen icons of various resolutions, including high quality ones.

Now the generated shim:

sample

There is an icon group with ID 101 containing only three low-res icons. That's why the generated shim appears ugly in Explorer.

Where did the icon group 101 come from? It is actually a leftover from the win-shim's default "umbrella" icon. Initially it contained three umbrella icons of resolutions 32x32, 64x64 and 256x256. During the shim creation umbrella icons were overwritten by Notepad icons. Now the icon group 101 points to the first three Notepad icons of much lower resolution. It is what causes the ugly appearance.

In summary, I believe shmake should copy icon groups from the input executable (numbered 2, 300, 301 and 302 in our particular case) and also remove umbrella icon group 101 to avoid unwanted leftovers and glitches.

mnivet commented

I’ve experienced the same issue. But since our need of shim.exe is on executables we compile ourself, for now we have just aligned the icons Embedded in our exe to match the icon groups from shim.exe.

I’ll be happy to see the fix to that issue officially integrated.