I'm trying to add basic junk methods to my obfuscator.
I grab all methods (besides constructors) from mscorlib.dll.
I then inject five functions into the global type, the exact same way i inject my string decryption functions (which works)
But when i write the assembly, i get this error:
Unhandled Exception: dnlib.DotNet.Writer.ModuleWriterException: Method System.Void System.Security.CodeAccessPermission::AssertAllPossible() (0600382C) is not defined in this module (). A method was removed that is still referenced by this module.
_RandomMethod returns a random method that is static and has a return type of System.Void
I've tried changing the method body to a nop, and the methods are injected successfully, so problem is 99% that the compiler isn't happy with my way of calling the methods?
You removed a method from an assembly but that assembly is still referencing the method Solution: change all refs to MemberRefs to the new assembly.
You just moved a method from some assembly to another assembly and the method contains references to the original assembly. Solution: do a proper clone of the method. See ConfuserEx source code.
I'm trying to add basic junk methods to my obfuscator. I grab all methods (besides constructors) from mscorlib.dll. I then inject five functions into the global type, the exact same way i inject my string decryption functions (which works) But when i write the assembly, i get this error:
Unhandled Exception: dnlib.DotNet.Writer.ModuleWriterException: Method System.Void System.Security.CodeAccessPermission::AssertAllPossible() (0600382C) is not defined in this module (). A method was removed that is still referenced by this module.
_RandomMethod returns a random method that is static and has a return type of System.Void
I've tried changing the method body to a nop, and the methods are injected successfully, so problem is 99% that the compiler isn't happy with my way of calling the methods?