diff options
| author | 2014-08-11 23:18:10 -0400 | |
|---|---|---|
| committer | 2014-08-11 23:18:10 -0400 | |
| commit | 603245ee6218668eb8eb39e63ecedce257b3ef35 (patch) | |
| tree | 80cc294f793758ed4509187c58b86d96f5b62473 /src | |
| parent | added method inheritance browsing (diff) | |
| download | enigma-fork-603245ee6218668eb8eb39e63ecedce257b3ef35.tar.gz enigma-fork-603245ee6218668eb8eb39e63ecedce257b3ef35.tar.xz enigma-fork-603245ee6218668eb8eb39e63ecedce257b3ef35.zip | |
refactor Ancestries into Ancestries and JarIndex
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuchaz/enigma/Deobfuscator.java | 16 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/Ancestries.java | 145 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/JarIndex.java | 176 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | 8 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 4 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/Renamer.java | 14 |
6 files changed, 197 insertions, 166 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index 5321d2d..c35a483 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java | |||
| @@ -31,7 +31,7 @@ import com.strobel.decompiler.languages.java.ast.AstBuilder; | |||
| 31 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 31 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 32 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; | 32 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; |
| 33 | 33 | ||
| 34 | import cuchaz.enigma.analysis.Ancestries; | 34 | import cuchaz.enigma.analysis.JarIndex; |
| 35 | import cuchaz.enigma.analysis.SourceIndex; | 35 | import cuchaz.enigma.analysis.SourceIndex; |
| 36 | import cuchaz.enigma.analysis.SourceIndexVisitor; | 36 | import cuchaz.enigma.analysis.SourceIndexVisitor; |
| 37 | import cuchaz.enigma.mapping.ArgumentEntry; | 37 | import cuchaz.enigma.mapping.ArgumentEntry; |
| @@ -50,7 +50,7 @@ public class Deobfuscator | |||
| 50 | private File m_file; | 50 | private File m_file; |
| 51 | private JarFile m_jar; | 51 | private JarFile m_jar; |
| 52 | private DecompilerSettings m_settings; | 52 | private DecompilerSettings m_settings; |
| 53 | private Ancestries m_ancestries; | 53 | private JarIndex m_jarIndex; |
| 54 | private Mappings m_mappings; | 54 | private Mappings m_mappings; |
| 55 | private Renamer m_renamer; | 55 | private Renamer m_renamer; |
| 56 | private List<String> m_obfClassNames; | 56 | private List<String> m_obfClassNames; |
| @@ -65,9 +65,9 @@ public class Deobfuscator | |||
| 65 | InputStream jarIn = null; | 65 | InputStream jarIn = null; |
| 66 | try | 66 | try |
| 67 | { | 67 | { |
| 68 | m_ancestries = new Ancestries(); | 68 | m_jarIndex = new JarIndex(); |
| 69 | jarIn = new FileInputStream( m_file ); | 69 | jarIn = new FileInputStream( m_file ); |
| 70 | m_ancestries.readFromJar( jarIn ); | 70 | m_jarIndex.indexJar( jarIn ); |
| 71 | } | 71 | } |
| 72 | finally | 72 | finally |
| 73 | { | 73 | { |
| @@ -107,9 +107,9 @@ public class Deobfuscator | |||
| 107 | return m_file.getName(); | 107 | return m_file.getName(); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | public Ancestries getAncestries( ) | 110 | public JarIndex getJarIndex( ) |
| 111 | { | 111 | { |
| 112 | return m_ancestries; | 112 | return m_jarIndex; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | public Mappings getMappings( ) | 115 | public Mappings getMappings( ) |
| @@ -123,7 +123,7 @@ public class Deobfuscator | |||
| 123 | val = new Mappings(); | 123 | val = new Mappings(); |
| 124 | } | 124 | } |
| 125 | m_mappings = val; | 125 | m_mappings = val; |
| 126 | m_renamer = new Renamer( m_ancestries, m_mappings ); | 126 | m_renamer = new Renamer( m_jarIndex, m_mappings ); |
| 127 | 127 | ||
| 128 | // update decompiler options | 128 | // update decompiler options |
| 129 | m_settings.setTypeLoader( new TranslatingTypeLoader( | 129 | m_settings.setTypeLoader( new TranslatingTypeLoader( |
| @@ -135,7 +135,7 @@ public class Deobfuscator | |||
| 135 | 135 | ||
| 136 | public Translator getTranslator( TranslationDirection direction ) | 136 | public Translator getTranslator( TranslationDirection direction ) |
| 137 | { | 137 | { |
| 138 | return m_mappings.getTranslator( m_ancestries, direction ); | 138 | return m_mappings.getTranslator( m_jarIndex.getAncestries(), direction ); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses ) | 141 | public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses ) |
diff --git a/src/cuchaz/enigma/analysis/Ancestries.java b/src/cuchaz/enigma/analysis/Ancestries.java index e6c8bbf..83c239c 100644 --- a/src/cuchaz/enigma/analysis/Ancestries.java +++ b/src/cuchaz/enigma/analysis/Ancestries.java | |||
| @@ -10,110 +10,27 @@ | |||
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | package cuchaz.enigma.analysis; | 11 | package cuchaz.enigma.analysis; |
| 12 | 12 | ||
| 13 | import java.io.ByteArrayOutputStream; | ||
| 14 | import java.io.IOException; | ||
| 15 | import java.io.InputStream; | ||
| 16 | import java.io.Serializable; | 13 | import java.io.Serializable; |
| 17 | import java.util.ArrayList; | 14 | import java.util.ArrayList; |
| 18 | import java.util.Collection; | ||
| 19 | import java.util.List; | 15 | import java.util.List; |
| 20 | import java.util.Map; | 16 | import java.util.Map; |
| 21 | import java.util.zip.ZipEntry; | ||
| 22 | import java.util.zip.ZipInputStream; | ||
| 23 | 17 | ||
| 24 | import javassist.ByteArrayClassPath; | ||
| 25 | import javassist.ClassPool; | ||
| 26 | import javassist.CtClass; | ||
| 27 | import javassist.NotFoundException; | ||
| 28 | import javassist.bytecode.Descriptor; | 18 | import javassist.bytecode.Descriptor; |
| 29 | import javassist.bytecode.MethodInfo; | ||
| 30 | 19 | ||
| 31 | import com.google.common.collect.HashMultimap; | ||
| 32 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
| 33 | import com.google.common.collect.Maps; | 21 | import com.google.common.collect.Maps; |
| 34 | import com.google.common.collect.Multimap; | ||
| 35 | |||
| 36 | import cuchaz.enigma.Constants; | ||
| 37 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 38 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 39 | import cuchaz.enigma.mapping.Translator; | ||
| 40 | 22 | ||
| 41 | public class Ancestries implements Serializable | 23 | public class Ancestries implements Serializable |
| 42 | { | 24 | { |
| 43 | private static final long serialVersionUID = 738687982126844179L; | 25 | private static final long serialVersionUID = 738687982126844179L; |
| 44 | 26 | ||
| 45 | private Map<String,String> m_superclasses; | 27 | private Map<String,String> m_superclasses; |
| 46 | private Multimap<String,String> m_methodImplementations; | ||
| 47 | 28 | ||
| 48 | public Ancestries( ) | 29 | public Ancestries( ) |
| 49 | { | 30 | { |
| 50 | m_superclasses = Maps.newHashMap(); | 31 | m_superclasses = Maps.newHashMap(); |
| 51 | m_methodImplementations = HashMultimap.create(); | ||
| 52 | } | 32 | } |
| 53 | 33 | ||
| 54 | @SuppressWarnings( "unchecked" ) | ||
| 55 | public void readFromJar( InputStream in ) | ||
| 56 | throws IOException | ||
| 57 | { | ||
| 58 | ClassPool classPool = new ClassPool(); | ||
| 59 | |||
| 60 | ZipInputStream zin = new ZipInputStream( in ); | ||
| 61 | ZipEntry entry; | ||
| 62 | while( ( entry = zin.getNextEntry() ) != null ) | ||
| 63 | { | ||
| 64 | // filter out non-classes | ||
| 65 | if( entry.isDirectory() || !entry.getName().endsWith( ".class" ) ) | ||
| 66 | { | ||
| 67 | continue; | ||
| 68 | } | ||
| 69 | |||
| 70 | // read the class into a buffer | ||
| 71 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
| 72 | byte[] buf = new byte[Constants.KiB]; | ||
| 73 | int totalNumBytesRead = 0; | ||
| 74 | while( zin.available() > 0 ) | ||
| 75 | { | ||
| 76 | int numBytesRead = zin.read( buf ); | ||
| 77 | if( numBytesRead < 0 ) | ||
| 78 | { | ||
| 79 | break; | ||
| 80 | } | ||
| 81 | bos.write( buf, 0, numBytesRead ); | ||
| 82 | |||
| 83 | // sanity checking | ||
| 84 | totalNumBytesRead += numBytesRead; | ||
| 85 | if( totalNumBytesRead > Constants.MiB ) | ||
| 86 | { | ||
| 87 | throw new Error( "Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!" ); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | // determine the class name (ie chop off the ".class") | ||
| 92 | String className = Descriptor.toJavaName( entry.getName().substring( 0, entry.getName().length() - ".class".length() ) ); | ||
| 93 | |||
| 94 | // get a javassist handle for the class | ||
| 95 | classPool.insertClassPath( new ByteArrayClassPath( className, bos.toByteArray() ) ); | ||
| 96 | try | ||
| 97 | { | ||
| 98 | CtClass c = classPool.get( className ); | ||
| 99 | addSuperclass( c.getName(), c.getClassFile().getSuperclass() ); | ||
| 100 | addMethodImplementations( c.getName(), (List<MethodInfo>)c.getClassFile().getMethods() ); | ||
| 101 | } | ||
| 102 | catch( NotFoundException ex ) | ||
| 103 | { | ||
| 104 | throw new Error( "Unable to load class: " + className ); | ||
| 105 | } | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | private void addMethodImplementations( String name, List<MethodInfo> methods ) | ||
| 110 | { | ||
| 111 | for( MethodInfo method : methods ) | ||
| 112 | { | ||
| 113 | m_methodImplementations.put( name, getMethodKey( method.getName(), method.getDescriptor() ) ); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | public void addSuperclass( String className, String superclassName ) | 34 | public void addSuperclass( String className, String superclassName ) |
| 118 | { | 35 | { |
| 119 | className = Descriptor.toJvmName( className ); | 36 | className = Descriptor.toJvmName( className ); |
| @@ -165,71 +82,9 @@ public class Ancestries implements Serializable | |||
| 165 | return subclasses; | 82 | return subclasses; |
| 166 | } | 83 | } |
| 167 | 84 | ||
| 168 | public boolean isMethodImplemented( MethodEntry methodEntry ) | ||
| 169 | { | ||
| 170 | return isMethodImplemented( methodEntry.getClassName(), methodEntry.getName(), methodEntry.getSignature() ); | ||
| 171 | } | ||
| 172 | |||
| 173 | public boolean isMethodImplemented( String className, String methodName, String methodSignature ) | ||
| 174 | { | ||
| 175 | Collection<String> implementations = m_methodImplementations.get( className ); | ||
| 176 | if( implementations == null ) | ||
| 177 | { | ||
| 178 | return false; | ||
| 179 | } | ||
| 180 | return implementations.contains( getMethodKey( methodName, methodSignature ) ); | ||
| 181 | } | ||
| 182 | |||
| 183 | public ClassInheritanceTreeNode getClassInheritance( Translator deobfuscatingTranslator, ClassEntry obfClassEntry ) | ||
| 184 | { | ||
| 185 | // get the root node | ||
| 186 | List<String> ancestry = getAncestry( obfClassEntry.getName() ); | ||
| 187 | ClassInheritanceTreeNode rootNode = new ClassInheritanceTreeNode( deobfuscatingTranslator, ancestry.get( ancestry.size() - 1 ) ); | ||
| 188 | |||
| 189 | // expand all children recursively | ||
| 190 | rootNode.load( this, true ); | ||
| 191 | |||
| 192 | return rootNode; | ||
| 193 | } | ||
| 194 | |||
| 195 | public MethodInheritanceTreeNode getMethodInheritance( Translator deobfuscatingTranslator, MethodEntry obfMethodEntry ) | ||
| 196 | { | ||
| 197 | // travel to the ancestor implementation | ||
| 198 | String baseImplementationClassName = obfMethodEntry.getClassName(); | ||
| 199 | for( String ancestorClassName : getAncestry( obfMethodEntry.getClassName() ) ) | ||
| 200 | { | ||
| 201 | if( isMethodImplemented( ancestorClassName, obfMethodEntry.getName(), obfMethodEntry.getSignature() ) ) | ||
| 202 | { | ||
| 203 | baseImplementationClassName = ancestorClassName; | ||
| 204 | } | ||
| 205 | } | ||
| 206 | |||
| 207 | // make a root node at the base | ||
| 208 | MethodEntry methodEntry = new MethodEntry( | ||
| 209 | new ClassEntry( baseImplementationClassName ), | ||
| 210 | obfMethodEntry.getName(), | ||
| 211 | obfMethodEntry.getSignature() | ||
| 212 | ); | ||
| 213 | MethodInheritanceTreeNode rootNode = new MethodInheritanceTreeNode( | ||
| 214 | deobfuscatingTranslator, | ||
| 215 | methodEntry, | ||
| 216 | isMethodImplemented( methodEntry ) | ||
| 217 | ); | ||
| 218 | |||
| 219 | // expand the full tree | ||
| 220 | rootNode.load( this, true ); | ||
| 221 | |||
| 222 | return rootNode; | ||
| 223 | } | ||
| 224 | |||
| 225 | private boolean isJre( String className ) | 85 | private boolean isJre( String className ) |
| 226 | { | 86 | { |
| 227 | return className.startsWith( "java/" ) | 87 | return className.startsWith( "java/" ) |
| 228 | || className.startsWith( "javax/" ); | 88 | || className.startsWith( "javax/" ); |
| 229 | } | 89 | } |
| 230 | |||
| 231 | private String getMethodKey( String name, String signature ) | ||
| 232 | { | ||
| 233 | return name + signature; | ||
| 234 | } | ||
| 235 | } | 90 | } |
diff --git a/src/cuchaz/enigma/analysis/JarIndex.java b/src/cuchaz/enigma/analysis/JarIndex.java new file mode 100644 index 0000000..8a8384c --- /dev/null +++ b/src/cuchaz/enigma/analysis/JarIndex.java | |||
| @@ -0,0 +1,176 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.analysis; | ||
| 12 | |||
| 13 | import java.io.ByteArrayOutputStream; | ||
| 14 | import java.io.IOException; | ||
| 15 | import java.io.InputStream; | ||
| 16 | import java.util.Collection; | ||
| 17 | import java.util.List; | ||
| 18 | import java.util.zip.ZipEntry; | ||
| 19 | import java.util.zip.ZipInputStream; | ||
| 20 | |||
| 21 | import com.google.common.collect.HashMultimap; | ||
| 22 | import com.google.common.collect.Multimap; | ||
| 23 | |||
| 24 | import javassist.ByteArrayClassPath; | ||
| 25 | import javassist.ClassPool; | ||
| 26 | import javassist.CtClass; | ||
| 27 | import javassist.NotFoundException; | ||
| 28 | import javassist.bytecode.Descriptor; | ||
| 29 | import javassist.bytecode.MethodInfo; | ||
| 30 | import cuchaz.enigma.Constants; | ||
| 31 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 32 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 33 | import cuchaz.enigma.mapping.Translator; | ||
| 34 | |||
| 35 | public class JarIndex | ||
| 36 | { | ||
| 37 | private Ancestries m_ancestries; | ||
| 38 | private Multimap<String,String> m_methodImplementations; | ||
| 39 | |||
| 40 | public JarIndex( ) | ||
| 41 | { | ||
| 42 | m_ancestries = new Ancestries(); | ||
| 43 | m_methodImplementations = HashMultimap.create(); | ||
| 44 | } | ||
| 45 | |||
| 46 | @SuppressWarnings( "unchecked" ) | ||
| 47 | public void indexJar( InputStream in ) | ||
| 48 | throws IOException | ||
| 49 | { | ||
| 50 | ClassPool classPool = new ClassPool(); | ||
| 51 | |||
| 52 | ZipInputStream zin = new ZipInputStream( in ); | ||
| 53 | ZipEntry entry; | ||
| 54 | while( ( entry = zin.getNextEntry() ) != null ) | ||
| 55 | { | ||
| 56 | // filter out non-classes | ||
| 57 | if( entry.isDirectory() || !entry.getName().endsWith( ".class" ) ) | ||
| 58 | { | ||
| 59 | continue; | ||
| 60 | } | ||
| 61 | |||
| 62 | // read the class into a buffer | ||
| 63 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
| 64 | byte[] buf = new byte[Constants.KiB]; | ||
| 65 | int totalNumBytesRead = 0; | ||
| 66 | while( zin.available() > 0 ) | ||
| 67 | { | ||
| 68 | int numBytesRead = zin.read( buf ); | ||
| 69 | if( numBytesRead < 0 ) | ||
| 70 | { | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | bos.write( buf, 0, numBytesRead ); | ||
| 74 | |||
| 75 | // sanity checking | ||
| 76 | totalNumBytesRead += numBytesRead; | ||
| 77 | if( totalNumBytesRead > Constants.MiB ) | ||
| 78 | { | ||
| 79 | throw new Error( "Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!" ); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | // determine the class name (ie chop off the ".class") | ||
| 84 | String className = Descriptor.toJavaName( entry.getName().substring( 0, entry.getName().length() - ".class".length() ) ); | ||
| 85 | |||
| 86 | // get a javassist handle for the class | ||
| 87 | classPool.insertClassPath( new ByteArrayClassPath( className, bos.toByteArray() ) ); | ||
| 88 | try | ||
| 89 | { | ||
| 90 | CtClass c = classPool.get( className ); | ||
| 91 | m_ancestries.addSuperclass( c.getName(), c.getClassFile().getSuperclass() ); | ||
| 92 | addMethodImplementations( c.getName(), (List<MethodInfo>)c.getClassFile().getMethods() ); | ||
| 93 | } | ||
| 94 | catch( NotFoundException ex ) | ||
| 95 | { | ||
| 96 | throw new Error( "Unable to load class: " + className ); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | private void addMethodImplementations( String name, List<MethodInfo> methods ) | ||
| 102 | { | ||
| 103 | for( MethodInfo method : methods ) | ||
| 104 | { | ||
| 105 | m_methodImplementations.put( name, getMethodKey( method.getName(), method.getDescriptor() ) ); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | public Ancestries getAncestries( ) | ||
| 110 | { | ||
| 111 | return m_ancestries; | ||
| 112 | } | ||
| 113 | |||
| 114 | public boolean isMethodImplemented( MethodEntry methodEntry ) | ||
| 115 | { | ||
| 116 | return isMethodImplemented( methodEntry.getClassName(), methodEntry.getName(), methodEntry.getSignature() ); | ||
| 117 | } | ||
| 118 | |||
| 119 | public boolean isMethodImplemented( String className, String methodName, String methodSignature ) | ||
| 120 | { | ||
| 121 | Collection<String> implementations = m_methodImplementations.get( className ); | ||
| 122 | if( implementations == null ) | ||
| 123 | { | ||
| 124 | return false; | ||
| 125 | } | ||
| 126 | return implementations.contains( getMethodKey( methodName, methodSignature ) ); | ||
| 127 | } | ||
| 128 | |||
| 129 | |||
| 130 | public ClassInheritanceTreeNode getClassInheritance( Translator deobfuscatingTranslator, ClassEntry obfClassEntry ) | ||
| 131 | { | ||
| 132 | // get the root node | ||
| 133 | List<String> ancestry = m_ancestries.getAncestry( obfClassEntry.getName() ); | ||
| 134 | ClassInheritanceTreeNode rootNode = new ClassInheritanceTreeNode( deobfuscatingTranslator, ancestry.get( ancestry.size() - 1 ) ); | ||
| 135 | |||
| 136 | // expand all children recursively | ||
| 137 | rootNode.load( m_ancestries, true ); | ||
| 138 | |||
| 139 | return rootNode; | ||
| 140 | } | ||
| 141 | |||
| 142 | public MethodInheritanceTreeNode getMethodInheritance( Translator deobfuscatingTranslator, MethodEntry obfMethodEntry ) | ||
| 143 | { | ||
| 144 | // travel to the ancestor implementation | ||
| 145 | String baseImplementationClassName = obfMethodEntry.getClassName(); | ||
| 146 | for( String ancestorClassName : m_ancestries.getAncestry( obfMethodEntry.getClassName() ) ) | ||
| 147 | { | ||
| 148 | if( isMethodImplemented( ancestorClassName, obfMethodEntry.getName(), obfMethodEntry.getSignature() ) ) | ||
| 149 | { | ||
| 150 | baseImplementationClassName = ancestorClassName; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | // make a root node at the base | ||
| 155 | MethodEntry methodEntry = new MethodEntry( | ||
| 156 | new ClassEntry( baseImplementationClassName ), | ||
| 157 | obfMethodEntry.getName(), | ||
| 158 | obfMethodEntry.getSignature() | ||
| 159 | ); | ||
| 160 | MethodInheritanceTreeNode rootNode = new MethodInheritanceTreeNode( | ||
| 161 | deobfuscatingTranslator, | ||
| 162 | methodEntry, | ||
| 163 | isMethodImplemented( methodEntry ) | ||
| 164 | ); | ||
| 165 | |||
| 166 | // expand the full tree | ||
| 167 | rootNode.load( this, true ); | ||
| 168 | |||
| 169 | return rootNode; | ||
| 170 | } | ||
| 171 | |||
| 172 | private String getMethodKey( String name, String signature ) | ||
| 173 | { | ||
| 174 | return name + signature; | ||
| 175 | } | ||
| 176 | } | ||
diff --git a/src/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index 1fecf48..a28a9f4 100644 --- a/src/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/src/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -79,11 +79,11 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | public void load( Ancestries ancestries, boolean recurse ) | 82 | public void load( JarIndex index, boolean recurse ) |
| 83 | { | 83 | { |
| 84 | // get all the child nodes | 84 | // get all the child nodes |
| 85 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); | 85 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 86 | for( String subclassName : ancestries.getSubclasses( m_entry.getClassName() ) ) | 86 | for( String subclassName : index.getAncestries().getSubclasses( m_entry.getClassName() ) ) |
| 87 | { | 87 | { |
| 88 | MethodEntry methodEntry = new MethodEntry( | 88 | MethodEntry methodEntry = new MethodEntry( |
| 89 | new ClassEntry( subclassName ), | 89 | new ClassEntry( subclassName ), |
| @@ -93,7 +93,7 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode | |||
| 93 | nodes.add( new MethodInheritanceTreeNode( | 93 | nodes.add( new MethodInheritanceTreeNode( |
| 94 | m_deobfuscatingTranslator, | 94 | m_deobfuscatingTranslator, |
| 95 | methodEntry, | 95 | methodEntry, |
| 96 | ancestries.isMethodImplemented( subclassName, m_entry.getName(), m_entry.getSignature() ) | 96 | index.isMethodImplemented( subclassName, m_entry.getName(), m_entry.getSignature() ) |
| 97 | ) ); | 97 | ) ); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -107,7 +107,7 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode | |||
| 107 | { | 107 | { |
| 108 | for( MethodInheritanceTreeNode node : nodes ) | 108 | for( MethodInheritanceTreeNode node : nodes ) |
| 109 | { | 109 | { |
| 110 | node.load( ancestries, true ); | 110 | node.load( index, true ); |
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index 1946b4a..880f001 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -132,7 +132,7 @@ public class GuiController | |||
| 132 | 132 | ||
| 133 | public ClassInheritanceTreeNode getClassInheritance( ClassEntry obfClassEntry ) | 133 | public ClassInheritanceTreeNode getClassInheritance( ClassEntry obfClassEntry ) |
| 134 | { | 134 | { |
| 135 | ClassInheritanceTreeNode rootNode = m_deobfuscator.getAncestries().getClassInheritance( | 135 | ClassInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getClassInheritance( |
| 136 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | 136 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 137 | obfClassEntry | 137 | obfClassEntry |
| 138 | ); | 138 | ); |
| @@ -141,7 +141,7 @@ public class GuiController | |||
| 141 | 141 | ||
| 142 | public MethodInheritanceTreeNode getMethodInheritance( MethodEntry obfMethodEntry ) | 142 | public MethodInheritanceTreeNode getMethodInheritance( MethodEntry obfMethodEntry ) |
| 143 | { | 143 | { |
| 144 | MethodInheritanceTreeNode rootNode = m_deobfuscator.getAncestries().getMethodInheritance( | 144 | MethodInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getMethodInheritance( |
| 145 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | 145 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 146 | obfMethodEntry | 146 | obfMethodEntry |
| 147 | ); | 147 | ); |
diff --git a/src/cuchaz/enigma/mapping/Renamer.java b/src/cuchaz/enigma/mapping/Renamer.java index 5a75c01..d372575 100644 --- a/src/cuchaz/enigma/mapping/Renamer.java +++ b/src/cuchaz/enigma/mapping/Renamer.java | |||
| @@ -15,17 +15,17 @@ import java.io.ObjectOutputStream; | |||
| 15 | import java.io.OutputStream; | 15 | import java.io.OutputStream; |
| 16 | import java.util.zip.GZIPOutputStream; | 16 | import java.util.zip.GZIPOutputStream; |
| 17 | 17 | ||
| 18 | import cuchaz.enigma.analysis.Ancestries; | 18 | import cuchaz.enigma.analysis.JarIndex; |
| 19 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | 19 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; |
| 20 | 20 | ||
| 21 | public class Renamer | 21 | public class Renamer |
| 22 | { | 22 | { |
| 23 | private Ancestries m_ancestries; | 23 | private JarIndex m_index; |
| 24 | private Mappings m_mappings; | 24 | private Mappings m_mappings; |
| 25 | 25 | ||
| 26 | public Renamer( Ancestries ancestries, Mappings mappings ) | 26 | public Renamer( JarIndex index, Mappings mappings ) |
| 27 | { | 27 | { |
| 28 | m_ancestries = ancestries; | 28 | m_index = index; |
| 29 | m_mappings = mappings; | 29 | m_mappings = mappings; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -61,7 +61,7 @@ public class Renamer | |||
| 61 | { | 61 | { |
| 62 | // get the method tree | 62 | // get the method tree |
| 63 | setMethodTreeName( | 63 | setMethodTreeName( |
| 64 | m_ancestries.getMethodInheritance( m_mappings.getTranslator( m_ancestries, TranslationDirection.Deobfuscating ), obf ), | 64 | m_index.getMethodInheritance( m_mappings.getTranslator( m_index.getAncestries(), TranslationDirection.Deobfuscating ), obf ), |
| 65 | deobfName | 65 | deobfName |
| 66 | ); | 66 | ); |
| 67 | } | 67 | } |
| @@ -90,7 +90,7 @@ public class Renamer | |||
| 90 | classMapping = createClassMapping( obf.getClassEntry() ); | 90 | classMapping = createClassMapping( obf.getClassEntry() ); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | String deobfSignature = m_mappings.getTranslator( m_ancestries, TranslationDirection.Deobfuscating ).translateSignature( obf.getSignature() ); | 93 | String deobfSignature = m_mappings.getTranslator( m_index.getAncestries(), TranslationDirection.Deobfuscating ).translateSignature( obf.getSignature() ); |
| 94 | classMapping.setMethodNameAndSignature( obf.getName(), obf.getSignature(), deobfName, deobfSignature ); | 94 | classMapping.setMethodNameAndSignature( obf.getName(), obf.getSignature(), deobfName, deobfSignature ); |
| 95 | 95 | ||
| 96 | // TODO: update ancestor/descendant methods in other classes in the inheritance hierarchy too | 96 | // TODO: update ancestor/descendant methods in other classes in the inheritance hierarchy too |
| @@ -129,7 +129,7 @@ public class Renamer | |||
| 129 | 129 | ||
| 130 | private void updateDeobfMethodSignatures( ) | 130 | private void updateDeobfMethodSignatures( ) |
| 131 | { | 131 | { |
| 132 | Translator translator = m_mappings.getTranslator( m_ancestries, TranslationDirection.Deobfuscating ); | 132 | Translator translator = m_mappings.getTranslator( m_index.getAncestries(), TranslationDirection.Deobfuscating ); |
| 133 | for( ClassMapping classMapping : m_mappings.m_classesByObf.values() ) | 133 | for( ClassMapping classMapping : m_mappings.m_classesByObf.values() ) |
| 134 | { | 134 | { |
| 135 | classMapping.updateDeobfMethodSignatures( translator ); | 135 | classMapping.updateDeobfMethodSignatures( translator ); |