diff --git a/src/main/java/net/runelite/deob/ClassGroup.java b/src/main/java/net/runelite/deob/ClassGroup.java index c775db277f..80393565d7 100644 --- a/src/main/java/net/runelite/deob/ClassGroup.java +++ b/src/main/java/net/runelite/deob/ClassGroup.java @@ -4,6 +4,7 @@ import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import net.runelite.deob.attributes.Code; public class ClassGroup { @@ -52,4 +53,19 @@ public class ClassGroup for (ClassFile c : classes) c.buildClassGraph(); } + + public void lookup() + { + for (ClassFile cf : this.getClasses()) + for (Method m : cf.getMethods().getMethods()) + { + Code code = m.getCode(); + + if (code == null) + continue; + + code.getInstructions().lookup(); + } + + } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeInterface.java b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeInterface.java index ba98a8d7c3..ebc32972f9 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeInterface.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeInterface.java @@ -20,6 +20,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.runelite.deob.execution.Execution; @@ -55,16 +56,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction @Override public List getMethods() { - ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); - - ClassFile otherClass = group.findClass(method.getClassEntry().getName()); - if (otherClass == null) - return new ArrayList<>(); // not our class - - // look up this method in this class and anything that inherits from it - List list = new ArrayList<>(); - findMethodFromClass(list, otherClass); - return list; + return myMethods != null ? myMethods : Arrays.asList(); } private void findMethodFromClass(List list, ClassFile clazz) @@ -143,7 +135,16 @@ public class InvokeInterface extends Instruction implements InvokeInstruction @Override public void lookup() { - myMethods = this.getMethods(); + ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); + + ClassFile otherClass = group.findClass(method.getClassEntry().getName()); + if (otherClass == null) + return; // not our class + + // look up this method in this class and anything that inherits from it + List list = new ArrayList<>(); + findMethodFromClass(list, otherClass); + myMethods = list; } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeSpecial.java b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeSpecial.java index 4b69f621b5..a7ca94662e 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeSpecial.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeSpecial.java @@ -20,6 +20,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.runelite.deob.execution.Execution; @@ -50,18 +51,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction @Override public List getMethods() { - ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); - - ClassFile otherClass = group.findClass(method.getClassEntry().getName()); - if (otherClass == null) - return new ArrayList<>(); // not our class - - net.runelite.deob.Method other = otherClass.findMethod(method.getNameAndType()); - assert other != null; - - List list = new ArrayList<>(); - list.add(other); - return list; + return myMethods != null ? myMethods : Arrays.asList(); } @Override @@ -136,7 +126,18 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction @Override public void lookup() { - myMethods = this.getMethods(); + ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); + + ClassFile otherClass = group.findClass(method.getClassEntry().getName()); + if (otherClass == null) + return; // not our class + + net.runelite.deob.Method other = otherClass.findMethod(method.getNameAndType()); + assert other != null; + + List list = new ArrayList<>(); + list.add(other); + myMethods = list; } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeStatic.java b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeStatic.java index 38a2b67d43..a322707740 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeStatic.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeStatic.java @@ -20,6 +20,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.runelite.deob.execution.Execution; @@ -57,18 +58,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction @Override public List getMethods() { - ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); - - ClassFile otherClass = group.findClass(method.getClassEntry().getName()); - if (otherClass == null) - return new ArrayList<>(); // not our class - - net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType()); - assert other != null; - - List list = new ArrayList<>(); - list.add(other); - return list; + return myMethods != null ? myMethods : Arrays.asList(); } @Override @@ -140,7 +130,18 @@ public class InvokeStatic extends Instruction implements InvokeInstruction @Override public void lookup() { - myMethods = this.getMethods(); + ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); + + ClassFile otherClass = group.findClass(method.getClassEntry().getName()); + if (otherClass == null) + return; // not our class + + net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType()); + assert other != null; + + List list = new ArrayList<>(); + list.add(other); + myMethods = list; } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeVirtual.java b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeVirtual.java index c9257271c5..bff79bc400 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeVirtual.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/InvokeVirtual.java @@ -20,6 +20,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.runelite.deob.execution.Execution; @@ -96,16 +97,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction @Override public List getMethods() { - ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); - - ClassFile otherClass = group.findClass(method.getClassEntry().getName()); - if (otherClass == null) - return new ArrayList<>(); // not our class - - // look up this method in this class and anything that inherits from it - List list = new ArrayList<>(); - findMethodFromClass(list, otherClass); - return list; + return myMethods != null ? myMethods : Arrays.asList(); } private void findMethodFromClass(List list, ClassFile clazz) @@ -141,7 +133,16 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction @Override public void lookup() { - myMethods = this.getMethods(); + ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); + + ClassFile otherClass = group.findClass(method.getClassEntry().getName()); + if (otherClass == null) + return; // not our class + + // look up this method in this class and anything that inherits from it + List list = new ArrayList<>(); + findMethodFromClass(list, otherClass); + myMethods = list; } @Override diff --git a/src/main/java/net/runelite/deob/deobfuscators/RenameUnique.java b/src/main/java/net/runelite/deob/deobfuscators/RenameUnique.java index 33e749d2c8..eef14dcddf 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/RenameUnique.java +++ b/src/main/java/net/runelite/deob/deobfuscators/RenameUnique.java @@ -255,19 +255,6 @@ public class RenameUnique implements Deobfuscator return map; } - private void lookup(ClassGroup group) - { - for (ClassFile cf : group.getClasses()) - for (Method m : cf.getMethods().getMethods()) - { - Code c = m.getCode(); - if (c == null) - continue; - - c.getInstructions().lookup(); - } - } - private void regeneratePool(ClassGroup group) { for (ClassFile cf : group.getClasses()) @@ -285,7 +272,6 @@ public class RenameUnique implements Deobfuscator public void run(ClassGroup group) { group.buildClassGraph(); - lookup(group); NameMappings mappings = this.generateClassNames(group); diff --git a/src/main/java/net/runelite/deob/execution/Execution.java b/src/main/java/net/runelite/deob/execution/Execution.java index 9f3d3f031c..7b670ca416 100644 --- a/src/main/java/net/runelite/deob/execution/Execution.java +++ b/src/main/java/net/runelite/deob/execution/Execution.java @@ -48,6 +48,7 @@ public class Execution List methods = new ArrayList<>(); group.buildClassGraph(); // required when looking up methods + group.lookup(); // lookup methods for (ClassFile cf : group.getClasses()) {