PEReader in .Net Framework?

Peter Volz 1,295 Reputation points
2024-03-12T20:25:20.2566667+00:00

Hello experts,

Going to determine if a file is an executable of any kind, exe dll ocx etc...

Checking the initial 2 bytes to be MZ or ZM is not accurate at all, so here's a good way, the second sample, PEReader:

https://learn.microsoft.com/en-us/dotnet/standard/assembly/identify

Seems only available to .NET and not .NET Framework!

Any trick to find out if a file is any executable?

Thanks for help :)

Developer technologies VB
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2024-03-13T01:30:27.5633333+00:00

    Hi @Peter Volz ,

    PEReader class can be used in .NET Framework, you need to install the System.Reflection.Metadata NuGet package.

    I tested it with sample code in .NET Framework 4.7.2

    User's image

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.