diff options
Diffstat (limited to 'src/cuchaz/enigma/Deobfuscator.java')
| -rw-r--r-- | src/cuchaz/enigma/Deobfuscator.java | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index c35a483..33eef08 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java | |||
| @@ -15,12 +15,9 @@ import java.io.FileInputStream; | |||
| 15 | import java.io.IOException; | 15 | import java.io.IOException; |
| 16 | import java.io.InputStream; | 16 | import java.io.InputStream; |
| 17 | import java.io.StringWriter; | 17 | import java.io.StringWriter; |
| 18 | import java.util.Enumeration; | ||
| 19 | import java.util.List; | 18 | import java.util.List; |
| 20 | import java.util.jar.JarEntry; | ||
| 21 | import java.util.jar.JarFile; | 19 | import java.util.jar.JarFile; |
| 22 | 20 | ||
| 23 | import com.google.common.collect.Lists; | ||
| 24 | import com.strobel.assembler.metadata.MetadataSystem; | 21 | import com.strobel.assembler.metadata.MetadataSystem; |
| 25 | import com.strobel.assembler.metadata.TypeDefinition; | 22 | import com.strobel.assembler.metadata.TypeDefinition; |
| 26 | import com.strobel.decompiler.DecompilerContext; | 23 | import com.strobel.decompiler.DecompilerContext; |
| @@ -53,7 +50,6 @@ public class Deobfuscator | |||
| 53 | private JarIndex m_jarIndex; | 50 | private JarIndex m_jarIndex; |
| 54 | private Mappings m_mappings; | 51 | private Mappings m_mappings; |
| 55 | private Renamer m_renamer; | 52 | private Renamer m_renamer; |
| 56 | private List<String> m_obfClassNames; | ||
| 57 | 53 | ||
| 58 | public Deobfuscator( File file ) | 54 | public Deobfuscator( File file ) |
| 59 | throws IOException | 55 | throws IOException |
| @@ -65,7 +61,7 @@ public class Deobfuscator | |||
| 65 | InputStream jarIn = null; | 61 | InputStream jarIn = null; |
| 66 | try | 62 | try |
| 67 | { | 63 | { |
| 68 | m_jarIndex = new JarIndex(); | 64 | m_jarIndex = new JarIndex( m_jar ); |
| 69 | jarIn = new FileInputStream( m_file ); | 65 | jarIn = new FileInputStream( m_file ); |
| 70 | m_jarIndex.indexJar( jarIn ); | 66 | m_jarIndex.indexJar( jarIn ); |
| 71 | } | 67 | } |
| @@ -74,26 +70,6 @@ public class Deobfuscator | |||
| 74 | Util.closeQuietly( jarIn ); | 70 | Util.closeQuietly( jarIn ); |
| 75 | } | 71 | } |
| 76 | 72 | ||
| 77 | // get the obf class names | ||
| 78 | m_obfClassNames = Lists.newArrayList(); | ||
| 79 | { | ||
| 80 | Enumeration<JarEntry> entries = m_jar.entries(); | ||
| 81 | while( entries.hasMoreElements() ) | ||
| 82 | { | ||
| 83 | JarEntry entry = entries.nextElement(); | ||
| 84 | |||
| 85 | // skip everything but class files | ||
| 86 | if( !entry.getName().endsWith( ".class" ) ) | ||
| 87 | { | ||
| 88 | continue; | ||
| 89 | } | ||
| 90 | |||
| 91 | // get the class name from the file | ||
| 92 | String className = entry.getName().substring( 0, entry.getName().length() - 6 ); | ||
| 93 | m_obfClassNames.add( className ); | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | // config the decompiler | 73 | // config the decompiler |
| 98 | m_settings = DecompilerSettings.javaDefaults(); | 74 | m_settings = DecompilerSettings.javaDefaults(); |
| 99 | m_settings.setShowSyntheticMembers( true ); | 75 | m_settings.setShowSyntheticMembers( true ); |
| @@ -140,7 +116,7 @@ public class Deobfuscator | |||
| 140 | 116 | ||
| 141 | public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses ) | 117 | public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses ) |
| 142 | { | 118 | { |
| 143 | for( String obfClassName : m_obfClassNames ) | 119 | for( String obfClassName : m_jarIndex.getObfClassNames() ) |
| 144 | { | 120 | { |
| 145 | // separate the classes | 121 | // separate the classes |
| 146 | ClassMapping classMapping = m_mappings.getClassByObf( obfClassName ); | 122 | ClassMapping classMapping = m_mappings.getClassByObf( obfClassName ); |
| @@ -302,15 +278,15 @@ public class Deobfuscator | |||
| 302 | if( obfEntry instanceof ClassEntry ) | 278 | if( obfEntry instanceof ClassEntry ) |
| 303 | { | 279 | { |
| 304 | // obf classes must be in the list | 280 | // obf classes must be in the list |
| 305 | return m_obfClassNames.contains( obfEntry.getName() ); | 281 | return m_jarIndex.getObfClassNames().contains( obfEntry.getName() ); |
| 306 | } | 282 | } |
| 307 | else if( obfEntry instanceof FieldEntry ) | 283 | else if( obfEntry instanceof FieldEntry ) |
| 308 | { | 284 | { |
| 309 | return m_obfClassNames.contains( ((FieldEntry)obfEntry).getClassName() ); | 285 | return m_jarIndex.getObfClassNames().contains( ((FieldEntry)obfEntry).getClassName() ); |
| 310 | } | 286 | } |
| 311 | else if( obfEntry instanceof MethodEntry ) | 287 | else if( obfEntry instanceof MethodEntry ) |
| 312 | { | 288 | { |
| 313 | return m_obfClassNames.contains( ((MethodEntry)obfEntry).getClassName() ); | 289 | return m_jarIndex.getObfClassNames().contains( ((MethodEntry)obfEntry).getClassName() ); |
| 314 | } | 290 | } |
| 315 | else if( obfEntry instanceof ArgumentEntry ) | 291 | else if( obfEntry instanceof ArgumentEntry ) |
| 316 | { | 292 | { |