Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fernflower not renaming fields/methods
#11
(05-16-2015, 06:55 PM)Bibl Wrote:  
(05-16-2015, 08:28 AM)sothatsit Wrote:  
(05-15-2015, 06:51 AM)Bibl Wrote:  just tried fernflower and the same thing is happening for me, guess you should rename with proguard or retroguard.
I think I'm actually going to use asm to edit the bytecode to rename the fields/methods/classes. This is good because then I don't have to recompile the source code afterwards. Thanks for your help Smile
nono, you can run retroguard it and the classes are renamed (still in classfile form)
i'm working on one with asm at the moment that doesnt rely on the asm visitors
http://hastebin.com/aqocujidaj.java
What is the issue with using ClassVisitors?

Just to give you an idea of what i am doing:

I am loading the classes using a ClassReader, i then use a ClassVisitor and map out all of values given for the classes/fields/methods into a ClassMap class, then i use this ClassMap to base my refactoring off of. So after that i loop through the classes from my ClassMap and do all the refactoring. My reasoning for this is that it would be a lot easier to manage super classes/interfaces by doing this as i can directly get access to all of the info whenever i need it.

I then create a RefactorMap using the ClassMap which i will later use to rename everything.

If you want to check out what i have done so far you can see it here https://github.com/Sothatsit/GamepackDownloader/
Reply
#12
I prefer the node system rather than the visitor system (it's much more flexible imo).
My idea for it is going through all the classes/fields/methods and grabbing a name from the mapping provider and then just setting it. all of the other stuff, such as descriptions, super classes, super interfaces, inherited methods etc. are handled by the refactorer and the remapper only gives new names for the nodes.
Reply
#13
https://gist.github.com/TheBiblMan/5e1d9e20c877b5ea6fcb
got field and class renaming done 100%, methods may not work 100% so i've gotta work on that.
Reply
#14
(05-18-2015, 05:51 AM)Bibl Wrote:  https://gist.github.com/TheBiblMan/5e1d9e20c877b5ea6fcb
got field and class renaming done 100%, methods may not work 100% so i've gotta work on that.

That looks interesting, I'll definitely take a look and see what you do. The main issue I have is that I want to rename classes/fields/methods to more unique and identifiable names, like class_eSomeClass_iSomeInterface_1. This is just as an attempt to make it less breakable if the order of the classes/methods/fields are changed. I have the renaming completely working, like working and mapping out there names, but I am having some issues with Frnflower throwing an error to something of the effect of "the archive or some of its contents is invalid". I'm not at the computer now so I can't check it. Do you think you could take a look at https://github.com/Sothatsit/GamepackDow...factor/asm and tell me if you see anything wrong? If not, no problem, I'm sure I'll figure it out Smile I have only implemented class refactoring thus far as I thought I would get that to work before working on methods/fields.
Reply
#15
I think you also need to handle TypeInsnNodes, maybe even LdcInsnNodes as well for(Types).
I'd recommend you look at the code I posted to see the sort of things you should refactor and what you shouldn't (which insns, which methods, hierarchy methods and classes etc)
Reply
#16
(05-18-2015, 02:59 PM)Bibl Wrote:  I think you also need to handle TypeInsnNodes, maybe even LdcInsnNodes as well for(Types).
I'd recommend you look at the code I posted to see the sort of things you should refactor and what you shouldn't (which insns, which methods, hierarchy methods and classes etc)

Sorry for the late reply, been really busy. I have been looking through AbstractInsnNode's sub classes and it seems these are the ones which refer to types which could be refactored:
TypeInsnNode
MethodInsnNode
MultiANewArrayInsnNode
FieldInsnNode

Those are the ones which refer to names which could be refactored.

On another note, i have started to switch from visitors to using ClassNodes. There is a performance difference but its not much of an issue for me.

Thanks for all your help with everything!
Reply
#17
Reply
#18
does the jar run properly?
Reply
#19
(05-24-2015, 03:12 AM)Bibl Wrote:  does the jar run properly?

I have not tried yet, but fernflower decompiles it properly, which it wasn't doing before. Having thought about how I did everything though I have made some mistakes which I need to fix. Like, duplicate methods does not take into account if the method is overriden in a super class or is from a sub-class. It doesn't rename the class file if the class name has changed. I'm sure there's more that I haven't thought of yet. So, I don't think it would run in its current state, but when I fix some of the issues with it, it hopefully will.
Reply
#20
yeah, inheritence was my biggest problem at the start.
Reply
 


Forum Jump:


Users browsing this thread: 1 Guest(s)

About The Bytecode Club

We're a community focused on Reverse Engineering, we try to target Java/Android but we also include other langauges/platforms. We pride ourselves in supporting and free and open sourced applications.

Website