From 7e9233a5d52af224d016d5f5cb93f00897fe081a Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 8 Sep 2015 15:46:29 -0400 Subject: [PATCH] Fix putfield pop order, runs on all fields it detects now. Don't know if it works. --- .../code/instructions/PutField.java | 2 +- .../deobfuscators/arithmetic/ModArith.java | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) 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 3df0c55b03..13e2552d19 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 @@ -50,7 +50,7 @@ public class PutField extends Instruction implements SetFieldInstruction StackContext value = stack.pop(); StackContext object = stack.pop(); - ins.pop(object, value); + ins.pop(value, object); Encryption encryption = frame.getExecution().getEncryption(); net.runelite.deob.Field myField = getMyField(); 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 526ccd31fd..d4826a987a 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java @@ -66,13 +66,16 @@ public class ModArith implements Deobfuscator int value = (int) pc.getConstant().getObject(); + if (value == 1 || value == 0) + continue; + constantGetters.put(field, value); } else if (ctx.getInstruction() instanceof SetFieldInstruction) { SetFieldInstruction sf = (SetFieldInstruction) ctx.getInstruction(); - StackContext value = ctx.getPops().get(0); // what setfield pops as value + StackContext value = ctx.getPops().get(0); // the first thing poppe from both putfield and putstatic is the value if (!(value.getPushed().getInstruction() instanceof IMul)) continue; @@ -101,6 +104,9 @@ public class ModArith implements Deobfuscator int value2 = (int) pc.getConstant().getObject(); + if (value2 == 1 || value2 == 0) + continue; + constantSetters.put(field, value2); } } @@ -263,8 +269,17 @@ public class ModArith implements Deobfuscator public void run(ClassGroup group) { this.group = group; + while (runOnce() > 0); + } + + private int runOnce() + { group.buildClassGraph(); + pairs.clear(); + constantGetters.clear();; + constantSetters.clear(); + execution = new Execution(group); execution.populateInitialMethods(); execution.run(); @@ -273,7 +288,7 @@ public class ModArith implements Deobfuscator reduce(); int i = 0; - int start = 0, end = 32; // 24 32 ok + int start = 0, end = pairs.size(); // 0-64 ok for (int j = start; j < end; ++j) //for (Pair pair : pairs) { @@ -322,6 +337,7 @@ public class ModArith implements Deobfuscator // // Field f = group.findClass("class41").findField("field1170"); // calculate(f); + return i; } }