diff --git a/src/main/java/info/sigterm/deob/Deob.java b/src/main/java/info/sigterm/deob/Deob.java index 219e364206..f265e49dbb 100644 --- a/src/main/java/info/sigterm/deob/Deob.java +++ b/src/main/java/info/sigterm/deob/Deob.java @@ -42,10 +42,7 @@ public class Deob long start = System.currentTimeMillis(); ClassGroup group = loadJar(args[0]); - - new RenameUnique().run(group); - - /* + // remove except RuntimeException new RuntimeExceptions().run(group); @@ -68,7 +65,8 @@ public class Deob new UnusedFields().run(group); //new ModularArithmeticDeobfuscation().run(group); - */ + + new RenameUnique().run(group); saveJar(group, args[1]); diff --git a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeInterface.java b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeInterface.java index b9c3c89525..233956e97a 100644 --- a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeInterface.java +++ b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeInterface.java @@ -180,7 +180,8 @@ public class InvokeInterface extends Instruction implements InvokeInstruction @Override public void renameMethod(info.sigterm.deob.Method m, String name) { - if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName())) - method = new InterfaceMethod(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); + for (info.sigterm.deob.Method m2 : getMethods()) + if (m2.equals(m)) + method = new InterfaceMethod(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); } } diff --git a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeSpecial.java b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeSpecial.java index 343899d854..28d8240f88 100644 --- a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeSpecial.java +++ b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeSpecial.java @@ -52,6 +52,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction return new ArrayList<>(); // not our class info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType()); + assert other != null; List list = new ArrayList<>(); list.add(other); @@ -172,7 +173,8 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction @Override public void renameMethod(info.sigterm.deob.Method m, String name) { - if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName())) - method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); + for (info.sigterm.deob.Method m2 : getMethods()) + if (m2.equals(m)) + method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); } } diff --git a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java index 8ba636468c..6115bd8439 100644 --- a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java +++ b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeStatic.java @@ -52,6 +52,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction return new ArrayList<>(); // not our class info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType()); + assert other != null; List list = new ArrayList<>(); list.add(other); @@ -169,7 +170,14 @@ public class InvokeStatic extends Instruction implements InvokeInstruction @Override public void renameMethod(info.sigterm.deob.Method m, String name) { - if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName())) + ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); + ClassFile otherClass = group.findClass(method.getClassEntry().getName()); + if (otherClass == null) + return; // not our class + + info.sigterm.deob.Method other = otherClass.findMethodDeep(method.getNameAndType()); + + if (other.equals(m)) method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); } } diff --git a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeVirtual.java b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeVirtual.java index 63dffe5144..03e7d11eaa 100644 --- a/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeVirtual.java +++ b/src/main/java/info/sigterm/deob/attributes/code/instructions/InvokeVirtual.java @@ -179,7 +179,8 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction @Override public void renameMethod(info.sigterm.deob.Method m, String name) { - if (method.getNameAndType().equals(m.getNameAndType()) && method.getClassEntry().getName().equals(m.getMethods().getClassFile().getName())) - method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); + for (info.sigterm.deob.Method m2 : getMethods()) + if (m2.equals(m)) + method = new Method(method.getClassEntry(), new NameAndType(name, method.getNameAndType().getDescriptor())); } } diff --git a/src/main/java/info/sigterm/deob/execution/Execution.java b/src/main/java/info/sigterm/deob/execution/Execution.java index faf00cadb5..29a3966986 100644 --- a/src/main/java/info/sigterm/deob/execution/Execution.java +++ b/src/main/java/info/sigterm/deob/execution/Execution.java @@ -3,7 +3,6 @@ package info.sigterm.deob.execution; import info.sigterm.deob.ClassFile; import info.sigterm.deob.ClassGroup; import info.sigterm.deob.Method; -import info.sigterm.deob.attributes.code.Exceptions; import java.util.ArrayList; import java.util.HashSet; @@ -40,6 +39,8 @@ public class Execution public void addMethod(Method method) { + assert method != null; + if (methods.contains(method)) return; // already processed