mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
cleanup
This commit is contained in:
@ -34,14 +34,14 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
PivotBarFingerprint.result?.let { result ->
|
||||
val startIndex = result.scanResult.patternScanResult!!.startIndex
|
||||
val pivotBarInstructions = result.mutableMethod.implementation!!.instructions
|
||||
PivotBarFingerprint.result?.let {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val pivotBarInstructions = it.mutableMethod.implementation!!.instructions
|
||||
createRef = (pivotBarInstructions.elementAt(startIndex) as ReferenceInstruction).reference as DexBackedMethodReference
|
||||
} ?: return PivotBarFingerprint.toErrorResult()
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { result ->
|
||||
with (result.mutableMethod){
|
||||
PivotBarCreateButtonViewFingerprint.result?.let {
|
||||
with (it.mutableMethod){
|
||||
val createButtonInstructions = implementation!!.instructions
|
||||
createButtonInstructions.filter { instruction ->
|
||||
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
|
||||
|
@ -1,23 +1,20 @@
|
||||
package app.revanced.patches.youtube.layout.general.startupshortsreset.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@FuzzyPatternScanMethod(3)
|
||||
object UserWasInShortsFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"),
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.MOVE_RESULT
|
||||
),
|
||||
strings = listOf("Failed to read user_was_in_shorts proto after successful warmup"),
|
||||
)
|
@ -11,7 +11,9 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.layout.general.startupshortsreset.bytecode.fingerprints.UserWasInShortsFingerprint
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("hide-startup-shorts-player-bytecode-patch")
|
||||
@YouTubeCompatibility
|
||||
@ -22,18 +24,22 @@ class HideShortsOnStartupBytecodePatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val userWasInShortsResult = UserWasInShortsFingerprint.result!!
|
||||
val userWasInShortsMethod = userWasInShortsResult.mutableMethod
|
||||
val moveResultIndex = userWasInShortsResult.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
userWasInShortsMethod.addInstructions(
|
||||
moveResultIndex + 1, """
|
||||
invoke-static { }, $GENERAL_LAYOUT->hideStartupShortsPlayer()Z
|
||||
move-result v5
|
||||
if-eqz v5, :show_startup_shorts_player
|
||||
return-void
|
||||
""", listOf(ExternalLabel("show_startup_shorts_player", userWasInShortsMethod.instruction(moveResultIndex + 1)))
|
||||
)
|
||||
UserWasInShortsFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex + 1
|
||||
|
||||
with (it.mutableMethod) {
|
||||
val register = (instruction(insertIndex - 1) as OneRegisterInstruction).registerA + 2
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static { }, $GENERAL_LAYOUT->hideStartupShortsPlayer()Z
|
||||
move-result v$register
|
||||
if-eqz v$register, :show_startup_shorts_player
|
||||
return-void
|
||||
""", listOf(ExternalLabel("show_startup_shorts_player", instruction(insertIndex)))
|
||||
)
|
||||
}
|
||||
} ?: return UserWasInShortsFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -1,22 +1,19 @@
|
||||
package app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
@FuzzyPatternScanMethod(2) // TODO: Find a good threshold value
|
||||
object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
listOf("L"),
|
||||
listOf(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.FLOAT_TO_DOUBLE,
|
||||
Opcode.CONST_WIDE_HIGH16,
|
||||
Opcode.CMPL_DOUBLE,
|
||||
)
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any { instruction ->
|
||||
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.floatybarQueueLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -6,6 +6,8 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object MiniPlayerOverrideFingerprint : MethodFingerprint(
|
||||
"Z", AccessFlags.STATIC or AccessFlags.PUBLIC,
|
||||
returnType = "Z",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(Opcode.RETURN), // anchor to insert the instruction
|
||||
)
|
@ -6,6 +6,7 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object MiniPlayerOverrideNoContextFingerprint : MethodFingerprint(
|
||||
"Z", AccessFlags.FINAL or AccessFlags.PRIVATE,
|
||||
returnType = "Z",
|
||||
access = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
opcodes = listOf(Opcode.RETURN), // anchor to insert the instruction
|
||||
)
|
@ -6,15 +6,15 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object MiniPlayerResponseModelSizeCheckFingerprint : MethodFingerprint(
|
||||
"L",
|
||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
listOf("L", "L"),
|
||||
listOf(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.RETURN_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.IF_NEZ
|
||||
)
|
||||
)
|
@ -4,21 +4,22 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
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.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.MiniPlayerDimensionsCalculatorFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.MiniPlayerOverrideFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.MiniPlayerOverrideNoContextFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.tabletminiplayer.bytecode.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("enable-tablet-miniplayer-bytecode-patch")
|
||||
@DependsOn([SharedResourcdIdPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class TabletMiniPlayerBytecodePatch : BytecodePatch(
|
||||
@ -28,35 +29,33 @@ class TabletMiniPlayerBytecodePatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// first resolve the fingerprints via the parent fingerprint
|
||||
val miniPlayerClass = MiniPlayerDimensionsCalculatorFingerprint.result!!.classDef
|
||||
|
||||
/*
|
||||
* no context parameter method
|
||||
*/
|
||||
MiniPlayerOverrideNoContextFingerprint.resolve(context, miniPlayerClass)
|
||||
val (method, _, parameterRegister) = MiniPlayerOverrideNoContextFingerprint.addProxyCall()
|
||||
// - 1 means to insert before the return instruction
|
||||
val secondInsertIndex = method.implementation!!.instructions.size - 1
|
||||
method.insertOverride(secondInsertIndex, parameterRegister /** same register used to return **/)
|
||||
MiniPlayerDimensionsCalculatorFingerprint.result?.let { parentResult ->
|
||||
// first resolve the fingerprints via the parent fingerprint
|
||||
val miniPlayerClass = parentResult.classDef
|
||||
|
||||
/*
|
||||
* method with context parameter
|
||||
*/
|
||||
MiniPlayerOverrideFingerprint.resolve(context, miniPlayerClass)
|
||||
val (_, _, _) = MiniPlayerOverrideFingerprint.addProxyCall()
|
||||
|
||||
/*
|
||||
* size check return value override
|
||||
*/
|
||||
val (_, _, _) = MiniPlayerResponseModelSizeCheckFingerprint.addProxyCall()
|
||||
arrayOf(
|
||||
MiniPlayerOverrideNoContextFingerprint,
|
||||
MiniPlayerOverrideFingerprint,
|
||||
MiniPlayerResponseModelSizeCheckFingerprint
|
||||
).map {
|
||||
it to (it.also { it.resolve(context, miniPlayerClass) }.result ?: return it.toErrorResult())
|
||||
}.forEach { (fingerprint, result) ->
|
||||
if (fingerprint == MiniPlayerOverrideNoContextFingerprint) {
|
||||
val (method, _, parameterRegister) = result.addProxyCall()
|
||||
method.insertOverride(method.implementation!!.instructions.size - 1, parameterRegister)
|
||||
} else {
|
||||
val (_, _, _) = result.addProxyCall()
|
||||
}
|
||||
}
|
||||
} ?: return MiniPlayerDimensionsCalculatorFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
// helper methods
|
||||
private companion object {
|
||||
fun MethodFingerprint.addProxyCall(): Triple<MutableMethod, Int, Int> {
|
||||
fun MethodFingerprintResult.addProxyCall(): Triple<MutableMethod, Int, Int> {
|
||||
val (method, scanIndex, parameterRegister) = this.unwrap()
|
||||
method.insertOverride(scanIndex, parameterRegister)
|
||||
|
||||
@ -73,10 +72,9 @@ class TabletMiniPlayerBytecodePatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
|
||||
fun MethodFingerprint.unwrap(): Triple<MutableMethod, Int, Int> {
|
||||
val result = this.result!!
|
||||
val scanIndex = result.scanResult.patternScanResult!!.endIndex
|
||||
val method = result.mutableMethod
|
||||
fun MethodFingerprintResult.unwrap(): Triple<MutableMethod, Int, Int> {
|
||||
val scanIndex = this.scanResult.patternScanResult!!.endIndex
|
||||
val method = this.mutableMethod
|
||||
val instructions = method.implementation!!.instructions
|
||||
val parameterRegister = (instructions[scanIndex] as OneRegisterInstruction).registerA
|
||||
|
||||
|
@ -6,7 +6,10 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object WideSearchbarOneFingerprint : MethodFingerprint(
|
||||
"L",AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L"), listOf(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
|
@ -5,6 +5,11 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object WideSearchbarOneParentFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PRIVATE or AccessFlags.FINAL, listOf("L"),
|
||||
strings = listOf("FEhistory", "FEmy_videos", "FEpurchases")
|
||||
returnType = "V", access = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
strings = listOf(
|
||||
"FEhistory",
|
||||
"FEmy_videos",
|
||||
"FEpurchases"
|
||||
)
|
||||
)
|
@ -6,7 +6,9 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object WideSearchbarTwoFingerprint : MethodFingerprint(
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, opcodes = listOf(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
|
@ -5,8 +5,8 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object WideSearchbarTwoParentFingerprint : MethodFingerprint(
|
||||
"L",
|
||||
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
strings = listOf(
|
||||
"Callback already registered.",
|
||||
"Failed to create SpotlightModeController."
|
||||
|
@ -10,11 +10,9 @@ 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.layout.general.widesearchbar.bytecode.fingerprints.WideSearchbarOneFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.WideSearchbarOneParentFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.WideSearchbarTwoFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.WideSearchbarTwoParentFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.widesearchbar.bytecode.fingerprints.*
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||
|
||||
@Name("enable-wide-searchbar-bytecode-patch")
|
||||
@ -22,29 +20,28 @@ import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||
@Version("0.0.1")
|
||||
class WideSearchbarBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
WideSearchbarOneParentFingerprint, WideSearchbarTwoParentFingerprint
|
||||
WideSearchbarOneParentFingerprint,
|
||||
WideSearchbarTwoParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
WideSearchbarOneFingerprint.resolve(context, WideSearchbarOneParentFingerprint.result!!.classDef)
|
||||
WideSearchbarTwoFingerprint.resolve(context, WideSearchbarTwoParentFingerprint.result!!.classDef)
|
||||
|
||||
val resultOne = WideSearchbarOneFingerprint.result
|
||||
val targetMethodOne =
|
||||
context
|
||||
.toMethodWalker(resultOne!!.method)
|
||||
.nextMethod(resultOne.scanResult.patternScanResult!!.endIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
arrayOf(
|
||||
WideSearchbarOneParentFingerprint to WideSearchbarOneFingerprint,
|
||||
WideSearchbarTwoParentFingerprint to WideSearchbarTwoFingerprint
|
||||
).map { (parentFingerprint, fingerprint) ->
|
||||
parentFingerprint.result?.let { parentResult ->
|
||||
fingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
val targetMethod =
|
||||
context
|
||||
.toMethodWalker(it.method)
|
||||
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
|
||||
val resultTwo = WideSearchbarTwoFingerprint.result
|
||||
val targetMethodTwo =
|
||||
context.toMethodWalker(resultTwo!!.method)
|
||||
.nextMethod(resultTwo.scanResult.patternScanResult!!.startIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
injectSearchBarHook(targetMethodOne)
|
||||
injectSearchBarHook(targetMethodTwo)
|
||||
injectSearchBarHook(targetMethod)
|
||||
} ?: return fingerprint.toErrorResult()
|
||||
} ?: return parentFingerprint.toErrorResult()
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -1,11 +1,17 @@
|
||||
package app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@FuzzyPatternScanMethod(3)
|
||||
object HideWatermarkFingerprint : MethodFingerprint (
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L"), null ,null, null
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_BOOLEAN
|
||||
)
|
||||
)
|
@ -1,11 +1,11 @@
|
||||
package app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
@FuzzyPatternScanMethod(3)
|
||||
object HideWatermarkParentFingerprint : MethodFingerprint (
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.FINAL, null, null, listOf("player_overlay_in_video_programming"), null
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf("player_overlay_in_video_programming")
|
||||
)
|
||||
|
@ -4,16 +4,18 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.extensions.removeInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints.HideWatermarkFingerprint
|
||||
import app.revanced.patches.youtube.layout.player.watermark.bytecode.fingerprints.HideWatermarkParentFingerprint
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.PLAYER_LAYOUT
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Name("hide-channel-watermark-bytecode-patch")
|
||||
@YouTubeCompatibility
|
||||
@ -24,20 +26,23 @@ class HideChannelWatermarkBytecodePatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
HideWatermarkFingerprint.resolve(context, HideWatermarkParentFingerprint.result!!.classDef)
|
||||
val result = HideWatermarkFingerprint.result
|
||||
?: return PatchResultError("Required parent method could not be found.")
|
||||
|
||||
val method = result.mutableMethod
|
||||
val line = method.implementation!!.instructions.size - 5
|
||||
HideWatermarkParentFingerprint.result?.let { parentResult ->
|
||||
HideWatermarkFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
method.removeInstruction(line)
|
||||
method.addInstructions(
|
||||
line, """
|
||||
invoke-static {}, $PLAYER_LAYOUT->hideChannelWatermark()Z
|
||||
move-result p2
|
||||
"""
|
||||
)
|
||||
with (it.mutableMethod) {
|
||||
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
|
||||
removeInstruction(insertIndex)
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {}, $PLAYER_LAYOUT->hideChannelWatermark()Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return HideWatermarkFingerprint.toErrorResult()
|
||||
} ?: return HideWatermarkParentFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -1,33 +1,26 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
|
||||
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
|
||||
object SeekbarTappingFingerprint : MethodFingerprint(
|
||||
"Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_WIDE,
|
||||
Opcode.IGET,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET,
|
||||
Opcode.DIV_INT_2ADDR,
|
||||
Opcode.ADD_INT,
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
Opcode.INT_TO_FLOAT,
|
||||
Opcode.CMPG_FLOAT,
|
||||
Opcode.IF_GTZ,
|
||||
Opcode.INT_TO_FLOAT,
|
||||
Opcode.CMPG_FLOAT,
|
||||
Opcode.IF_GTZ,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
returnType = "Z",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
)
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN
|
||||
),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.name == "onTouchEvent"
|
||||
&& methodDef.implementation!!.instructions.any {
|
||||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 2147483647)
|
||||
}
|
||||
}
|
||||
)
|
@ -1,43 +1,19 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
|
||||
object SeekbarTappingParentFingerprint : MethodFingerprint(
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.NEW_ARRAY,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_WIDE,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.APUT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_WIDE,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.APUT_OBJECT,
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.RETURN_OBJECT
|
||||
)
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any { instruction ->
|
||||
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.accessibilityProgressTimeLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -4,21 +4,25 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints.SeekbarTappingFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.seekbartapping.bytecode.fingerprints.SeekbarTappingParentFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.util.integrations.Constants.SEEKBAR_LAYOUT
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11n
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
|
||||
@Name("enable-seekbar-tapping-bytecode-patch")
|
||||
@DependsOn([SharedResourcdIdPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class SeekbarTappingBytecodePatch : BytecodePatch(
|
||||
@ -27,65 +31,51 @@ class SeekbarTappingBytecodePatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
var result = SeekbarTappingParentFingerprint.result!!
|
||||
|
||||
val tapSeekMethods = mutableMapOf<String, Method>()
|
||||
|
||||
// find the methods which tap the seekbar
|
||||
for (it in result.classDef.methods) {
|
||||
if (it.implementation == null) continue
|
||||
SeekbarTappingParentFingerprint.result?.let { parentResult ->
|
||||
for (it in parentResult.classDef.methods) {
|
||||
if (it.implementation == null) continue
|
||||
|
||||
val instructions = it.implementation!!.instructions
|
||||
// here we make sure we actually find the method because it has more than 7 instructions
|
||||
if (instructions.count() < 7) continue
|
||||
val instructions = it.implementation!!.instructions
|
||||
// here we make sure we actually find the method because it has more than 7 instructions
|
||||
if (instructions.count() < 7) continue
|
||||
|
||||
// we know that the 7th instruction has the opcode CONST_4
|
||||
val instruction = instructions.elementAt(6)
|
||||
if (instruction.opcode != Opcode.CONST_4) continue
|
||||
// we know that the 7th instruction has the opcode CONST_4
|
||||
val instruction = instructions.elementAt(6)
|
||||
if (instruction.opcode != Opcode.CONST_4) continue
|
||||
|
||||
// the literal for this instruction has to be either 1 or 2
|
||||
val literal = (instruction as Instruction11n).narrowLiteral
|
||||
// the literal for this instruction has to be either 1 or 2
|
||||
val literal = (instruction as Instruction11n).narrowLiteral
|
||||
|
||||
// method founds
|
||||
if (literal == 1) tapSeekMethods["P"] = it
|
||||
if (literal == 2) tapSeekMethods["O"] = it
|
||||
}
|
||||
// method founds
|
||||
if (literal == 1) tapSeekMethods["P"] = it
|
||||
if (literal == 2) tapSeekMethods["O"] = it
|
||||
}
|
||||
} ?: return SeekbarTappingParentFingerprint.toErrorResult()
|
||||
|
||||
// replace map because we don't need the upper one anymore
|
||||
result = SeekbarTappingFingerprint.result!!
|
||||
SeekbarTappingFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
val implementation = result.mutableMethod.implementation!!
|
||||
with (it.mutableMethod) {
|
||||
val instructions = implementation!!.instructions
|
||||
val register = (instructions[insertIndex - 1] as Instruction35c).registerC
|
||||
|
||||
// if tap-seeking is enabled, do not invoke the two methods below
|
||||
val pMethod = tapSeekMethods["P"]!!
|
||||
val oMethod = tapSeekMethods["O"]!!
|
||||
val pMethod = tapSeekMethods["P"]!!
|
||||
val oMethod = tapSeekMethods["O"]!!
|
||||
|
||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {}, $SEEKBAR_LAYOUT->enableSeekbarTapping()Z
|
||||
move-result v0
|
||||
if-eqz v0, :off
|
||||
invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
|
||||
invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
|
||||
""", listOf(ExternalLabel("off", instruction(insertIndex)))
|
||||
)
|
||||
}
|
||||
} ?: return SeekbarTappingFingerprint.toErrorResult()
|
||||
|
||||
// get the required register
|
||||
val instruction = implementation.instructions[insertIndex - 1]
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register")
|
||||
val register = (instruction as Instruction35c).registerC
|
||||
|
||||
val elseLabel = implementation.newLabelForIndex(insertIndex)
|
||||
// the instructions are written in reverse order.
|
||||
result.mutableMethod.addInstructions(
|
||||
insertIndex, """
|
||||
invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
|
||||
invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
|
||||
"""
|
||||
)
|
||||
|
||||
// if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label
|
||||
implementation.addInstruction(
|
||||
insertIndex, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)
|
||||
)
|
||||
result.mutableMethod.addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static { }, $SEEKBAR_LAYOUT->enableSeekbarTapping()Z
|
||||
move-result v0
|
||||
"""
|
||||
)
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,24 +1,15 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@FuzzyPatternScanMethod(3)
|
||||
object TimeCounterFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IGET_WIDE,
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.CONST_WIDE_16,
|
||||
Opcode.CMP_LONG,
|
||||
Opcode.IF_LEZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.GOTO,
|
||||
Opcode.CMP_LONG
|
||||
)
|
||||
)
|
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
object TimeCounterParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any { instruction ->
|
||||
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.timebarColorLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -5,42 +5,50 @@ import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints.TimeCounterFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.timeandseekbar.bytecode.fingerprints.TimeCounterParentFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.patches.timebar.HookTimebarPatch
|
||||
import app.revanced.shared.util.integrations.Constants.SEEKBAR_LAYOUT
|
||||
|
||||
@DependsOn([HookTimebarPatch::class])
|
||||
@DependsOn([HookTimebarPatch::class, SharedResourcdIdPatch::class])
|
||||
@Name("hide-time-and-seekbar-bytecode-patch")
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideTimeAndSeekbarBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
TimeCounterFingerprint
|
||||
TimeCounterParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
listOf(
|
||||
HookTimebarPatch.SetTimbarFingerprintResult,
|
||||
TimeCounterFingerprint.result!!
|
||||
).forEach { result ->
|
||||
val method = result.mutableMethod
|
||||
method.addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x0
|
||||
invoke-static { }, $SEEKBAR_LAYOUT->hideTimeAndSeekbar()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
return-void
|
||||
""", listOf(ExternalLabel("hide_time_and_seekbar", method.instruction(0)))
|
||||
)
|
||||
}
|
||||
TimeCounterParentFingerprint.result?.let { parentResult ->
|
||||
TimeCounterFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { counterResult ->
|
||||
listOf(
|
||||
HookTimebarPatch.SetTimbarFingerprintResult,
|
||||
counterResult
|
||||
).forEach {
|
||||
val method = it.mutableMethod
|
||||
method.addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $SEEKBAR_LAYOUT->hideTimeAndSeekbar()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
return-void
|
||||
""", listOf(ExternalLabel("hide_time_and_seekbar", method.instruction(0)))
|
||||
)
|
||||
}
|
||||
|
||||
} ?: return TimeCounterFingerprint.toErrorResult()
|
||||
} ?: return TimeCounterParentFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
Reference in New Issue
Block a user