This commit is contained in:
inotia00
2023-01-30 10:46:54 +09:00
parent 7cc0397ef2
commit 96a55c5049
7 changed files with 0 additions and 202 deletions

View File

@ -1,18 +0,0 @@
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.Opcode
object MaxBufferFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("J", "J", "F"),
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.CONST_WIDE_16,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL
)
)

View File

@ -1,23 +0,0 @@
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 PlaybackBufferFingerprint : MethodFingerprint(
returnType = "I",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IF_LEZ,
Opcode.RETURN
),
customFingerprint = {
it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;"
&& it.implementation!!.instructions.any { instruction ->
((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 1600)
}
}
)

View File

@ -1,23 +0,0 @@
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 ReBufferFingerprint : MethodFingerprint(
returnType = "I",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IF_LEZ,
Opcode.RETURN
),
customFingerprint = {
it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;"
&& it.implementation!!.instructions.any { instruction ->
((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 5000)
}
}
)

View File

@ -1,73 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch
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.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints.*
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.extensions.toErrorResult
import app.revanced.shared.util.integrations.Constants.MISC_PATH
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("custom-video-buffer-bytecode-patch")
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoBufferBytecodePatch : BytecodePatch(
listOf(
MaxBufferFingerprint,
PlaybackBufferFingerprint,
ReBufferFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
MaxBufferFingerprint.result?.injectMaxBuffer(context) ?: return MaxBufferFingerprint.toErrorResult()
arrayOf(
PlaybackBufferFingerprint to "setPlaybackBuffer",
ReBufferFingerprint to "setReBuffer"
).map { (fingerprint, name) ->
fingerprint.result?.mutableMethod?.insertOverride(name) ?: return fingerprint.toErrorResult()
}
return PatchResultSuccess()
}
private companion object {
const val INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR =
"$MISC_PATH/CustomVideoBufferPatch;"
}
private fun MethodFingerprintResult.injectMaxBuffer(
context: BytecodeContext
) {
val insertMethod = context.toMethodWalker(this.method)
.nextMethod(this.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod
insertMethod.insertOverride("setMaxBuffer")
}
private fun MutableMethod.insertOverride(
descriptor: String
) {
val index = this.implementation!!.instructions.size - 1 - 2
val register = (this.instruction(index) as OneRegisterInstruction).registerA
this.addInstructions(
index,
"""
invoke-static {}, $INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR->$descriptor()I
move-result v$register
"""
)
}
}

View File

@ -1,48 +0,0 @@
package app.revanced.patches.youtube.misc.customvideobuffer.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch.CustomVideoBufferBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("custom-video-buffer")
@Description("Lets you change the buffers of videos.")
@DependsOn(
[
CustomVideoBufferBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoBufferPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
"PREFERENCE: MISC_SETTINGS",
"SETTINGS: CUSTOM_VIDEO_BUFFER"
)
ResourceHelper.patchSuccess(
context,
"custom-video-buffer"
)
return PatchResultSuccess()
}
}