From 6ae0d124e1f27faecd20e4008951b08353572d98 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 11 Nov 2024 02:50:10 +0100 Subject: [PATCH] fix(Twitter): Fix patches by matching fingerprint using correct class --- .../twitter/misc/hook/json/JsonHookPatch.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt index 093305379..08d18d3ae 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt @@ -47,18 +47,22 @@ val jsonHookPatch = bytecodePatch( dependsOn(sharedExtensionPatch) execute { - val jsonFactoryClassDef = jsonHookPatchFingerprint.apply { + jsonHookPatchFingerprint.apply { // Make sure the extension is present. val jsonHookPatch = classBy { classDef -> classDef.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR } ?: throw PatchException("Could not find the extension.") matchOrNull(jsonHookPatch.immutableClass) ?: throw PatchException("Unexpected extension.") - }.originalClassDef // Conveniently find the type to hook a method in, via a named field. - .fields - .firstOrNull { it.name == "JSON_FACTORY" } - ?.type - .let { type -> classes.find { it.type == type } } ?: throw PatchException("Could not find required class.") + } + + val jsonFactoryClassDef = + loganSquareFingerprint.originalClassDef // Conveniently find the type to hook a method in, via a named field. + .fields + .firstOrNull { it.name == "JSON_FACTORY" } + ?.type + .let { type -> classes.find { it.type == type } } + ?: throw PatchException("Could not find required class.") // Hook the methods first parameter. jsonInputStreamFingerprint.match(jsonFactoryClassDef).method.addInstructions(