Closed MizzMaster closed 3 years ago
1.x
versions of Recaf allowed changing all CFR options. It'd be nice if this can be supported again. Some reflection (e.g. on here) can be used to avoid the tedious work of keeping all the options up-to-date.
--renameillegalidents
would solve the problem in this case.
Does --renameillegalidents
change the ones that use "reserved keywords"?
$ cfr --help renameillegalidents
Rename identifiers which are not valid java identifiers. Note - this WILL break reflection based access, so is not automatically enabled.
Yes.
I hope this does not break Recaf
CFR just decompiles and gives us text based representation. Not all the time perfect and not all the time same, i was trying to rename that illegal metod in Recaf but i couldnt
So, CFR doesnt change the actual name, it just changes while showing you up
And i forgot to mention, I was trying to rename it on "Table Mode", but when i press enter, it does nothing
~If you just want to rename stuff, the Table view will surely work?~
Or not, I guess.
By the way, I've always find the decompile view not very helpful because any obfuscation can easily break the parser, and if that failed, the whole page is reduced to a fancy textbox. Proper IDEs and language servers have the ability to parse partial source, but I imagine that'd be hard to implement.
Yeah, decompile mode is not intended for obfuscated code. This is stated in the docs: https://www.coley.software/Recaf/doc-edit-mode-decompile.html
I wish it could be better suited but all I can do is implement JavaParser, which is very strict and doesn't allow for small mistakes in the decompiled code. Its understandable why it is that way, but it is unfortunate.
CFR renaming is cool but would break how decompile mode context actions work.
You should change the default mode to table otherwise. Which shows fields and methods properly. If renaming doesn't work can you provide what is necessary for minimally reproducing the issue?
I tried to reproduce this issue by writing a new class from scratch, it didn't happen anywhere. But I took the .class file from the jar that I was working on, and loaded it on Recaf, I couldn't rename variables using Table Mode.
If it is possible, can you give me a link that I can send this class file to you? (Maybe it's not suitable for guidelines)
Actually, if this issue coming from JUST because obfuscation, I can open an issue on Java Deobfuscator to fix that by renaming the illegal idents, or maybe there is already a transformer to do that, whatever, this caused Recaf to cant rename.
Before I sent this post, I checked if I can edit the name on assembler, I could. But i dont know if it is renamed in other classes
Put it into a zip and drag and drop it in a comment here or dm me on discord
Ah the renaming failure is because they put junk data into the signature attribute and ASM crashes.
2.8.0
should allow you to rename these things :)
It may still have some trouble with whitespace.... that's a tougher problem.
Closing as the specific problem has been resolved.
As mentioned, whitespace names and other tricky things are on a different level.
You know that there are words that we cant use while declaring a method or a variable. BUT FU***NG OBFUSCATORS CAN! I spent more than 30 hours dealing with bugs. I got mad, sorry.
If an obfuscator rename a variable with an illegal(unicode or reserved keywords), this causes Recaf suck while parsing decompiled code. If an variable name gets invisible, that means it is unicode, but if a method name gets unparseable, it means you cant even change it's name using table mode.
In my jar, there are 2 methods named "do" and "if" and maybe a lot more. I don't know if it is your job to fix this but it causes your program to cant even rename this illegal method. If you say that is not my job, i will open an issue on "Java Deobfuscator" repo.
Btw, you can run CFR with -renameillegalidents to prevent unicode bug.