jbevain / cecil

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

Assemply.Write damage my dll #830

Closed HPXCoder closed 2 years ago

HPXCoder commented 2 years ago

hi, iam working on a program that edit a dll but i tried to only read and write the dll but its changing the size examble in this pics

the code : sse

the input dll size and the output dll size changed in this pic aa dll1 is the input dll new2 is the output

after write, the dll is no working

ThumbGen commented 2 years ago

I get the same, attempting to patch a regular .Net 4.8 WPF executable. Writing a .NET 5/6 executable crashes.

jbevain commented 2 years ago

Without any form of repro or actionable information I can't do much to help. A few KB of differences can be expected given that Cecil might organize the PE layout slightly differently. I can't do much with «the dll is not working» or «executable crashes». Please file a repro with actionable data.

ThumbGen commented 2 years ago

Sorry, I forgot to come back: I found the root of my problem: I was trying to 'touch' a .NET 4.8 executable by running the Cecil code in a .NET6 command line tool. After migrating the tool from .NET6 back to .NET 4.8, everything works perfectly.