diff options
| author | 2015-03-30 11:40:24 -0400 | |
|---|---|---|
| committer | 2015-03-30 11:40:24 -0400 | |
| commit | 3b57f50a1d9429966e7aced0b81b3b3d4cfa41c7 (patch) | |
| tree | 84341bffdef6223f68e3d89b682a4598e05118ca /src | |
| parent | add methods for better runtime obfuscation in M3L (diff) | |
| download | enigma-3b57f50a1d9429966e7aced0b81b3b3d4cfa41c7.tar.gz enigma-3b57f50a1d9429966e7aced0b81b3b3d4cfa41c7.tar.xz enigma-3b57f50a1d9429966e7aced0b81b3b3d4cfa41c7.zip | |
fix unintentional compile time transitive dependency on procyon
Diffstat (limited to 'src')
4 files changed, 52 insertions, 47 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java index eb120b66..3a176ffc 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java | |||
| @@ -31,9 +31,9 @@ import cuchaz.enigma.mapping.ArgumentEntry; | |||
| 31 | import cuchaz.enigma.mapping.BehaviorEntry; | 31 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 32 | import cuchaz.enigma.mapping.ClassEntry; | 32 | import cuchaz.enigma.mapping.ClassEntry; |
| 33 | import cuchaz.enigma.mapping.ConstructorEntry; | 33 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 34 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 35 | import cuchaz.enigma.mapping.FieldEntry; | 34 | import cuchaz.enigma.mapping.FieldEntry; |
| 36 | import cuchaz.enigma.mapping.MethodEntry; | 35 | import cuchaz.enigma.mapping.MethodEntry; |
| 36 | import cuchaz.enigma.mapping.ProcyonEntryFactory; | ||
| 37 | import cuchaz.enigma.mapping.Signature; | 37 | import cuchaz.enigma.mapping.Signature; |
| 38 | import cuchaz.enigma.mapping.Type; | 38 | import cuchaz.enigma.mapping.Type; |
| 39 | 39 | ||
| @@ -113,7 +113,7 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 113 | ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION); | 113 | ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION); |
| 114 | if (def.getMethod() instanceof MethodDefinition) { | 114 | if (def.getMethod() instanceof MethodDefinition) { |
| 115 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); | 115 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); |
| 116 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(methodDef); | 116 | BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(methodDef); |
| 117 | ArgumentEntry argumentEntry = new ArgumentEntry(behaviorEntry, def.getPosition(), node.getName()); | 117 | ArgumentEntry argumentEntry = new ArgumentEntry(behaviorEntry, def.getPosition(), node.getName()); |
| 118 | index.addDeclaration(node.getNameToken(), argumentEntry); | 118 | index.addDeclaration(node.getNameToken(), argumentEntry); |
| 119 | } | 119 | } |
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index f4202b5b..37a893d7 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -28,8 +28,8 @@ import com.strobel.decompiler.languages.java.ast.VariableInitializer; | |||
| 28 | import cuchaz.enigma.mapping.BehaviorEntry; | 28 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 29 | import cuchaz.enigma.mapping.ClassEntry; | 29 | import cuchaz.enigma.mapping.ClassEntry; |
| 30 | import cuchaz.enigma.mapping.ConstructorEntry; | 30 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 31 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 32 | import cuchaz.enigma.mapping.FieldEntry; | 31 | import cuchaz.enigma.mapping.FieldEntry; |
| 32 | import cuchaz.enigma.mapping.ProcyonEntryFactory; | ||
| 33 | 33 | ||
| 34 | public class SourceIndexClassVisitor extends SourceIndexVisitor { | 34 | public class SourceIndexClassVisitor extends SourceIndexVisitor { |
| 35 | 35 | ||
| @@ -67,7 +67,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 67 | @Override | 67 | @Override |
| 68 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { | 68 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { |
| 69 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); | 69 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 70 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(def); | 70 | BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def); |
| 71 | AstNode tokenNode = node.getNameToken(); | 71 | AstNode tokenNode = node.getNameToken(); |
| 72 | 72 | ||
| 73 | if (behaviorEntry instanceof ConstructorEntry) { | 73 | if (behaviorEntry instanceof ConstructorEntry) { |
| @@ -84,7 +84,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 84 | @Override | 84 | @Override |
| 85 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { | 85 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { |
| 86 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); | 86 | MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION); |
| 87 | ConstructorEntry constructorEntry = EntryFactory.getConstructorEntry(def); | 87 | ConstructorEntry constructorEntry = ProcyonEntryFactory.getConstructorEntry(def); |
| 88 | index.addDeclaration(node.getNameToken(), constructorEntry); | 88 | index.addDeclaration(node.getNameToken(), constructorEntry); |
| 89 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(constructorEntry), index); | 89 | return node.acceptVisitor(new SourceIndexBehaviorVisitor(constructorEntry), index); |
| 90 | } | 90 | } |
| @@ -92,7 +92,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 92 | @Override | 92 | @Override |
| 93 | public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { | 93 | public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { |
| 94 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); | 94 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 95 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(def); | 95 | FieldEntry fieldEntry = ProcyonEntryFactory.getFieldEntry(def); |
| 96 | assert (node.getVariables().size() == 1); | 96 | assert (node.getVariables().size() == 1); |
| 97 | VariableInitializer variable = node.getVariables().firstOrNullObject(); | 97 | VariableInitializer variable = node.getVariables().firstOrNullObject(); |
| 98 | index.addDeclaration(variable.getNameToken(), fieldEntry); | 98 | index.addDeclaration(variable.getNameToken(), fieldEntry); |
| @@ -104,7 +104,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 104 | public Void visitEnumValueDeclaration(EnumValueDeclaration node, SourceIndex index) { | 104 | public Void visitEnumValueDeclaration(EnumValueDeclaration node, SourceIndex index) { |
| 105 | // treat enum declarations as field declarations | 105 | // treat enum declarations as field declarations |
| 106 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); | 106 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 107 | FieldEntry fieldEntry = EntryFactory.getFieldEntry(def); | 107 | FieldEntry fieldEntry = ProcyonEntryFactory.getFieldEntry(def); |
| 108 | index.addDeclaration(node.getNameToken(), fieldEntry); | 108 | index.addDeclaration(node.getNameToken(), fieldEntry); |
| 109 | 109 | ||
| 110 | return recurse(node, index); | 110 | return recurse(node, index); |
diff --git a/src/cuchaz/enigma/mapping/EntryFactory.java b/src/cuchaz/enigma/mapping/EntryFactory.java index 69c1630f..af96eb35 100644 --- a/src/cuchaz/enigma/mapping/EntryFactory.java +++ b/src/cuchaz/enigma/mapping/EntryFactory.java | |||
| @@ -11,9 +11,6 @@ import javassist.expr.FieldAccess; | |||
| 11 | import javassist.expr.MethodCall; | 11 | import javassist.expr.MethodCall; |
| 12 | import javassist.expr.NewExpr; | 12 | import javassist.expr.NewExpr; |
| 13 | 13 | ||
| 14 | import com.strobel.assembler.metadata.FieldDefinition; | ||
| 15 | import com.strobel.assembler.metadata.MethodDefinition; | ||
| 16 | |||
| 17 | import cuchaz.enigma.analysis.JarIndex; | 14 | import cuchaz.enigma.analysis.JarIndex; |
| 18 | 15 | ||
| 19 | public class EntryFactory { | 16 | public class EntryFactory { |
| @@ -55,14 +52,6 @@ public class EntryFactory { | |||
| 55 | ); | 52 | ); |
| 56 | } | 53 | } |
| 57 | 54 | ||
| 58 | public static FieldEntry getFieldEntry(FieldDefinition def) { | ||
| 59 | return new FieldEntry( | ||
| 60 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 61 | def.getName(), | ||
| 62 | new Type(def.getErasedSignature()) | ||
| 63 | ); | ||
| 64 | } | ||
| 65 | |||
| 66 | public static FieldEntry getFieldEntry(String className, String name, String type) { | 55 | public static FieldEntry getFieldEntry(String className, String name, String type) { |
| 67 | return new FieldEntry(new ClassEntry(className), name, new Type(type)); | 56 | return new FieldEntry(new ClassEntry(className), name, new Type(type)); |
| 68 | } | 57 | } |
| @@ -91,14 +80,6 @@ public class EntryFactory { | |||
| 91 | ); | 80 | ); |
| 92 | } | 81 | } |
| 93 | 82 | ||
| 94 | public static MethodEntry getMethodEntry(MethodDefinition def) { | ||
| 95 | return new MethodEntry( | ||
| 96 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 97 | def.getName(), | ||
| 98 | new Signature(def.getErasedSignature()) | ||
| 99 | ); | ||
| 100 | } | ||
| 101 | |||
| 102 | public static ConstructorEntry getConstructorEntry(CtConstructor constructor) { | 83 | public static ConstructorEntry getConstructorEntry(CtConstructor constructor) { |
| 103 | if (constructor.isClassInitializer()) { | 84 | if (constructor.isClassInitializer()) { |
| 104 | return new ConstructorEntry( | 85 | return new ConstructorEntry( |
| @@ -126,19 +107,6 @@ public class EntryFactory { | |||
| 126 | ); | 107 | ); |
| 127 | } | 108 | } |
| 128 | 109 | ||
| 129 | public static ConstructorEntry getConstructorEntry(MethodDefinition def) { | ||
| 130 | if (def.isTypeInitializer()) { | ||
| 131 | return new ConstructorEntry( | ||
| 132 | new ClassEntry(def.getDeclaringType().getInternalName()) | ||
| 133 | ); | ||
| 134 | } else { | ||
| 135 | return new ConstructorEntry( | ||
| 136 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 137 | new Signature(def.getErasedSignature()) | ||
| 138 | ); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | public static BehaviorEntry getBehaviorEntry(CtBehavior behavior) { | 110 | public static BehaviorEntry getBehaviorEntry(CtBehavior behavior) { |
| 143 | if (behavior instanceof CtMethod) { | 111 | if (behavior instanceof CtMethod) { |
| 144 | return getMethodEntry((CtMethod)behavior); | 112 | return getMethodEntry((CtMethod)behavior); |
| @@ -178,14 +146,6 @@ public class EntryFactory { | |||
| 178 | } | 146 | } |
| 179 | } | 147 | } |
| 180 | 148 | ||
| 181 | public static BehaviorEntry getBehaviorEntry(MethodDefinition def) { | ||
| 182 | if (def.isConstructor() || def.isTypeInitializer()) { | ||
| 183 | return getConstructorEntry(def); | ||
| 184 | } else { | ||
| 185 | return getMethodEntry(def); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | public static BehaviorEntry getObfBehaviorEntry(ClassEntry classEntry, MethodMapping methodMapping) { | 149 | public static BehaviorEntry getObfBehaviorEntry(ClassEntry classEntry, MethodMapping methodMapping) { |
| 190 | return getBehaviorEntry(classEntry, methodMapping.getObfName(), methodMapping.getObfSignature()); | 150 | return getBehaviorEntry(classEntry, methodMapping.getObfName(), methodMapping.getObfSignature()); |
| 191 | } | 151 | } |
diff --git a/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java b/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java new file mode 100644 index 00000000..eb0563c2 --- /dev/null +++ b/src/cuchaz/enigma/mapping/ProcyonEntryFactory.java | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | package cuchaz.enigma.mapping; | ||
| 2 | |||
| 3 | import com.strobel.assembler.metadata.FieldDefinition; | ||
| 4 | import com.strobel.assembler.metadata.MethodDefinition; | ||
| 5 | |||
| 6 | |||
| 7 | public class ProcyonEntryFactory { | ||
| 8 | |||
| 9 | public static FieldEntry getFieldEntry(FieldDefinition def) { | ||
| 10 | return new FieldEntry( | ||
| 11 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 12 | def.getName(), | ||
| 13 | new Type(def.getErasedSignature()) | ||
| 14 | ); | ||
| 15 | } | ||
| 16 | |||
| 17 | public static MethodEntry getMethodEntry(MethodDefinition def) { | ||
| 18 | return new MethodEntry( | ||
| 19 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 20 | def.getName(), | ||
| 21 | new Signature(def.getErasedSignature()) | ||
| 22 | ); | ||
| 23 | } | ||
| 24 | |||
| 25 | public static ConstructorEntry getConstructorEntry(MethodDefinition def) { | ||
| 26 | if (def.isTypeInitializer()) { | ||
| 27 | return new ConstructorEntry( | ||
| 28 | new ClassEntry(def.getDeclaringType().getInternalName()) | ||
| 29 | ); | ||
| 30 | } else { | ||
| 31 | return new ConstructorEntry( | ||
| 32 | new ClassEntry(def.getDeclaringType().getInternalName()), | ||
| 33 | new Signature(def.getErasedSignature()) | ||
| 34 | ); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | public static BehaviorEntry getBehaviorEntry(MethodDefinition def) { | ||
| 39 | if (def.isConstructor() || def.isTypeInitializer()) { | ||
| 40 | return getConstructorEntry(def); | ||
| 41 | } else { | ||
| 42 | return getMethodEntry(def); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||