diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Encryption.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Encryption.java index e626e94835..e92d758448 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Encryption.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Encryption.java @@ -10,7 +10,15 @@ public class Encryption public void addPair(Pair pair) { - fields.put(pair.field, pair); + Pair existing = fields.get(pair.field); + if (existing != null) + { + fields.put(pair.field, new Pair(pair, existing)); + } + else + { + fields.put(pair.field, pair); + } } public Pair getField(Field field) diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java index 5de05ed88e..a028d6f9ce 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java @@ -37,6 +37,7 @@ public class ModArith implements Deobfuscator private MultiValueMap constantGetters = new MultiValueMap<>(), constantSetters = new MultiValueMap<>(); private List pairs = new ArrayList<>(); + private Encryption encryption = new Encryption(); private List getInsInExpr(InstructionContext ctx, Set set) { @@ -637,7 +638,7 @@ public class ModArith implements Deobfuscator group.buildClassGraph(); pairs.clear(); - constantGetters.clear();; + constantGetters.clear(); constantSetters.clear(); constants.clear(); @@ -658,6 +659,7 @@ public class ModArith implements Deobfuscator Encryption encr = new Encryption(); encr.addPair(pair); + encryption.addPair(pair); // sum total insertGetterSetterMuls(encr); @@ -668,5 +670,9 @@ public class ModArith implements Deobfuscator return i; } - + + public Encryption getEncryption() + { + return encryption; + } } diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Pair.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Pair.java index 8c0dbe2017..efcee01071 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Pair.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/Pair.java @@ -7,6 +7,19 @@ public class Pair public Field field; public Number getter, setter; + public Pair() + { + } + + public Pair(Pair one, Pair two) + { + assert one.getType() == two.getType(); + assert one.field == two.field; + + getter = DMath.multiply(one.getter, two.getter); + setter = DMath.multiply(one.setter, two.setter); + } + public Class getType() { assert getter.getClass() == setter.getClass(); diff --git a/src/main/java/net/runelite/deob/execution/Execution.java b/src/main/java/net/runelite/deob/execution/Execution.java index d976e6774e..9c34e1c7e8 100644 --- a/src/main/java/net/runelite/deob/execution/Execution.java +++ b/src/main/java/net/runelite/deob/execution/Execution.java @@ -18,7 +18,6 @@ import net.runelite.deob.attributes.code.instruction.types.FieldInstruction; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instructions.InvokeStatic; -import net.runelite.deob.deobfuscators.arithmetic.Encryption; import net.runelite.deob.deobfuscators.rename.graph.EdgeType; import net.runelite.deob.deobfuscators.rename.graph.Graph; import org.apache.commons.collections4.map.MultiValueMap; @@ -31,7 +30,6 @@ public class Execution public Set methods = new HashSet<>(); // all methods public Set executed = new HashSet<>(); // executed instructions private MultiValueMap invokes = new MultiValueMap<>(); - private Encryption encryption; public MultiValueMap contexts = new MultiValueMap<>(); private Map methodContexts = new HashMap<>(); private boolean buildGraph; // if true the frame graph is built and execution hasJumped also compares previous instructions @@ -41,16 +39,6 @@ public class Execution { this.group = group; } - - public Encryption getEncryption() - { - return encryption; - } - - public void setEncryption(Encryption encryption) - { - this.encryption = encryption; - } public List getInitialMethods() {