fix(Twitter): Fix patches by matching fingerprint using correct class

This commit is contained in:
oSumAtrIX 2024-11-11 02:50:10 +01:00
parent a0d9c25ffa
commit 6ae0d124e1
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -47,18 +47,22 @@ val jsonHookPatch = bytecodePatch(
dependsOn(sharedExtensionPatch) dependsOn(sharedExtensionPatch)
execute { execute {
val jsonFactoryClassDef = jsonHookPatchFingerprint.apply { jsonHookPatchFingerprint.apply {
// Make sure the extension is present. // Make sure the extension is present.
val jsonHookPatch = classBy { classDef -> classDef.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR } val jsonHookPatch = classBy { classDef -> classDef.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR }
?: throw PatchException("Could not find the extension.") ?: throw PatchException("Could not find the extension.")
matchOrNull(jsonHookPatch.immutableClass) matchOrNull(jsonHookPatch.immutableClass)
?: throw PatchException("Unexpected extension.") ?: throw PatchException("Unexpected extension.")
}.originalClassDef // Conveniently find the type to hook a method in, via a named field. }
.fields
.firstOrNull { it.name == "JSON_FACTORY" } val jsonFactoryClassDef =
?.type loganSquareFingerprint.originalClassDef // Conveniently find the type to hook a method in, via a named field.
.let { type -> classes.find { it.type == type } } ?: throw PatchException("Could not find required class.") .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. // Hook the methods first parameter.
jsonInputStreamFingerprint.match(jsonFactoryClassDef).method.addInstructions( jsonInputStreamFingerprint.match(jsonFactoryClassDef).method.addInstructions(