Washi1337 / AsmResolver

A library for creating, reading and editing PE files and .NET modules.
https://docs.washi.dev/asmresolver/
MIT License
826 stars 125 forks source link

`IWin32Resource::WriteToDirectory` does not take sorting into account #532

Closed Washi1337 closed 2 months ago

Washi1337 commented 3 months ago

AsmResolver Version

5.5.1

.NET Version

.NET 6.0

Operating System

Windows

Describe the Bug

The PE file format states that entries in the resource directories should be sorted. Currently, IconResource and VersionResource do not take this into account. This results in resources not getting interpreted by Windows (e.g., adding GroupIcon before Icon removes the icons from explorer).

How To Reproduce

Expected Behavior

The directories are added in the following order: Icon, GroupIcon.

Actual Behavior

The GroupIcon directory is added before the Icon directory.

Additional Context

https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#resource-directory-entries