[API Proposal]: Add capability in PEReader
to reject COFF files.
#112830
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Reflection.Metadata
untriaged
New issue has not been triaged by the area owner
Background and motivation
When
PEReader
reads an image that does not have a PE header, it tries to read it as a COFF file. However, because COFF files do not have a signature, the reader will not immediately fail when reading files that are not COFF files, which has misleading behavior by not failing, and wastes memory to store section headers. This has affected both first-party (#112653 (comment)) and third-party users (#48419).I am proposing to add an option to cause
PEReader
to immediately throw if the image does not contain a PE header and not attempt to further read it.API Proposal
API Usage
Alternative Designs
PEHeaders(Stream peStream, int size, bool isLoadedImage, bool requirePEHeader)
constructor overload?Risks
The API might be too niche or too hard to discover. Users can do the PE signature validation themselves before creating the
PEReader
; it's quite simple to implement.The text was updated successfully, but these errors were encountered: