Skip to content

Commit

Permalink
add protobuf-spoof patch
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Mar 14, 2023
1 parent 9c1179a commit 995f6a6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.patches.youtube.misc.fix.playback.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode

object ProtobufParameterBuilderFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_VIRTUAL_RANGE, // target reference
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
),
strings = listOf("Unexpected empty videoId.", "Prefetch request are disabled.")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package app.revanced.patches.youtube.misc.fix.playback.patch

import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint

@Patch
@Name("protobuf-spoof")
@Description("Spoofs the protobuf to prevent playback issues.")
@YouTubeCompatibility
@Version("0.0.1")
class ProtobufSpoofPatch : BytecodePatch(
listOf(ProtobufParameterBuilderFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {

ProtobufParameterBuilderFingerprint.result?.let {
with (context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
) {
val protobufParam = 3
val protobufParameter = "8AEByAMTuAQP" /* Protobuf Parameter of shorts */

addInstruction(
0,
"const-string p$protobufParam, \"$protobufParameter\""
)
}
} ?: return ProtobufParameterBuilderFingerprint.toErrorResult()

return PatchResultSuccess()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.options.PatchOptions
import app.revanced.patches.youtube.layout.player.castbutton.patch.HideCastButtonPatch
import app.revanced.patches.youtube.misc.clientspoof.patch.ClientSpoofPatch
import app.revanced.patches.youtube.misc.fix.playback.patch.ProtobufSpoofPatch
import app.revanced.patches.youtube.misc.microg.bytecode.fingerprints.*
import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME
import app.revanced.util.bytecode.BytecodeHelper.injectInit
Expand All @@ -21,7 +22,8 @@ import app.revanced.util.microg.MicroGBytecodeHelper
[
ClientSpoofPatch::class,
HideCastButtonPatch::class,
PatchOptions::class
PatchOptions::class,
ProtobufSpoofPatch::class
]
)
@YouTubeCompatibility
Expand Down

0 comments on commit 995f6a6

Please sign in to comment.