fix(YouTube - ReturnYouTubeDislike): Revert support for 18.37.36 (#3041)

This commit is contained in:
LisoUseInAIKyrios 2023-09-28 17:39:29 +04:00 committed by GitHub
parent 0037dea0d0
commit 37610732da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 30 deletions

View File

@ -31,7 +31,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
PlayerTypeHookPatch::class, PlayerTypeHookPatch::class,
], ],
compatiblePackages = [ compatiblePackages = [
CompatiblePackage("com.google.android.youtube", ["18.37.36"]) CompatiblePackage("com.google.android.youtube", ["18.32.39"])
] ]
) )
@Suppress("unused") @Suppress("unused")
@ -89,40 +89,49 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
throw TextComponentAtomicReferenceFingerprint.exception throw TextComponentAtomicReferenceFingerprint.exception
}?.let { textComponentContextFingerprintResult -> }?.let { textComponentContextFingerprintResult ->
val conversionContextIndex = textComponentContextFingerprintResult val conversionContextIndex = textComponentContextFingerprintResult
.scanResult.patternScanResult!!.endIndex .scanResult.patternScanResult!!.startIndex
val atomicReferenceStartIndex = TextComponentAtomicReferenceFingerprint.result!! val atomicReferenceStartIndex = TextComponentAtomicReferenceFingerprint.result!!
.scanResult.patternScanResult!!.startIndex .scanResult.patternScanResult!!.startIndex
val insertIndex = atomicReferenceStartIndex + 9 val insertIndex = atomicReferenceStartIndex + 6
textComponentContextFingerprintResult.mutableMethod.apply { textComponentContextFingerprintResult.mutableMethod.apply {
// Get the conversion context obfuscated field name // Get the conversion context obfuscated field name, and the registers for the AtomicReference and CharSequence
val conversionContextFieldReference = val conversionContextFieldReference =
getInstruction<ReferenceInstruction>(conversionContextIndex).reference getInstruction<ReferenceInstruction>(conversionContextIndex).reference
// Free register to hold the conversion context // Reuse the free register to make room for the atomic reference register.
val freeRegister = val freeRegister =
getInstruction<TwoRegisterInstruction>(atomicReferenceStartIndex).registerB getInstruction<TwoRegisterInstruction>(atomicReferenceStartIndex).registerB
val atomicReferenceRegister = val atomicReferenceRegister =
getInstruction<FiveRegisterInstruction>(atomicReferenceStartIndex + 6).registerC getInstruction<FiveRegisterInstruction>(atomicReferenceStartIndex + 1).registerC
// Instruction that is replaced, and also has the CharacterSequence register. val moveCharSequenceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex - 1)
val moveCharSequenceInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
val charSequenceSourceRegister = moveCharSequenceInstruction.registerB val charSequenceSourceRegister = moveCharSequenceInstruction.registerB
val charSequenceTargetRegister = moveCharSequenceInstruction.registerA val charSequenceTargetRegister = moveCharSequenceInstruction.registerA
// In order to preserve the atomic reference register, because it is overwritten,
// use another free register to store it.
replaceInstruction(
atomicReferenceStartIndex + 2,
"move-result-object v$freeRegister"
)
replaceInstruction(
atomicReferenceStartIndex + 3,
"move-object v$charSequenceSourceRegister, v$freeRegister"
)
// Move the current instance to the free register, and get the conversion context from it. // Move the current instance to the free register, and get the conversion context from it.
// Must replace the instruction to preserve the control flow label. replaceInstruction(insertIndex - 1, "move-object/from16 v$freeRegister, p0")
replaceInstruction(insertIndex, "move-object/from16 v$freeRegister, p0")
addInstructions( addInstructions(
insertIndex + 1, insertIndex,
""" """
# Move context to free register # Move context to free register
iget-object v$freeRegister, v$freeRegister, $conversionContextFieldReference iget-object v$freeRegister, v$freeRegister, $conversionContextFieldReference
invoke-static {v$freeRegister, v$atomicReferenceRegister, v$charSequenceSourceRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onLithoTextLoaded(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; invoke-static {v$freeRegister, v$atomicReferenceRegister, v$charSequenceSourceRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onLithoTextLoaded(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
move-result-object v$freeRegister move-result-object v$freeRegister
# Replace the original instruction # Replace the original char sequence with the modified one.
move-object v${charSequenceTargetRegister}, v${freeRegister} move-object v${charSequenceTargetRegister}, v${freeRegister}
""" """
) )
@ -141,7 +150,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch(
val isDisLikesBooleanReference = getInstruction<ReferenceInstruction>(patternResult.endIndex).reference val isDisLikesBooleanReference = getInstruction<ReferenceInstruction>(patternResult.endIndex).reference
val textViewFieldReference = // Like/Dislike button TextView field val textViewFieldReference = // Like/Dislike button TextView field
getInstruction<ReferenceInstruction>(patternResult.endIndex - 1).reference getInstruction<ReferenceInstruction>(patternResult.endIndex - 2).reference
// Check if the hooked TextView object is that of the dislike button. // Check if the hooked TextView object is that of the dislike button.
// If RYD is disabled, or the TextView object is not that of the dislike button, the execution flow is not interrupted. // If RYD is disabled, or the TextView object is not that of the dislike button, the execution flow is not interrupted.

View File

@ -27,6 +27,7 @@ object ShortsTextViewFingerprint : MethodFingerprint(
Opcode.IF_EQ, Opcode.IF_EQ,
Opcode.RETURN_VOID, Opcode.RETURN_VOID,
Opcode.IGET_OBJECT, // TextView field Opcode.IGET_OBJECT, // TextView field
Opcode.CHECK_CAST,
Opcode.IGET_BOOLEAN, // boolean field Opcode.IGET_BOOLEAN, // boolean field
) )
) )

View File

@ -13,17 +13,13 @@ object TextComponentAtomicReferenceFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
parameters = listOf("L"), parameters = listOf("L"),
opcodes = listOf( opcodes = listOf(
Opcode.MOVE_OBJECT, // Register B is free register Opcode.MOVE_OBJECT, // Register A and B is context, use B as context, reuse A as free register
Opcode.MOVE_OBJECT_FROM16,
Opcode.MOVE_OBJECT_FROM16,
Opcode.MOVE_OBJECT_FROM16,
Opcode.MOVE_OBJECT_FROM16,
Opcode.MOVE_OBJECT_FROM16,
Opcode.INVOKE_VIRTUAL, // Register C is atomic reference Opcode.INVOKE_VIRTUAL, // Register C is atomic reference
Opcode.MOVE_RESULT_OBJECT, // Register A is char sequence Opcode.MOVE_RESULT_OBJECT, // Register A is char sequence
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST, Opcode.CHECK_CAST,
Opcode.MOVE_OBJECT, // Replace this instruction with patch code Opcode.MOVE_OBJECT,
Opcode.INVOKE_INTERFACE, Opcode.INVOKE_INTERFACE, // Insert hook here
Opcode.MOVE_RESULT, Opcode.MOVE_RESULT,
Opcode.IF_EQZ, Opcode.IF_EQZ,
Opcode.INVOKE_INTERFACE, Opcode.INVOKE_INTERFACE,

View File

@ -13,14 +13,12 @@ object TextComponentContextFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL,
parameters = listOf("L"), parameters = listOf("L"),
opcodes = listOf( opcodes = listOf(
Opcode.MOVE_OBJECT_FROM16,
Opcode.MOVE_OBJECT_FROM16,
Opcode.INVOKE_STATIC_RANGE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT, // conversion context field name Opcode.IGET_OBJECT, // conversion context field name
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_BOOLEAN,
Opcode.IGET,
Opcode.IGET,
Opcode.IGET,
) )
) )