From 96468b1547937100668145109a2f7b5e2d616737 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 22 Nov 2015 16:19:07 -0600 Subject: [PATCH] Fix test, but I don't think this fixes the underlying problem --- .../attributes/code/instructions/AALoad.java | 3 ++- .../attributes/code/instructions/AAStore.java | 3 ++- .../attributes/code/instructions/BALoad.java | 3 ++- .../attributes/code/instructions/BAStore.java | 3 ++- .../attributes/code/instructions/CALoad.java | 3 ++- .../attributes/code/instructions/CAStore.java | 3 ++- .../attributes/code/instructions/DALoad.java | 3 ++- .../attributes/code/instructions/DAStore.java | 3 ++- .../attributes/code/instructions/FALoad.java | 3 ++- .../attributes/code/instructions/FAStore.java | 3 ++- .../attributes/code/instructions/IALoad.java | 3 ++- .../attributes/code/instructions/IAStore.java | 3 ++- .../attributes/code/instructions/LALoad.java | 3 ++- .../attributes/code/instructions/LAStore.java | 3 ++- .../attributes/code/instructions/SALoad.java | 3 ++- .../attributes/code/instructions/SAStore.java | 3 ++- .../deobfuscators/arithmetic/ModArith.java | 12 ++++-------- .../deobfuscators/arithmetic/ModArithTest.java | 18 +++--------------- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/AALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/AALoad.java index 7f103bac74..3c860ff89c 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/AALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/AALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class AALoad extends Instruction +public class AALoad extends Instruction implements ArrayLoad { public AALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/AAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/AAStore.java index 61c975566a..9e515b7f45 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/AAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/AAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class AAStore extends Instruction +public class AAStore extends Instruction implements ArrayStore { public AAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/BALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/BALoad.java index 7d4b19c325..73a09a31cb 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/BALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/BALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class BALoad extends Instruction +public class BALoad extends Instruction implements ArrayLoad { public BALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/BAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/BAStore.java index 5e2f1738e5..9597caf911 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/BAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/BAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class BAStore extends Instruction +public class BAStore extends Instruction implements ArrayStore { public BAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/CALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/CALoad.java index 29a9649e67..d3703aad4d 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/CALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/CALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class CALoad extends Instruction +public class CALoad extends Instruction implements ArrayLoad { public CALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/CAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/CAStore.java index 0d591afade..9907e55873 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/CAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/CAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class CAStore extends Instruction +public class CAStore extends Instruction implements ArrayStore { public CAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/DALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/DALoad.java index 5f23c407ed..7e074ec42f 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/DALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/DALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class DALoad extends Instruction +public class DALoad extends Instruction implements ArrayLoad { public DALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/DAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/DAStore.java index c6d2bea587..4d1399ae5b 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/DAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/DAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class DAStore extends Instruction +public class DAStore extends Instruction implements ArrayStore { public DAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/FALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/FALoad.java index fcd0074012..aad69caf0c 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/FALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/FALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class FALoad extends Instruction +public class FALoad extends Instruction implements ArrayLoad { public FALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/FAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/FAStore.java index c0ec63105c..6df897f4bd 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/FAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/FAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class FAStore extends Instruction +public class FAStore extends Instruction implements ArrayStore { public FAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IALoad.java index cc94c5223b..4bdcd0faeb 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class IALoad extends Instruction +public class IALoad extends Instruction implements ArrayLoad { public IALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IAStore.java index ed4bb60642..07012b7197 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class IAStore extends Instruction +public class IAStore extends Instruction implements ArrayStore { public IAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LALoad.java index 68f7ff844c..6611348040 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class LALoad extends Instruction +public class LALoad extends Instruction implements ArrayLoad { public LALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/LAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/LAStore.java index e7ae81c9b5..0d183114da 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/LAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/LAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class LAStore extends Instruction +public class LAStore extends Instruction implements ArrayStore { public LAStore(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/SALoad.java b/src/main/java/net/runelite/deob/attributes/code/instructions/SALoad.java index 9775c664a3..6c3282e833 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/SALoad.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/SALoad.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayLoad; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class SALoad extends Instruction +public class SALoad extends Instruction implements ArrayLoad { public SALoad(Instructions instructions, InstructionType type, int pc) { diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/SAStore.java b/src/main/java/net/runelite/deob/attributes/code/instructions/SAStore.java index 322ee142d7..6a1d9080ba 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/SAStore.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/SAStore.java @@ -3,12 +3,13 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; import net.runelite.deob.execution.Frame; import net.runelite.deob.execution.InstructionContext; import net.runelite.deob.execution.Stack; import net.runelite.deob.execution.StackContext; -public class SAStore extends Instruction +public class SAStore extends Instruction implements ArrayStore { public SAStore(Instructions instructions, InstructionType type, int pc) { 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 4269d24073..9c1790c2f5 100644 --- a/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java +++ b/src/main/java/net/runelite/deob/deobfuscators/arithmetic/ModArith.java @@ -1,15 +1,11 @@ package net.runelite.deob.deobfuscators.arithmetic; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; import net.runelite.deob.ClassFile; import net.runelite.deob.ClassGroup; @@ -19,6 +15,7 @@ import net.runelite.deob.Method; import net.runelite.deob.attributes.Code; import net.runelite.deob.attributes.code.Instruction; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.attributes.code.instruction.types.ArrayStore; 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; @@ -52,7 +49,9 @@ public class ModArith implements Deobfuscator if (ctx == null || set.contains(ctx.getInstruction())) return l; - if (ctx.getInstruction() instanceof InvokeInstruction) + // invoke and array store pops are unrelated to each other + if (ctx.getInstruction() instanceof InvokeInstruction || + ctx.getInstruction() instanceof ArrayStore) return l; set.add(ctx.getInstruction()); @@ -218,9 +217,6 @@ public class ModArith implements Deobfuscator boolean other = false; // check if this contains another field for (InstructionContext i : l) { - if (i.getInstruction() instanceof InvokeInstruction) - continue; - if (i.getInstruction() instanceof FieldInstruction) { FieldInstruction fi2 = (FieldInstruction) i.getInstruction(); diff --git a/src/test/java/net/runelite/deob/deobfuscators/arithmetic/ModArithTest.java b/src/test/java/net/runelite/deob/deobfuscators/arithmetic/ModArithTest.java index 62fe0db246..13f5532b4b 100644 --- a/src/test/java/net/runelite/deob/deobfuscators/arithmetic/ModArithTest.java +++ b/src/test/java/net/runelite/deob/deobfuscators/arithmetic/ModArithTest.java @@ -124,22 +124,10 @@ public class ModArithTest ModArith d1 = new ModArith(); d1.run(group); + d1.runOnce(); - int last = -1, cur; - while ((cur = d1.runOnce()) > 0) - { - Deobfuscator d2 = new MultiplicationDeobfuscator(); - d2.run(group); - - new MultiplyOneDeobfuscator().run(group); - - new MultiplyZeroDeobfuscator().run(group); - - if (last == cur) - break; - - last = cur; - } + Deobfuscator d2 = new MultiplicationDeobfuscator(); + d2.run(group); Encryption e = d1.getEncryption();