diff options
| author | 2014-07-30 23:43:09 -0400 | |
|---|---|---|
| committer | 2014-07-30 23:43:09 -0400 | |
| commit | 4349d22cc8abf5ec74075dde1b45c5f2f8679bbf (patch) | |
| tree | 6200f39f3539e2def5010078200592141498be33 /src/cuchaz/enigma/Deobfuscator.java | |
| parent | forgot to apply copyright notices (diff) | |
| download | enigma-fork-4349d22cc8abf5ec74075dde1b45c5f2f8679bbf.tar.gz enigma-fork-4349d22cc8abf5ec74075dde1b45c5f2f8679bbf.tar.xz enigma-fork-4349d22cc8abf5ec74075dde1b45c5f2f8679bbf.zip | |
switched to line-by-line mergable, human-readable file format for mappings
Diffstat (limited to 'src/cuchaz/enigma/Deobfuscator.java')
| -rw-r--r-- | src/cuchaz/enigma/Deobfuscator.java | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index bc7065f..7be5706 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java | |||
| @@ -32,9 +32,10 @@ import cuchaz.enigma.mapping.ArgumentEntry; | |||
| 32 | import cuchaz.enigma.mapping.ClassEntry; | 32 | import cuchaz.enigma.mapping.ClassEntry; |
| 33 | import cuchaz.enigma.mapping.Entry; | 33 | import cuchaz.enigma.mapping.Entry; |
| 34 | import cuchaz.enigma.mapping.FieldEntry; | 34 | import cuchaz.enigma.mapping.FieldEntry; |
| 35 | import cuchaz.enigma.mapping.Mappings; | ||
| 35 | import cuchaz.enigma.mapping.MethodEntry; | 36 | import cuchaz.enigma.mapping.MethodEntry; |
| 37 | import cuchaz.enigma.mapping.Renamer; | ||
| 36 | import cuchaz.enigma.mapping.TranslationDirection; | 38 | import cuchaz.enigma.mapping.TranslationDirection; |
| 37 | import cuchaz.enigma.mapping.TranslationMappings; | ||
| 38 | import cuchaz.enigma.mapping.Translator; | 39 | import cuchaz.enigma.mapping.Translator; |
| 39 | 40 | ||
| 40 | public class Deobfuscator | 41 | public class Deobfuscator |
| @@ -43,7 +44,8 @@ public class Deobfuscator | |||
| 43 | private JarFile m_jar; | 44 | private JarFile m_jar; |
| 44 | private DecompilerSettings m_settings; | 45 | private DecompilerSettings m_settings; |
| 45 | private Ancestries m_ancestries; | 46 | private Ancestries m_ancestries; |
| 46 | private TranslationMappings m_mappings; | 47 | private Mappings m_mappings; |
| 48 | private Renamer m_renamer; | ||
| 47 | 49 | ||
| 48 | private static Comparator<ClassFile> m_obfuscatedClassSorter; | 50 | private static Comparator<ClassFile> m_obfuscatedClassSorter; |
| 49 | 51 | ||
| @@ -89,7 +91,7 @@ public class Deobfuscator | |||
| 89 | m_settings.setShowSyntheticMembers( true ); | 91 | m_settings.setShowSyntheticMembers( true ); |
| 90 | 92 | ||
| 91 | // init mappings | 93 | // init mappings |
| 92 | setMappings( new TranslationMappings( m_ancestries ) ); | 94 | setMappings( new Mappings() ); |
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | public String getJarName( ) | 97 | public String getJarName( ) |
| @@ -97,23 +99,24 @@ public class Deobfuscator | |||
| 97 | return m_file.getName(); | 99 | return m_file.getName(); |
| 98 | } | 100 | } |
| 99 | 101 | ||
| 100 | public TranslationMappings getMappings( ) | 102 | public Mappings getMappings( ) |
| 101 | { | 103 | { |
| 102 | return m_mappings; | 104 | return m_mappings; |
| 103 | } | 105 | } |
| 104 | public void setMappings( TranslationMappings val ) | 106 | public void setMappings( Mappings val ) |
| 105 | { | 107 | { |
| 106 | if( val == null ) | 108 | if( val == null ) |
| 107 | { | 109 | { |
| 108 | val = new TranslationMappings( m_ancestries ); | 110 | val = new Mappings(); |
| 109 | } | 111 | } |
| 110 | m_mappings = val; | 112 | m_mappings = val; |
| 113 | m_renamer = new Renamer( m_ancestries, m_mappings ); | ||
| 111 | 114 | ||
| 112 | // update decompiler options | 115 | // update decompiler options |
| 113 | m_settings.setTypeLoader( new TranslatingTypeLoader( | 116 | m_settings.setTypeLoader( new TranslatingTypeLoader( |
| 114 | m_jar, | 117 | m_jar, |
| 115 | m_mappings.getTranslator( TranslationDirection.Deobfuscating ), | 118 | m_mappings.getTranslator( m_ancestries, TranslationDirection.Deobfuscating ), |
| 116 | m_mappings.getTranslator( TranslationDirection.Obfuscating ) | 119 | m_mappings.getTranslator( m_ancestries, TranslationDirection.Obfuscating ) |
| 117 | ) ); | 120 | ) ); |
| 118 | } | 121 | } |
| 119 | 122 | ||
| @@ -168,19 +171,19 @@ public class Deobfuscator | |||
| 168 | { | 171 | { |
| 169 | if( entry instanceof ClassEntry ) | 172 | if( entry instanceof ClassEntry ) |
| 170 | { | 173 | { |
| 171 | m_mappings.setClassName( (ClassEntry)entry, newName ); | 174 | m_renamer.setClassName( (ClassEntry)entry, newName ); |
| 172 | } | 175 | } |
| 173 | else if( entry instanceof FieldEntry ) | 176 | else if( entry instanceof FieldEntry ) |
| 174 | { | 177 | { |
| 175 | m_mappings.setFieldName( (FieldEntry)entry, newName ); | 178 | m_renamer.setFieldName( (FieldEntry)entry, newName ); |
| 176 | } | 179 | } |
| 177 | else if( entry instanceof MethodEntry ) | 180 | else if( entry instanceof MethodEntry ) |
| 178 | { | 181 | { |
| 179 | m_mappings.setMethodName( (MethodEntry)entry, newName ); | 182 | m_renamer.setMethodName( (MethodEntry)entry, newName ); |
| 180 | } | 183 | } |
| 181 | else if( entry instanceof ArgumentEntry ) | 184 | else if( entry instanceof ArgumentEntry ) |
| 182 | { | 185 | { |
| 183 | m_mappings.setArgumentName( (ArgumentEntry)entry, newName ); | 186 | m_renamer.setArgumentName( (ArgumentEntry)entry, newName ); |
| 184 | } | 187 | } |
| 185 | else | 188 | else |
| 186 | { | 189 | { |
| @@ -190,7 +193,7 @@ public class Deobfuscator | |||
| 190 | 193 | ||
| 191 | public Entry obfuscate( Entry in ) | 194 | public Entry obfuscate( Entry in ) |
| 192 | { | 195 | { |
| 193 | Translator translator = m_mappings.getTranslator( TranslationDirection.Obfuscating ); | 196 | Translator translator = m_mappings.getTranslator( m_ancestries, TranslationDirection.Obfuscating ); |
| 194 | if( in instanceof ClassEntry ) | 197 | if( in instanceof ClassEntry ) |
| 195 | { | 198 | { |
| 196 | return translator.translateEntry( (ClassEntry)in ); | 199 | return translator.translateEntry( (ClassEntry)in ); |
| @@ -215,7 +218,7 @@ public class Deobfuscator | |||
| 215 | 218 | ||
| 216 | public Entry deobfuscate( Entry in ) | 219 | public Entry deobfuscate( Entry in ) |
| 217 | { | 220 | { |
| 218 | Translator translator = m_mappings.getTranslator( TranslationDirection.Deobfuscating ); | 221 | Translator translator = m_mappings.getTranslator( m_ancestries, TranslationDirection.Deobfuscating ); |
| 219 | if( in instanceof ClassEntry ) | 222 | if( in instanceof ClassEntry ) |
| 220 | { | 223 | { |
| 221 | return translator.translateEntry( (ClassEntry)in ); | 224 | return translator.translateEntry( (ClassEntry)in ); |