From f426f16d721f27712f20f5279f9bd13cac1c39b5 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 29 Aug 2019 12:21:49 +0100 Subject: [PATCH] Simplify DummyLocalTransformer The obfuscated client only contains dummy locals of type int. --- .../deob/transform/DummyLocalTransformer.java | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyLocalTransformer.java b/deob/src/main/java/dev/openrs2/deob/transform/DummyLocalTransformer.java index cce93fe666..0d1162ed01 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyLocalTransformer.java +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyLocalTransformer.java @@ -1,6 +1,5 @@ package dev.openrs2.deob.transform; -import com.google.common.collect.ImmutableSet; import dev.openrs2.asm.InsnNodeUtils; import dev.openrs2.asm.classpath.ClassPath; import dev.openrs2.asm.transform.Transformer; @@ -14,24 +13,6 @@ import org.slf4j.LoggerFactory; public final class DummyLocalTransformer extends Transformer { private static final Logger logger = LoggerFactory.getLogger(DummyLocalTransformer.class); - private static final int TYPES = 5; - - private static final ImmutableSet LOAD_OPCODES = ImmutableSet.of( - Opcodes.ILOAD, - Opcodes.LLOAD, - Opcodes.FLOAD, - Opcodes.DLOAD, - Opcodes.ALOAD - ); - - private static final ImmutableSet STORE_OPCODES = ImmutableSet.of( - Opcodes.ISTORE, - Opcodes.LSTORE, - Opcodes.FSTORE, - Opcodes.DSTORE, - Opcodes.ASTORE - ); - private int localsRemoved; @Override @@ -47,28 +28,30 @@ public final class DummyLocalTransformer extends Transformer { * forward data flow), however, it seems to be good enough to catch * most dummy locals. */ - var loads = new boolean[TYPES][method.maxLocals]; + var loads = new boolean[method.maxLocals]; for (var it = method.instructions.iterator(); it.hasNext(); ) { var insn = it.next(); + var opcode = insn.getOpcode(); - if (LOAD_OPCODES.contains(opcode)) { - var type = opcode - Opcodes.ILOAD; - var load = (VarInsnNode) insn; - loads[type][load.var] = true; + if (opcode != Opcodes.ILOAD) { + continue; } + + var load = (VarInsnNode) insn; + loads[load.var] = true; } for (var it = method.instructions.iterator(); it.hasNext(); ) { var insn = it.next(); + var opcode = insn.getOpcode(); - if (!STORE_OPCODES.contains(opcode)) { + if (opcode != Opcodes.ISTORE) { continue; } - var type = opcode - Opcodes.ISTORE; var store = (VarInsnNode) insn; - if (loads[type][store.var]) { + if (loads[store.var]) { continue; }