Skip to content

Commit

Permalink
fix(Twitter): Fix patches by matching fingerprint using correct class
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 11, 2024
1 parent a0d9c25 commit 6ae0d12
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6ae0d12

Please sign in to comment.