From b2f9bd6ded96c7c184ec865d6ecaf029f2701c6f Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 10 Jul 2021 14:58:46 +0100 Subject: [PATCH] Update client checksum in the giant try/catch block in the loader Signed-off-by: Graham --- .../patcher/transform/ResourceTransformer.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/patcher/src/main/kotlin/org/openrs2/patcher/transform/ResourceTransformer.kt b/patcher/src/main/kotlin/org/openrs2/patcher/transform/ResourceTransformer.kt index e554e530..2448419e 100644 --- a/patcher/src/main/kotlin/org/openrs2/patcher/transform/ResourceTransformer.kt +++ b/patcher/src/main/kotlin/org/openrs2/patcher/transform/ResourceTransformer.kt @@ -10,6 +10,7 @@ import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.TypeInsnNode +import org.objectweb.asm.tree.VarInsnNode import org.openrs2.asm.InsnMatcher import org.openrs2.asm.classpath.ClassPath import org.openrs2.asm.classpath.Library @@ -52,6 +53,17 @@ public class ResourceTransformer( method.instructions.set(match[28 + 4 * j], byte.toInt().toAbstractInsnNode()) } } + + val checksumMatch = CLIENT_CHECKSUM_MATCHER.match(method).filter { m -> + val astore = m[0] as VarInsnNode + val aload = m[3] as VarInsnNode + val instanceof = m[4] as TypeInsnNode + astore.`var` == aload.`var` && instanceof.desc == "java/lang/reflect/InvocationTargetException" + }.singleOrNull() + if (checksumMatch != null) { + val client = resources.single { it.source == "runescape.js5" || it.source == "runescape_gl.js5" } + method.instructions.set(checksumMatch[1], client.checksum.toAbstractInsnNode()) + } } val match = GL_RESOURCES_MATCHER.match(method).singleOrNull() @@ -212,6 +224,9 @@ public class ResourceTransformer( """ ) private val MISC_RESOURCES_MATCHER = InsnMatcher.compile("$RESOURCE_ARRAY_CONSTRUCTOR PUTSTATIC") + private val CLIENT_CHECKSUM_MATCHER = InsnMatcher.compile( + "ASTORE (ICONST | BIPUSH | SIPUSH | LDC) PUTSTATIC ALOAD INSTANCEOF" + ) private val GL_LOADING_MESSAGES = listOf( "Loading 3D library",