2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.misc.fix.playback
|
2023-03-14 13:15:26 +01:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
import app.revanced.extensions.exception
|
2023-03-14 13:15:26 +01:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
2023-09-25 16:28:11 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
2023-07-20 01:17:47 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
|
|
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
2023-03-14 13:15:26 +01:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2023-03-14 13:15:26 +01:00
|
|
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
2023-09-25 16:28:11 +02:00
|
|
|
import app.revanced.patcher.util.smali.ExternalLabel
|
|
|
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.*
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch
|
2023-09-25 16:28:11 +02:00
|
|
|
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
|
|
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
2023-03-14 13:15:26 +01:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
2023-09-23 23:48:45 +02:00
|
|
|
description = "Spoofs the signature to prevent playback issues.",
|
2023-09-20 05:33:02 +02:00
|
|
|
dependencies = [
|
2023-09-23 23:48:45 +02:00
|
|
|
SpoofSignatureResourcePatch::class,
|
2023-09-20 05:33:02 +02:00
|
|
|
IntegrationsPatch::class,
|
2023-09-25 16:28:11 +02:00
|
|
|
PlayerTypeHookPatch::class,
|
|
|
|
VideoInformationPatch::class
|
2023-09-20 05:33:02 +02:00
|
|
|
]
|
|
|
|
)
|
2023-09-23 23:48:45 +02:00
|
|
|
object SpoofSignaturePatch : BytecodePatch(
|
2023-09-20 05:33:02 +02:00
|
|
|
setOf(
|
2023-03-17 18:58:41 +01:00
|
|
|
ProtobufParameterBuilderFingerprint,
|
2023-07-20 01:17:47 +02:00
|
|
|
StoryboardThumbnailParentFingerprint,
|
2023-09-25 16:28:11 +02:00
|
|
|
StoryboardRendererSpecFingerprint,
|
|
|
|
PlayerResponseModelImplFingerprint
|
2023-03-17 18:58:41 +01:00
|
|
|
)
|
2023-03-14 13:15:26 +01:00
|
|
|
) {
|
2023-09-20 05:33:02 +02:00
|
|
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
2023-09-25 16:28:11 +02:00
|
|
|
"Lapp/revanced/integrations/patches/spoof/SpoofSignaturePatch;"
|
2023-09-20 05:33:02 +02:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2023-09-25 16:28:11 +02:00
|
|
|
// Hook parameter.
|
2023-03-14 13:15:26 +01:00
|
|
|
ProtobufParameterBuilderFingerprint.result?.let {
|
|
|
|
val setParamMethod = context
|
|
|
|
.toMethodWalker(it.method)
|
2023-03-17 18:58:41 +01:00
|
|
|
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true).getMethod() as MutableMethod
|
2023-03-14 13:15:26 +01:00
|
|
|
|
|
|
|
setParamMethod.apply {
|
|
|
|
val protobufParameterRegister = 3
|
|
|
|
|
|
|
|
addInstructions(
|
|
|
|
0,
|
|
|
|
"""
|
2023-09-23 23:48:45 +02:00
|
|
|
invoke-static {p$protobufParameterRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->spoofParameter(Ljava/lang/String;)Ljava/lang/String;
|
2023-03-15 18:39:03 +01:00
|
|
|
move-result-object p$protobufParameterRegister
|
|
|
|
"""
|
|
|
|
)
|
2023-03-14 13:15:26 +01:00
|
|
|
}
|
2023-08-27 21:40:49 +02:00
|
|
|
} ?: throw ProtobufParameterBuilderFingerprint.exception
|
2023-03-14 13:15:26 +01:00
|
|
|
|
2023-07-20 01:17:47 +02:00
|
|
|
// When signature spoofing is enabled, the seekbar when tapped does not show
|
|
|
|
// the video time, chapter names, or the video thumbnail.
|
|
|
|
// Changing the value returned of this method forces all of these to show up,
|
|
|
|
// except the thumbnails are blank, which is handled with the patch below.
|
2023-09-25 16:28:11 +02:00
|
|
|
StoryboardThumbnailParentFingerprint.result?.classDef?.let { classDef ->
|
|
|
|
StoryboardThumbnailFingerprint.also {
|
|
|
|
it.resolve(
|
|
|
|
context,
|
|
|
|
classDef
|
|
|
|
)
|
|
|
|
}.result?.let {
|
|
|
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
|
|
|
// Replace existing instruction to preserve control flow label.
|
|
|
|
// The replaced return instruction always returns false
|
|
|
|
// (it is the 'no thumbnails found' control path),
|
|
|
|
// so there is no need to pass the existing return value to integrations.
|
|
|
|
it.mutableMethod.replaceInstruction(
|
|
|
|
endIndex,
|
|
|
|
"""
|
|
|
|
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarThumbnailOverrideValue()Z
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
// Since this is end of the method must replace one line then add the rest.
|
|
|
|
it.mutableMethod.addInstructions(
|
|
|
|
endIndex + 1,
|
|
|
|
"""
|
|
|
|
move-result v0
|
|
|
|
return v0
|
2023-07-20 01:17:47 +02:00
|
|
|
"""
|
2023-09-25 16:28:11 +02:00
|
|
|
)
|
|
|
|
} ?: throw StoryboardThumbnailFingerprint.exception
|
2023-07-20 01:17:47 +02:00
|
|
|
|
2023-09-25 16:28:11 +02:00
|
|
|
/**
|
|
|
|
* Hook StoryBoard renderer url
|
|
|
|
*/
|
|
|
|
PlayerResponseModelImplFingerprint.result?.let {
|
|
|
|
it.mutableMethod.apply {
|
|
|
|
val getStoryBoardIndex = it.scanResult.patternScanResult!!.endIndex
|
|
|
|
val getStoryBoardRegister = getInstruction<OneRegisterInstruction>(getStoryBoardIndex).registerA
|
2023-07-20 01:17:47 +02:00
|
|
|
|
2023-09-25 16:28:11 +02:00
|
|
|
addInstructions(
|
|
|
|
getStoryBoardIndex,
|
|
|
|
"""
|
|
|
|
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec()Ljava/lang/String;
|
|
|
|
move-result-object v$getStoryBoardRegister
|
2023-07-20 01:17:47 +02:00
|
|
|
"""
|
2023-09-25 16:28:11 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
} ?: throw PlayerResponseModelImplFingerprint.exception
|
|
|
|
|
|
|
|
StoryboardRendererSpecFingerprint.result?.let {
|
|
|
|
it.mutableMethod.apply {
|
|
|
|
val storyBoardUrlParams = 0
|
|
|
|
|
|
|
|
addInstructionsWithLabels(
|
|
|
|
0,
|
|
|
|
"""
|
|
|
|
if-nez p$storyBoardUrlParams, :ignore
|
|
|
|
invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->getStoryboardRendererSpec()Ljava/lang/String;
|
|
|
|
move-result-object p$storyBoardUrlParams
|
|
|
|
""",
|
|
|
|
ExternalLabel("ignore", getInstruction(0))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} ?: throw StoryboardRendererSpecFingerprint.exception
|
|
|
|
}
|
2023-03-14 13:15:26 +01:00
|
|
|
}
|
2023-09-25 16:28:11 +02:00
|
|
|
}
|