domingo, 12 de enero de 2014

[.NET Reflection] How to rename correctly to get a working assembly?

Hello!
Maybe you are trying to do an obfuscator/deobfuscator. You got all the types and the methods and you're applying .Name = "My new name". But the symbol renaming has some rules to get again a working assembly.

The renaming rules for types.
It mustn't be...

  • <Module> class.
  • "Runtime".
  • "RuntimeSpecialName".
  • Contain "Resources" or "__".
  • Be an Enum.
For some types you also need to edit the resources. For example in a "System.Windows.Forms.Form" it creates a resource which is "Project_Name.FormName.resources". If you edit the name, it won't run anymore. The solution is to rename also the resource with:
"Project_Name.NewFormName.resources". Just that.

The renaming rules for methods.
It mustn't be...
  • contructor (.ctor and .cctor).
  • "Runtime".
  • "RuntimeSpecialName".
  • "Virtual".
  • "Abstract"
  • No "Overrides" of that method.
  • "PInvokeImpl" of any library.

All of this have a reason. Mostly because of the calling from other methods. For example, if any method is with PInvokeImpl which means it calls to an external function on a DLL you can't rename it.

In some cases, you also need to forget "InitializeComponent". But it depends on the assembly.


I hope this helps as in the internet there is no good documentation about symbol renaming.

See you,
LordCoder//REiS

No hay comentarios:

Publicar un comentario