diff options
| author | 2015-02-09 23:31:24 -0500 | |
|---|---|---|
| committer | 2015-02-09 23:31:24 -0500 | |
| commit | ab6de199201f3cb292b986b2803d7d30b1485a47 (patch) | |
| tree | df9760cab6ad95ef1ab10cfb98c89d84324024e4 /src | |
| parent | fix translation issues, particularly with fields (diff) | |
| download | enigma-ab6de199201f3cb292b986b2803d7d30b1485a47.tar.gz enigma-ab6de199201f3cb292b986b2803d7d30b1485a47.tar.xz enigma-ab6de199201f3cb292b986b2803d7d30b1485a47.zip | |
work around bad tokens generated by procyon for now
Diffstat (limited to 'src')
5 files changed, 16 insertions, 29 deletions
diff --git a/src/cuchaz/enigma/TranslatingTypeLoader.java b/src/cuchaz/enigma/TranslatingTypeLoader.java index cfa03a1a..8bec17fb 100644 --- a/src/cuchaz/enigma/TranslatingTypeLoader.java +++ b/src/cuchaz/enigma/TranslatingTypeLoader.java | |||
| @@ -104,6 +104,7 @@ public class TranslatingTypeLoader implements ITypeLoader { | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | private byte[] loadType(String deobfClassName) { | 106 | private byte[] loadType(String deobfClassName) { |
| 107 | |||
| 107 | ClassEntry deobfClassEntry = new ClassEntry(deobfClassName); | 108 | ClassEntry deobfClassEntry = new ClassEntry(deobfClassName); |
| 108 | ClassEntry obfClassEntry = m_obfuscatingTranslator.translateEntry(deobfClassEntry); | 109 | ClassEntry obfClassEntry = m_obfuscatingTranslator.translateEntry(deobfClassEntry); |
| 109 | 110 | ||
| @@ -176,7 +177,9 @@ public class TranslatingTypeLoader implements ITypeLoader { | |||
| 176 | } | 177 | } |
| 177 | } | 178 | } |
| 178 | 179 | ||
| 179 | public CtClass transformClass(CtClass c) throws IOException, NotFoundException, CannotCompileException { | 180 | public CtClass transformClass(CtClass c) |
| 181 | throws IOException, NotFoundException, CannotCompileException { | ||
| 182 | |||
| 180 | // we moved a lot of classes out of the default package into the none package | 183 | // we moved a lot of classes out of the default package into the none package |
| 181 | // make sure all the class references are consistent | 184 | // make sure all the class references are consistent |
| 182 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); | 185 | ClassRenamer.moveAllClassesOutOfDefaultPackage(c, Constants.NonePackage); |
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java index b43ab614..e31b8032 100644 --- a/src/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -82,10 +82,11 @@ public class SourceIndex { | |||
| 82 | // DEBUG | 82 | // DEBUG |
| 83 | // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) ); | 83 | // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) ); |
| 84 | 84 | ||
| 85 | // for tokens representing inner classes, make sure we only get the simple name | 85 | // if the token has a $ in it, something's wrong. Ignore this token |
| 86 | int pos = name.lastIndexOf('$'); | 86 | if (name.lastIndexOf('$') >= 0) { |
| 87 | if (pos >= 0) { | 87 | // DEBUG |
| 88 | token.end -= pos + 1; | 88 | System.err.println(String.format("WARNING: %s \"%s\" is probably a bad token. It was ignored", node.getNodeType(), name)); |
| 89 | return null; | ||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | return token; | 92 | return token; |
diff --git a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java index b4094d9e..a9a055be 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexBehaviorVisitor.java | |||
| @@ -17,12 +17,10 @@ import com.strobel.assembler.metadata.ParameterDefinition; | |||
| 17 | import com.strobel.assembler.metadata.TypeReference; | 17 | import com.strobel.assembler.metadata.TypeReference; |
| 18 | import com.strobel.decompiler.languages.TextLocation; | 18 | import com.strobel.decompiler.languages.TextLocation; |
| 19 | import com.strobel.decompiler.languages.java.ast.AstNode; | 19 | import com.strobel.decompiler.languages.java.ast.AstNode; |
| 20 | import com.strobel.decompiler.languages.java.ast.ConstructorDeclaration; | ||
| 21 | import com.strobel.decompiler.languages.java.ast.IdentifierExpression; | 20 | import com.strobel.decompiler.languages.java.ast.IdentifierExpression; |
| 22 | import com.strobel.decompiler.languages.java.ast.InvocationExpression; | 21 | import com.strobel.decompiler.languages.java.ast.InvocationExpression; |
| 23 | import com.strobel.decompiler.languages.java.ast.Keys; | 22 | import com.strobel.decompiler.languages.java.ast.Keys; |
| 24 | import com.strobel.decompiler.languages.java.ast.MemberReferenceExpression; | 23 | import com.strobel.decompiler.languages.java.ast.MemberReferenceExpression; |
| 25 | import com.strobel.decompiler.languages.java.ast.MethodDeclaration; | ||
| 26 | import com.strobel.decompiler.languages.java.ast.ObjectCreationExpression; | 24 | import com.strobel.decompiler.languages.java.ast.ObjectCreationExpression; |
| 27 | import com.strobel.decompiler.languages.java.ast.ParameterDeclaration; | 25 | import com.strobel.decompiler.languages.java.ast.ParameterDeclaration; |
| 28 | import com.strobel.decompiler.languages.java.ast.SimpleType; | 26 | import com.strobel.decompiler.languages.java.ast.SimpleType; |
| @@ -33,6 +31,7 @@ import cuchaz.enigma.mapping.ArgumentEntry; | |||
| 33 | import cuchaz.enigma.mapping.BehaviorEntry; | 31 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 34 | import cuchaz.enigma.mapping.ClassEntry; | 32 | import cuchaz.enigma.mapping.ClassEntry; |
| 35 | import cuchaz.enigma.mapping.ConstructorEntry; | 33 | import cuchaz.enigma.mapping.ConstructorEntry; |
| 34 | import cuchaz.enigma.mapping.EntryFactory; | ||
| 36 | import cuchaz.enigma.mapping.FieldEntry; | 35 | import cuchaz.enigma.mapping.FieldEntry; |
| 37 | import cuchaz.enigma.mapping.MethodEntry; | 36 | import cuchaz.enigma.mapping.MethodEntry; |
| 38 | import cuchaz.enigma.mapping.Signature; | 37 | import cuchaz.enigma.mapping.Signature; |
| @@ -47,16 +46,6 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | @Override | 48 | @Override |
| 50 | public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) { | ||
| 51 | return recurse(node, index); | ||
| 52 | } | ||
| 53 | |||
| 54 | @Override | ||
| 55 | public Void visitConstructorDeclaration(ConstructorDeclaration node, SourceIndex index) { | ||
| 56 | return recurse(node, index); | ||
| 57 | } | ||
| 58 | |||
| 59 | @Override | ||
| 60 | public Void visitInvocationExpression(InvocationExpression node, SourceIndex index) { | 49 | public Void visitInvocationExpression(InvocationExpression node, SourceIndex index) { |
| 61 | MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE); | 50 | MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE); |
| 62 | 51 | ||
| @@ -122,14 +111,8 @@ public class SourceIndexBehaviorVisitor extends SourceIndexVisitor { | |||
| 122 | @Override | 111 | @Override |
| 123 | public Void visitParameterDeclaration(ParameterDeclaration node, SourceIndex index) { | 112 | public Void visitParameterDeclaration(ParameterDeclaration node, SourceIndex index) { |
| 124 | ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION); | 113 | ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION); |
| 125 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); | ||
| 126 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); | 114 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); |
| 127 | BehaviorEntry behaviorEntry; | 115 | BehaviorEntry behaviorEntry = EntryFactory.getBehaviorEntry(methodDef); |
| 128 | if (methodDef.isConstructor()) { | ||
| 129 | behaviorEntry = new ConstructorEntry(classEntry, new Signature(methodDef.getSignature())); | ||
| 130 | } else { | ||
| 131 | behaviorEntry = new MethodEntry(classEntry, methodDef.getName(), new Signature(methodDef.getSignature())); | ||
| 132 | } | ||
| 133 | ArgumentEntry argumentEntry = new ArgumentEntry(behaviorEntry, def.getPosition(), node.getName()); | 116 | ArgumentEntry argumentEntry = new ArgumentEntry(behaviorEntry, def.getPosition(), node.getName()); |
| 134 | index.addDeclaration(node.getNameToken(), argumentEntry); | 117 | index.addDeclaration(node.getNameToken(), argumentEntry); |
| 135 | 118 | ||
diff --git a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java index d6692f60..f4f49568 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexClassVisitor.java | |||
| @@ -94,7 +94,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 94 | public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { | 94 | public Void visitFieldDeclaration(FieldDeclaration node, SourceIndex index) { |
| 95 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); | 95 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 96 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); | 96 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 97 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getSignature())); | 97 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getErasedSignature())); |
| 98 | assert (node.getVariables().size() == 1); | 98 | assert (node.getVariables().size() == 1); |
| 99 | VariableInitializer variable = node.getVariables().firstOrNullObject(); | 99 | VariableInitializer variable = node.getVariables().firstOrNullObject(); |
| 100 | index.addDeclaration(variable.getNameToken(), fieldEntry); | 100 | index.addDeclaration(variable.getNameToken(), fieldEntry); |
| @@ -107,7 +107,7 @@ public class SourceIndexClassVisitor extends SourceIndexVisitor { | |||
| 107 | // treat enum declarations as field declarations | 107 | // treat enum declarations as field declarations |
| 108 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); | 108 | FieldDefinition def = node.getUserData(Keys.FIELD_DEFINITION); |
| 109 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); | 109 | ClassEntry classEntry = new ClassEntry(def.getDeclaringType().getInternalName()); |
| 110 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getSignature())); | 110 | FieldEntry fieldEntry = new FieldEntry(classEntry, def.getName(), new Type(def.getErasedSignature())); |
| 111 | index.addDeclaration(node.getNameToken(), fieldEntry); | 111 | index.addDeclaration(node.getNameToken(), fieldEntry); |
| 112 | 112 | ||
| 113 | return recurse(node, index); | 113 | return recurse(node, index); |
diff --git a/src/cuchaz/enigma/bytecode/InnerClassWriter.java b/src/cuchaz/enigma/bytecode/InnerClassWriter.java index 817500b7..5350b86c 100644 --- a/src/cuchaz/enigma/bytecode/InnerClassWriter.java +++ b/src/cuchaz/enigma/bytecode/InnerClassWriter.java | |||
| @@ -13,7 +13,6 @@ package cuchaz.enigma.bytecode; | |||
| 13 | import java.util.Collection; | 13 | import java.util.Collection; |
| 14 | 14 | ||
| 15 | import javassist.CtClass; | 15 | import javassist.CtClass; |
| 16 | import javassist.bytecode.AccessFlag; | ||
| 17 | import javassist.bytecode.ConstPool; | 16 | import javassist.bytecode.ConstPool; |
| 18 | import javassist.bytecode.Descriptor; | 17 | import javassist.bytecode.Descriptor; |
| 19 | import javassist.bytecode.EnclosingMethodAttribute; | 18 | import javassist.bytecode.EnclosingMethodAttribute; |
| @@ -77,18 +76,19 @@ public class InnerClassWriter { | |||
| 77 | int innerClassIndex = constPool.addClassInfo(obfClassEntry.getName()); | 76 | int innerClassIndex = constPool.addClassInfo(obfClassEntry.getName()); |
| 78 | int outerClassIndex = 0; | 77 | int outerClassIndex = 0; |
| 79 | int innerClassSimpleNameIndex = 0; | 78 | int innerClassSimpleNameIndex = 0; |
| 79 | int accessFlags = 0; | ||
| 80 | if (!m_jarIndex.isAnonymousClass(obfInnerClassName)) { | 80 | if (!m_jarIndex.isAnonymousClass(obfInnerClassName)) { |
| 81 | outerClassIndex = constPool.addClassInfo(obfClassEntry.getOuterClassName()); | 81 | outerClassIndex = constPool.addClassInfo(obfClassEntry.getOuterClassName()); |
| 82 | innerClassSimpleNameIndex = constPool.addUtf8Info(obfClassEntry.getInnerClassName()); | 82 | innerClassSimpleNameIndex = constPool.addUtf8Info(obfClassEntry.getInnerClassName()); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | attr.append(innerClassIndex, outerClassIndex, innerClassSimpleNameIndex, c.getClassFile().getAccessFlags() & ~AccessFlag.SUPER); | 85 | attr.append(innerClassIndex, outerClassIndex, innerClassSimpleNameIndex, accessFlags); |
| 86 | 86 | ||
| 87 | /* DEBUG | 87 | /* DEBUG |
| 88 | System.out.println(String.format("\tOBF: %s -> ATTR: %s,%s,%s (replace %s with %s)", | 88 | System.out.println(String.format("\tOBF: %s -> ATTR: %s,%s,%s (replace %s with %s)", |
| 89 | obfClassEntry, | 89 | obfClassEntry, |
| 90 | attr.outerClass(attr.tableLength() - 1), | ||
| 91 | attr.innerClass(attr.tableLength() - 1), | 90 | attr.innerClass(attr.tableLength() - 1), |
| 91 | attr.outerClass(attr.tableLength() - 1), | ||
| 92 | attr.innerName(attr.tableLength() - 1), | 92 | attr.innerName(attr.tableLength() - 1), |
| 93 | Constants.NonePackage + "/" + obfInnerClassName, | 93 | Constants.NonePackage + "/" + obfInnerClassName, |
| 94 | obfClassEntry.getName() | 94 | obfClassEntry.getName() |