mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
feat(YouTube): replace with a fingerprint that supports a wider range of versions
This commit is contained in:
parent
12127d6f25
commit
41e00d6a4f
@ -96,10 +96,12 @@ object LithoFilterPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
.map { (index, _) -> index }
|
.map { (index, _) -> index }
|
||||||
.reversed()
|
.reversed()
|
||||||
.forEach {
|
.forEach { index ->
|
||||||
|
val insertInstruction = getInstruction(index + 1)
|
||||||
|
if (insertInstruction is OneRegisterInstruction) {
|
||||||
val insertRegister =
|
val insertRegister =
|
||||||
getInstruction<OneRegisterInstruction>(it + 1).registerA
|
insertInstruction.registerA
|
||||||
val insertIndex = it + 2
|
val insertIndex = index + 2
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
insertIndex, """
|
insertIndex, """
|
||||||
@ -108,6 +110,7 @@ object LithoFilterPatch : BytecodePatch(
|
|||||||
ExternalLabel("ignore", getInstruction(insertIndex))
|
ExternalLabel("ignore", getInstruction(insertIndex))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emptyComponentLabel = """
|
emptyComponentLabel = """
|
||||||
const/4 v0, 0x0
|
const/4 v0, 0x0
|
||||||
|
@ -50,6 +50,7 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
|||||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||||
import app.revanced.util.findMethodOrThrow
|
import app.revanced.util.findMethodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
|
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
|
||||||
@ -147,7 +148,8 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
|||||||
hookInitVideoPanel(1)
|
hookInitVideoPanel(1)
|
||||||
} else {
|
} else {
|
||||||
val syntheticIndex =
|
val syntheticIndex =
|
||||||
indexOfFirstInstructionOrThrow(Opcode.NEW_INSTANCE)
|
indexOfFirstInstruction(0, Opcode.NEW_INSTANCE)
|
||||||
|
if (syntheticIndex >= 0) {
|
||||||
val syntheticReference =
|
val syntheticReference =
|
||||||
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
|
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
|
||||||
|
|
||||||
@ -157,6 +159,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EngagementPanelBuilderFingerprint.resultOrThrow().let {
|
EngagementPanelBuilderFingerprint.resultOrThrow().let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
|
@ -25,7 +25,7 @@ internal object BuildBrowseRequestFingerprint : MethodFingerprint(
|
|||||||
fun indexOfRequestFinishedListenerInstruction(methodDef: Method) =
|
fun indexOfRequestFinishedListenerInstruction(methodDef: Method) =
|
||||||
methodDef.indexOfFirstInstruction {
|
methodDef.indexOfFirstInstruction {
|
||||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||||
getReference<MethodReference>().toString() == "Lorg/chromium/net/ExperimentalUrlRequest${'$'}Builder;->setRequestFinishedListener(Lorg/chromium/net/RequestFinishedInfo${'$'}Listener;)Lorg/chromium/net/ExperimentalUrlRequest${'$'}Builder;"
|
getReference<MethodReference>()?.name == "setRequestFinishedListener"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun indexOfNewUrlRequestBuilderInstruction(methodDef: Method) =
|
fun indexOfNewUrlRequestBuilderInstruction(methodDef: Method) =
|
||||||
|
@ -6,20 +6,28 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
|
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.AutoNavConstructorFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.AutoNavStatusFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.RemoveOnLayoutChangeListenerFingerprint
|
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.RemoveOnLayoutChangeListenerFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||||
|
import app.revanced.util.alsoResolve
|
||||||
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.getWalkerMethod
|
import app.revanced.util.getWalkerMethod
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
description = "Fixes an issue where the suggested video end screen is always visible regardless of whether autoplay is set or not."
|
description = "Fixes an issue where the suggested video end screen is always visible regardless of whether autoplay is set or not."
|
||||||
)
|
)
|
||||||
object SuggestedVideoEndScreenPatch : BytecodePatch(
|
object SuggestedVideoEndScreenPatch : BytecodePatch(
|
||||||
setOf(RemoveOnLayoutChangeListenerFingerprint)
|
setOf(
|
||||||
|
AutoNavConstructorFingerprint,
|
||||||
|
RemoveOnLayoutChangeListenerFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
@ -36,15 +44,23 @@ object SuggestedVideoEndScreenPatch : BytecodePatch(
|
|||||||
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
|
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
|
||||||
|
|
||||||
walkerIndex.apply {
|
walkerIndex.apply {
|
||||||
val invokeInterfaceIndex =
|
val autoNavStatusMethodName = AutoNavStatusFingerprint.alsoResolve(
|
||||||
indexOfFirstInstructionOrThrow(opcode = Opcode.INVOKE_INTERFACE)
|
context, AutoNavConstructorFingerprint
|
||||||
|
).mutableMethod.name
|
||||||
|
val invokeIndex =
|
||||||
|
indexOfFirstInstructionOrThrow {
|
||||||
|
val reference = getReference<MethodReference>()
|
||||||
|
reference?.returnType == "Z" &&
|
||||||
|
reference.parameterTypes.size == 0 &&
|
||||||
|
reference.name == autoNavStatusMethodName
|
||||||
|
}
|
||||||
val iGetObjectIndex =
|
val iGetObjectIndex =
|
||||||
indexOfFirstInstructionReversedOrThrow(invokeInterfaceIndex, Opcode.IGET_OBJECT)
|
indexOfFirstInstructionReversedOrThrow(invokeIndex, Opcode.IGET_OBJECT)
|
||||||
|
|
||||||
val invokeInterfaceReference =
|
val invokeReference = getInstruction<ReferenceInstruction>(invokeIndex).reference
|
||||||
getInstruction<ReferenceInstruction>(invokeInterfaceIndex).reference
|
|
||||||
val iGetObjectReference =
|
val iGetObjectReference =
|
||||||
getInstruction<ReferenceInstruction>(iGetObjectIndex).reference
|
getInstruction<ReferenceInstruction>(iGetObjectIndex).reference
|
||||||
|
val opcodeName = getInstruction(invokeIndex).opcode.name
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
0,
|
0,
|
||||||
@ -56,7 +72,7 @@ object SuggestedVideoEndScreenPatch : BytecodePatch(
|
|||||||
iget-object v0, p0, $iGetObjectReference
|
iget-object v0, p0, $iGetObjectReference
|
||||||
|
|
||||||
# This reference checks whether autoplay is turned on.
|
# This reference checks whether autoplay is turned on.
|
||||||
invoke-interface {v0}, $invokeInterfaceReference
|
$opcodeName {v0}, $invokeReference
|
||||||
move-result v0
|
move-result v0
|
||||||
|
|
||||||
# Hide suggested video end screen only when autoplay is turned off.
|
# Hide suggested video end screen only when autoplay is turned off.
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object AutoNavConstructorFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
strings = listOf("main_app_autonav"),
|
||||||
|
)
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object AutoNavStatusFingerprint : MethodFingerprint(
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
returnType = "Z",
|
||||||
|
parameters = emptyList()
|
||||||
|
)
|
@ -7,7 +7,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchException
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
||||||
@ -18,7 +17,6 @@ import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFinge
|
|||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||||
import app.revanced.util.addStaticFieldToIntegration
|
import app.revanced.util.addStaticFieldToIntegration
|
||||||
import app.revanced.util.alsoResolve
|
|
||||||
import app.revanced.util.findMethodOrThrow
|
import app.revanced.util.findMethodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
@ -38,7 +36,7 @@ object PlayerTypeHookPatch : BytecodePatch(
|
|||||||
BrowseIdClassFingerprint,
|
BrowseIdClassFingerprint,
|
||||||
PlayerTypeFingerprint,
|
PlayerTypeFingerprint,
|
||||||
ReelWatchPagerFingerprint,
|
ReelWatchPagerFingerprint,
|
||||||
YouTubeControlsOverlayFingerprint
|
VideoStateFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private const val INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR =
|
||||||
@ -79,11 +77,9 @@ object PlayerTypeHookPatch : BytecodePatch(
|
|||||||
|
|
||||||
// region patch for set video state
|
// region patch for set video state
|
||||||
|
|
||||||
VideoStateFingerprint.alsoResolve(
|
VideoStateFingerprint.resultOrThrow().let {
|
||||||
context, YouTubeControlsOverlayFingerprint
|
|
||||||
).let {
|
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
val endIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||||
val videoStateFieldName =
|
val videoStateFieldName =
|
||||||
getInstruction<ReferenceInstruction>(endIndex).reference
|
getInstruction<ReferenceInstruction>(endIndex).reference
|
||||||
|
|
||||||
|
@ -6,22 +6,22 @@ import app.revanced.util.getReference
|
|||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
internal object VideoStateFingerprint : MethodFingerprint(
|
internal object VideoStateFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("Lcom/google/android/libraries/youtube/player/features/overlay/controls/ControlsState;"),
|
parameters = listOf("Lcom/google/android/libraries/youtube/player/features/overlay/controls/ControlsState;"),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.IF_EQZ,
|
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
Opcode.IGET_OBJECT, // obfuscated parameter field name
|
Opcode.IGET_OBJECT, // obfuscated parameter field name
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.IF_NE,
|
||||||
),
|
),
|
||||||
customFingerprint = { methodDef, _ ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.indexOfFirstInstruction {
|
methodDef.indexOfFirstInstruction {
|
||||||
opcode == Opcode.IGET_OBJECT &&
|
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||||
getReference<FieldReference>()?.definingClass == methodDef.parameterTypes.firstOrNull()
|
getReference<MethodReference>()?.name == "equals"
|
||||||
} >= 0
|
} >= 0
|
||||||
}
|
},
|
||||||
)
|
)
|
@ -2,7 +2,9 @@ package app.revanced.patches.youtube.video.information
|
|||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
@ -38,6 +40,7 @@ import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHoo
|
|||||||
import app.revanced.patches.youtube.video.videoid.VideoIdPatch
|
import app.revanced.patches.youtube.video.videoid.VideoIdPatch
|
||||||
import app.revanced.util.addStaticFieldToIntegration
|
import app.revanced.util.addStaticFieldToIntegration
|
||||||
import app.revanced.util.alsoResolve
|
import app.revanced.util.alsoResolve
|
||||||
|
import app.revanced.util.cloneMutable
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.getWalkerMethod
|
import app.revanced.util.getWalkerMethod
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
@ -119,6 +122,7 @@ object VideoInformationPatch : BytecodePatch(
|
|||||||
private var seekSourceEnumType = ""
|
private var seekSourceEnumType = ""
|
||||||
private var seekSourceMethodName = ""
|
private var seekSourceMethodName = ""
|
||||||
private var seekRelativeSourceMethodName = ""
|
private var seekRelativeSourceMethodName = ""
|
||||||
|
private var cloneSeekRelativeSourceMethod = false
|
||||||
|
|
||||||
private lateinit var context: BytecodeContext
|
private lateinit var context: BytecodeContext
|
||||||
|
|
||||||
@ -135,6 +139,32 @@ object VideoInformationPatch : BytecodePatch(
|
|||||||
internal lateinit var speedSelectionInsertMethod: MutableMethod
|
internal lateinit var speedSelectionInsertMethod: MutableMethod
|
||||||
internal lateinit var videoEndMethod: MutableMethod
|
internal lateinit var videoEndMethod: MutableMethod
|
||||||
|
|
||||||
|
private fun cloneSeekRelativeSourceMethod(fingerprintResult: MethodFingerprintResult) {
|
||||||
|
if (!cloneSeekRelativeSourceMethod) return
|
||||||
|
|
||||||
|
val methods = fingerprintResult.mutableClass.methods
|
||||||
|
|
||||||
|
methods.find { method ->
|
||||||
|
method.name == seekRelativeSourceMethodName
|
||||||
|
}?.apply {
|
||||||
|
methods.add(
|
||||||
|
cloneMutable(
|
||||||
|
returnType = "Z"
|
||||||
|
).apply {
|
||||||
|
val lastIndex = implementation!!.instructions.lastIndex
|
||||||
|
|
||||||
|
removeInstruction(lastIndex)
|
||||||
|
addInstructions(
|
||||||
|
lastIndex, """
|
||||||
|
move-result p1
|
||||||
|
return p1
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun addSeekInterfaceMethods(
|
private fun addSeekInterfaceMethods(
|
||||||
result: MethodFingerprintResult,
|
result: MethodFingerprintResult,
|
||||||
seekMethodName: String,
|
seekMethodName: String,
|
||||||
@ -203,12 +233,16 @@ object VideoInformationPatch : BytecodePatch(
|
|||||||
// hook the player controller for use through integrations
|
// hook the player controller for use through integrations
|
||||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||||
|
|
||||||
seekSourceEnumType = parameterTypes[1].toString()
|
val seekRelativeMethod = SeekRelativeFingerprint.alsoResolve(
|
||||||
seekSourceMethodName = name
|
|
||||||
seekRelativeSourceMethodName = SeekRelativeFingerprint.alsoResolve(
|
|
||||||
context,
|
context,
|
||||||
VideoEndFingerprint
|
VideoEndFingerprint
|
||||||
).mutableMethod.name
|
).mutableMethod
|
||||||
|
|
||||||
|
seekSourceEnumType = parameterTypes[1].toString()
|
||||||
|
seekSourceMethodName = name
|
||||||
|
seekRelativeSourceMethodName = seekRelativeMethod.name
|
||||||
|
cloneSeekRelativeSourceMethod = seekRelativeMethod.returnType == "V"
|
||||||
|
cloneSeekRelativeSourceMethod(it)
|
||||||
|
|
||||||
// Create integrations interface methods.
|
// Create integrations interface methods.
|
||||||
addSeekInterfaceMethods(
|
addSeekInterfaceMethods(
|
||||||
@ -250,6 +284,8 @@ object VideoInformationPatch : BytecodePatch(
|
|||||||
// hook the MDX director for use through integrations
|
// hook the MDX director for use through integrations
|
||||||
onCreateHookMdx(INTEGRATIONS_CLASS_DESCRIPTOR, "initializeMdx")
|
onCreateHookMdx(INTEGRATIONS_CLASS_DESCRIPTOR, "initializeMdx")
|
||||||
|
|
||||||
|
cloneSeekRelativeSourceMethod(it)
|
||||||
|
|
||||||
// Create integrations interface methods.
|
// Create integrations interface methods.
|
||||||
addSeekInterfaceMethods(
|
addSeekInterfaceMethods(
|
||||||
it,
|
it,
|
||||||
|
@ -11,12 +11,11 @@ import com.android.tools.smali.dexlib2.Opcode
|
|||||||
*/
|
*/
|
||||||
internal object SeekRelativeFingerprint : MethodFingerprint(
|
internal object SeekRelativeFingerprint : MethodFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
returnType = "Z",
|
// returnType = "Z", ~ YouTube 19.39.39
|
||||||
|
// returnType = "V", YouTube 19.40.xx ~
|
||||||
parameters = listOf("J", "L"),
|
parameters = listOf("J", "L"),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.ADD_LONG_2ADDR,
|
Opcode.ADD_LONG_2ADDR,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT,
|
|
||||||
Opcode.RETURN
|
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -16,10 +16,12 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.util.fingerprint.MultiMethodFingerprint
|
import app.revanced.util.fingerprint.MultiMethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.Method
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
|
import com.android.tools.smali.dexlib2.iface.MethodParameter
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@ -30,6 +32,8 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|||||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||||
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
import com.android.tools.smali.dexlib2.immutable.ImmutableField
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
|
||||||
|
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
const val REGISTER_TEMPLATE_REPLACEMENT: String = "REGISTER_INDEX"
|
const val REGISTER_TEMPLATE_REPLACEMENT: String = "REGISTER_INDEX"
|
||||||
@ -55,6 +59,18 @@ val MultiMethodFingerprint.exception
|
|||||||
fun MethodFingerprint.alsoResolve(context: BytecodeContext, fingerprint: MethodFingerprint) =
|
fun MethodFingerprint.alsoResolve(context: BytecodeContext, fingerprint: MethodFingerprint) =
|
||||||
also { resolve(context, fingerprint.resultOrThrow().classDef) }.resultOrThrow()
|
also { resolve(context, fingerprint.resultOrThrow().classDef) }.resultOrThrow()
|
||||||
|
|
||||||
|
fun MethodFingerprint.getMethodCall() =
|
||||||
|
resultOrThrow().mutableMethod.getMethodCall()
|
||||||
|
|
||||||
|
fun MutableMethod.getMethodCall(): String {
|
||||||
|
var methodCall = "$definingClass->$name("
|
||||||
|
for (i in 0 until parameters.size) {
|
||||||
|
methodCall += parameterTypes[i]
|
||||||
|
}
|
||||||
|
methodCall += ")$returnType"
|
||||||
|
return methodCall
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
|
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
|
||||||
*
|
*
|
||||||
@ -371,7 +387,7 @@ fun Method.findOpcodeIndicesReversed(opcode: Opcode): List<Int> =
|
|||||||
fun Method.findOpcodeIndicesReversed(filter: Instruction.() -> Boolean): List<Int> {
|
fun Method.findOpcodeIndicesReversed(filter: Instruction.() -> Boolean): List<Int> {
|
||||||
val indexes = implementation!!.instructions
|
val indexes = implementation!!.instructions
|
||||||
.withIndex()
|
.withIndex()
|
||||||
.filter { (_, instruction) -> filter.invoke(instruction) }
|
.filter { (_, instruction) -> filter(instruction) }
|
||||||
.map { (index, _) -> index }
|
.map { (index, _) -> index }
|
||||||
.reversed()
|
.reversed()
|
||||||
|
|
||||||
@ -573,6 +589,38 @@ fun BytecodeContext.updatePatchStatus(
|
|||||||
"const/4 v0, 0x1"
|
"const/4 v0, 0x1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taken from BiliRoamingX:
|
||||||
|
* https://github.com/BiliRoamingX/BiliRoamingX/blob/ae58109f3acdd53ec2d2b3fb439c2a2ef1886221/patches/src/main/kotlin/app/revanced/patches/bilibili/utils/Extenstions.kt#L51
|
||||||
|
*/
|
||||||
|
fun Method.cloneMutable(
|
||||||
|
registerCount: Int = implementation?.registerCount ?: 0,
|
||||||
|
clearImplementation: Boolean = false,
|
||||||
|
name: String = this.name,
|
||||||
|
accessFlags: Int = this.accessFlags,
|
||||||
|
parameters: List<MethodParameter> = this.parameters,
|
||||||
|
returnType: String = this.returnType
|
||||||
|
): MutableMethod {
|
||||||
|
val clonedImplementation = implementation?.let {
|
||||||
|
ImmutableMethodImplementation(
|
||||||
|
registerCount,
|
||||||
|
if (clearImplementation) emptyList() else it.instructions,
|
||||||
|
if (clearImplementation) emptyList() else it.tryBlocks,
|
||||||
|
if (clearImplementation) emptyList() else it.debugItems,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return ImmutableMethod(
|
||||||
|
definingClass,
|
||||||
|
name,
|
||||||
|
parameters,
|
||||||
|
returnType,
|
||||||
|
accessFlags,
|
||||||
|
annotations,
|
||||||
|
hiddenApiRestrictions,
|
||||||
|
clonedImplementation
|
||||||
|
).toMutable()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the resolved methods of [MethodFingerprint]s early.
|
* Return the resolved methods of [MethodFingerprint]s early.
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,9 @@ private typealias StringMatch = MethodFingerprintResult.MethodFingerprintScanRes
|
|||||||
private typealias StringsScanResult = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
private typealias StringsScanResult = MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Taken from BiliRoamingX:
|
||||||
|
* https://github.com/BiliRoamingX/BiliRoamingX/blob/ae58109f3acdd53ec2d2b3fb439c2a2ef1886221/patches/src/main/kotlin/app/revanced/patches/bilibili/patcher/fingerprint/MultiMethodFingerprint.kt
|
||||||
|
*
|
||||||
* Represents the [MethodFingerprint] for a method.
|
* Represents the [MethodFingerprint] for a method.
|
||||||
* @param returnType The return type of the method.
|
* @param returnType The return type of the method.
|
||||||
* @param accessFlags The access flags of the method.
|
* @param accessFlags The access flags of the method.
|
||||||
|
@ -6,6 +6,10 @@ import app.revanced.patcher.patch.BytecodePatch
|
|||||||
import app.revanced.util.fingerprint.MultiMethodFingerprint
|
import app.revanced.util.fingerprint.MultiMethodFingerprint
|
||||||
import app.revanced.util.fingerprint.MultiMethodFingerprint.Companion.resolve
|
import app.revanced.util.fingerprint.MultiMethodFingerprint.Companion.resolve
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taken from BiliRoamingX:
|
||||||
|
* https://github.com/BiliRoamingX/BiliRoamingX/blob/ae58109f3acdd53ec2d2b3fb439c2a2ef1886221/patches/src/main/kotlin/app/revanced/patches/bilibili/patcher/patch/MultiMethodBytecodePatch.kt
|
||||||
|
*/
|
||||||
abstract class MultiMethodBytecodePatch(
|
abstract class MultiMethodBytecodePatch(
|
||||||
val fingerprints: Set<MethodFingerprint> = setOf(),
|
val fingerprints: Set<MethodFingerprint> = setOf(),
|
||||||
val multiFingerprints: Set<MultiMethodFingerprint> = setOf()
|
val multiFingerprints: Set<MultiMethodFingerprint> = setOf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user