From deb2775d35f5a6d2b464782242e6b30c37279124 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 28 Aug 2014 10:12:24 -0400 Subject: added checks to find buggy mappings --- src/cuchaz/enigma/Deobfuscator.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index 8a516b1..cc1465a 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java @@ -41,6 +41,7 @@ import cuchaz.enigma.mapping.Entry; import cuchaz.enigma.mapping.FieldEntry; import cuchaz.enigma.mapping.Mappings; import cuchaz.enigma.mapping.MethodEntry; +import cuchaz.enigma.mapping.MethodMapping; import cuchaz.enigma.mapping.Renamer; import cuchaz.enigma.mapping.TranslationDirection; import cuchaz.enigma.mapping.Translator; @@ -101,6 +102,37 @@ public class Deobfuscator { val = new Mappings(); } + + // make sure all the mappings match the classes in the jar + for( ClassMapping classMapping : val.classes() ) + { + ClassEntry classEntry = new ClassEntry( classMapping.getObfName() ); + if( !m_jarIndex.getObfClassEntries().contains( classEntry ) ) + { + throw new Error( "Class " + classEntry + " not found in Jar!" ); + } + + // and method implementations + for( MethodMapping methodMapping : classMapping.methods() ) + { + if( methodMapping.getObfName().startsWith( "<" ) ) + { + // skip constructors and static initializers + continue; + } + + MethodEntry methodEntry = new MethodEntry( + classEntry, + methodMapping.getObfName(), + methodMapping.getObfSignature() + ); + if( !m_jarIndex.isMethodImplemented( methodEntry ) ) + { + throw new Error( "Method " + methodEntry + " not found in Jar!" ); + } + } + } + m_mappings = val; m_renamer = new Renamer( m_jarIndex, m_mappings ); -- cgit v1.2.3