diff options
| author | 2016-08-19 10:48:19 +0200 | |
|---|---|---|
| committer | 2016-08-19 10:48:19 +0200 | |
| commit | 38a790423bddce4a928a83d8f17cc5f4a41eeb81 (patch) | |
| tree | 2b389595dd00204c16dff5f1900fcaa94bf206b5 /src/main/java | |
| parent | Update Procyon to 0.5.32 (diff) | |
| download | enigma-38a790423bddce4a928a83d8f17cc5f4a41eeb81.tar.gz enigma-38a790423bddce4a928a83d8f17cc5f4a41eeb81.tar.xz enigma-38a790423bddce4a928a83d8f17cc5f4a41eeb81.zip | |
Update Procyon (fix UTF-8 issues), disable debug line number in source code and make all decompiler settings configurable with system properties
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/Deobfuscator.java | 40 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java | 5 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/utils/Utils.java | 6 |
3 files changed, 31 insertions, 20 deletions
diff --git a/src/main/java/cuchaz/enigma/Deobfuscator.java b/src/main/java/cuchaz/enigma/Deobfuscator.java index 4bd9414d..7c36e89a 100644 --- a/src/main/java/cuchaz/enigma/Deobfuscator.java +++ b/src/main/java/cuchaz/enigma/Deobfuscator.java | |||
| @@ -13,7 +13,6 @@ package cuchaz.enigma; | |||
| 13 | import com.google.common.base.Charsets; | 13 | import com.google.common.base.Charsets; |
| 14 | import com.google.common.collect.Maps; | 14 | import com.google.common.collect.Maps; |
| 15 | import com.google.common.collect.Sets; | 15 | import com.google.common.collect.Sets; |
| 16 | |||
| 17 | import com.strobel.assembler.metadata.MetadataSystem; | 16 | import com.strobel.assembler.metadata.MetadataSystem; |
| 18 | import com.strobel.assembler.metadata.TypeDefinition; | 17 | import com.strobel.assembler.metadata.TypeDefinition; |
| 19 | import com.strobel.assembler.metadata.TypeReference; | 18 | import com.strobel.assembler.metadata.TypeReference; |
| @@ -24,6 +23,13 @@ import com.strobel.decompiler.languages.java.JavaOutputVisitor; | |||
| 24 | import com.strobel.decompiler.languages.java.ast.AstBuilder; | 23 | import com.strobel.decompiler.languages.java.ast.AstBuilder; |
| 25 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 24 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 26 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; | 25 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; |
| 26 | import cuchaz.enigma.analysis.*; | ||
| 27 | import cuchaz.enigma.bytecode.ClassProtectifier; | ||
| 28 | import cuchaz.enigma.bytecode.ClassPublifier; | ||
| 29 | import cuchaz.enigma.mapping.*; | ||
| 30 | import cuchaz.enigma.utils.Utils; | ||
| 31 | import javassist.CtClass; | ||
| 32 | import javassist.bytecode.Descriptor; | ||
| 27 | 33 | ||
| 28 | import java.io.*; | 34 | import java.io.*; |
| 29 | import java.util.List; | 35 | import java.util.List; |
| @@ -33,13 +39,6 @@ import java.util.jar.JarEntry; | |||
| 33 | import java.util.jar.JarFile; | 39 | import java.util.jar.JarFile; |
| 34 | import java.util.jar.JarOutputStream; | 40 | import java.util.jar.JarOutputStream; |
| 35 | 41 | ||
| 36 | import cuchaz.enigma.analysis.*; | ||
| 37 | import cuchaz.enigma.bytecode.ClassProtectifier; | ||
| 38 | import cuchaz.enigma.bytecode.ClassPublifier; | ||
| 39 | import cuchaz.enigma.mapping.*; | ||
| 40 | import javassist.CtClass; | ||
| 41 | import javassist.bytecode.Descriptor; | ||
| 42 | |||
| 43 | public class Deobfuscator { | 42 | public class Deobfuscator { |
| 44 | 43 | ||
| 45 | public interface ProgressListener { | 44 | public interface ProgressListener { |
| @@ -48,12 +47,12 @@ public class Deobfuscator { | |||
| 48 | void onProgress(int numDone, String message); | 47 | void onProgress(int numDone, String message); |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | private JarFile jar; | 50 | private final JarFile jar; |
| 52 | private DecompilerSettings settings; | 51 | private final DecompilerSettings settings; |
| 53 | private JarIndex jarIndex; | 52 | private final JarIndex jarIndex; |
| 53 | private final MappingsRenamer renamer; | ||
| 54 | private final Map<TranslationDirection, Translator> translatorCache; | ||
| 54 | private Mappings mappings; | 55 | private Mappings mappings; |
| 55 | private MappingsRenamer renamer; | ||
| 56 | private Map<TranslationDirection, Translator> translatorCache; | ||
| 57 | 56 | ||
| 58 | public Deobfuscator(JarFile jar) { | 57 | public Deobfuscator(JarFile jar) { |
| 59 | this.jar = jar; | 58 | this.jar = jar; |
| @@ -64,16 +63,17 @@ public class Deobfuscator { | |||
| 64 | 63 | ||
| 65 | // config the decompiler | 64 | // config the decompiler |
| 66 | this.settings = DecompilerSettings.javaDefaults(); | 65 | this.settings = DecompilerSettings.javaDefaults(); |
| 67 | this.settings.setMergeVariables(true); | 66 | this.settings.setMergeVariables(Utils.getSystemPropertyAsBoolean("enigma.mergeVariables", true)); |
| 68 | this.settings.setForceExplicitImports(true); | 67 | this.settings.setForceExplicitImports(Utils.getSystemPropertyAsBoolean("enigma.forceExplicitImports", true)); |
| 69 | this.settings.setForceExplicitTypeArguments(true); | 68 | this.settings.setForceExplicitTypeArguments( |
| 70 | this.settings.setShowDebugLineNumbers(true); | 69 | Utils.getSystemPropertyAsBoolean("enigma.forceExplicitTypeArguments", true)); |
| 71 | // DEBUG | 70 | // DEBUG |
| 72 | //this.settings.setShowSyntheticMembers(true); | 71 | this.settings.setShowDebugLineNumbers(Utils.getSystemPropertyAsBoolean("enigma.showDebugLineNumbers", false)); |
| 72 | this.settings.setShowSyntheticMembers(Utils.getSystemPropertyAsBoolean("enigma.showSyntheticMembers", false)); | ||
| 73 | 73 | ||
| 74 | // init defaults | 74 | // init defaults |
| 75 | this.translatorCache = Maps.newTreeMap(); | 75 | this.translatorCache = Maps.newTreeMap(); |
| 76 | 76 | this.renamer = new MappingsRenamer(this.jarIndex, null); | |
| 77 | // init mappings | 77 | // init mappings |
| 78 | setMappings(new Mappings()); | 78 | setMappings(new Mappings()); |
| 79 | } | 79 | } |
| @@ -122,7 +122,7 @@ public class Deobfuscator { | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | this.mappings = val; | 124 | this.mappings = val; |
| 125 | this.renamer = new MappingsRenamer(this.jarIndex, val); | 125 | this.renamer.setMappings(mappings); |
| 126 | this.translatorCache.clear(); | 126 | this.translatorCache.clear(); |
| 127 | } | 127 | } |
| 128 | 128 | ||
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java b/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java index 5d23dc0b..f244748f 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsRenamer.java | |||
| @@ -31,6 +31,11 @@ public class MappingsRenamer { | |||
| 31 | m_mappings = mappings; | 31 | m_mappings = mappings; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | public void setMappings(Mappings mappings) | ||
| 35 | { | ||
| 36 | this.m_mappings = mappings; | ||
| 37 | } | ||
| 38 | |||
| 34 | public void setClassName(ClassEntry obf, String deobfName) { | 39 | public void setClassName(ClassEntry obf, String deobfName) { |
| 35 | 40 | ||
| 36 | deobfName = NameValidator.validateClassName(deobfName, !obf.isInnerClass()); | 41 | deobfName = NameValidator.validateClassName(deobfName, !obf.isInnerClass()); |
diff --git a/src/main/java/cuchaz/enigma/utils/Utils.java b/src/main/java/cuchaz/enigma/utils/Utils.java index c16c1fbf..73c2bc7e 100644 --- a/src/main/java/cuchaz/enigma/utils/Utils.java +++ b/src/main/java/cuchaz/enigma/utils/Utils.java | |||
| @@ -88,4 +88,10 @@ public class Utils { | |||
| 88 | manager.mouseMoved(new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false)); | 88 | manager.mouseMoved(new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false)); |
| 89 | manager.setInitialDelay(oldDelay); | 89 | manager.setInitialDelay(oldDelay); |
| 90 | } | 90 | } |
| 91 | |||
| 92 | public static boolean getSystemPropertyAsBoolean(String property, boolean defValue) | ||
| 93 | { | ||
| 94 | String value = System.getProperty(property); | ||
| 95 | return value == null ? defValue : Boolean.parseBoolean(value); | ||
| 96 | } | ||
| 91 | } | 97 | } |