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.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java
index b7440a7..0b7808d 100644
--- a/src/cuchaz/enigma/Deobfuscator.java
+++ b/src/cuchaz/enigma/Deobfuscator.java
@@ -204,33 +204,36 @@ public class Deobfuscator {
204 } 204 }
205 } 205 }
206 206
207 public CompilationUnit getSourceTree(String obfClassName) { 207 public CompilationUnit getSourceTree(String className) {
208 // is this class deobfuscated? 208
209 // we don't know if this class name is obfuscated or deobfuscated
209 // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out 210 // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out
210 // the decompiler only sees the deobfuscated class, so we need to load it by the deobfuscated name 211 // the decompiler only sees classes after deobfuscation, so we need to load it by the deobfuscated name if there is one
211 String lookupClassName = obfClassName;
212 ClassMapping classMapping = m_mappings.getClassByObf(obfClassName);
213 if (classMapping != null && classMapping.getDeobfName() != null) {
214 lookupClassName = classMapping.getDeobfName();
215 }
216 212
217 // is this class even in the jar? 213 // first, assume class name is deobf
218 if (!m_jarIndex.containsObfClass(new ClassEntry(obfClassName))) { 214 String deobfClassName = className;
219 return null; 215
216 // if it wasn't actually deobf, then we can find a mapping for it and get the deobf name
217 ClassMapping classMapping = m_mappings.getClassByObf(className);
218 if (classMapping != null && classMapping.getDeobfName() != null) {
219 deobfClassName = classMapping.getDeobfName();
220 } 220 }
221 221
222 // set the type loader 222 // set the type loader
223 m_settings.setTypeLoader(new TranslatingTypeLoader( 223 TranslatingTypeLoader loader = new TranslatingTypeLoader(
224 m_jar, 224 m_jar,
225 m_jarIndex, 225 m_jarIndex,
226 getTranslator(TranslationDirection.Obfuscating), 226 getTranslator(TranslationDirection.Obfuscating),
227 getTranslator(TranslationDirection.Deobfuscating) 227 getTranslator(TranslationDirection.Deobfuscating)
228 )); 228 );
229 m_settings.setTypeLoader(loader);
229 230
230 // see if procyon can find the type 231 // see if procyon can find the type
231 TypeReference type = new MetadataSystem(m_settings.getTypeLoader()).lookupType(lookupClassName); 232 TypeReference type = new MetadataSystem(loader).lookupType(deobfClassName);
232 if (type == null) { 233 if (type == null) {
233 throw new Error("Unable to find type: " + lookupClassName + " (obf name: " + obfClassName + ")"); 234 throw new Error(String.format("Unable to find type: %s (deobf: %s)\nTried class names: %s",
235 className, deobfClassName, loader.getClassNamesToTry(deobfClassName)
236 ));
234 } 237 }
235 TypeDefinition resolvedType = type.resolve(); 238 TypeDefinition resolvedType = type.resolve();
236 239