From 2292b9449c066921e27f6deeb6bc31a017a53c00 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 7 May 2022 20:08:45 +0100 Subject: [PATCH] Ensure flow obstructor initializers always read a static field This fixes a bug when deobfuscating the build 225 client, which has code that looks like a flow obstructor initializer, but it reads an argument rather than a static variable. Signed-off-by: Graham --- .../transform/OpaquePredicateTransformer.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/OpaquePredicateTransformer.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/OpaquePredicateTransformer.kt index 7267536c..1c2a043f 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/OpaquePredicateTransformer.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/OpaquePredicateTransformer.kt @@ -42,8 +42,25 @@ public class OpaquePredicateTransformer : Transformer() { private fun findFlowObstructors(library: Library, method: MethodNode) { for (match in FLOW_OBSTRUCTOR_INITIALIZER_MATCHER.match(method)) { - // add flow obstructor to set val putstatic = match.last() as FieldInsnNode + + /* + * if the initializer reads a local variable, check the local + * variable is populated with a static field + */ + val first = match.first() + if (first is VarInsnNode) { + val storeFound = STORE_MATCHER.match(method).any { + val istore = it[1] as VarInsnNode + return@any first.`var` == istore.`var` + } + + if (!storeFound) { + continue + } + } + + // add flow obstructor to set flowObstructors.add(MemberRef(putstatic)) /*