mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
refactor(Utils): appropriate message is displayed in the exception when the index is not found
This commit is contained in:
@ -11,8 +11,8 @@ import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PAC
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -49,9 +49,9 @@ object AmbientModeSwitchPatch : BaseBytecodePatch(
|
||||
getStringInstructionIndex("android.os.action.POWER_SAVE_MODE_CHANGED")
|
||||
val targetIndex =
|
||||
if (reversed)
|
||||
getTargetIndexReversed(stringIndex, Opcode.INVOKE_DIRECT)
|
||||
getTargetIndexReversedOrThrow(stringIndex, Opcode.INVOKE_DIRECT)
|
||||
else
|
||||
getTargetIndex(stringIndex, Opcode.INVOKE_DIRECT)
|
||||
getTargetIndexOrThrow(stringIndex, Opcode.INVOKE_DIRECT)
|
||||
val targetClass =
|
||||
(getInstruction<ReferenceInstruction>(targetIndex).reference as MethodReference).definingClass
|
||||
|
||||
|
@ -24,7 +24,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullS
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.PlayerCollapseButton
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TitleAnchor
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -65,7 +65,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(AutoNavToggle)
|
||||
val constRegister = getInstruction<OneRegisterInstruction>(constIndex).registerA
|
||||
val jumpIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL) + 1
|
||||
val jumpIndex = getTargetIndexOrThrow(constIndex + 2, Opcode.INVOKE_VIRTUAL) + 1
|
||||
|
||||
addInstructionsWithLabels(
|
||||
constIndex, """
|
||||
@ -125,7 +125,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
|
||||
TitleAnchorFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val titleAnchorConstIndex = getWideLiteralInstructionIndex(TitleAnchor)
|
||||
val titleAnchorIndex = getTargetIndex(titleAnchorConstIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val titleAnchorIndex = getTargetIndexOrThrow(titleAnchorConstIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val titleAnchorRegister =
|
||||
getInstruction<OneRegisterInstruction>(titleAnchorIndex).registerA
|
||||
|
||||
@ -137,7 +137,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
val playerCollapseButtonConstIndex =
|
||||
getWideLiteralInstructionIndex(PlayerCollapseButton)
|
||||
val playerCollapseButtonIndex =
|
||||
getTargetIndex(playerCollapseButtonConstIndex, Opcode.CHECK_CAST)
|
||||
getTargetIndexOrThrow(playerCollapseButtonConstIndex, Opcode.CHECK_CAST)
|
||||
val playerCollapseButtonRegister =
|
||||
getInstruction<OneRegisterInstruction>(playerCollapseButtonIndex).registerA
|
||||
|
||||
@ -158,7 +158,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
(instruction.value as? WideLiteralInstruction)?.wideLiteral == FullScreenButton
|
||||
}
|
||||
val constIndex = buttonCalls.elementAt(buttonCalls.size - 1).index
|
||||
val castIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST)
|
||||
val castIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
val insertIndex = castIndex + 1
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(castIndex).registerA
|
||||
|
||||
@ -179,7 +179,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
||||
|
||||
PlayerControlsVisibilityModelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val callIndex = getTargetIndex(Opcode.INVOKE_DIRECT_RANGE)
|
||||
val callIndex = getTargetIndexOrThrow(Opcode.INVOKE_DIRECT_RANGE)
|
||||
val callInstruction = getInstruction<Instruction3rc>(callIndex)
|
||||
|
||||
val hasNextParameterRegister = callInstruction.startRegister + HAS_NEXT
|
||||
|
@ -12,7 +12,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -58,12 +58,12 @@ object CommentsComponentPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val emojiPickerEndpointIndex = getWideLiteralInstructionIndex(126326492)
|
||||
val emojiPickerOnClickListenerIndex =
|
||||
getTargetIndex(emojiPickerEndpointIndex, Opcode.INVOKE_DIRECT)
|
||||
getTargetIndexOrThrow(emojiPickerEndpointIndex, Opcode.INVOKE_DIRECT)
|
||||
val emojiPickerOnClickListenerMethod =
|
||||
getWalkerMethod(context, emojiPickerOnClickListenerIndex)
|
||||
|
||||
emojiPickerOnClickListenerMethod.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.IF_EQZ)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.IF_EQZ)
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
|
@ -38,9 +38,9 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FadeD
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ScrimOverlay
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.SeekUndoEduOverlayStub
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -90,7 +90,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
YouTubeControlsOverlayFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(ScrimOverlay)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST)
|
||||
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
val targetParameter = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
@ -203,7 +203,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(FadeDurationFast)
|
||||
val constRegister = getInstruction<OneRegisterInstruction>(constIndex).registerA
|
||||
val insertIndex = getTargetIndexReversed(constIndex, Opcode.INVOKE_VIRTUAL) + 1
|
||||
val insertIndex = getTargetIndexReversedOrThrow(constIndex, Opcode.INVOKE_VIRTUAL) + 1
|
||||
val jumpIndex = implementation!!.instructions.let { instruction ->
|
||||
insertIndex + instruction.subList(insertIndex, instruction.size - 1)
|
||||
.indexOfFirst { instructions ->
|
||||
@ -272,7 +272,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
val onClickListenerIndex =
|
||||
getTargetIndexWithMethodReferenceName(insertIndex, "setOnClickListener")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow(insertIndex, "setOnClickListener")
|
||||
val constComponent = getConstComponent(insertIndex, onClickListenerIndex - 1)
|
||||
|
||||
if (constComponent.isNotEmpty()) {
|
||||
@ -318,7 +318,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
method.parameters == listOf("Landroid/view/View${'$'}OnClickListener;")
|
||||
}?.apply {
|
||||
val setOnClickListenerIndex =
|
||||
getTargetIndexWithMethodReferenceName("setOnClickListener")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow("setOnClickListener")
|
||||
val setOnClickListenerRegister =
|
||||
getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||
|
||||
|
@ -19,7 +19,7 @@ import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -61,7 +61,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val imageSpanIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val setTextIndex = getTargetIndexWithMethodReferenceName("setText")
|
||||
val setTextIndex = getTargetIndexWithMethodReferenceNameOrThrow("setText")
|
||||
|
||||
addInstruction(setTextIndex, "nop")
|
||||
addInstructionsWithLabels(
|
||||
@ -94,7 +94,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
if (SettingsPatch.upward1902) {
|
||||
TextViewComponentFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable")
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("setTextIsSelectable")
|
||||
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
|
||||
|
||||
replaceInstruction(
|
||||
@ -111,7 +111,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
)
|
||||
EngagementPanelTitleFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val contentDescriptionIndex =
|
||||
getTargetIndexWithMethodReferenceName("setContentDescription")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow("setContentDescription")
|
||||
val contentDescriptionRegister =
|
||||
getInstruction<FiveRegisterInstruction>(contentDescriptionIndex).registerD
|
||||
|
||||
|
@ -16,7 +16,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomSheetFooterText
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.literalInstructionViewHook
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -64,7 +64,7 @@ object PlayerFlyoutMenuPatch : BaseBytecodePatch(
|
||||
QualityMenuViewInflateFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("addHeaderView")
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("addHeaderView")
|
||||
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
|
||||
addInstructions(
|
||||
|
@ -18,9 +18,10 @@ import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DE
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -132,7 +133,7 @@ object ChangeTogglePatch : BaseBytecodePatch(
|
||||
|
||||
CinematicLightingFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val iGetIndex = indexOfFirstInstruction {
|
||||
val iGetIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.IGET
|
||||
&& getReference<FieldReference>()?.definingClass == definingClass
|
||||
}
|
||||
@ -140,10 +141,10 @@ object ChangeTogglePatch : BaseBytecodePatch(
|
||||
|
||||
val stringIndex = getStringInstructionIndex("menu_item_cinematic_lighting")
|
||||
|
||||
val checkCastIndex = getTargetIndexReversed(stringIndex, Opcode.CHECK_CAST)
|
||||
val checkCastIndex = getTargetIndexReversedOrThrow(stringIndex, Opcode.CHECK_CAST)
|
||||
val iGetObjectPrimaryIndex =
|
||||
getTargetIndexReversed(checkCastIndex, Opcode.IGET_OBJECT)
|
||||
val iGetObjectSecondaryIndex = getTargetIndex(checkCastIndex, Opcode.IGET_OBJECT)
|
||||
getTargetIndexReversedOrThrow(checkCastIndex, Opcode.IGET_OBJECT)
|
||||
val iGetObjectSecondaryIndex = getTargetIndexOrThrow(checkCastIndex, Opcode.IGET_OBJECT)
|
||||
|
||||
val checkCastReference =
|
||||
getInstruction<ReferenceInstruction>(checkCastIndex).reference
|
||||
@ -152,14 +153,14 @@ object ChangeTogglePatch : BaseBytecodePatch(
|
||||
val iGetObjectSecondaryReference =
|
||||
getInstruction<ReferenceInstruction>(iGetObjectSecondaryIndex).reference
|
||||
|
||||
val invokeVirtualIndex = getTargetIndex(stringIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val invokeVirtualIndex = getTargetIndexOrThrow(stringIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val invokeVirtualInstruction =
|
||||
getInstruction<FiveRegisterInstruction>(invokeVirtualIndex)
|
||||
val freeRegisterC = invokeVirtualInstruction.registerC
|
||||
val freeRegisterD = invokeVirtualInstruction.registerD
|
||||
val freeRegisterE = invokeVirtualInstruction.registerE
|
||||
|
||||
val insertIndex = getTargetIndex(stringIndex, Opcode.RETURN_VOID)
|
||||
val insertIndex = getTargetIndexOrThrow(stringIndex, Opcode.RETURN_VOID)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
|
@ -32,8 +32,8 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullS
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.QuickActionsElementContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -80,7 +80,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
EngagementPanelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val literalIndex = getWideLiteralInstructionIndex(FullScreenEngagementPanel)
|
||||
val targetIndex = getTargetIndex(literalIndex, Opcode.CHECK_CAST)
|
||||
val targetIndex = getTargetIndexOrThrow(literalIndex, Opcode.CHECK_CAST)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -93,7 +93,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
PlayerTitleViewFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("addView")
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("addView")
|
||||
val insertReference =
|
||||
getInstruction<ReferenceInstruction>(insertIndex).reference.toString()
|
||||
if (!insertReference.startsWith("Landroid/widget/FrameLayout;"))
|
||||
@ -116,7 +116,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(AutoNavPreviewStub)
|
||||
val constRegister = getInstruction<OneRegisterInstruction>(constIndex).registerA
|
||||
val jumpIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL) + 1
|
||||
val jumpIndex = getTargetIndexOrThrow(constIndex + 2, Opcode.INVOKE_VIRTUAL) + 1
|
||||
|
||||
addInstructionsWithLabels(
|
||||
constIndex, """
|
||||
@ -158,7 +158,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
}
|
||||
val constIndex = containerCalls.elementAt(containerCalls.size - 1).index
|
||||
|
||||
val checkCastIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST)
|
||||
val checkCastIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(checkCastIndex).registerA
|
||||
|
||||
@ -182,8 +182,8 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
YouTubeControlsOverlayFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceName("setFocusableInTouchMode")
|
||||
val walkerIndex = getTargetIndex(targetIndex, Opcode.INVOKE_STATIC)
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("setFocusableInTouchMode")
|
||||
val walkerIndex = getTargetIndexOrThrow(targetIndex, Opcode.INVOKE_STATIC)
|
||||
|
||||
val walkerMethod = getWalkerMethod(context, walkerIndex)
|
||||
walkerMethod.apply {
|
||||
@ -243,8 +243,8 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex =
|
||||
getStringInstructionIndex("Acquiring NetLatencyActionLogger failed. taskId=")
|
||||
val invokeIndex = getTargetIndex(stringIndex, Opcode.INVOKE_INTERFACE)
|
||||
val targetIndex = getTargetIndex(invokeIndex, Opcode.CHECK_CAST)
|
||||
val invokeIndex = getTargetIndexOrThrow(stringIndex, Opcode.INVOKE_INTERFACE)
|
||||
val targetIndex = getTargetIndexOrThrow(invokeIndex, Opcode.CHECK_CAST)
|
||||
val targetClass = context
|
||||
.findClass(getInstruction<ReferenceInstruction>(targetIndex).reference.toString())!!
|
||||
.mutableClass
|
||||
@ -310,7 +310,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
result.mutableMethod.apply {
|
||||
val stringIndex =
|
||||
getStringInstructionIndex("android.intent.action.SCREEN_ON")
|
||||
val insertIndex = getTargetIndex(stringIndex, Opcode.IF_EQZ) + 1
|
||||
val insertIndex = getTargetIndexOrThrow(stringIndex, Opcode.IF_EQZ) + 1
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.patches.youtube.player.hapticfeedback.fingerprints.ZoomHapti
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -65,7 +65,7 @@ object HapticFeedBackPatch : BaseBytecodePatch(
|
||||
var register = 0
|
||||
|
||||
if (name == "run") {
|
||||
index = getTargetIndex(Opcode.SGET)
|
||||
index = getTargetIndexOrThrow(Opcode.SGET)
|
||||
register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.addFieldAndInstructions
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -84,7 +84,7 @@ object OverlayButtonsBytecodePatch : BytecodePatch(
|
||||
PlayerButtonConstructorFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val registerResolver = implementation!!.registerCount - parameters.size - 1 + 6 // p6
|
||||
|
||||
val invokerObjectIndex = indexOfFirstInstruction {
|
||||
val invokerObjectIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.IPUT_OBJECT
|
||||
&& getReference<FieldReference>()?.definingClass == definingClass
|
||||
&& (this as TwoRegisterInstruction).registerA == registerResolver
|
||||
@ -93,7 +93,7 @@ object OverlayButtonsBytecodePatch : BytecodePatch(
|
||||
getInstruction<ReferenceInstruction>(invokerObjectIndex).reference
|
||||
|
||||
val onClickListenerReferenceIndex =
|
||||
getTargetIndexWithReference("<init>(Ljava/lang/Object;I[B)V")
|
||||
getTargetIndexWithReferenceOrThrow("<init>(Ljava/lang/Object;I[B)V")
|
||||
val onClickListenerReference =
|
||||
getInstruction<ReferenceInstruction>(onClickListenerReferenceIndex).reference
|
||||
val onClickListenerClass =
|
||||
@ -103,7 +103,7 @@ object OverlayButtonsBytecodePatch : BytecodePatch(
|
||||
onClickListenerClass.methods.find { method -> method.name == "onClick" }
|
||||
?.apply {
|
||||
val invokeInterfaceIndex =
|
||||
getTargetIndexWithReference(invokerObjectReference.toString()) + 1
|
||||
getTargetIndexWithReferenceOrThrow(invokerObjectReference.toString()) + 1
|
||||
if (getInstruction(invokeInterfaceIndex).opcode != Opcode.INVOKE_INTERFACE)
|
||||
throw PatchException("Opcode does not match")
|
||||
invokeInterfaceReference =
|
||||
|
@ -29,8 +29,8 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelT
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
@ -132,10 +132,10 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
TotalTimeFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val charSequenceIndex = getTargetIndexWithMethodReferenceName("getString") + 1
|
||||
val charSequenceIndex = getTargetIndexWithMethodReferenceNameOrThrow("getString") + 1
|
||||
val charSequenceRegister =
|
||||
getInstruction<OneRegisterInstruction>(charSequenceIndex).registerA
|
||||
val textViewIndex = getTargetIndexWithMethodReferenceName("getText")
|
||||
val textViewIndex = getTargetIndexWithMethodReferenceNameOrThrow("getText")
|
||||
val textViewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(textViewIndex).registerC
|
||||
|
||||
@ -204,7 +204,7 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
|
||||
PlayerButtonsVisibilityFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val viewIndex = getTargetIndex(Opcode.INVOKE_INTERFACE)
|
||||
val viewIndex = getTargetIndexOrThrow(Opcode.INVOKE_INTERFACE)
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(viewIndex).registerD
|
||||
|
||||
addInstructionsWithLabels(
|
||||
|
@ -20,12 +20,12 @@ import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverla
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversedOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -102,7 +102,7 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
// Used on YouTube 19.18.41~
|
||||
|
||||
NextGenWatchLayoutFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val booleanValueIndex = getTargetIndexWithMethodReferenceName("booleanValue")
|
||||
val booleanValueIndex = getTargetIndexWithMethodReferenceNameOrThrow("booleanValue")
|
||||
|
||||
val insertIndex = findIGetIndex(booleanValueIndex - 10, booleanValueIndex)
|
||||
val insertInstruction = getInstruction<TwoRegisterInstruction>(insertIndex)
|
||||
@ -139,9 +139,9 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
}
|
||||
|
||||
slideToSeekBooleanMethod.apply {
|
||||
var insertIndex = getTargetIndex(Opcode.IGET_OBJECT)
|
||||
var insertIndex = getTargetIndexOrThrow(Opcode.IGET_OBJECT)
|
||||
var insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
var jumpIndex = getTargetIndexReversed(Opcode.INVOKE_VIRTUAL)
|
||||
var jumpIndex = getTargetIndexReversedOrThrow(Opcode.INVOKE_VIRTUAL)
|
||||
|
||||
hook(insertIndex, insertRegister, jumpIndex)
|
||||
|
||||
@ -151,7 +151,7 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
?: throw PatchException("Could not find constructor method")
|
||||
|
||||
constructorMethod.apply {
|
||||
val syntheticIndex = getTargetIndexReversed(Opcode.NEW_INSTANCE)
|
||||
val syntheticIndex = getTargetIndexReversedOrThrow(Opcode.NEW_INSTANCE)
|
||||
val syntheticClass =
|
||||
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
|
||||
|
||||
@ -162,7 +162,7 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
|
||||
syntheticMethod.apply {
|
||||
val speedOverlayValueIndex =
|
||||
indexOfFirstInstruction { (this as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() }
|
||||
indexOfFirstInstructionOrThrow { (this as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() }
|
||||
val speedOverlayValueRegister =
|
||||
getInstruction<OneRegisterInstruction>(speedOverlayValueIndex).registerA
|
||||
|
||||
@ -173,13 +173,13 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
|
||||
insertIndex = getTargetIndexWithMethodReferenceNameReversed(
|
||||
insertIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow(
|
||||
speedOverlayValueIndex,
|
||||
"removeCallbacks"
|
||||
) + 1
|
||||
insertRegister =
|
||||
getInstruction<FiveRegisterInstruction>(insertIndex - 1).registerC
|
||||
jumpIndex = getTargetIndex(speedOverlayValueIndex, Opcode.RETURN_VOID) + 1
|
||||
jumpIndex = getTargetIndexOrThrow(speedOverlayValueIndex, Opcode.RETURN_VOID) + 1
|
||||
hook(insertIndex, insertRegister, jumpIndex)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user