summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/Deobfuscator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/Deobfuscator.java')
-rw-r--r--src/cuchaz/enigma/Deobfuscator.java25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java
index 16c11d3..8d4394c 100644
--- a/src/cuchaz/enigma/Deobfuscator.java
+++ b/src/cuchaz/enigma/Deobfuscator.java
@@ -17,7 +17,6 @@ import java.io.InputStream;
17import java.io.StringWriter; 17import java.io.StringWriter;
18import java.util.Enumeration; 18import java.util.Enumeration;
19import java.util.List; 19import java.util.List;
20import java.util.Map;
21import java.util.jar.JarEntry; 20import java.util.jar.JarEntry;
22import java.util.jar.JarFile; 21import java.util.jar.JarFile;
23 22
@@ -139,43 +138,41 @@ public class Deobfuscator
139 return m_mappings.getTranslator( m_ancestries, direction ); 138 return m_mappings.getTranslator( m_ancestries, direction );
140 } 139 }
141 140
142 public void getSeparatedClasses( List<ClassFile> obfClasses, Map<ClassFile,String> deobfClasses ) 141 public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses )
143 { 142 {
144 for( String obfClassName : m_obfClassNames ) 143 for( String obfClassName : m_obfClassNames )
145 { 144 {
146 ClassFile classFile = new ClassFile( obfClassName );
147
148 // separate the classes 145 // separate the classes
149 ClassMapping classMapping = m_mappings.getClassByObf( classFile.getName() ); 146 ClassMapping classMapping = m_mappings.getClassByObf( obfClassName );
150 if( classMapping != null ) 147 if( classMapping != null )
151 { 148 {
152 deobfClasses.put( classFile, classMapping.getDeobfName() ); 149 deobfClasses.add( classMapping.getDeobfName() );
153 } 150 }
154 else if( classFile.isInPackage() ) 151 else if( obfClassName.indexOf( '/' ) >= 0 )
155 { 152 {
156 deobfClasses.put( classFile, classFile.getName() ); 153 // this class is in a package and therefore is not obfuscated
154 deobfClasses.add( obfClassName );
157 } 155 }
158 else 156 else
159 { 157 {
160 obfClasses.add( classFile ); 158 obfClasses.add( obfClassName );
161 } 159 }
162 } 160 }
163 } 161 }
164 162
165 public SourceIndex getSource( final ClassFile classFile ) 163 public SourceIndex getSource( String className )
166 { 164 {
167 // is this class deobfuscated? 165 // is this class deobfuscated?
168 // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out 166 // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out
169 // the decompiler only sees the deobfuscated class, so we need to load it by the deobfuscated name 167 // the decompiler only sees the deobfuscated class, so we need to load it by the deobfuscated name
170 String deobfName = classFile.getName(); 168 ClassMapping classMapping = m_mappings.getClassByObf( className );
171 ClassMapping classMapping = m_mappings.getClassByObf( classFile.getName() );
172 if( classMapping != null ) 169 if( classMapping != null )
173 { 170 {
174 deobfName = classMapping.getDeobfName(); 171 className = classMapping.getDeobfName();
175 } 172 }
176 173
177 // decompile it! 174 // decompile it!
178 TypeDefinition resolvedType = new MetadataSystem( m_settings.getTypeLoader() ).lookupType( deobfName ).resolve(); 175 TypeDefinition resolvedType = new MetadataSystem( m_settings.getTypeLoader() ).lookupType( className ).resolve();
179 DecompilerContext context = new DecompilerContext(); 176 DecompilerContext context = new DecompilerContext();
180 context.setCurrentType( resolvedType ); 177 context.setCurrentType( resolvedType );
181 context.setSettings( m_settings ); 178 context.setSettings( m_settings );