Ildasm, then ilasm with the same metadata

We need to fix the build, and we cannot restore the source code at the moment. I can reset IL using ildasm mydll.dll / all / out = mydll.il, and then I can rebuild it using ilasm / dll mydll.il, and all this is fine, except that all things like version file, public key, etc., missing a new binary. How can I say ilasm to add them? I tried the / mdv switch with no luck.

+4
source share
1 answer

The key will not pass both ways - otherwise you can crack any assembly and transfer it as an original.

To sign the assembly in your situation, you will need a key. After you decompile your assembly, fix it - it's easiest if you continue and add the following line to the area where the other Assmbly attributes are:

.custom instance void [mscorlib]System.Reflection.AssemblyDelaySignAttribute::.ctor(bool) = ( 01 00 00 00 00 ) 

This attribute tells ilasm to leave space for the key. After you add this attribute and reassemble your code with ilasm, you need to use the sn utility to delay it. The syntax should be something like this:

 sn /R myreassembled.dll originalassemblykey.snk 

This should exit the assembly.

What version of file are you linking to? This should be an assembly attribute in IL, but if not, you may need al.exe utility to do this.

+7
source

Source: https://habr.com/ru/post/1389704/


All Articles