From be1d5ed010d77ffaabaab507a9cee6e07b6da00b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Nov 2015 20:39:17 -0500 Subject: [PATCH] Instruction clone wasnt creating new jump lists... --- .../net/runelite/deob/attributes/code/Instruction.java | 9 ++++++++- .../deob/attributes/code/instructions/LookupSwitch.java | 3 ++- .../deob/attributes/code/instructions/TableSwitch.java | 3 ++- .../net/runelite/deob/deobfuscators/MethodInliner.java | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/runelite/deob/attributes/code/Instruction.java b/src/main/java/net/runelite/deob/attributes/code/Instruction.java index 8abc663c3b..b8f64a87c6 100644 --- a/src/main/java/net/runelite/deob/attributes/code/Instruction.java +++ b/src/main/java/net/runelite/deob/attributes/code/Instruction.java @@ -33,14 +33,21 @@ public abstract class Instruction implements Cloneable @Override public Instruction clone() { + Instruction i; try { - return (Instruction) super.clone(); + i = (Instruction) super.clone(); } catch (CloneNotSupportedException ex) { throw new RuntimeException(); } + + i.block = null; + i.from = new ArrayList<>(); + i.jump = new ArrayList<>(); + + return i; } public void load(DataInputStream is) throws IOException diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LookupSwitch.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LookupSwitch.java index cf499f1086..f81d923f13 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LookupSwitch.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LookupSwitch.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class LookupSwitch extends Instruction implements JumpingInstruction { @@ -144,6 +145,6 @@ public class LookupSwitch extends Instruction implements JumpingInstruction for (Instruction i : branchi) list.add(i); list.add(defi); - return list; + return list.stream().distinct().collect(Collectors.toList()); } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/TableSwitch.java b/src/main/java/net/runelite/deob/attributes/code/instructions/TableSwitch.java index cc88def589..0082885845 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/TableSwitch.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/TableSwitch.java @@ -14,6 +14,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class TableSwitch extends Instruction implements JumpingInstruction { @@ -140,6 +141,6 @@ public class TableSwitch extends Instruction implements JumpingInstruction for (Instruction i : branchi) list.add(i); list.add(defi); - return list; + return list.stream().distinct().collect(Collectors.toList()); } } diff --git a/src/main/java/net/runelite/deob/deobfuscators/MethodInliner.java b/src/main/java/net/runelite/deob/deobfuscators/MethodInliner.java index d416f327c4..5bae0882f0 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/MethodInliner.java +++ b/src/main/java/net/runelite/deob/deobfuscators/MethodInliner.java @@ -99,7 +99,6 @@ public class MethodInliner implements Deobfuscator assert ins.getInstructions().get(invokeIdx).getInstructions() == ins; int lvtIndex = code.getMaxLocals(), - //startLvtIndex = lvtIndex, theirLocals = invokedMethod.getCode().getMaxLocals(); if (lvtIndex + theirLocals > 127)