C/C++ has the set of predefined structures and constants corresponding to an exe-header and so on. Do exist some analogical standard namespaces, classes in C# special for analyzing of portable executable files? Or is it only a prerogative of unmanaged unsafe more native languages?
-
C# is perfectly capable of reading binary files. Nothing at all to stop you doing this.David Heffernan– David Heffernan2013-10-01 11:00:53 +00:00Commented Oct 1, 2013 at 11:00
-
2David, it's exactly what I did before, but I think maybe I try to reinvent the wheel.SerG– SerG2013-10-01 11:09:47 +00:00Commented Oct 1, 2013 at 11:09
-
Well, you could always try a websearch.David Heffernan– David Heffernan2013-10-01 11:12:58 +00:00Commented Oct 1, 2013 at 11:12
-
2Of course, I did, but could not find the answer.SerG– SerG2013-10-01 11:17:14 +00:00Commented Oct 1, 2013 at 11:17
-
1Google. Oh, really "C# pe file" works, it seems I use too specific request form. I think it's not a reason to remove the question, isn't it? Maybe it can be userful for people having the same mindset.SerG– SerG2013-10-01 12:17:21 +00:00Commented Oct 1, 2013 at 12:17
3 Answers
There exists an managed library called PeNet which is available as open source and as a NuGet package, too. You can access and change nearly all structures in the PE header with this library. PeNet GitHub
Disclaimer: I'm the main author of the library
Comments
There's not much built-in to the language (if anything), but there's lots of examples out there, such as
1 Comment
An interesting library which is published for a number of languages including c#:
https://formats.kaitai.io/microsoft_pe/csharp.html
It uses another Kaitai's class named "Kaitai Struct", which is another interesting and more general class for reading binary files.