Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify metadata programmatically (of .net executable)

I want my application to be able to modify the metadata of a .net executable. Is there a .net class to do that, or do I have to parse the executable? (Can Roslyn be of any help here?)

If I need to parse the exe - What is its format? I searched, but only came up with this Wikipedia entry.

like image 799
ispiro Avatar asked Nov 20 '25 22:11

ispiro


2 Answers

There are no .NET classes that allow you to rewrite IL.

You'll have to choose between using Mono.Cecil or reading CLR via C# and then writing your own IL rewriter. (It's technically possible, after all JB Evain wrote Mono.Cecil almost entirely by himself).

Mono.Cecil's source is available in full on Github.

Basics on Mono.Cecil's usage maybe found in its wiki.

like image 104
JoshVarty Avatar answered Nov 23 '25 12:11

JoshVarty


If I need to parse the exe - What is its format?

The format is specified in ECMA 335, which describes the Common Language Infrastructure. But it's over 400 pages, you don't want to implement a reader/writer for all of that yourself. If you really do, you should probably start with the section that describes the file header (§II.25).

like image 32
svick Avatar answered Nov 23 '25 10:11

svick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!