drop support for old YouTube versions

This commit is contained in:
inotia00 2023-05-03 21:53:27 +09:00
parent bd1428fc34
commit b086822adb
4 changed files with 18 additions and 67 deletions

View File

@ -6,17 +6,10 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf( "com.google.android.youtube", arrayOf(
"18.06.41",
"18.07.35",
"18.08.39",
"18.09.39",
"18.10.37",
"18.11.36",
"18.12.35", "18.12.35",
"18.13.38", "18.13.38",
"18.14.41", "18.14.41",
"18.15.40", "18.15.40",
"18.16.37",
"18.16.39" "18.16.39"
) )
)] )]

View File

@ -47,26 +47,15 @@ class ButtonContainerPatch : ResourcePatch {
""" """
with(LithoFilterPatch.lithoMethod) { with(LithoFilterPatch.lithoMethod) {
if (LithoFilterPatch.bufferFingerprintResolved) { addInstructions(
// 18.11.36+ 0, """
addInstructions(
0, """
move-object/from16 v10, p3 move-object/from16 v10, p3
iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type} iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type}
if-eqz v10, :do_not_block if-eqz v10, :do_not_block
check-cast v10, ${LithoFilterPatch.bufferReference} check-cast v10, ${LithoFilterPatch.bufferReference}
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer; iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
) )
} else {
val secondParameter = LithoFilterPatch.lithoMethod.parameters[2]
LithoFilterPatch.lithoMethod.addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
} }
/* /*

View File

@ -47,26 +47,15 @@ class QuickActionsPatch : ResourcePatch {
""" """
with(LithoFilterPatch.lithoMethod) { with(LithoFilterPatch.lithoMethod) {
if (LithoFilterPatch.bufferFingerprintResolved) { addInstructions(
// 18.11.36+ 0, """
addInstructions(
0, """
move-object/from16 v10, p3 move-object/from16 v10, p3
iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type} iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type}
if-eqz v10, :do_not_block if-eqz v10, :do_not_block
check-cast v10, ${LithoFilterPatch.bufferReference} check-cast v10, ${LithoFilterPatch.bufferReference}
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer; iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0))) """ + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
) )
} else {
val secondParameter = LithoFilterPatch.lithoMethod.parameters[2]
LithoFilterPatch.lithoMethod.addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
} }
/* /*

View File

@ -47,14 +47,9 @@ class LithoFilterPatch : BytecodePatch(
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
try { with (LithoBufferFingerprint.result!!) {
with (LithoBufferFingerprint.result!!) { val startIndex = this.scanResult.patternScanResult!!.startIndex
val startIndex = this.scanResult.patternScanResult!!.startIndex bufferReference = (this.mutableMethod.instruction(startIndex) as BuilderInstruction21c).reference.toString()
bufferReference = (this.mutableMethod.instruction(startIndex) as BuilderInstruction21c).reference.toString()
}
bufferFingerprintResolved = true
} catch (_: Exception) {
bufferFingerprintResolved = false
} }
LithoObjectFingerprint.result?.let { LithoObjectFingerprint.result?.let {
@ -67,14 +62,12 @@ class LithoFilterPatch : BytecodePatch(
lithoMethod = result.mutableMethod lithoMethod = result.mutableMethod
with (lithoMethod.implementation!!.instructions) { with (lithoMethod.implementation!!.instructions) {
// 18.06.41+
val bufferIndex = indexOfFirst { val bufferIndex = indexOfFirst {
it.opcode == Opcode.CONST && it.opcode == Opcode.CONST &&
(it as Instruction31i).narrowLiteral == 168777401 (it as Instruction31i).narrowLiteral == 168777401
} }
val bufferRegister = (lithoMethod.instruction(bufferIndex) as Instruction31i).registerA val bufferRegister = (lithoMethod.instruction(bufferIndex) as Instruction31i).registerA
// 18.06.41+
val targetIndex = indexOfFirst { val targetIndex = indexOfFirst {
it.opcode == Opcode.CONST_STRING && it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "Element missing type extension" (it as BuilderInstruction21c).reference.toString() == "Element missing type extension"
@ -103,33 +96,21 @@ class LithoFilterPatch : BytecodePatch(
return-object v0 return-object v0
""" """
if (bufferFingerprintResolved) { val objectIndex = indexOfFirst {
// 18.11.36+ it.opcode == Opcode.CONST_STRING &&
val objectIndex = indexOfFirst { (it as BuilderInstruction21c).reference.toString() == ""
it.opcode == Opcode.CONST_STRING && } - 2
(it as BuilderInstruction21c).reference.toString() == "" objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference
} - 2 lithoMethod.addInstructions(
objectReference = (elementAt(objectIndex) as ReferenceInstruction).reference as FieldReference insertIndex + 1,
lithoMethod.addInstructions( """
insertIndex + 1,
"""
move-object/from16 v$bufferRegister, p3 move-object/from16 v$bufferRegister, p3
iget-object v$bufferRegister, v$bufferRegister, ${objectReference.definingClass}->${objectReference.name}:${objectReference.type} iget-object v$bufferRegister, v$bufferRegister, ${objectReference.definingClass}->${objectReference.name}:${objectReference.type}
if-eqz v$bufferRegister, :not_an_ad if-eqz v$bufferRegister, :not_an_ad
check-cast v$bufferRegister, $bufferReference check-cast v$bufferRegister, $bufferReference
iget-object v$bufferRegister, v$bufferRegister, $bufferReference->b:Ljava/nio/ByteBuffer; iget-object v$bufferRegister, v$bufferRegister, $bufferReference->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1))) """ + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1)))
) )
} else {
val secondParameter = lithoMethod.parameters[2]
lithoMethod.addInstructions(
insertIndex + 1,
"""
move-object/from16 v$bufferRegister, p3
iget-object v$bufferRegister, v$bufferRegister, $secondParameter->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex + 1)))
)
}
} }
} }
} ?: return LithoFingerprint.toErrorResult() } ?: return LithoFingerprint.toErrorResult()
@ -140,7 +121,6 @@ class LithoFilterPatch : BytecodePatch(
} }
internal companion object { internal companion object {
var objectRegister by Delegates.notNull<Int>() var objectRegister by Delegates.notNull<Int>()
var bufferFingerprintResolved by Delegates.notNull<Boolean>()
lateinit var lithoMethod: MutableMethod lateinit var lithoMethod: MutableMethod
lateinit var bufferReference: String lateinit var bufferReference: String