mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 23:54:33 +02:00
refactor(Utils): appropriate message is displayed in the exception when the index is not found
This commit is contained in:
parent
27c40de516
commit
e1f3da76c4
@ -14,8 +14,8 @@ import app.revanced.patches.music.utils.integrations.Constants.ACCOUNT_CLASS_DES
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -43,8 +43,8 @@ object AccountComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
MenuEntryFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val textIndex = getTargetIndexWithMethodReferenceName("setText")
|
||||
val viewIndex = getTargetIndexWithMethodReferenceName("addView")
|
||||
val textIndex = getTargetIndexWithMethodReferenceNameOrThrow("setText")
|
||||
val viewIndex = getTargetIndexWithMethodReferenceNameOrThrow("addView")
|
||||
|
||||
val textRegister = getInstruction<FiveRegisterInstruction>(textIndex).registerD
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(viewIndex).registerD
|
||||
@ -64,9 +64,9 @@ object AccountComponentsPatch : BaseBytecodePatch(
|
||||
AccountSwitcherAccessibilityLabelFingerprint.resultOrThrow().let { result ->
|
||||
result.mutableMethod.apply {
|
||||
|
||||
val textColorIndex = getTargetIndexWithMethodReferenceName("setTextColor")
|
||||
val textColorIndex = getTargetIndexWithMethodReferenceNameOrThrow("setTextColor")
|
||||
val setVisibilityIndex =
|
||||
getTargetIndexWithMethodReferenceName(textColorIndex, "setVisibility")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow(textColorIndex, "setVisibility")
|
||||
val textViewInstruction =
|
||||
getInstruction<FiveRegisterInstruction>(setVisibilityIndex)
|
||||
|
||||
@ -99,7 +99,7 @@ object AccountComponentsPatch : BaseBytecodePatch(
|
||||
TermsOfServiceFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex =
|
||||
getTargetIndexWithReference("/PrivacyTosFooter;->setVisibility(I)V")
|
||||
getTargetIndexWithReferenceOrThrow("/PrivacyTosFooter;->setVisibility(I)V")
|
||||
val visibilityRegister =
|
||||
getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
|
||||
|
@ -15,10 +15,10 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.LikeDis
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.music.video.information.VideoInformationPatch
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
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
|
||||
@ -48,7 +48,7 @@ object ActionBarComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
|
||||
// hook download button
|
||||
val addViewIndex = getTargetIndexWithMethodReferenceName("addView")
|
||||
val addViewIndex = getTargetIndexWithMethodReferenceNameOrThrow("addView")
|
||||
val addViewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(addViewIndex).registerD
|
||||
|
||||
@ -58,13 +58,13 @@ object ActionBarComponentsPatch : BaseBytecodePatch(
|
||||
)
|
||||
|
||||
// hide action button label
|
||||
val noLabelIndex = indexOfFirstInstruction {
|
||||
val noLabelIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = (this as? ReferenceInstruction)?.reference.toString()
|
||||
opcode == Opcode.INVOKE_DIRECT
|
||||
&& reference.endsWith("<init>(Landroid/content/Context;)V")
|
||||
&& !reference.contains("Lcom/google/android/libraries/youtube/common/ui/YouTubeButton;")
|
||||
} - 2
|
||||
val replaceIndex = indexOfFirstInstruction {
|
||||
val replaceIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = (this as? ReferenceInstruction)?.reference.toString()
|
||||
opcode == Opcode.INVOKE_DIRECT
|
||||
&& reference.endsWith("Lcom/google/android/libraries/youtube/common/ui/YouTubeButton;-><init>(Landroid/content/Context;)V")
|
||||
@ -83,10 +83,10 @@ object ActionBarComponentsPatch : BaseBytecodePatch(
|
||||
removeInstruction(replaceIndex)
|
||||
|
||||
// hide action button
|
||||
val hasNextIndex = getTargetIndexWithMethodReferenceName("hasNext")
|
||||
val hasNextIndex = getTargetIndexWithMethodReferenceNameOrThrow("hasNext")
|
||||
val freeRegister = min(implementation!!.registerCount - parameters.size - 2, 15)
|
||||
|
||||
val spannedIndex = getTargetIndexWithReference(")Landroid/text/Spanned;")
|
||||
val spannedIndex = getTargetIndexWithReferenceOrThrow(")Landroid/text/Spanned;")
|
||||
val spannedRegister =
|
||||
getInstruction<FiveRegisterInstruction>(spannedIndex).registerC
|
||||
val spannedReference = getInstruction<ReferenceInstruction>(spannedIndex).reference
|
||||
|
@ -25,8 +25,8 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.Interst
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -139,15 +139,15 @@ object AdsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val constIndex =
|
||||
getWideLiteralInstructionIndex(SharedResourceIdPatch.PrivacyTosFooter)
|
||||
val walkerIndex = getTargetIndex(constIndex + 2, Opcode.INVOKE_VIRTUAL)
|
||||
val viewIndex = getTargetIndex(constIndex, Opcode.IGET_OBJECT)
|
||||
val walkerIndex = getTargetIndexOrThrow(constIndex + 2, Opcode.INVOKE_VIRTUAL)
|
||||
val viewIndex = getTargetIndexOrThrow(constIndex, Opcode.IGET_OBJECT)
|
||||
val viewReference =
|
||||
getInstruction<ReferenceInstruction>(viewIndex).reference.toString()
|
||||
|
||||
val walkerMethod = getWalkerMethod(context, walkerIndex)
|
||||
walkerMethod.apply {
|
||||
val insertIndex = getTargetIndexWithReference(viewReference)
|
||||
val nullCheckIndex = getTargetIndex(insertIndex - 1, Opcode.IF_NEZ)
|
||||
val insertIndex = getTargetIndexWithReferenceOrThrow(viewReference)
|
||||
val nullCheckIndex = getTargetIndexOrThrow(insertIndex - 1, Opcode.IF_NEZ)
|
||||
val nullCheckRegister =
|
||||
getInstruction<OneRegisterInstruction>(nullCheckIndex).registerA
|
||||
|
||||
|
@ -25,11 +25,11 @@ import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
|
||||
import app.revanced.patches.music.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
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.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -98,7 +98,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
val constIndex =
|
||||
getWideLiteralInstructionIndex(SharedResourceIdPatch.TrimSilenceSwitch)
|
||||
val onCheckedChangedListenerIndex =
|
||||
getTargetIndex(constIndex, Opcode.INVOKE_DIRECT)
|
||||
getTargetIndexOrThrow(constIndex, Opcode.INVOKE_DIRECT)
|
||||
val onCheckedChangedListenerReference =
|
||||
getInstruction<ReferenceInstruction>(onCheckedChangedListenerIndex).reference
|
||||
val onCheckedChangedListenerDefiningClass =
|
||||
@ -108,7 +108,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
onCheckedChangedListenerClass.methods.find { method -> method.name == "onCheckedChanged" }
|
||||
?.apply {
|
||||
val walkerIndex = indexOfFirstInstruction {
|
||||
val walkerIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference =
|
||||
((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||
|
||||
@ -118,7 +118,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
&& reference.parameterTypes[0] == "Z"
|
||||
}
|
||||
getWalkerMethod(context, walkerIndex).apply {
|
||||
val insertIndex = getTargetIndex(Opcode.MOVE_RESULT)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.MOVE_RESULT)
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
@ -142,7 +142,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
MenuItemFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val freeIndex = getTargetIndex(Opcode.OR_INT_LIT16)
|
||||
val freeIndex = getTargetIndexOrThrow(Opcode.OR_INT_LIT16)
|
||||
val textViewIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val imageViewIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
@ -153,7 +153,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
val imageViewRegister =
|
||||
getInstruction<OneRegisterInstruction>(imageViewIndex).registerA
|
||||
|
||||
val enumIndex = indexOfFirstInstruction {
|
||||
val enumIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_STATIC
|
||||
&& (this as? ReferenceInstruction)?.reference.toString()
|
||||
.contains("(I)L")
|
||||
@ -176,7 +176,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
TouchOutsideFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val setOnClickListenerIndex =
|
||||
getTargetIndexWithMethodReferenceName("setOnClickListener")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow("setOnClickListener")
|
||||
val setOnClickListenerRegister =
|
||||
getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||
|
||||
@ -190,7 +190,7 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
EndButtonsContainerFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = getWideLiteralInstructionIndex(EndButtonsContainer)
|
||||
val targetIndex = getTargetIndex(startIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetIndex = getTargetIndexOrThrow(startIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -33,8 +33,8 @@ import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.shared.voicesearch.VoiceSearchUtils.patchXml
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -186,7 +186,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
if (SettingsPatch.upward0642) {
|
||||
TopBarMenuItemImageViewFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(TopBarMenuItemImageView)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -237,7 +237,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
parentResult.mutableMethod.apply {
|
||||
val constIndex =
|
||||
getWideLiteralInstructionIndex(SharedResourceIdPatch.MusicTasteBuilderShelf)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -284,7 +284,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
)
|
||||
SearchBarFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val setVisibilityIndex = getTargetIndexWithMethodReferenceName("setVisibility")
|
||||
val setVisibilityIndex = getTargetIndexWithMethodReferenceNameOrThrow("setVisibility")
|
||||
val setVisibilityInstruction =
|
||||
getInstruction<FiveRegisterInstruction>(setVisibilityIndex)
|
||||
|
||||
|
@ -9,7 +9,7 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -28,7 +28,7 @@ object OldStyleLibraryShelfPatch : BaseBytecodePatch(
|
||||
BrowseIdFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex = getStringInstructionIndex("FEmusic_offline")
|
||||
val targetIndex = getTargetIndexReversed(stringIndex, Opcode.IGET_OBJECT)
|
||||
val targetIndex = getTargetIndexReversedOrThrow(stringIndex, Opcode.IGET_OBJECT)
|
||||
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
|
@ -12,10 +12,10 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DES
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
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
|
||||
@ -42,15 +42,15 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
|
||||
PendingIntentReceiverFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = getStringInstructionIndex("YTM Dislike")
|
||||
val onClickRelayIndex = getTargetIndexReversed(startIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val onClickRelayIndex = getTargetIndexReversedOrThrow(startIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val onClickRelayMethod = getWalkerMethod(context, onClickRelayIndex)
|
||||
|
||||
onClickRelayMethod.apply {
|
||||
val onClickMethodIndex = getTargetIndexReversed(Opcode.INVOKE_DIRECT)
|
||||
val onClickMethodIndex = getTargetIndexReversedOrThrow(Opcode.INVOKE_DIRECT)
|
||||
val onClickMethod = getWalkerMethod(context, onClickMethodIndex)
|
||||
|
||||
onClickMethod.apply {
|
||||
val onClickIndex = indexOfFirstInstruction {
|
||||
val onClickIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference =
|
||||
((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||
|
||||
@ -69,7 +69,7 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
|
||||
|
||||
DislikeButtonOnClickListenerFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val onClickIndex = getTargetIndexWithReference(onClickReference.toString())
|
||||
val onClickIndex = getTargetIndexWithReferenceOrThrow(onClickReference.toString())
|
||||
injectCall(onClickIndex)
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ object DislikeRedirectionPatch : BaseBytecodePatch(
|
||||
}
|
||||
|
||||
private fun MutableMethod.injectCall(onClickIndex: Int) {
|
||||
val targetIndex = getTargetIndexReversed(onClickIndex, Opcode.IF_EQZ)
|
||||
val targetIndex = getTargetIndexReversedOrThrow(onClickIndex, Opcode.IF_EQZ)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructionsWithLabels(
|
||||
|
@ -12,8 +12,8 @@ import app.revanced.patches.music.utils.integrations.Constants.NAVIGATION_CLASS_
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -64,7 +64,7 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
|
||||
TabLayoutTextFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(SharedResourceIdPatch.Text1)
|
||||
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
|
||||
|
||||
@ -98,9 +98,9 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val enumIndex = it.scanResult.patternScanResult!!.startIndex + 3
|
||||
val enumRegister = getInstruction<OneRegisterInstruction>(enumIndex).registerA
|
||||
val insertEnumIndex = getTargetIndex(Opcode.AND_INT_LIT8) - 2
|
||||
val insertEnumIndex = getTargetIndexOrThrow(Opcode.AND_INT_LIT8) - 2
|
||||
|
||||
val pivotTabIndex = getTargetIndexWithMethodReferenceName("getVisibility")
|
||||
val pivotTabIndex = getTargetIndexWithMethodReferenceNameOrThrow("getVisibility")
|
||||
val pivotTabRegister = getInstruction<Instruction35c>(pivotTabIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
|
@ -51,9 +51,9 @@ import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceType
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
@ -133,8 +133,8 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
colorMathPlayerMethodParameter = parameters
|
||||
|
||||
val relativeIndex = it.scanResult.patternScanResult!!.endIndex + 1
|
||||
val invokeVirtualIndex = getTargetIndex(relativeIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val iGetIndex = getTargetIndex(relativeIndex, Opcode.IGET)
|
||||
val invokeVirtualIndex = getTargetIndexOrThrow(relativeIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val iGetIndex = getTargetIndexOrThrow(relativeIndex, Opcode.IGET)
|
||||
|
||||
colorMathPlayerInvokeVirtualReference =
|
||||
getInstruction<ReferenceInstruction>(invokeVirtualIndex).reference
|
||||
@ -142,11 +142,11 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
getInstruction<ReferenceInstruction>(iGetIndex).reference
|
||||
|
||||
// black player background
|
||||
val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT)
|
||||
val invokeDirectIndex = getTargetIndexOrThrow(Opcode.INVOKE_DIRECT)
|
||||
val targetMethod = getWalkerMethod(context, invokeDirectIndex)
|
||||
|
||||
targetMethod.apply {
|
||||
val insertIndex = getTargetIndex(0, Opcode.IF_NE)
|
||||
val insertIndex = getTargetIndexOrThrow(0, Opcode.IF_NE)
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
@ -161,7 +161,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
parentResult.mutableMethod.apply {
|
||||
val colorGreyIndex = getWideLiteralInstructionIndex(ColorGrey)
|
||||
val iPutIndex = getTargetIndex(colorGreyIndex, Opcode.IPUT)
|
||||
val iPutIndex = getTargetIndexOrThrow(colorGreyIndex, Opcode.IPUT)
|
||||
|
||||
colorMathPlayerIPutReference =
|
||||
getInstruction<ReferenceInstruction>(iPutIndex).reference
|
||||
@ -175,10 +175,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 3
|
||||
|
||||
val invokeDirectIndex = getTargetIndexReversed(
|
||||
implementation!!.instructions.size - 1,
|
||||
Opcode.INVOKE_DIRECT
|
||||
)
|
||||
val invokeDirectIndex = getTargetIndexReversedOrThrow(Opcode.INVOKE_DIRECT)
|
||||
val invokeDirectReference =
|
||||
getInstruction<ReferenceInstruction>(invokeDirectIndex).reference
|
||||
|
||||
@ -339,9 +336,9 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
reversed: Boolean
|
||||
): Reference {
|
||||
val targetIndex = if (reversed)
|
||||
getTargetIndexReversed(swipeToDismissWidgetIndex, opcode)
|
||||
getTargetIndexReversedOrThrow(swipeToDismissWidgetIndex, opcode)
|
||||
else
|
||||
getTargetIndex(swipeToDismissWidgetIndex, opcode)
|
||||
getTargetIndexOrThrow(swipeToDismissWidgetIndex, opcode)
|
||||
|
||||
return getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
}
|
||||
@ -369,7 +366,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex =
|
||||
getStringInstructionIndex("INTERACTION_LOGGING_GESTURE_TYPE_SWIPE")
|
||||
val sPutObjectIndex = getTargetIndex(stringIndex, Opcode.SPUT_OBJECT)
|
||||
val sPutObjectIndex = getTargetIndexOrThrow(stringIndex, Opcode.SPUT_OBJECT)
|
||||
|
||||
swipeToDismissSGetObjectReference =
|
||||
getInstruction<ReferenceInstruction>(sPutObjectIndex).reference
|
||||
@ -407,7 +404,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
dismissBehaviorMethod.apply {
|
||||
val insertIndex =
|
||||
getTargetIndexWithFieldReferenceType("Ljava/util/concurrent/atomic/AtomicBoolean;")
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Ljava/util/concurrent/atomic/AtomicBoolean;")
|
||||
val primaryRegister =
|
||||
getInstruction<TwoRegisterInstruction>(insertIndex).registerB
|
||||
val secondaryRegister = primaryRegister + 1
|
||||
@ -530,7 +527,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
SwitchToggleColorFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT)
|
||||
val invokeDirectIndex = getTargetIndexOrThrow(Opcode.INVOKE_DIRECT)
|
||||
val walkerMethod = getWalkerMethod(context, invokeDirectIndex)
|
||||
|
||||
walkerMethod.addInstructions(
|
||||
@ -563,7 +560,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
AudioVideoSwitchToggleFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(AudioVideoSwitchToggle)
|
||||
val viewIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val viewIndex = getTargetIndexOrThrow(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val viewRegister = getInstruction<OneRegisterInstruction>(viewIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -659,7 +656,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val imageViewIndex =
|
||||
getTargetIndexWithFieldReferenceType("Landroid/widget/ImageView;")
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Landroid/widget/ImageView;")
|
||||
|
||||
val shuffleReference1 = getInstruction<ReferenceInstruction>(startIndex).reference
|
||||
val shuffleReference2 =
|
||||
@ -833,7 +830,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
val miniPlayerPlayPauseReplayButtonRegister =
|
||||
getInstruction<OneRegisterInstruction>(miniPlayerPlayPauseReplayButtonIndex).registerA
|
||||
val findViewByIdIndex =
|
||||
getTargetIndex(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_VIRTUAL)
|
||||
getTargetIndexOrThrow(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val parentViewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(findViewByIdIndex).registerC
|
||||
|
||||
@ -856,7 +853,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
val constRegister =
|
||||
getInstruction<OneRegisterInstruction>(miniPlayerPlayPauseReplayButtonIndex).registerA
|
||||
val findViewByIdIndex =
|
||||
getTargetIndex(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_VIRTUAL)
|
||||
getTargetIndexOrThrow(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val findViewByIdRegister =
|
||||
getInstruction<FiveRegisterInstruction>(findViewByIdIndex).registerC
|
||||
|
||||
@ -874,7 +871,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
val miniPlayerPlayPauseReplayButtonIndex =
|
||||
getWideLiteralInstructionIndex(MiniPlayerPlayPauseReplayButton)
|
||||
val invokeStaticIndex =
|
||||
getTargetIndex(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_STATIC)
|
||||
getTargetIndexOrThrow(miniPlayerPlayPauseReplayButtonIndex, Opcode.INVOKE_STATIC)
|
||||
val viewArrayRegister = getInstruction<FiveRegisterInstruction>(invokeStaticIndex).registerC
|
||||
|
||||
addInstructions(
|
||||
@ -892,7 +889,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
fieldName: String
|
||||
) {
|
||||
val startIndex = getStringInstructionIndex(intentString)
|
||||
val onClickIndex = getTargetIndexReversed(startIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val onClickIndex = getTargetIndexReversedOrThrow(startIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val onClickReference = getInstruction<ReferenceInstruction>(onClickIndex).reference
|
||||
val onClickReferenceDefiningClass = (onClickReference as MethodReference).definingClass
|
||||
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.music.layout.header.ChangeHeaderPatch
|
||||
import app.revanced.patches.music.utils.fix.header.fingerprints.HeaderSwitchConfigFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -33,7 +33,7 @@ object RestoreOldHeaderPatch : BytecodePatch(
|
||||
HeaderSwitchConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex =
|
||||
getTargetIndex(getWideLiteralInstructionIndex(45617851), Opcode.MOVE_RESULT)
|
||||
getTargetIndexOrThrow(getWideLiteralInstructionIndex(45617851), Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.LikeFi
|
||||
import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.RemoveLikeFingerprint
|
||||
import app.revanced.patches.music.utils.returnyoutubedislike.fingerprints.TextComponentFingerprint
|
||||
import app.revanced.patches.music.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
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
|
||||
@ -53,7 +53,7 @@ object ReturnYouTubeDislikeBytecodePatch : BytecodePatch(
|
||||
|
||||
TextComponentFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = indexOfFirstInstruction {
|
||||
val insertIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_STATIC
|
||||
&& (this as ReferenceInstruction).reference.toString()
|
||||
.endsWith("Ljava/lang/CharSequence;")
|
||||
|
@ -17,7 +17,7 @@ import app.revanced.patches.music.utils.settings.fingerprints.PreferenceFingerpr
|
||||
import app.revanced.patches.music.utils.settings.fingerprints.SettingsHeadersFragmentFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.SharedSettingFingerprint
|
||||
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -52,7 +52,7 @@ object SettingsBytecodePatch : BytecodePatch(
|
||||
*/
|
||||
SharedSettingFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex = getTargetIndex(Opcode.CONST_STRING)
|
||||
val stringIndex = getTargetIndexOrThrow(Opcode.CONST_STRING)
|
||||
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
|
||||
|
||||
replaceInstruction(
|
||||
|
@ -14,8 +14,8 @@ import app.revanced.patches.music.utils.sponsorblock.fingerprints.MusicPlaybackC
|
||||
import app.revanced.patches.music.utils.sponsorblock.fingerprints.SeekbarOnDrawFingerprint
|
||||
import app.revanced.patches.music.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.music.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversedOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -70,7 +70,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
)
|
||||
|
||||
// Set seekbar thickness
|
||||
val roundIndex = getTargetIndexWithMethodReferenceName("round") + 1
|
||||
val roundIndex = getTargetIndexWithMethodReferenceNameOrThrow("round") + 1
|
||||
val roundRegister = getInstruction<OneRegisterInstruction>(roundIndex).registerA
|
||||
addInstruction(
|
||||
roundIndex + 1,
|
||||
@ -79,7 +79,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
)
|
||||
|
||||
// Draw segment
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceNameReversed("drawCircle")
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow("drawCircle")
|
||||
val drawCircleInstruction = getInstruction<FiveRegisterInstruction>(drawCircleIndex)
|
||||
addInstruction(
|
||||
drawCircleIndex,
|
||||
@ -114,7 +114,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
)
|
||||
|
||||
// Draw segment
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceName("drawCircle")
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceNameOrThrow("drawCircle")
|
||||
val drawCircleInstruction = getInstruction<FiveRegisterInstruction>(drawCircleIndex)
|
||||
addInstruction(
|
||||
drawCircleIndex,
|
||||
|
@ -23,8 +23,8 @@ import app.revanced.patches.music.video.information.fingerprints.VideoQualityLis
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoQualityTextFingerprint
|
||||
import app.revanced.patches.music.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.addFieldAndInstructions
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversedOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
@ -138,8 +138,8 @@ object VideoInformationPatch : BytecodePatch(
|
||||
)
|
||||
VideoLengthFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversed("invalidate")
|
||||
val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversed(
|
||||
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow("invalidate")
|
||||
val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversedOrThrow(
|
||||
invalidateIndex + 1,
|
||||
"Landroid/graphics/Rect;"
|
||||
)
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.patches.music.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.music.video.playback.fingerprints.PlaybackSpeedBottomSheetFingerprint
|
||||
import app.revanced.patches.music.video.playback.fingerprints.UserQualityChangeFingerprint
|
||||
import app.revanced.patches.music.video.videoid.VideoIdPatch
|
||||
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
|
||||
@ -52,7 +52,7 @@ object VideoPlaybackPatch : BaseBytecodePatch(
|
||||
it.mutableClass.methods.find { method -> method.name == "onItemClick" }
|
||||
|
||||
onItemClickMethod?.apply {
|
||||
val targetIndex = getTargetIndex(Opcode.IGET)
|
||||
val targetIndex = getTargetIndexOrThrow(Opcode.IGET)
|
||||
val targetRegister =
|
||||
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
|
@ -12,8 +12,8 @@ import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACK
|
||||
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceNameOrThrow
|
||||
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
|
||||
@ -42,7 +42,7 @@ object AdsPatch : BaseBytecodePatch(
|
||||
// region Filter promoted ads (does not work in popular or latest feed)
|
||||
AdPostFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithFieldReferenceName("children")
|
||||
val targetIndex = getTargetIndexWithFieldReferenceNameOrThrow("children")
|
||||
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
@ -59,7 +59,7 @@ object AdsPatch : BaseBytecodePatch(
|
||||
// By removing the appending instruction no ad posts gets appended to the feed.
|
||||
NewAdPostFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceName("add")
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("add")
|
||||
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
|
||||
|
||||
replaceInstruction(
|
||||
|
@ -9,10 +9,10 @@ import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACK
|
||||
import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceName
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -41,19 +41,19 @@ object RecentlyVisitedShelfPatch : BaseBytecodePatch(
|
||||
it.mutableClass.methods.find { method -> method.name == "<init>" }
|
||||
?.apply {
|
||||
val recentlyVisitedFieldIndex =
|
||||
getTargetIndexWithFieldReferenceName("RECENTLY_VISITED")
|
||||
getTargetIndexWithFieldReferenceNameOrThrow("RECENTLY_VISITED")
|
||||
val recentlyVisitedObjectIndex =
|
||||
getTargetIndex(recentlyVisitedFieldIndex, Opcode.IPUT_OBJECT)
|
||||
getTargetIndexOrThrow(recentlyVisitedFieldIndex, Opcode.IPUT_OBJECT)
|
||||
recentlyVisitedReference =
|
||||
getInstruction<ReferenceInstruction>(recentlyVisitedObjectIndex).reference
|
||||
} ?: throw PatchException("Constructor method not found!")
|
||||
|
||||
it.mutableMethod.apply {
|
||||
val recentlyVisitedObjectIndex =
|
||||
getTargetIndexWithReference(recentlyVisitedReference.toString())
|
||||
getTargetIndexWithReferenceOrThrow(recentlyVisitedReference.toString())
|
||||
arrayOf(
|
||||
getTargetIndex(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC),
|
||||
getTargetIndexReversed(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC)
|
||||
getTargetIndexOrThrow(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC),
|
||||
getTargetIndexReversedOrThrow(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC)
|
||||
).forEach { staticIndex ->
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(staticIndex + 1).registerA
|
||||
|
@ -15,7 +15,7 @@ import app.revanced.patches.reddit.utils.settings.fingerprints.AcknowledgementsL
|
||||
import app.revanced.patches.reddit.utils.settings.fingerprints.OssLicensesMenuActivityOnCreateFingerprint
|
||||
import app.revanced.patches.reddit.utils.settings.fingerprints.SettingsStatusLoadFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.SharedSettingFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -49,7 +49,7 @@ object SettingsBytecodePatch : BytecodePatch(
|
||||
*/
|
||||
SharedSettingFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val stringIndex = getTargetIndex(Opcode.CONST_STRING)
|
||||
val stringIndex = getTargetIndexOrThrow(Opcode.CONST_STRING)
|
||||
val stringRegister = getInstruction<OneRegisterInstruction>(stringIndex).registerA
|
||||
|
||||
replaceInstruction(
|
||||
|
@ -12,11 +12,11 @@ import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint
|
||||
import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint
|
||||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH
|
||||
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.indexOfFirstInstruction
|
||||
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.FiveRegisterInstruction
|
||||
@ -37,7 +37,7 @@ abstract class BaseAdsPatch(
|
||||
override fun execute(context: BytecodeContext) {
|
||||
MusicAdsFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||
|
||||
opcode == Opcode.INVOKE_VIRTUAL
|
||||
@ -112,7 +112,7 @@ abstract class BaseAdsPatch(
|
||||
// Find the instruction whose name is "show" in [MethodReference] and click the 'AlertDialog.BUTTON_POSITIVE' button.
|
||||
// In this case, an instruction for 'getButton' must be added to smali, not in integrations
|
||||
// (This custom dialog cannot be cast to [AlertDialog] or [Dialog])
|
||||
val dialogIndex = getTargetIndexWithMethodReferenceName("show")
|
||||
val dialogIndex = getTargetIndexWithMethodReferenceNameOrThrow("show")
|
||||
val dialogReference = getInstruction<ReferenceInstruction>(dialogIndex).reference
|
||||
val dialogDefiningClass = (dialogReference as MethodReference).definingClass
|
||||
val getButtonMethod = context.findClass(dialogDefiningClass)!!
|
||||
@ -123,7 +123,7 @@ abstract class BaseAdsPatch(
|
||||
val getButtonCall =
|
||||
dialogDefiningClass + "->" + getButtonMethod.name + "(I)Landroid/widget/Button;"
|
||||
val dialogRegister = getInstruction<FiveRegisterInstruction>(dialogIndex).registerC
|
||||
val freeIndex = getTargetIndex(dialogIndex, Opcode.IF_EQZ)
|
||||
val freeIndex = getTargetIndexOrThrow(dialogIndex, Opcode.IF_EQZ)
|
||||
val freeRegister = getInstruction<OneRegisterInstruction>(freeIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
|
@ -8,10 +8,10 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.shared.customspeed.fingerprints.SpeedArrayGeneratorFingerprint
|
||||
import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFallBackFingerprint
|
||||
import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceType
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
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.NarrowLiteralInstruction
|
||||
@ -39,7 +39,7 @@ abstract class BaseCustomPlaybackSpeedPatch(
|
||||
"""
|
||||
)
|
||||
|
||||
val sizeIndex = getTargetIndexWithMethodReferenceName("size") + 1
|
||||
val sizeIndex = getTargetIndexWithMethodReferenceNameOrThrow("size") + 1
|
||||
val sizeRegister = getInstruction<OneRegisterInstruction>(sizeIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
@ -49,7 +49,7 @@ abstract class BaseCustomPlaybackSpeedPatch(
|
||||
"""
|
||||
)
|
||||
|
||||
val arrayIndex = getTargetIndexWithFieldReferenceType("[F")
|
||||
val arrayIndex = getTargetIndexWithFieldReferenceTypeOrThrow("[F")
|
||||
val arrayRegister = getInstruction<OneRegisterInstruction>(arrayIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
@ -71,9 +71,9 @@ abstract class BaseCustomPlaybackSpeedPatch(
|
||||
).forEach {
|
||||
it.mutableMethod.apply {
|
||||
val limiterMinConstIndex =
|
||||
indexOfFirstInstruction { (this as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() }
|
||||
indexOfFirstInstructionOrThrow { (this as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() }
|
||||
val limiterMaxConstIndex =
|
||||
getTargetIndex(limiterMinConstIndex + 1, Opcode.CONST_HIGH16)
|
||||
getTargetIndexOrThrow(limiterMinConstIndex + 1, Opcode.CONST_HIGH16)
|
||||
|
||||
val limiterMinConstDestination =
|
||||
getInstruction<OneRegisterInstruction>(limiterMinConstIndex).registerA
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.dialog.fingerprints.CreateDialogFingerprint
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -22,7 +22,7 @@ abstract class BaseViewerDiscretionDialogPatch(
|
||||
}
|
||||
) {
|
||||
private fun MutableMethod.invoke(isAgeVerified: Boolean) {
|
||||
val showDialogIndex = getTargetIndexWithMethodReferenceName("show")
|
||||
val showDialogIndex = getTargetIndexWithMethodReferenceNameOrThrow("show")
|
||||
val dialogRegister = getInstruction<FiveRegisterInstruction>(showDialogIndex).registerC
|
||||
|
||||
val methodName =
|
||||
|
@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.drawable.fingerprints.DrawableFingerprint
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversedOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
@ -17,7 +17,7 @@ object DrawableColorPatch : BytecodePatch(
|
||||
|
||||
DrawableFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
insertMethod = this
|
||||
insertIndex = getTargetIndexWithMethodReferenceNameReversed("setColor")
|
||||
insertIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow("setColor")
|
||||
insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ import app.revanced.patches.shared.litho.fingerprints.LithoFilterPatchConstructo
|
||||
import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint
|
||||
import app.revanced.patches.shared.litho.fingerprints.SetByteBufferFingerprint
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceType
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
@ -56,7 +56,7 @@ object LithoFilterPatch : BytecodePatch(
|
||||
|
||||
SetByteBufferFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.IF_EQZ) + 1
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.IF_EQZ) + 1
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
@ -136,17 +136,17 @@ object LithoFilterPatch : BytecodePatch(
|
||||
}
|
||||
|
||||
val stringBuilderIndex =
|
||||
getTargetIndexWithFieldReferenceType("Ljava/lang/StringBuilder;")
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Ljava/lang/StringBuilder;")
|
||||
val stringBuilderRegister =
|
||||
getInstruction<TwoRegisterInstruction>(stringBuilderIndex).registerA
|
||||
|
||||
val emptyStringIndex = getStringInstructionIndex("")
|
||||
|
||||
val identifierIndex = getTargetIndexReversed(emptyStringIndex, Opcode.IPUT_OBJECT)
|
||||
val identifierIndex = getTargetIndexReversedOrThrow(emptyStringIndex, Opcode.IPUT_OBJECT)
|
||||
val identifierRegister =
|
||||
getInstruction<TwoRegisterInstruction>(identifierIndex).registerA
|
||||
|
||||
val objectIndex = getTargetIndex(emptyStringIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val objectIndex = getTargetIndexOrThrow(emptyStringIndex, Opcode.INVOKE_VIRTUAL)
|
||||
val objectRegister = getInstruction<BuilderInstruction35c>(objectIndex).registerC
|
||||
|
||||
val insertIndex = stringBuilderIndex + 1
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import kotlin.properties.Delegates
|
||||
@ -37,7 +37,7 @@ abstract class BaseMainActivityResolvePatch(
|
||||
|
||||
// set onBackPressed method
|
||||
onBackPressedMethod = getMethod("onBackPressed")
|
||||
onBackPressedMethodIndex = onBackPressedMethod.getTargetIndex(Opcode.RETURN_VOID)
|
||||
onBackPressedMethodIndex = onBackPressedMethod.getTargetIndexOrThrow(Opcode.RETURN_VOID)
|
||||
}
|
||||
|
||||
fun injectConstructorMethodCall(classDescriptor: String, methodDescriptor: String) =
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.opus.fingerprints.CodecReferenceFingerprint
|
||||
import app.revanced.patches.shared.opus.fingerprints.CodecSelectorFingerprint
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@ -31,7 +31,7 @@ abstract class BaseOpusCodecsPatch(
|
||||
|
||||
CodecReferenceFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithReference("Ljava/util/Set;")
|
||||
val targetIndex = getTargetIndexWithReferenceOrThrow("Ljava/util/Set;")
|
||||
opusCodecReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint.indexOfReleaseInstruction
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
@ -20,7 +20,7 @@ abstract class BaseSpoofAppVersionPatch(
|
||||
|
||||
CreatePlayerRequestBodyWithModelFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val versionIndex = indexOfReleaseInstruction(this) + 1
|
||||
val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT)
|
||||
val insertIndex = getTargetIndexReversedOrThrow(versionIndex, Opcode.IPUT_OBJECT)
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
|
@ -33,11 +33,11 @@ import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CaptionToggleContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
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
|
||||
@ -114,7 +114,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
CaptionsButtonFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val insertIndex = getTargetIndexReversed(constIndex, Opcode.IF_EQZ)
|
||||
val insertIndex = getTargetIndexReversedOrThrow(constIndex, Opcode.IF_EQZ)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
@ -127,7 +127,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
CaptionsButtonSyntheticFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(CaptionToggleContainer)
|
||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetIndex = getTargetIndexOrThrow(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -190,7 +190,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
ElementParserFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val insertIndex = indexOfFirstInstruction {
|
||||
val insertIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||
|
||||
reference?.parameterTypes?.size == 1
|
||||
@ -198,7 +198,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
&& reference.returnType.startsWith("L")
|
||||
}
|
||||
|
||||
val objectIndex = getTargetIndex(Opcode.MOVE_OBJECT)
|
||||
val objectIndex = getTargetIndexOrThrow(Opcode.MOVE_OBJECT)
|
||||
val objectRegister = getInstruction<TwoRegisterInstruction>(objectIndex).registerA
|
||||
|
||||
val jumpIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
@ -257,7 +257,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
val iteratorRegister =
|
||||
getInstruction<FiveRegisterInstruction>(iteratorIndex).registerC
|
||||
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||
|
||||
opcode == Opcode.INVOKE_INTERFACE
|
||||
@ -265,7 +265,7 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
||||
&& reference.parameterTypes == channelTabBuilderMethod.parameterTypes
|
||||
}
|
||||
|
||||
val objectIndex = getTargetIndexReversed(targetIndex, Opcode.IGET_OBJECT)
|
||||
val objectIndex = getTargetIndexReversedOrThrow(targetIndex, Opcode.IGET_OBJECT)
|
||||
val objectInstruction = getInstruction<TwoRegisterInstruction>(objectIndex)
|
||||
val objectReference = getInstruction<ReferenceInstruction>(objectIndex).reference
|
||||
|
||||
|
@ -7,8 +7,8 @@ import app.revanced.patches.youtube.general.audiotracks.fingerprints.StreamingMo
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -28,16 +28,16 @@ object AudioTracksPatch : BaseBytecodePatch(
|
||||
|
||||
StreamingModelBuilderFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val formatStreamModelIndex = indexOfFirstInstruction {
|
||||
val formatStreamModelIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.CHECK_CAST
|
||||
&& (this as ReferenceInstruction).reference.toString() == "Lcom/google/android/libraries/youtube/innertube/model/media/FormatStreamModel;"
|
||||
}
|
||||
val arrayListIndex = getTargetIndexWithReference(
|
||||
val arrayListIndex = getTargetIndexWithReferenceOrThrow(
|
||||
formatStreamModelIndex,
|
||||
"Ljava/util/List;->add(Ljava/lang/Object;)Z"
|
||||
)
|
||||
val insertIndex =
|
||||
getTargetIndexWithReference(arrayListIndex, "Ljava/util/List;->isEmpty()Z") + 2
|
||||
getTargetIndexWithReferenceOrThrow(arrayListIndex, "Ljava/util/List;->isEmpty()Z") + 2
|
||||
|
||||
val formatStreamModelRegister =
|
||||
getInstruction<OneRegisterInstruction>(formatStreamModelIndex).registerA
|
||||
|
@ -27,8 +27,8 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.viewgroup.ViewGroupMarginLayoutParamsHookPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceType
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
@ -173,7 +173,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
AccountSwitcherAccessibilityLabelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(AccountSwitcherAccessibility)
|
||||
val insertIndex = getTargetIndex(constIndex, Opcode.IF_EQZ)
|
||||
val insertIndex = getTargetIndexOrThrow(constIndex, Opcode.IF_EQZ)
|
||||
val setVisibilityIndex =
|
||||
getTargetIndexWithMethodReferenceName(insertIndex, "setVisibility")
|
||||
val visibilityRegister =
|
||||
@ -195,7 +195,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
SettingsMenuFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex =
|
||||
getTargetIndexWithFieldReferenceType("Landroid/support/v7/widget/RecyclerView;")
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Landroid/support/v7/widget/RecyclerView;")
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -229,7 +229,7 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
TooltipContentFullscreenFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val literalIndex = getWideLiteralInstructionIndex(45384061)
|
||||
val targetIndex = getTargetIndex(literalIndex, Opcode.MOVE_RESULT)
|
||||
val targetIndex = getTargetIndexOrThrow(literalIndex, Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -10,8 +10,8 @@ import app.revanced.patches.youtube.general.layoutswitch.fingerprints.LayoutSwit
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -34,7 +34,7 @@ object LayoutSwitchPatch : BaseBytecodePatch(
|
||||
|
||||
GetFormFactorFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val jumpIndex = getTargetIndexReversed(Opcode.SGET_OBJECT)
|
||||
val jumpIndex = getTargetIndexReversedOrThrow(Opcode.SGET_OBJECT)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
0, """
|
||||
@ -56,7 +56,7 @@ object LayoutSwitchPatch : BaseBytecodePatch(
|
||||
|
||||
LayoutSwitchFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.IF_NEZ)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.IF_NEZ)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_D
|
||||
import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
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
|
||||
@ -82,7 +82,7 @@ object NavigationBarComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
PivotBarSetTextFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceName("setText")
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("setText")
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
|
@ -39,10 +39,10 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||
import app.revanced.patches.youtube.utils.toolbar.ToolBarHookPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.doRecursively
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexWithReferenceReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceReversedOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.literalInstructionHook
|
||||
@ -129,7 +129,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
||||
)
|
||||
DrawerContentViewFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("addView")
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("addView")
|
||||
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
|
||||
addInstruction(
|
||||
@ -145,7 +145,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
||||
setActionBarRingoMutableClass.methods.first { method ->
|
||||
MethodUtil.isConstructor(method)
|
||||
}.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.IPUT_BOOLEAN)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.IPUT_BOOLEAN)
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -278,12 +278,12 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
||||
CreateSearchSuggestionsFingerprint.resultOrThrow().let { result ->
|
||||
result.mutableMethod.apply {
|
||||
val relativeIndex = getWideLiteralInstructionIndex(40)
|
||||
val replaceIndex = getTargetIndexWithReferenceReversed(
|
||||
val replaceIndex = getTargetIndexWithReferenceReversedOrThrow(
|
||||
relativeIndex,
|
||||
"Landroid/widget/ImageView;->setVisibility(I)V"
|
||||
) - 1
|
||||
|
||||
val jumpIndex = getTargetIndexWithReference(
|
||||
val jumpIndex = getTargetIndexWithReferenceOrThrow(
|
||||
relativeIndex,
|
||||
"Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;"
|
||||
) + 4
|
||||
@ -333,7 +333,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val setVisibilityIndex =
|
||||
getTargetIndexWithMethodReferenceName(startIndex, "setVisibility")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow(startIndex, "setVisibility")
|
||||
val setVisibilityInstruction =
|
||||
getInstruction<FiveRegisterInstruction>(setVisibilityIndex)
|
||||
|
||||
@ -349,7 +349,7 @@ object ToolBarComponentsPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = getWideLiteralInstructionIndex(VoiceSearch)
|
||||
val setOnClickListenerIndex =
|
||||
getTargetIndexWithMethodReferenceName(startIndex, "setOnClickListener")
|
||||
getTargetIndexWithMethodReferenceNameOrThrow(startIndex, "setOnClickListener")
|
||||
val viewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(setOnClickListenerIndex).registerC
|
||||
|
||||
|
@ -8,7 +8,7 @@ import app.revanced.patches.youtube.misc.openlinksdirectly.fingerprints.OpenLink
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
||||
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
|
||||
@ -32,7 +32,7 @@ object OpenLinksDirectlyPatch : BaseBytecodePatch(
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("parse")
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("parse")
|
||||
val insertRegister =
|
||||
getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelR
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.RightComment
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
@ -96,7 +96,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
val constIndex = getWideLiteralInstructionIndex(ReelRightDislikeIcon)
|
||||
val constRegister = getInstruction<OneRegisterInstruction>(constIndex).registerA
|
||||
|
||||
val jumpIndex = getTargetIndex(constIndex, Opcode.CONST_CLASS) + 2
|
||||
val jumpIndex = getTargetIndexOrThrow(constIndex, Opcode.CONST_CLASS) + 2
|
||||
|
||||
addInstructionsWithLabels(
|
||||
constIndex + 1, """
|
||||
@ -117,7 +117,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getWideLiteralInstructionIndex(ReelRightLikeIcon)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
val jumpIndex = getTargetIndex(insertIndex, Opcode.CONST_CLASS) + 2
|
||||
val jumpIndex = getTargetIndexOrThrow(insertIndex, Opcode.CONST_CLASS) + 2
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex + 1, """
|
||||
@ -139,8 +139,8 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
val targetIndex = getWideLiteralInstructionIndex(ReelForcedMuteButton)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
val insertIndex = getTargetIndexReversed(targetIndex, Opcode.IF_EQZ)
|
||||
val jumpIndex = getTargetIndex(targetIndex, Opcode.GOTO)
|
||||
val insertIndex = getTargetIndexReversedOrThrow(targetIndex, Opcode.IF_EQZ)
|
||||
val jumpIndex = getTargetIndexOrThrow(targetIndex, Opcode.GOTO)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
@ -157,7 +157,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
(instruction.value as? WideLiteralInstruction)?.wideLiteral == ReelPivotButton
|
||||
}
|
||||
val targetIndex = constCalls.elementAt(constCalls.size - 1).index
|
||||
val insertIndex = getTargetIndexReversed(targetIndex, Opcode.INVOKE_STATIC) + 1
|
||||
val insertIndex = getTargetIndexReversedOrThrow(targetIndex, Opcode.INVOKE_STATIC) + 1
|
||||
if (insertIndex == 0)
|
||||
throw PatchException("insert index not found")
|
||||
|
||||
@ -267,7 +267,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
TextComponentSpecFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex =
|
||||
getTargetIndexWithReference("Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;")
|
||||
getTargetIndexWithReferenceOrThrow("Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;")
|
||||
|
||||
val charSequenceRegister =
|
||||
getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
@ -318,9 +318,9 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(id)
|
||||
val insertIndex = if (reversed)
|
||||
getTargetIndexReversed(constIndex, Opcode.CHECK_CAST)
|
||||
getTargetIndexReversedOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
else
|
||||
getTargetIndex(constIndex, Opcode.CHECK_CAST)
|
||||
getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -338,7 +338,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
||||
resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val constIndex = getWideLiteralInstructionIndex(id)
|
||||
val insertIndex = getTargetIndex(constIndex, Opcode.CHECK_CAST)
|
||||
val insertIndex = getTargetIndexOrThrow(constIndex, Opcode.CHECK_CAST)
|
||||
|
||||
hideButtons(insertIndex, descriptor)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import app.revanced.patches.youtube.shorts.components.fingerprints.RenderBottomN
|
||||
import app.revanced.patches.youtube.shorts.components.fingerprints.SetPivotBarFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -51,7 +51,7 @@ object ShortsNavigationBarPatch : BytecodePatch(
|
||||
|
||||
BottomNavigationBarFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceName("findViewById") + 1
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("findViewById") + 1
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.containsReferenceInstructionIndex
|
||||
import app.revanced.util.findMutableMethodOf
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
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
|
||||
@ -45,7 +45,7 @@ object ShortsRepeatPatch : BaseBytecodePatch(
|
||||
val endScreenStringIndex =
|
||||
getStringInstructionIndex("REEL_LOOP_BEHAVIOR_END_SCREEN")
|
||||
val endScreenReferenceIndex =
|
||||
getTargetIndex(endScreenStringIndex, Opcode.SPUT_OBJECT)
|
||||
getTargetIndexOrThrow(endScreenStringIndex, Opcode.SPUT_OBJECT)
|
||||
val endScreenReference =
|
||||
getInstruction<ReferenceInstruction>(endScreenReferenceIndex).reference.toString()
|
||||
|
||||
@ -74,7 +74,7 @@ object ShortsRepeatPatch : BaseBytecodePatch(
|
||||
fieldName: String
|
||||
) {
|
||||
val stringIndex = getStringInstructionIndex(enumName)
|
||||
val insertIndex = getTargetIndex(stringIndex, Opcode.SPUT_OBJECT)
|
||||
val insertIndex = getTargetIndexOrThrow(stringIndex, Opcode.SPUT_OBJECT)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -14,7 +14,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DE
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
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
|
||||
@ -70,12 +70,11 @@ object ResumingShortsOnStartupPatch : BaseBytecodePatch(
|
||||
|
||||
UserWasInShortsFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val listenableInstructionIndex = indexOfFirstInstruction {
|
||||
val listenableInstructionIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_INTERFACE &&
|
||||
getReference<MethodReference>()?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" &&
|
||||
getReference<MethodReference>()?.name == "isDone"
|
||||
}
|
||||
if (listenableInstructionIndex < 0) throw PatchException("Could not find instruction index")
|
||||
val originalInstructionRegister =
|
||||
getInstruction<FiveRegisterInstruction>(listenableInstructionIndex).registerC
|
||||
val freeRegister =
|
||||
|
@ -17,7 +17,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.PATCH_STATUS_CL
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import app.revanced.util.updatePatchStatus
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -64,7 +64,7 @@ object CastButtonPatch : BytecodePatch(
|
||||
|
||||
internal fun hookPlayerButton(context: BytecodeContext) {
|
||||
playerButtonMethod.apply {
|
||||
val index = getTargetIndexWithMethodReferenceName("setVisibility")
|
||||
val index = getTargetIndexWithMethodReferenceNameOrThrow("setVisibility")
|
||||
val instruction = getInstruction<FiveRegisterInstruction>(index)
|
||||
val viewRegister = instruction.registerC
|
||||
val visibilityRegister = instruction.registerD
|
||||
@ -84,7 +84,7 @@ object CastButtonPatch : BytecodePatch(
|
||||
|
||||
internal fun hookToolBarButton(context: BytecodeContext) {
|
||||
toolbarMenuItemInitializeMethod.apply {
|
||||
val index = getTargetIndexWithMethodReferenceName("setShowAsAction") + 1
|
||||
val index = getTargetIndexWithMethodReferenceNameOrThrow("setShowAsAction") + 1
|
||||
|
||||
addInstruction(
|
||||
index,
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.misc.backgroundplayback.BackgroundPlaybackPatch
|
||||
import app.revanced.patches.youtube.utils.fix.cairo.fingerprints.CarioFragmentConfigFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -33,7 +33,7 @@ object CairoSettingsPatch : BytecodePatch(
|
||||
CarioFragmentConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex =
|
||||
getTargetIndex(getWideLiteralInstructionIndex(45532100), Opcode.MOVE_RESULT)
|
||||
getTargetIndexOrThrow(getWideLiteralInstructionIndex(45532100), Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints.FullscreenButtonPositionFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints.FullscreenButtonViewStubFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -33,7 +33,7 @@ object FullscreenButtonViewStubPatch : BytecodePatch(
|
||||
).forEach { (fingerprint, literalValue) ->
|
||||
fingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndex(
|
||||
val targetIndex = getTargetIndexOrThrow(
|
||||
getWideLiteralInstructionIndex(literalValue.toLong()),
|
||||
Opcode.MOVE_RESULT
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.utils.fix.litho.fingerprints.ObfuscationConfigFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -27,7 +27,7 @@ object ConversionContextObfuscationPatch : BytecodePatch(
|
||||
ObfuscationConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex =
|
||||
getTargetIndex(getWideLiteralInstructionIndex(45631264), Opcode.MOVE_RESULT)
|
||||
getTargetIndexOrThrow(getWideLiteralInstructionIndex(45631264), Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.utils.fix.shortsplayback.fingerprints.ShortsPlaybackFingerprint
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -28,7 +28,7 @@ object ShortsPlaybackPatch : BytecodePatch(
|
||||
ShortsPlaybackFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex =
|
||||
getTargetIndex(getWideLiteralInstructionIndex(45387052), Opcode.MOVE_RESULT)
|
||||
getTargetIndexOrThrow(getWideLiteralInstructionIndex(45387052), Opcode.MOVE_RESULT)
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
|
@ -8,8 +8,8 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.RemoveOnLayoutChangeListenerFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -36,9 +36,9 @@ object SuggestedVideoEndScreenPatch : BytecodePatch(
|
||||
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
|
||||
|
||||
walkerIndex.apply {
|
||||
val invokeInterfaceIndex = getTargetIndex(Opcode.INVOKE_INTERFACE)
|
||||
val invokeInterfaceIndex = getTargetIndexOrThrow(Opcode.INVOKE_INTERFACE)
|
||||
val iGetObjectIndex =
|
||||
getTargetIndexReversed(invokeInterfaceIndex, Opcode.IGET_OBJECT)
|
||||
getTargetIndexReversedOrThrow(invokeInterfaceIndex, Opcode.IGET_OBJECT)
|
||||
|
||||
val invokeInterfaceReference =
|
||||
getInstruction<ReferenceInstruction>(invokeInterfaceIndex).reference
|
||||
|
@ -16,8 +16,8 @@ import app.revanced.patches.youtube.utils.playercontrols.fingerprints.MotionEven
|
||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityEntityModelFingerprint
|
||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -56,7 +56,7 @@ object PlayerControlsPatch : BytecodePatch(
|
||||
)
|
||||
PlayerButtonsVisibilityFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val viewIndex = getTargetIndex(Opcode.INVOKE_INTERFACE)
|
||||
val viewIndex = getTargetIndexOrThrow(Opcode.INVOKE_INTERFACE)
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(viewIndex).registerD
|
||||
|
||||
addInstruction(
|
||||
@ -88,7 +88,7 @@ object PlayerControlsPatch : BytecodePatch(
|
||||
YouTubeControlsOverlayFingerprint.resultOrThrow().mutableClass
|
||||
)
|
||||
MotionEventFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("setTranslationY") + 1
|
||||
val insertIndex = getTargetIndexWithMethodReferenceNameOrThrow("setTranslationY") + 1
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
|
@ -9,7 +9,7 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityEntityModelFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@ -31,7 +31,7 @@ object PlayerControlsVisibilityHookPatch : BytecodePatch(
|
||||
val staticReference = getInstruction<ReferenceInstruction>(startIndex + 1).reference
|
||||
|
||||
it.mutableClass.methods.find { method -> method.name == "<init>" }?.apply {
|
||||
val targetIndex = getTargetIndex(Opcode.IPUT_OBJECT)
|
||||
val targetIndex = getTargetIndexOrThrow(Opcode.IPUT_OBJECT)
|
||||
val targetRegister =
|
||||
getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
|
@ -17,8 +17,8 @@ import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFinge
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.addFieldAndInstructions
|
||||
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.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -90,7 +90,7 @@ object PlayerTypeHookPatch : BytecodePatch(
|
||||
|
||||
targetClass.methods.find { method -> method.name == "<init>" }
|
||||
?.apply {
|
||||
val browseIdFieldIndex = getTargetIndex(Opcode.IPUT_OBJECT)
|
||||
val browseIdFieldIndex = getTargetIndexOrThrow(Opcode.IPUT_OBJECT)
|
||||
val browseIdFieldName =
|
||||
(getInstruction<ReferenceInstruction>(browseIdFieldIndex).reference as FieldReference).name
|
||||
|
||||
@ -128,7 +128,7 @@ object PlayerTypeHookPatch : BytecodePatch(
|
||||
// Insert before the first ViewGroup method call after inflating,
|
||||
// so this works regardless which layout is used.
|
||||
ActionBarSearchResultsFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val instructionIndex = getTargetIndexWithMethodReferenceName("setLayoutDirection")
|
||||
val instructionIndex = getTargetIndexWithMethodReferenceNameOrThrow("setLayoutDirection")
|
||||
val viewRegister = getInstruction<FiveRegisterInstruction>(instructionIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
|
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.ReturnYouT
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.youtube.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceType
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@ -71,12 +71,12 @@ object ReturnYouTubeDislikePatch : BaseBytecodePatch(
|
||||
TextComponentContextFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val conversionContextFieldIndex =
|
||||
getTargetIndexWithFieldReferenceType("Ljava/util/Map;") - 1
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Ljava/util/Map;") - 1
|
||||
val conversionContextFieldReference =
|
||||
getInstruction<ReferenceInstruction>(conversionContextFieldIndex).reference
|
||||
|
||||
val charSequenceIndex =
|
||||
getTargetIndexWithFieldReferenceType("Ljava/util/BitSet;") - 1
|
||||
getTargetIndexWithFieldReferenceTypeOrThrow("Ljava/util/BitSet;") - 1
|
||||
val charSequenceRegister =
|
||||
getInstruction<TwoRegisterInstruction>(charSequenceIndex).registerA
|
||||
val freeRegister =
|
||||
|
@ -17,8 +17,8 @@ import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fin
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberMeasureTextParentFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberSetterFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -60,7 +60,7 @@ object ReturnYouTubeDislikeRollingNumberPatch : BytecodePatch(
|
||||
|
||||
rollingNumberClass.methods.find { method -> method.name == "<init>" }
|
||||
?.apply {
|
||||
val rollingNumberFieldIndex = getTargetIndex(Opcode.IPUT_OBJECT)
|
||||
val rollingNumberFieldIndex = getTargetIndexOrThrow(Opcode.IPUT_OBJECT)
|
||||
charSequenceFieldReference =
|
||||
getInstruction<ReferenceInstruction>(rollingNumberFieldIndex).reference
|
||||
} ?: throw PatchException("RollingNumberClass not found!")
|
||||
@ -103,7 +103,7 @@ object ReturnYouTubeDislikeRollingNumberPatch : BytecodePatch(
|
||||
"""
|
||||
)
|
||||
|
||||
val ifGeIndex = getTargetIndex(Opcode.IF_GE)
|
||||
val ifGeIndex = getTargetIndexOrThrow(Opcode.IF_GE)
|
||||
val ifGeInstruction = getInstruction<TwoRegisterInstruction>(ifGeIndex)
|
||||
|
||||
removeInstruction(ifGeIndex)
|
||||
@ -153,7 +153,7 @@ object ReturnYouTubeDislikeRollingNumberPatch : BytecodePatch(
|
||||
realTimeUpdateTextViewMethod
|
||||
).forEach { insertMethod ->
|
||||
insertMethod.apply {
|
||||
val setTextIndex = getTargetIndexWithMethodReferenceName("setText")
|
||||
val setTextIndex = getTargetIndexWithMethodReferenceNameOrThrow("setText")
|
||||
val textViewRegister =
|
||||
getInstruction<FiveRegisterInstruction>(setTextIndex).registerC
|
||||
val textSpanRegister =
|
||||
|
@ -12,9 +12,9 @@ import app.revanced.patches.youtube.utils.fingerprints.TextComponentSpecFingerpr
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexWithReference
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithReferenceOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
@ -36,8 +36,8 @@ object ReturnYouTubeDislikeShortsPatch : BytecodePatch(
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
|
||||
val isDisLikesBooleanIndex = getTargetIndexReversed(startIndex, Opcode.IGET_BOOLEAN)
|
||||
val textViewFieldIndex = getTargetIndexReversed(startIndex, Opcode.IGET_OBJECT)
|
||||
val isDisLikesBooleanIndex = getTargetIndexReversedOrThrow(startIndex, Opcode.IGET_BOOLEAN)
|
||||
val textViewFieldIndex = getTargetIndexReversedOrThrow(startIndex, Opcode.IGET_OBJECT)
|
||||
|
||||
// If the field is true, the TextView is for a dislike button.
|
||||
val isDisLikesBooleanReference =
|
||||
@ -49,7 +49,7 @@ object ReturnYouTubeDislikeShortsPatch : BytecodePatch(
|
||||
// Check if the hooked TextView object is that of the dislike button.
|
||||
// If RYD is disabled, or the TextView object is not that of the dislike button, the execution flow is not interrupted.
|
||||
// Otherwise, the TextView object is modified, and the execution flow is interrupted to prevent it from being changed afterward.
|
||||
val insertIndex = getTargetIndex(Opcode.CHECK_CAST) + 1
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.CHECK_CAST) + 1
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
@ -72,7 +72,7 @@ object ReturnYouTubeDislikeShortsPatch : BytecodePatch(
|
||||
TextComponentSpecFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex =
|
||||
getTargetIndexWithReference("Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;")
|
||||
getTargetIndexWithReferenceOrThrow("Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;")
|
||||
|
||||
val charSequenceRegister =
|
||||
getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
|
@ -19,10 +19,10 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.Inset
|
||||
import app.revanced.patches.youtube.utils.sponsorblock.fingerprints.RectangleFieldInvalidatorFingerprint
|
||||
import app.revanced.patches.youtube.utils.sponsorblock.fingerprints.SegmentPlaybackControllerFingerprint
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversed
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexWithFieldReferenceTypeReversedOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameReversedOrThrow
|
||||
import app.revanced.util.getWideLiteralInstructionIndex
|
||||
import app.revanced.util.resultOrThrow
|
||||
import app.revanced.util.updatePatchStatus
|
||||
@ -80,7 +80,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
|
||||
SeekbarOnDrawFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
// Get left and right of seekbar rectangle
|
||||
val moveObjectIndex = getTargetIndex(Opcode.MOVE_OBJECT_FROM16)
|
||||
val moveObjectIndex = getTargetIndexOrThrow(Opcode.MOVE_OBJECT_FROM16)
|
||||
|
||||
addInstruction(
|
||||
moveObjectIndex + 1,
|
||||
@ -89,7 +89,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
)
|
||||
|
||||
// Set seekbar thickness
|
||||
val roundIndex = getTargetIndexWithMethodReferenceName("round") + 1
|
||||
val roundIndex = getTargetIndexWithMethodReferenceNameOrThrow("round") + 1
|
||||
val roundRegister = getInstruction<OneRegisterInstruction>(roundIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -99,7 +99,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
)
|
||||
|
||||
// Draw segment
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceNameReversed("drawCircle")
|
||||
val drawCircleIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow("drawCircle")
|
||||
val drawCircleInstruction = getInstruction<FiveRegisterInstruction>(drawCircleIndex)
|
||||
addInstruction(
|
||||
drawCircleIndex,
|
||||
@ -116,7 +116,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
// Append timestamp
|
||||
TotalTimeFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceName("getString") + 1
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("getString") + 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
@ -132,7 +132,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
YouTubeControlsOverlayFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getWideLiteralInstructionIndex(InsetOverlayViewLayout)
|
||||
val checkCastIndex = getTargetIndex(targetIndex, Opcode.CHECK_CAST)
|
||||
val checkCastIndex = getTargetIndexOrThrow(targetIndex, Opcode.CHECK_CAST)
|
||||
val targetRegister =
|
||||
getInstruction<OneRegisterInstruction>(checkCastIndex).registerA
|
||||
|
||||
@ -146,8 +146,8 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
||||
// Replace strings
|
||||
RectangleFieldInvalidatorFingerprint.resultOrThrow().let { result ->
|
||||
result.mutableMethod.apply {
|
||||
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversed("invalidate")
|
||||
val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversed(
|
||||
val invalidateIndex = getTargetIndexWithMethodReferenceNameReversedOrThrow("invalidate")
|
||||
val rectangleIndex = getTargetIndexWithFieldReferenceTypeReversedOrThrow(
|
||||
invalidateIndex + 1,
|
||||
"Landroid/graphics/Rect;"
|
||||
)
|
||||
|
@ -34,10 +34,10 @@ import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHoo
|
||||
import app.revanced.patches.youtube.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.addFieldAndInstructions
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexReversed
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.getTargetIndexReversedOrThrow
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -192,11 +192,10 @@ object VideoInformationPatch : BytecodePatch(
|
||||
|
||||
PlaybackInitializationFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_DIRECT
|
||||
&& getReference<MethodReference>()?.returnType == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||
} + 1
|
||||
if (targetIndex == 0) throw PatchException("Could not find instruction index.")
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -213,11 +212,10 @@ object VideoInformationPatch : BytecodePatch(
|
||||
|
||||
VideoIdFingerprintBackgroundPlay.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_INTERFACE
|
||||
&& getReference<MethodReference>()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||
}
|
||||
if (targetIndex < 0) throw PatchException("Could not find instruction index.")
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
@ -232,11 +230,10 @@ object VideoInformationPatch : BytecodePatch(
|
||||
|
||||
VideoIdFingerprintShorts.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_INTERFACE
|
||||
&& getReference<MethodReference>()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||
}
|
||||
if (targetIndex < 0) throw PatchException("Could not find instruction index.")
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
@ -281,10 +278,10 @@ object VideoInformationPatch : BytecodePatch(
|
||||
OnPlaybackSpeedItemClickFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
speedSelectionInsertMethod = this
|
||||
val speedSelectionValueInstructionIndex = getTargetIndex(Opcode.IGET)
|
||||
val speedSelectionValueInstructionIndex = getTargetIndexOrThrow(Opcode.IGET)
|
||||
|
||||
val setPlaybackSpeedContainerClassFieldIndex =
|
||||
getTargetIndexReversed(speedSelectionValueInstructionIndex, Opcode.IGET_OBJECT)
|
||||
getTargetIndexReversedOrThrow(speedSelectionValueInstructionIndex, Opcode.IGET_OBJECT)
|
||||
val setPlaybackSpeedContainerClassFieldReference =
|
||||
getInstruction<ReferenceInstruction>(setPlaybackSpeedContainerClassFieldIndex).reference.toString()
|
||||
|
||||
@ -455,12 +452,11 @@ object VideoInformationPatch : BytecodePatch(
|
||||
|
||||
private fun MethodFingerprint.getMethodName(returnType: String): String {
|
||||
resultOrThrow().mutableMethod.apply {
|
||||
val targetIndex = indexOfFirstInstruction {
|
||||
val targetIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.INVOKE_INTERFACE
|
||||
&& getReference<MethodReference>()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR
|
||||
&& getReference<MethodReference>()?.returnType == returnType
|
||||
}
|
||||
if (targetIndex < 0) throw PatchException("Could not find instruction index.")
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
return "invoke-interface {v${REGISTER_PLAYER_RESPONSE_MODEL}}, $targetReference"
|
||||
|
@ -34,7 +34,9 @@ import app.revanced.patches.youtube.video.videoid.VideoIdPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getStringInstructionIndex
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexOrThrow
|
||||
import app.revanced.util.indexOfFirstInstruction
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import app.revanced.util.updatePatchStatus
|
||||
@ -133,7 +135,7 @@ object VideoPlaybackPatch : BaseBytecodePatch(
|
||||
speedSelectionInsertMethod
|
||||
).forEach {
|
||||
it.apply {
|
||||
val speedSelectionValueInstructionIndex = getTargetIndex(Opcode.IGET)
|
||||
val speedSelectionValueInstructionIndex = getTargetIndexOrThrow(Opcode.IGET)
|
||||
val speedSelectionValueRegister =
|
||||
getInstruction<TwoRegisterInstruction>(speedSelectionValueInstructionIndex).registerA
|
||||
|
||||
@ -206,7 +208,7 @@ object VideoPlaybackPatch : BaseBytecodePatch(
|
||||
|
||||
QualityMenuViewInflateFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.CHECK_CAST)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.CHECK_CAST)
|
||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
@ -219,10 +221,10 @@ object VideoPlaybackPatch : BaseBytecodePatch(
|
||||
it.mutableClass.methods.find { method -> method.name == "onItemClick" }
|
||||
|
||||
onItemClickMethod?.apply {
|
||||
val insertIndex = getTargetIndex(Opcode.IGET_OBJECT)
|
||||
val insertIndex = getTargetIndexOrThrow(Opcode.IGET_OBJECT)
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
val jumpIndex = indexOfFirstInstruction {
|
||||
val jumpIndex = indexOfFirstInstructionOrThrow {
|
||||
opcode == Opcode.IGET_OBJECT
|
||||
&& this.getReference<FieldReference>()?.type == videoQualityClass
|
||||
}
|
||||
|
@ -340,10 +340,81 @@ inline fun <reified T : Reference> Instruction.getReference() =
|
||||
fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) =
|
||||
this.implementation!!.instructions.indexOfFirst(predicate)
|
||||
|
||||
fun MutableMethod.getTargetIndex(opcode: Opcode) = getTargetIndex(0, opcode)
|
||||
fun MutableMethod.getTargetIndexOrThrow(opcode: Opcode) =
|
||||
getTargetIndexOrThrow(0, opcode)
|
||||
|
||||
fun MutableMethod.getTargetIndexReversed(opcode: Opcode) =
|
||||
getTargetIndexReversed(implementation!!.instructions.size - 1, opcode)
|
||||
fun MutableMethod.getTargetIndexOrThrow(startIndex: Int, opcode: Opcode) =
|
||||
checkIndex(getTargetIndex(startIndex, opcode), startIndex, opcode)
|
||||
|
||||
fun MutableMethod.getTargetIndexReversedOrThrow(opcode: Opcode) =
|
||||
getTargetIndexReversedOrThrow(implementation!!.instructions.lastIndex, opcode)
|
||||
|
||||
fun MutableMethod.getTargetIndexReversedOrThrow(startIndex: Int, opcode: Opcode) =
|
||||
checkIndex(getTargetIndexReversed(startIndex, opcode), startIndex, opcode)
|
||||
|
||||
fun Method.getTargetIndexWithFieldReferenceNameOrThrow(filedName: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceName(filedName), 0, filedName)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameOrThrow(startIndex: Int, filedName: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceName(startIndex, filedName), startIndex, filedName)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameReversedOrThrow(returnType: String) =
|
||||
getTargetIndexWithFieldReferenceNameReversedOrThrow(implementation!!.instructions.lastIndex, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameReversedOrThrow(startIndex: Int, returnType: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceNameReversed(startIndex, returnType), startIndex, returnType)
|
||||
|
||||
fun Method.getTargetIndexWithFieldReferenceTypeOrThrow(returnType: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceType(returnType), 0, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceTypeOrThrow(startIndex: Int, returnType: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceType(startIndex, returnType), startIndex, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceTypeReversedOrThrow(returnType: String) =
|
||||
getTargetIndexWithFieldReferenceTypeReversedOrThrow(implementation!!.instructions.lastIndex, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceTypeReversedOrThrow(startIndex: Int, returnType: String) =
|
||||
checkIndex(getTargetIndexWithFieldReferenceTypeReversed(startIndex, returnType), startIndex, returnType)
|
||||
|
||||
fun Method.getTargetIndexWithMethodReferenceNameOrThrow(methodName: String) =
|
||||
checkIndex(getTargetIndexWithMethodReferenceName(methodName), 0, methodName)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithMethodReferenceNameOrThrow(startIndex: Int, methodName: String) =
|
||||
checkIndex(getTargetIndexWithMethodReferenceName(startIndex, methodName), startIndex, methodName)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithMethodReferenceNameReversedOrThrow(methodName: String) =
|
||||
getTargetIndexWithMethodReferenceNameReversedOrThrow(implementation!!.instructions.lastIndex, methodName)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithMethodReferenceNameReversedOrThrow(startIndex: Int, methodName: String) =
|
||||
checkIndex(getTargetIndexWithMethodReferenceNameReversed(startIndex, methodName), startIndex, methodName)
|
||||
|
||||
fun Method.getTargetIndexWithReferenceOrThrow(reference: String) =
|
||||
checkIndex(getTargetIndexWithReference(reference), 0, reference)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithReferenceOrThrow(startIndex: Int, reference: String) =
|
||||
checkIndex(getTargetIndexWithReference(startIndex, reference), startIndex, reference)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithReferenceReversedOrThrow(reference: String) =
|
||||
getTargetIndexWithReferenceReversedOrThrow(implementation!!.instructions.lastIndex, reference)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithReferenceReversedOrThrow(startIndex: Int, reference: String) =
|
||||
checkIndex(getTargetIndexWithReferenceReversed(startIndex, reference), startIndex, reference)
|
||||
|
||||
fun checkIndex(index: Int, startIndex: Int, opcode: Opcode): Int {
|
||||
if (index < 0) {
|
||||
throw PatchException("Target index not found. startIndex: $startIndex, opcode: $opcode")
|
||||
}
|
||||
return index
|
||||
}
|
||||
|
||||
fun checkIndex(index: Int, startIndex: Int, name: String): Int {
|
||||
if (index < 0) {
|
||||
throw PatchException("Target index not found. startIndex: $startIndex, name: $name")
|
||||
}
|
||||
return index
|
||||
}
|
||||
|
||||
fun MutableMethod.getTargetIndex(opcode: Opcode) = getTargetIndex(0, opcode)
|
||||
|
||||
fun MutableMethod.getTargetIndex(startIndex: Int, opcode: Opcode) =
|
||||
implementation!!.instructions.let {
|
||||
@ -352,6 +423,9 @@ fun MutableMethod.getTargetIndex(startIndex: Int, opcode: Opcode) =
|
||||
}
|
||||
}
|
||||
|
||||
fun MutableMethod.getTargetIndexReversed(opcode: Opcode) =
|
||||
getTargetIndexReversed(implementation!!.instructions.size - 1, opcode)
|
||||
|
||||
fun MutableMethod.getTargetIndexReversed(startIndex: Int, opcode: Opcode): Int {
|
||||
for (index in startIndex downTo 0) {
|
||||
if (getInstruction(index).opcode != opcode)
|
||||
@ -368,16 +442,16 @@ fun Method.getTargetIndexWithFieldReferenceName(filedName: String) = implementat
|
||||
}
|
||||
} ?: -1
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameReversed(returnType: String) =
|
||||
getTargetIndexWithFieldReferenceTypeReversed(implementation!!.instructions.size - 1, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceName(startIndex: Int, filedName: String) =
|
||||
implementation!!.instructions.let {
|
||||
startIndex + it.subList(startIndex, it.size - 1).indexOfFirst { instruction ->
|
||||
startIndex + it.subList(startIndex, it.lastIndex).indexOfFirst { instruction ->
|
||||
instruction.getReference<FieldReference>()?.name == filedName
|
||||
}
|
||||
}
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameReversed(returnType: String) =
|
||||
getTargetIndexWithFieldReferenceTypeReversed(implementation!!.instructions.lastIndex, returnType)
|
||||
|
||||
fun MutableMethod.getTargetIndexWithFieldReferenceNameReversed(
|
||||
startIndex: Int,
|
||||
filedName: String
|
||||
|
Loading…
x
Reference in New Issue
Block a user