mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
feat(youtube): support version 18.16.37
This commit is contained in:
parent
795f7d37e6
commit
8beb5ea860
3 changed files with 36 additions and 10 deletions
|
@ -7,5 +7,17 @@ import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object MiniPlayerOverrideFingerprint : MethodFingerprint(
|
object MiniPlayerOverrideFingerprint : MethodFingerprint(
|
||||||
"Z", AccessFlags.STATIC or AccessFlags.PUBLIC,
|
"Z", AccessFlags.STATIC or AccessFlags.PUBLIC,
|
||||||
opcodes = listOf(Opcode.RETURN), // anchor to insert the instruction
|
listOf("L"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.IF_EQ,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.IF_EQ,
|
||||||
|
Opcode.CONST_4, // override this value
|
||||||
|
Opcode.RETURN,
|
||||||
|
Opcode.CONST_4, // override this value
|
||||||
|
Opcode.RETURN
|
||||||
|
),
|
||||||
)
|
)
|
|
@ -1,13 +1,7 @@
|
||||||
package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints
|
package app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
|
|
||||||
object MiniPlayerOverrideParentFingerprint : MethodFingerprint(
|
object MiniPlayerOverrideParentFingerprint : MethodFingerprint(
|
||||||
returnType = "L",
|
strings = listOf("Possible Context wrapper loop - chain of wrappers larger than 10000")
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
|
||||||
parameters = listOf("L"),
|
|
||||||
strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT")
|
|
||||||
)
|
)
|
|
@ -10,6 +10,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
@ -20,6 +21,7 @@ import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMi
|
||||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.*
|
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.*
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
|
@ -68,10 +70,28 @@ class TabletMiniPlayerPatch : BytecodePatch(
|
||||||
MiniPlayerOverrideParentFingerprint.result?.let {
|
MiniPlayerOverrideParentFingerprint.result?.let {
|
||||||
if (!MiniPlayerOverrideFingerprint.resolve(context, it.classDef))
|
if (!MiniPlayerOverrideFingerprint.resolve(context, it.classDef))
|
||||||
throw MiniPlayerOverrideFingerprint.toErrorResult()
|
throw MiniPlayerOverrideFingerprint.toErrorResult()
|
||||||
|
|
||||||
MiniPlayerOverrideFingerprint.addProxyCall()
|
|
||||||
} ?: return MiniPlayerOverrideParentFingerprint.toErrorResult()
|
} ?: return MiniPlayerOverrideParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Override every return instruction with the proxy call.
|
||||||
|
*/
|
||||||
|
MiniPlayerOverrideFingerprint.result!!.mutableMethod.apply {
|
||||||
|
implementation!!.let { implementation ->
|
||||||
|
val returnIndices = implementation.instructions
|
||||||
|
.withIndex()
|
||||||
|
.filter { (_, instruction) -> instruction.opcode == Opcode.RETURN }
|
||||||
|
.map { (index, _) -> index }
|
||||||
|
|
||||||
|
if (returnIndices.isEmpty()) throw PatchResultError("No return instructions found.")
|
||||||
|
|
||||||
|
// This method clobbers register p0 to return the value, calculate to override.
|
||||||
|
val returnedRegister = implementation.registerCount - parameters.size
|
||||||
|
|
||||||
|
// Hook the returned register on every return instruction.
|
||||||
|
returnIndices.forEach { index -> insertOverride(index, returnedRegister) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Size check return value override.
|
* Size check return value override.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue