fix: some fingerprints are broken

This commit is contained in:
inotia00 2023-01-12 18:20:55 +09:00
parent 3bdb182b03
commit f0dba52004
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,26 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.Opcode
object MaxBufferAltFingerprint : MethodFingerprint(
returnType = "I",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.SGET_OBJECT,
Opcode.IGET,
Opcode.IF_EQZ,
Opcode.RETURN
),
customFingerprint = {
it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;"
&& it.implementation!!.instructions.any { instruction ->
((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 120000)
&& it.name == "t"
}
}
)

View File

@ -20,13 +20,24 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Version("0.0.1")
class CustomVideoBufferBytecodePatch : BytecodePatch(
listOf(
MaxBufferAltFingerprint,
MaxBufferFingerprint,
PlaybackBufferFingerprint,
ReBufferFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
execMaxBuffer()
/**
* Temporary try .. catch is used because priority of fingerprint properties are not implemented yet
* But it's not an ideal method
* see https://github.com/revanced/revanced-patcher/issues/148
*/
try {
execMaxBuffer()
} catch (_: Exception) {
execMaxBufferAlt()
}
execPlaybackBuffer()
execReBuffer()
return PatchResultSuccess()
@ -36,6 +47,18 @@ class CustomVideoBufferBytecodePatch : BytecodePatch(
const val INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR =
"$MISC_PATH/CustomVideoBufferPatch;"
}
private fun execMaxBufferAlt() {
val (method, result) = MaxBufferAltFingerprint.unwrap(true, -1)
val (index, register) = result
method.addInstructions(
index + 1, """
invoke-static {}, $INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR->setMaxBuffer()I
move-result v$register
"""
)
}
private fun execMaxBuffer() {
val (method, result) = MaxBufferFingerprint.unwrap(true, -1)
val (index, register) = result