jbevain / cecil

Cecil is a library to inspect, modify and create .NET programs and libraries.
MIT License
2.71k stars 619 forks source link

The MVID is not added to the sections #934

Open mattleibow opened 6 months ago

mattleibow commented 6 months ago

Looking at the code use a C# build: https://github.com/dotnet/roslyn/blob/main/src/Compilers/Core/MSBuildTask/MvidReader.cs

I see it scans the sections for a .mvid to locate the MVID. If I open, edit, and then write the module, I lose the .mvid section.

When debugging, I see that before saving, there are 4 sections, after there are 3.

mattleibow commented 6 months ago

Looking at the sections builder in the writer, I do only see 3 being written: https://github.com/jbevain/cecil/blob/56d4409b8a0165830565c6e3f96f41bead2c418b/Mono.Cecil.PE/ImageWriter.cs#L116-L134

I see the .mvid section being loaded in the module image before