diff options
| author | 2015-02-25 00:12:04 -0500 | |
|---|---|---|
| committer | 2015-02-25 00:12:04 -0500 | |
| commit | 4479acf3df4faf9daac93a396f5bba7cddb0759b (patch) | |
| tree | 7893ff75cecdadfdc196e34b89c929bfe42d8955 /src/cuchaz/enigma/analysis/JarIndex.java | |
| parent | lots of work in better handling of inner classes (diff) | |
| download | enigma-fork-4479acf3df4faf9daac93a396f5bba7cddb0759b.tar.gz enigma-fork-4479acf3df4faf9daac93a396f5bba7cddb0759b.tar.xz enigma-fork-4479acf3df4faf9daac93a396f5bba7cddb0759b.zip | |
more work getting inner class trees working in obf'd and deobf'd land
Diffstat (limited to 'src/cuchaz/enigma/analysis/JarIndex.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/JarIndex.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java index 6e7c69d..1afcb76 100644 --- a/src/cuchaz/enigma/analysis/JarIndex.java +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -28,6 +28,7 @@ import javassist.NotFoundException; | |||
| 28 | import javassist.bytecode.AccessFlag; | 28 | import javassist.bytecode.AccessFlag; |
| 29 | import javassist.bytecode.Descriptor; | 29 | import javassist.bytecode.Descriptor; |
| 30 | import javassist.bytecode.FieldInfo; | 30 | import javassist.bytecode.FieldInfo; |
| 31 | import javassist.bytecode.InnerClassesAttribute; | ||
| 31 | import javassist.expr.ConstructorCall; | 32 | import javassist.expr.ConstructorCall; |
| 32 | import javassist.expr.ExprEditor; | 33 | import javassist.expr.ExprEditor; |
| 33 | import javassist.expr.FieldAccess; | 34 | import javassist.expr.FieldAccess; |
| @@ -160,9 +161,11 @@ public class JarIndex { | |||
| 160 | ClassEntry innerClassEntry = mapEntry.getValue(); | 161 | ClassEntry innerClassEntry = mapEntry.getValue(); |
| 161 | outerClassEntry = EntryFactory.getChainedOuterClassName(this, outerClassEntry); | 162 | outerClassEntry = EntryFactory.getChainedOuterClassName(this, outerClassEntry); |
| 162 | String newName = outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName(); | 163 | String newName = outerClassEntry.getName() + "$" + innerClassEntry.getSimpleName(); |
| 163 | // DEBUG | 164 | if (!innerClassEntry.getName().equals(newName)) { |
| 164 | //System.out.println("REPLACE: " + innerClassEntry.getName() + " WITH " + newName); | 165 | // DEBUG |
| 165 | renames.put(innerClassEntry.getName(), newName); | 166 | //System.out.println("REPLACE: " + innerClassEntry.getName() + " WITH " + newName); |
| 167 | renames.put(innerClassEntry.getName(), newName); | ||
| 168 | } | ||
| 166 | } | 169 | } |
| 167 | EntryRenamer.renameClassesInSet(renames, m_obfClassEntries); | 170 | EntryRenamer.renameClassesInSet(renames, m_obfClassEntries); |
| 168 | m_translationIndex.renameClasses(renames); | 171 | m_translationIndex.renameClasses(renames); |
| @@ -299,6 +302,22 @@ public class JarIndex { | |||
| 299 | 302 | ||
| 300 | private ClassEntry findOuterClass(CtClass c) { | 303 | private ClassEntry findOuterClass(CtClass c) { |
| 301 | 304 | ||
| 305 | ClassEntry classEntry = EntryFactory.getClassEntry(c); | ||
| 306 | |||
| 307 | // does this class already have an outer class? | ||
| 308 | if (classEntry.isInnerClass()) { | ||
| 309 | return classEntry.getOuterClassEntry(); | ||
| 310 | } | ||
| 311 | InnerClassesAttribute innerClassesAttribute = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag); | ||
| 312 | if (innerClassesAttribute != null) { | ||
| 313 | for (int i=0; i<innerClassesAttribute.tableLength(); i++) { | ||
| 314 | ClassEntry innerClassEntry = new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.innerClass(i))); | ||
| 315 | if (classEntry.equals(innerClassEntry)) { | ||
| 316 | return new ClassEntry(Descriptor.toJvmName(innerClassesAttribute.outerClass(i))); | ||
| 317 | } | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 302 | // inner classes: | 321 | // inner classes: |
| 303 | // have constructors that can (illegally) set synthetic fields | 322 | // have constructors that can (illegally) set synthetic fields |
| 304 | // the outer class is the only class that calls constructors | 323 | // the outer class is the only class that calls constructors |
| @@ -310,7 +329,6 @@ public class JarIndex { | |||
| 310 | continue; | 329 | continue; |
| 311 | } | 330 | } |
| 312 | 331 | ||
| 313 | ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(c.getName())); | ||
| 314 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(constructor); | 332 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(constructor); |
| 315 | 333 | ||
| 316 | // gather the classes from the illegally-set synthetic fields | 334 | // gather the classes from the illegally-set synthetic fields |