From 164b5fd5afccd336011d4b760e9ad2e4cbaf56f1 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 1 Oct 2015 17:02:25 -0400 Subject: [PATCH] ahhhhhhhhhhhhhhh --- src/main/java/net/runelite/deob/Deob.java | 2 +- .../arithmetic/MultiplicationDeobfuscator.java | 14 ++++++++++---- .../arithmetic/MultiplicationExpression.java | 18 +++++++++--------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/runelite/deob/Deob.java b/src/main/java/net/runelite/deob/Deob.java index 9008a1ae50..0a823896b2 100644 --- a/src/main/java/net/runelite/deob/Deob.java +++ b/src/main/java/net/runelite/deob/Deob.java @@ -84,7 +84,7 @@ public class Deob //new ModArith().run(group); - new MultiplicationDeobfuscator().run(group); // this causes spinning? + new MultiplicationDeobfuscator().run(group); // new MultiplyOneDeobfuscator().run(group); // diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationDeobfuscator.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationDeobfuscator.java index e334bab948..ea6b4cc598 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationDeobfuscator.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationDeobfuscator.java @@ -146,10 +146,16 @@ public class MultiplicationDeobfuscator implements Deobfuscator MultiplicationExpression other = parseExpression(orig.getPushed()); // this expression is used elsewhere like 'pushConstant' so any changes // done to it affect that, too. so multiply it by existing values? - me.instructions.addAll(other.instructions); - me.dupedInstructions.addAll(other.instructions); - me.subexpressions.addAll(other.subexpressions); - //me.subexpressions.add(other); + if (orig.getPushed().getInstruction() instanceof IAdd || orig.getPushed().getInstruction() instanceof ISub) + { + me.subexpressions.add(other); + } + else + { + me.instructions.addAll(other.instructions); + me.dupedInstructions.addAll(other.instructions); + me.subexpressions.addAll(other.subexpressions); + } } catch (IllegalStateException ex) { diff --git a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationExpression.java b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationExpression.java index 6ee8e16dbe..7f1ebb0cc1 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationExpression.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/MultiplicationExpression.java @@ -62,15 +62,15 @@ public class MultiplicationExpression count += me.simplify(result); } -// if (dupmagic != null) -// { -// PushConstantInstruction pci = (PushConstantInstruction) dupmagic.getInstruction(); -// int value = (int) pci.getConstant().getObject(); -// -// value *= DMath.modInverse(result); -// -// pci.setConstant(new net.runelite.deob.pool.Integer(value)); -// } + if (dupmagic != null) + { + PushConstantInstruction pci = (PushConstantInstruction) dupmagic.getInstruction(); + int value = (int) pci.getConstant().getObject(); + + value *= DMath.modInverse(result); + + pci.setConstant(new net.runelite.deob.pool.Integer(value)); + } result = 1; // constant has been distributed, outer numbers all go to 1 }