From 98e3b7ec9e9bb6c4bca9ae9eac1566254acd0603 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 13 Sep 2015 19:38:36 -0400 Subject: [PATCH] setConstant --- .../code/instruction/types/PushConstantInstruction.java | 3 ++- .../deob/attributes/code/instructions/BiPush.java | 2 +- .../deob/attributes/code/instructions/DConst_0.java | 2 +- .../deob/attributes/code/instructions/DConst_1.java | 2 +- .../deob/attributes/code/instructions/FConst_0.java | 2 +- .../deob/attributes/code/instructions/FConst_1.java | 2 +- .../deob/attributes/code/instructions/FConst_2.java | 2 +- .../deob/attributes/code/instructions/IConst_0.java | 2 +- .../deob/attributes/code/instructions/IConst_1.java | 4 ++-- .../deob/attributes/code/instructions/IConst_2.java | 2 +- .../deob/attributes/code/instructions/IConst_3.java | 2 +- .../deob/attributes/code/instructions/IConst_4.java | 2 +- .../deob/attributes/code/instructions/IConst_5.java | 2 +- .../deob/attributes/code/instructions/IConst_M1.java | 2 +- .../deob/attributes/code/instructions/LConst_0.java | 2 +- .../deob/attributes/code/instructions/LConst_1.java | 2 +- .../deob/attributes/code/instructions/LDC2_W.java | 3 ++- .../deob/attributes/code/instructions/LDC_W.java | 3 ++- .../deob/attributes/code/instructions/SiPush.java | 2 +- .../deobfuscators/ModularArithmeticDeobfuscation.java | 9 ++++++--- 20 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/runelite/deob/attributes/code/instruction/types/PushConstantInstruction.java b/src/main/java/net/runelite/deob/attributes/code/instruction/types/PushConstantInstruction.java index 7aeda1f371..de451ab1fe 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instruction/types/PushConstantInstruction.java +++ b/src/main/java/net/runelite/deob/attributes/code/instruction/types/PushConstantInstruction.java @@ -1,10 +1,11 @@ package net.runelite.deob.attributes.code.instruction.types; +import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.pool.PoolEntry; public interface PushConstantInstruction { public PoolEntry getConstant(); - public void setConstant(PoolEntry entry); + public Instruction setConstant(PoolEntry entry); } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/BiPush.java b/src/main/java/net/runelite/deob/attributes/code/instructions/BiPush.java index cb341e2bff..7207072db9 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/BiPush.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/BiPush.java @@ -55,7 +55,7 @@ public class BiPush extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_0.java b/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_0.java index 124752f07b..8075194ae9 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_0.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_0.java @@ -40,7 +40,7 @@ public class DConst_0 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_1.java b/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_1.java index 6404d7df51..5957255930 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_1.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/DConst_1.java @@ -40,7 +40,7 @@ public class DConst_1 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_0.java b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_0.java index afe0edde87..4ce94c86d3 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_0.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_0.java @@ -40,7 +40,7 @@ public class FConst_0 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_1.java b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_1.java index 6045c2a192..4f8837cd38 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_1.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_1.java @@ -40,7 +40,7 @@ public class FConst_1 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_2.java b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_2.java index e342d96609..ff5f51ca4e 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_2.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/FConst_2.java @@ -40,7 +40,7 @@ public class FConst_2 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_0.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_0.java index 268701a82f..0db3ebe004 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_0.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_0.java @@ -40,7 +40,7 @@ public class IConst_0 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_1.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_1.java index ffaa661d0d..4d8e47a43b 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_1.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_1.java @@ -40,8 +40,8 @@ public class IConst_1 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return new LDC_W(this.getInstructions(), entry); } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_2.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_2.java index 29b5bea5d2..8461db8f82 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_2.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_2.java @@ -40,7 +40,7 @@ public class IConst_2 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_3.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_3.java index fb4b1d6464..2f44c072bc 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_3.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_3.java @@ -40,7 +40,7 @@ public class IConst_3 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_4.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_4.java index f548584ac9..b5d011f815 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_4.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_4.java @@ -40,7 +40,7 @@ public class IConst_4 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_5.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_5.java index 75d62b9fe8..c991de2308 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_5.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_5.java @@ -40,7 +40,7 @@ public class IConst_5 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_M1.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_M1.java index 8045437289..bdbafebf5f 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_M1.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IConst_M1.java @@ -40,7 +40,7 @@ public class IConst_M1 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_0.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_0.java index 7d55b1b7a1..2838b7690c 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_0.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_0.java @@ -40,7 +40,7 @@ public class LConst_0 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_1.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_1.java index 978d77f736..96823a9350 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_1.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LConst_1.java @@ -40,7 +40,7 @@ public class LConst_1 extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LDC2_W.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LDC2_W.java index 2a6425eba9..cbc026db64 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LDC2_W.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LDC2_W.java @@ -55,8 +55,9 @@ public class LDC2_W extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { value = entry; + return this; } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LDC_W.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LDC_W.java index a80c87e2c7..2b2e0d993a 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LDC_W.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LDC_W.java @@ -105,8 +105,9 @@ public class LDC_W extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { value = entry; + return this; } } diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/SiPush.java b/src/main/java/net/runelite/deob/attributes/code/instructions/SiPush.java index daa4055694..e86ffe9159 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/SiPush.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/SiPush.java @@ -55,7 +55,7 @@ public class SiPush extends Instruction implements PushConstantInstruction } @Override - public void setConstant(PoolEntry entry) + public Instruction setConstant(PoolEntry entry) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/src/main/java/net/runelite/deob/deobfuscators/ModularArithmeticDeobfuscation.java b/src/main/java/net/runelite/deob/deobfuscators/ModularArithmeticDeobfuscation.java index f644ae9f7e..927fb5c13f 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/ModularArithmeticDeobfuscation.java +++ b/src/main/java/net/runelite/deob/deobfuscators/ModularArithmeticDeobfuscation.java @@ -747,7 +747,8 @@ public class ModularArithmeticDeobfuscation implements Deobfuscator //assert m.setter == modInverse(m.getter); int newConstant = constant * m.setter; - pc.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + Instruction i2 = pc.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + assert i2 == (Instruction) pc; if (newConstant != 1) System.out.println("new constant: " + newConstant); else @@ -775,7 +776,8 @@ public class ModularArithmeticDeobfuscation implements Deobfuscator // field = setter * value, solve for value by * modInverse(setter) int newConstant = constant * m.getter; - pi.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + Instruction i2 = pi.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + assert i2 == (Instruction) pi; ++replaced; } else if (value.getPushed().getInstruction() instanceof IMul) @@ -810,7 +812,8 @@ public class ModularArithmeticDeobfuscation implements Deobfuscator // field = expression * constant int newConstant = constant * m.getter; - pc.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + Instruction i2 = pc.setConstant(new net.runelite.deob.pool.Integer(newConstant)); + assert i2 == (Instruction) pc; ++replaced; } }