0

How can I rename every single unicode variable name ?
Its hard to analyse, and also build. It raises a lot errors.
I know, I can change their name via edit property, but its really hard to change names in bulk manually.

Please view images: enter image description here

enter image description here

So is there any method, I can rename it in dnspy or any other hack to recover this wound ?

Gray Programmerz
  • 479
  • 1
  • 5
  • 22
  • Source code is text and any text editor will work. Why can't you fix in VS using replace (CNTL F) and select project instead of current module. – jdweng Apr 30 '21 at 06:38
  • As before I mentioned, there are tons of variables. So I can't really rename them all via hands/manually. – Gray Programmerz Apr 30 '21 at 06:42
  • This is close to "how do I write a de-obfuscator", which is a big topic that's not exactly suited to a small answer. If the obfuscator is any good renamed identifiers are the least of your problems; it may generate IL that cannot easily be translated back into valid C# (as you can do more things in IL than you can do in C#). Nor is there really any guarantee that the code will roundtrip when compiled again. If all you want to do is patch out some licensing code, disassembling to IL, tweaking a jump or check and reassembling is probably faster. – Jeroen Mostert Apr 30 '21 at 07:02
  • Its NOT obfuscated. Just unicode characters like `` are shown as hex encoded `\uXXXX`. So I wanna replace`` with some text name. – Gray Programmerz Apr 30 '21 at 07:07
  • And I tried with ildasm, but variables remain same. – Gray Programmerz Apr 30 '21 at 07:07
  • Then write an applicaton that does the replacement. The source files are just text files. – jdweng Apr 30 '21 at 07:15
  • If we're not dealing with obfuscated code but just garden variety Unicode identifiers (and I doubt that, as your screenshot blatantly includes method names like `checkLicense` and `DecryptString`) it's a shortcoming in the decompiler -- `U+1F642 SLIGHTLY SMILING FACE` would be encoded with two code points. `\uE000` is a sequence for a private use character that has no representation in C# as a (readable) identifier, so the decompiler is doing the best it can without actually changing the code (as that could easily break things). – Jeroen Mostert Apr 30 '21 at 07:18

1 Answers1

1

This is ok that you are getting errors, try to write in Method name and the symbols as you using in dnspy in Visual Studio or somewhere else, you will get the same thing. You could change the User-strings in ILSpy String heap or UserString heap or in dnSpy US and change the strings without errors. Stay a space (empty string) is enough to make the same thing as you show, also you may use dnlib list all of types then rename them, or use de4dot.

Example, select method -> press edit method then change method name -> save module -> done. enter image description here

enter image description here

sunnamed
  • 96
  • 1
  • 10