diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/GetField.java b/src/main/java/net/runelite/deob/attributes/code/instructions/GetField.java index 712d7a1ea9..2f2505366a 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/GetField.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/GetField.java @@ -106,6 +106,10 @@ public class GetField extends Instruction implements GetFieldInstruction public void regeneratePool() { if (myField != null) - field = myField.getPoolField(); + // only rebuild field info if the field has changed. + // otherwise it will rewrite the pool field into to something + // different if the field was deep + if (getMyField() != myField) + field = myField.getPoolField(); } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/GetStatic.java b/src/main/java/net/runelite/deob/attributes/code/instructions/GetStatic.java index 3c73029e20..96503fdc89 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/GetStatic.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/GetStatic.java @@ -103,6 +103,7 @@ public class GetStatic extends Instruction implements GetFieldInstruction public void regeneratePool() { if (myField != null) - field = myField.getPoolField(); + if (getMyField() != myField) + field = myField.getPoolField(); } } 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 c4caa5c808..4f56cf24ee 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 @@ -146,26 +146,29 @@ public class InvokeInterface extends Instruction implements InvokeInstruction return method; } - @Override - public void lookup() + private List lookupMethods() { ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); ClassFile otherClass = group.findClass(method.getClassEntry().getName()); if (otherClass == null) - return; // not our class + return null; // not our class - // look up this method in this class and anything that inherits from it - //List list = new ArrayList<>(); - //findMethodFromClass(list, otherClass); - myMethods = Renamer.getVirutalMethods(otherClass.findMethod(method.getNameAndType())); + return Renamer.getVirutalMethods(otherClass.findMethod(method.getNameAndType())); + } + + @Override + public void lookup() + { + myMethods = lookupMethods(); } @Override public void regeneratePool() { if (myMethods != null && !myMethods.isEmpty()) - method = myMethods.get(0).getPoolInterfaceMethod(); // is this right? + if (!myMethods.equals(lookupMethods())) + method = myMethods.get(0).getPoolInterfaceMethod(); // is this right? } @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 7fba2f5c18..6bbb25edcb 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 @@ -32,7 +32,7 @@ import net.runelite.deob.execution.Value; public class InvokeStatic extends Instruction implements InvokeInstruction { private Method method; - private List myMethods; + private net.runelite.deob.Method myMethod; public InvokeStatic(Instructions instructions, InstructionType type, int pc) { @@ -69,7 +69,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction @Override public List getMethods() { - return myMethods != null ? myMethods : Arrays.asList(); + return myMethod != null ? Arrays.asList(myMethod) : Arrays.asList(); } @Override @@ -141,28 +141,32 @@ public class InvokeStatic extends Instruction implements InvokeInstruction return method; } - @Override - public void lookup() + private net.runelite.deob.Method lookupMethod() { ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); ClassFile otherClass = group.findClass(method.getClassEntry().getName()); if (otherClass == null) - return; // not our class + return null; // not our class net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType()); assert other != null; - List list = new ArrayList<>(); - list.add(other); - myMethods = list; + return other; + } + + @Override + public void lookup() + { + myMethod = lookupMethod(); } @Override public void regeneratePool() { - if (myMethods != null && !myMethods.isEmpty()) - method = myMethods.get(0).getPoolMethod(); + if (myMethod != null) + if (myMethod != lookupMethod()) + method = myMethod.getPoolMethod(); } @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 196485d73a..b566727291 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 @@ -21,7 +21,6 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.Arrays; import java.util.List; -import java.util.Set; import net.runelite.deob.Field; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.deobfuscators.Renamer; @@ -140,33 +139,37 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction return method; } - @Override - public void lookup() + private List lookupMethods() { ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup(); ClassFile otherClass = group.findClass(method.getClassEntry().getName()); if (otherClass == null) - return; // not our class + return null; // not our class // when I recompile classes I can see the class of invokevirtuals methods change, get all methods - //List list = new ArrayList<>(); - //findMethodFromClass(new HashSet<>(), list, otherClass); net.runelite.deob.Method m = otherClass.findMethodDeep(method.getNameAndType()); if (m == null) { - return; + return null; } - myMethods = Renamer.getVirutalMethods(m); + return Renamer.getVirutalMethods(m); + } + + @Override + public void lookup() + { + myMethods = lookupMethods(); } @Override public void regeneratePool() { if (myMethods != null && !myMethods.isEmpty()) - method = myMethods.get(0).getPoolMethod(); // is this right? + if (!myMethods.equals(lookupMethods())) + method = myMethods.get(0).getPoolMethod(); // is this right? } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java b/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java index bfaff7fb63..d1dec3d4e5 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/PutField.java @@ -18,7 +18,6 @@ import java.io.DataOutputStream; import java.io.IOException; import net.runelite.deob.Method; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; -import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil; import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; @@ -97,7 +96,8 @@ public class PutField extends Instruction implements SetFieldInstruction public void regeneratePool() { if (myField != null) - field = myField.getPoolField(); + if (getMyField() != myField) + field = myField.getPoolField(); } @Override diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java b/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java index be3774f2b5..71144368cc 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/PutStatic.java @@ -18,7 +18,6 @@ import java.io.DataOutputStream; import java.io.IOException; import net.runelite.deob.Method; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; -import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil; import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping; @@ -95,7 +94,8 @@ public class PutStatic extends Instruction implements SetFieldInstruction public void regeneratePool() { if (myField != null) - field = myField.getPoolField(); + if (getMyField() != myField) + field = myField.getPoolField(); } @Override