2023-03-14 13:15:26 +01:00
|
|
|
package app.revanced.patches.youtube.misc.fix.playback.patch
|
|
|
|
|
2023-08-27 04:26:14 +02:00
|
|
|
import app.revanced.extensions.toErrorResult
|
2023-03-14 13:15:26 +01:00
|
|
|
import app.revanced.patcher.annotation.Description
|
|
|
|
import app.revanced.patcher.annotation.Name
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-08-27 04:26:14 +02:00
|
|
|
import app.revanced.patcher.data.toMethodWalker
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
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-08-27 04:26:14 +02:00
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
2023-03-17 18:58:41 +01:00
|
|
|
import app.revanced.patcher.patch.annotations.DependsOn
|
2023-03-14 13:15:26 +01:00
|
|
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
2023-07-30 19:02:41 +02:00
|
|
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
|
|
|
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ScrubbedPreviewLayoutFingerprint
|
|
|
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailFingerprint
|
|
|
|
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailParentFingerprint
|
2023-03-17 18:58:41 +01:00
|
|
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
2023-04-13 06:06:11 +02:00
|
|
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
2023-08-27 04:26:14 +02:00
|
|
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
2023-03-14 13:15:26 +01:00
|
|
|
|
2023-07-10 20:02:05 +02:00
|
|
|
@Name("Spoof signature verification")
|
2023-07-30 19:02:41 +02:00
|
|
|
@Description("Spoofs the client to prevent playback issues.")
|
2023-04-20 03:23:45 +02:00
|
|
|
@DependsOn([
|
2023-07-20 01:17:47 +02:00
|
|
|
SpoofSignatureVerificationResourcePatch::class,
|
2023-04-20 03:23:45 +02:00
|
|
|
IntegrationsPatch::class,
|
2023-07-20 01:17:47 +02:00
|
|
|
PlayerTypeHookPatch::class
|
2023-04-20 03:23:45 +02:00
|
|
|
])
|
2023-03-14 13:15:26 +01:00
|
|
|
class SpoofSignatureVerificationPatch : BytecodePatch(
|
2023-03-17 18:58:41 +01:00
|
|
|
listOf(
|
|
|
|
ProtobufParameterBuilderFingerprint,
|
2023-07-20 01:17:47 +02:00
|
|
|
StoryboardThumbnailParentFingerprint,
|
|
|
|
ScrubbedPreviewLayoutFingerprint,
|
2023-03-17 18:58:41 +01:00
|
|
|
)
|
2023-03-14 13:15:26 +01:00
|
|
|
) {
|
2023-08-27 04:26:14 +02:00
|
|
|
override fun execute(context: BytecodeContext): PatchResult {
|
2023-03-17 18:58:41 +01: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-03-17 18:58:41 +01:00
|
|
|
invoke-static {p$protobufParameterRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideProtobufParameter(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 04:26:14 +02:00
|
|
|
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()
|
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-08-27 04:26:14 +02:00
|
|
|
StoryboardThumbnailParentFingerprint.result ?: return StoryboardThumbnailParentFingerprint.toErrorResult()
|
2023-07-20 01:17:47 +02:00
|
|
|
StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef)
|
|
|
|
StoryboardThumbnailFingerprint.result?.apply {
|
|
|
|
val endIndex = 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.
|
|
|
|
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.
|
|
|
|
mutableMethod.addInstructions(
|
|
|
|
endIndex + 1,
|
|
|
|
"""
|
|
|
|
move-result v0
|
|
|
|
return v0
|
|
|
|
"""
|
|
|
|
)
|
2023-08-27 04:26:14 +02:00
|
|
|
} ?: return StoryboardThumbnailFingerprint.toErrorResult()
|
2023-07-20 01:17:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Seekbar thumbnail now show up but are always a blank image.
|
|
|
|
// Additional changes are needed to force the client to generate the thumbnails (assuming it's possible),
|
|
|
|
// but for now hide the empty thumbnail.
|
|
|
|
ScrubbedPreviewLayoutFingerprint.result?.apply {
|
|
|
|
val endIndex = scanResult.patternScanResult!!.endIndex
|
|
|
|
mutableMethod.apply {
|
|
|
|
val imageViewFieldName = getInstruction<ReferenceInstruction>(endIndex).reference
|
|
|
|
addInstructions(
|
|
|
|
implementation!!.instructions.lastIndex,
|
|
|
|
"""
|
|
|
|
iget-object v0, p0, $imageViewFieldName # copy imageview field to a register
|
|
|
|
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->seekbarImageViewCreated(Landroid/widget/ImageView;)V
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
}
|
2023-08-27 04:26:14 +02:00
|
|
|
} ?: return ScrubbedPreviewLayoutFingerprint.toErrorResult()
|
|
|
|
|
|
|
|
return PatchResultSuccess()
|
2023-03-14 13:15:26 +01:00
|
|
|
}
|
2023-03-15 18:39:03 +01:00
|
|
|
|
2023-03-19 23:24:31 +01:00
|
|
|
private companion object {
|
2023-03-15 18:39:03 +01:00
|
|
|
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SpoofSignatureVerificationPatch;"
|
|
|
|
}
|
2023-03-14 13:15:26 +01:00
|
|
|
}
|