dotnet / ILMerge

ILMerge is a static linker for .NET Assemblies.
MIT License
1.23k stars 170 forks source link

Fixed invalid RT_GROUP_ICON when adding icons directly from the Writer class #74

Closed vocero closed 4 years ago

vocero commented 4 years ago

Resource type RT_GROUP_ICON weren't written properly when calling the AddWin32Icon methods on the Writer class, the ID of each GRPICONDIRENTRY were written as an INT instead of a USHORT.

mike-barnett commented 4 years ago

Wow! How did you ever find this? Thanks so much!

vocero commented 4 years ago

That's exactly what I told myself when I found it hehe. I was trying to find a method to make ILMerge use a different icon for the output file that the source or the attribute assemblies. So after experimenting with the AddWin32Icon method of the Writer class, I couldn't get it to work (the generated exe only contained the first icon size, and the rest were missing). I then tried loading the that generated exe in a win32 resource viewer, and I had the same problem (only the first icon size was showing).

I ended up writing a test .net app that would parse all the icons from the Win32 resources, and only after that I noticed that all GRPICONDIRENTRY icon structures were there, but only the first one had correct values, all subsequent structures values were invalid. I then came to the conclusion that ILMerge must not be writing them properly, debugged it and found it.

I assume that it was never reported as this method is not really exposed as an option in the ILMerge.exe, I just stumbled on it because I ended up calling it.

Glad I could help.

mike-barnett commented 4 years ago

Very impressive! Congrats!