mono/website

Troubles reading dll libraries (ModuleDefinition.ReadModule)

oliluc opened this issue · 2 comments

The ModuleDefinition.ReadModule method builds a module from a file and it uses the ImageReader class, that can trigger a BadImageFormatException. In particular if CLIHeader (CLR Runtime Header in the microsoft documentation) is zero, the exception is triggered by the ReadOptionalHeaders method of ImageReader class.
Since many dll libraries respect the PE format (https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format) but are not a valid Image, It would be great if Mono.Cecil could provide an API to test the PE headers before reading the image.
Looking at the source code, such functionality seems almost already implemented in the “Mono.Cecil.PE” package which is currently not accessible for public use.
I would like to kindly ask for a change of visibility of the above mentioned package or, at least, or to provide basic check functionalities of PE format.

Mono.Cecil is maintained in the https://github.com/jbevain/cecil repository, please file this issue over there.

This repo is just for the mono-project.com website :)

Oh sorry, thank you! I will upload the question on the right repository :)