diff --git a/build.gradle.kts b/build.gradle.kts index ad15946fa..b98a3e141 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,7 @@ repositories { } dependencies { - implementation("app.revanced:revanced-patcher:10.0.0") + implementation("app.revanced:revanced-patcher:11.0.0") implementation("app.revanced:multidexlib2:2.5.3-a3836654") // Required for meta implementation("com.google.code.gson:gson:2.10.1") diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index 37b9ffcee..df0f5205d 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -1,7 +1,7 @@ package app.revanced.extensions import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.util.proxy.mutableTypes.MutableClass diff --git a/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt index 94f41526c..0bac5f550 100644 --- a/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -28,8 +28,8 @@ class ProUnlockPatch : BytecodePatch( val registerIndex = result.scanResult.patternScanResult!!.endIndex - 1 result.mutableMethod.apply { - val register = instruction(registerIndex).registerA - addInstructions( + val register = getInstruction(registerIndex).registerA + addInstruction( result.scanResult.patternScanResult!!.endIndex, """ const/4 v$register, 0x1 diff --git a/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt index 9905df4de..ab4597e98 100644 --- a/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -22,15 +22,13 @@ class UnlockProPatch : BytecodePatch( listOf(IsPremiumPurchasedFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - IsPremiumPurchasedFingerprint.result?.let { - it.mutableMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """ - ) - } ?: return IsPremiumPurchasedFingerprint.toErrorResult() + IsPremiumPurchasedFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) ?: return IsPremiumPurchasedFingerprint.toErrorResult() return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/citra/misc/premium/patch/PremiumUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/citra/misc/premium/patch/PremiumUnlockPatch.kt index 10d4eebea..a83b5ba55 100644 --- a/src/main/kotlin/app/revanced/patches/citra/misc/premium/patch/PremiumUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/citra/misc/premium/patch/PremiumUnlockPatch.kt @@ -3,14 +3,14 @@ package app.revanced.patches.citra.misc.premium.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.citra.misc.premium.annotations.PremiumUnlockCompatbility import app.revanced.patches.citra.misc.premium.fingerprints.PremiumUnlockFingerprint diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt index 0c763d628..0e22b04aa 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt index 4995e0705..4a3878c8a 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/hexeditor/ad/patch/HexEditorAdsPatch.kt b/src/main/kotlin/app/revanced/patches/hexeditor/ad/patch/HexEditorAdsPatch.kt index 67bc0940d..7dcf13c96 100644 --- a/src/main/kotlin/app/revanced/patches/hexeditor/ad/patch/HexEditorAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/hexeditor/ad/patch/HexEditorAdsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/patch/UnlockProPatch.kt index a4a2d4f99..25d289b58 100644 --- a/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/patch/UnlockProPatch.kt @@ -4,8 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/patch/RootDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/patch/RootDetectionPatch.kt index 41f5929de..c0a451d02 100644 --- a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/patch/RootDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/patch/RootDetectionPatch.kt @@ -1,8 +1,10 @@ package app.revanced.patches.idaustria.detection.root.patch -import app.revanced.patcher.annotation.* +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -19,7 +21,7 @@ class RootDetectionPatch : BytecodePatch( listOf(RootDetectionFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - RootDetectionFingerprint.result!!.mutableMethod.addInstructions(0, "return-void") + RootDetectionFingerprint.result!!.mutableMethod.addInstruction(0, "return-void") return PatchResultSuccess() } } diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/patch/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/patch/SpoofSignaturePatch.kt index 71d713763..a5dad6cca 100644 --- a/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/patch/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/patch/SpoofSignaturePatch.kt @@ -1,8 +1,10 @@ package app.revanced.patches.idaustria.detection.signature.patch -import app.revanced.patcher.annotation.* +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt b/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt index 7c809f6f8..ba63db767 100644 --- a/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt b/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt index 6ba2dd958..321f78e12 100644 --- a/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt @@ -3,9 +3,9 @@ package app.revanced.patches.instagram.patches.ads.timeline.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -55,8 +55,8 @@ class HideTimelineAdsPatch : BytecodePatch( val scanStart = scanResult.patternScanResult!!.startIndex val jumpIndex = scanStart - 1 - val mediaInstanceRegister = mutableMethod.instruction(scanStart).registerC - val freeRegister = mutableMethod.instruction(jumpIndex).registerA + val mediaInstanceRegister = mutableMethod.getInstruction(scanStart).registerC + val freeRegister = mutableMethod.getInstruction(jumpIndex).registerA val returnFalseLabel = "an_ad" @@ -77,14 +77,12 @@ class HideTimelineAdsPatch : BytecodePatch( val insertIndex = scanStart + 3 - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( insertIndex, checkForAdInstructions, - listOf( - ExternalLabel( - returnFalseLabel, - mutableMethod.instruction(mutableMethod.implementation!!.instructions.size - 2 /* return false = ad */) - ) + ExternalLabel( + returnFalseLabel, + mutableMethod.getInstruction(mutableMethod.implementation!!.instructions.size - 2 /* return false = ad */) ) ) @@ -93,10 +91,10 @@ class HideTimelineAdsPatch : BytecodePatch( // region Jump to checks for ads from previous patch. mutableMethod.apply { - addInstructions( + addInstructionsWithLabels( jumpIndex + 1, "if-nez v$freeRegister, :start_check", - listOf(ExternalLabel("start_check", instruction(insertIndex))) + ExternalLabel("start_check", getInstruction(insertIndex)) ) }.removeInstruction(jumpIndex) diff --git a/src/main/kotlin/app/revanced/patches/irplus/ad/patch/IrplusAdsPatch.kt b/src/main/kotlin/app/revanced/patches/irplus/ad/patch/IrplusAdsPatch.kt index 9a7f0a66e..90108c6ee 100644 --- a/src/main/kotlin/app/revanced/patches/irplus/ad/patch/IrplusAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/irplus/ad/patch/IrplusAdsPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt index 6e514ff70..d360d4c10 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt @@ -4,7 +4,7 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt index 1b9ca3064..5a4c35e48 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt @@ -4,7 +4,7 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt index c0c928e24..952b67a49 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt b/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt index f18a78d5f..e115a281a 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.messenger.ads.inbox.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt index 3d577a339..bcfd58c72 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt @@ -3,8 +3,8 @@ package app.revanced.patches.messenger.inputfield.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -23,7 +23,7 @@ class DisableSwitchingEmojiToStickerInMessageInputField : BytecodePatch(listOf(S val setStringIndex = it.scanResult.patternScanResult!!.startIndex + 2 it.mutableMethod.apply { - val targetRegister = instruction(setStringIndex).registerA + val targetRegister = getInstruction(setStringIndex).registerA replaceInstruction( setStringIndex, diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt index d25d46ed9..25618ccee 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/moneymanager/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/moneymanager/patch/UnlockProPatch.kt index e857e7140..7190a9759 100644 --- a/src/main/kotlin/app/revanced/patches/moneymanager/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/moneymanager/patch/UnlockProPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -24,10 +24,9 @@ class UnlockProPatch : BytecodePatch( UnlockProFingerprint.result!!.mutableMethod.addInstructions( 0, """ - const/4 v0, 0x1 - - return v0 - """ + const/4 v0, 0x1 + return v0 + """ ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt index bbf484831..bd4d91107 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/patch/MusicVideoAdsPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -29,8 +29,9 @@ class MusicVideoAdsPatch : BytecodePatch( val result = ShowMusicVideoAdsFingerprint.result!! - result.mutableMethod.addInstructions( - result.scanResult.patternScanResult!!.startIndex, """ + result.mutableMethod.addInstruction( + result.scanResult.patternScanResult!!.startIndex, + """ const/4 p1, 0x0 """ ) diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt index d679e8702..4579235e0 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt index 879dfa0c0..843c7e46f 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/compactheader/patch/CompactHeaderPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt index dcfdb9f05..e6239db7f 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -23,10 +23,11 @@ class MinimizedPlaybackPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext): PatchResult { - MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstructions( - 0, """ + MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstruction( + 0, + """ return-void - """ + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt index 727ff9dd9..b4f8c1a9d 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/patch/HideGetPremiumPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -40,10 +40,11 @@ class HideGetPremiumPatch : BytecodePatch( val result = HideGetPremiumFingerprint.result!! val method = result.mutableMethod - method.addInstructions( - startIndex, """ - const/16 v0, 0x8 - """ + method.addInstruction( + startIndex, + """ + const/16 v0, 0x8 + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt index d3b61a3f7..5f1ef34b8 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -30,7 +30,8 @@ class RemoveTasteBuilderPatch : BytecodePatch( val insertIndex = result.scanResult.patternScanResult!!.endIndex - 8 val register = (method.implementation!!.instructions[insertIndex] as Instruction22c).registerA method.addInstructions( - insertIndex, """ + insertIndex, + """ const/16 v1, 0x8 invoke-virtual {v${register}, v1}, Landroid/view/View;->setVisibility(I)V """ diff --git a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt index 9bf8ad011..1a134862d 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/patch/RemoveUpgradeButtonPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt index db5af5baf..e429b1187 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt index 9c860a9c3..c1f39c9b5 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt index ebf34e63e..5d92e64d5 100644 --- a/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/patch/UnlockProPatch.kt @@ -4,8 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt index d49d19d67..0d4cc60a4 100644 --- a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/nova/prime/patch/UnlockPrimePatch.kt b/src/main/kotlin/app/revanced/patches/nova/prime/patch/UnlockPrimePatch.kt index 0b6ae48e0..3615f2fc4 100644 --- a/src/main/kotlin/app/revanced/patches/nova/prime/patch/UnlockPrimePatch.kt +++ b/src/main/kotlin/app/revanced/patches/nova/prime/patch/UnlockPrimePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -43,7 +43,7 @@ class UnlockPrimePatch : BytecodePatch( const/16 v$primeStatusRegister, $PRIME_STATUS """ ) - } ?: UnlockPrimeFingerprint.toErrorResult() + } ?: return UnlockPrimeFingerprint.toErrorResult() return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt index bb0ee5960..d24eb41a2 100644 --- a/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt @@ -4,8 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt index d8c5beaae..c1aa53f62 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt @@ -4,8 +4,8 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -21,7 +21,7 @@ class SignatureDetectionPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext): PatchResult { CheckSignatureFingerprint.result?.apply { - val signatureCheckInstruction = mutableMethod.instruction(scanResult.patternScanResult!!.endIndex) + val signatureCheckInstruction = mutableMethod.getInstruction(scanResult.patternScanResult!!.endIndex) val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA mutableMethod.replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1") diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt index eb5cb8064..fedacb55d 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -31,9 +31,9 @@ class UnlockPlusPatch : BytecodePatch( addInstructions( 0, """ - const/4 v0, 0x1 - return v0 - """ + const/4 v0, 0x1 + return v0 + """ ) } ?: return IsPlusUnlockedFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt index 156c746b9..ead7f2ebe 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/patch/PremiumIconPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt index 1f494a401..edbf4fdbd 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -29,7 +29,7 @@ class SanitizeUrlQueryPatch : BytecodePatch( ShareLinkFactoryFingerprint.result?.let { result -> result.mutableMethod.apply { val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1 - val urlRegister = instruction(insertIndex - 1).registerA + val urlRegister = getInstruction(insertIndex - 1).registerA addInstructions( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/scbeasy/detection/debugging/patch/RemoveDebuggingDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/scbeasy/detection/debugging/patch/RemoveDebuggingDetectionPatch.kt index cc3f1111a..5d335f9e3 100644 --- a/src/main/kotlin/app/revanced/patches/scbeasy/detection/debugging/patch/RemoveDebuggingDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/scbeasy/detection/debugging/patch/RemoveDebuggingDetectionPatch.kt @@ -1,8 +1,10 @@ package app.revanced.patches.scbeasy.detection.debugging.patch -import app.revanced.patcher.annotation.* +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -19,7 +21,7 @@ class RemoveDebuggingDetectionPatch : BytecodePatch( listOf(DebuggingDetectionFingerprint) ) { override fun execute(context: BytecodeContext): PatchResult { - DebuggingDetectionFingerprint.result!!.mutableMethod.addInstructions( + DebuggingDetectionFingerprint.result!!.mutableMethod.addInstructionsWithLabels( 0, """ const/4 v0, 0x0 diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt index efa8d35be..c95d914a0 100644 --- a/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/integrations/patch/AbstractIntegrationsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.shared.integrations.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt index e251f1dec..96aa87b28 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt @@ -4,8 +4,8 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -23,7 +23,7 @@ class VerticalScrollPatch : BytecodePatch( CanScrollVerticallyFingerprint.result?.let { it.mutableMethod.apply { val moveResultIndex = it.scanResult.patternScanResult!!.endIndex - val moveResultRegister = instruction(moveResultIndex).registerA + val moveResultRegister = getInstruction(moveResultIndex).registerA val insertIndex = moveResultIndex + 1 addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt b/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt index bbb5159ef..928d4df85 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt b/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt index e45bb6fbe..6463974e2 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult diff --git a/src/main/kotlin/app/revanced/patches/syncforreddit/ads/patch/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/syncforreddit/ads/patch/DisableAdsPatch.kt index ef5e2a945..648d15fb3 100644 --- a/src/main/kotlin/app/revanced/patches/syncforreddit/ads/patch/DisableAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/syncforreddit/ads/patch/DisableAdsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/syncforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/syncforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt index ad7f2f9a1..feb02a06c 100644 --- a/src/main/kotlin/app/revanced/patches/syncforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/syncforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt @@ -4,7 +4,7 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -15,11 +15,11 @@ import app.revanced.patches.syncforreddit.detection.piracy.fingerprints.PiracyDe class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) { override fun execute(context: BytecodeContext): PatchResult { PiracyDetectionFingerprint.result?.mutableMethod?.apply { - addInstructions( + addInstruction( 0, """ - return-void - """ + return-void + """ ) } ?: return PiracyDetectionFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/tasker/trial/unlock/patch/UnlockLicensePatch.kt b/src/main/kotlin/app/revanced/patches/tasker/trial/unlock/patch/UnlockLicensePatch.kt index 9d644faa0..f458e31f4 100644 --- a/src/main/kotlin/app/revanced/patches/tasker/trial/unlock/patch/UnlockLicensePatch.kt +++ b/src/main/kotlin/app/revanced/patches/tasker/trial/unlock/patch/UnlockLicensePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch diff --git a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt index d61f3539c..46f1cd88f 100644 --- a/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/patch/UnlockThemePatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/HideAdsPatch.kt index 862f80517..501ad8f31 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/ad/patch/HideAdsPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError diff --git a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/FeedFilterPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/FeedFilterPatch.kt index fb6ba0b32..dedeb85b2 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/FeedFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/patch/FeedFilterPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt index a3ea7572f..80cfea646 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/patch/DownloadsPatch.kt @@ -5,10 +5,11 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.extensions.replaceInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError @@ -63,7 +64,7 @@ class DownloadsPatch : BytecodePatch( ) //Download videos without watermark. val method3 = ACLCommonShareFingerprint3.result!!.mutableMethod - method3.addInstructions( + method3.addInstructionsWithLabels( 0, """ invoke-static {}, Lapp/revanced/tiktok/download/DownloadsPatch;->shouldRemoveWatermark()Z diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt index 31d6d1289..b06caac0a 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/PlaybackSpeedPatch.kt index c1f15a75d..50ee73981 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/patch/PlaybackSpeedPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/patch/DisableLoginRequirementPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/patch/DisableLoginRequirementPatch.kt index 0967f7269..6072e46f5 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/patch/DisableLoginRequirementPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/patch/DisableLoginRequirementPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/patch/FixGoogleLoginPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/patch/FixGoogleLoginPatch.kt index 9e27025c7..007662fca 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/patch/FixGoogleLoginPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/patch/FixGoogleLoginPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt index 66b060494..8b60e9fd9 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError @@ -45,7 +45,7 @@ class SettingsPatch : BytecodePatch( // Find the indices that need to be patched. val copyrightPolicyLabelId = AboutPageFingerprint.result?.let { val startIndex = it.scanResult.patternScanResult!!.startIndex - it.mutableMethod.instruction(startIndex).wideLiteral + it.mutableMethod.getInstruction(startIndex).wideLiteral } ?: return AboutPageFingerprint.toErrorResult() val copyrightIndex = instructions.indexOfFirst { @@ -62,7 +62,7 @@ class SettingsPatch : BytecodePatch( copyrightIndex, copyrightPolicyIndex ).forEach { index -> - val instruction = instruction(index) + val instruction = getInstruction(index) if (instruction.opcode != Opcode.MOVE_RESULT_OBJECT) return PatchResultError("Hardcoded offset changed.") @@ -77,7 +77,7 @@ class SettingsPatch : BytecodePatch( ) // Replace the OnClickListener class with a custom one. - val onClickListener = instruction(index + 4).reference.toString() + val onClickListener = getInstruction(index + 4).reference.toString() context.findClass(onClickListener)?.mutableClass?.methods?.first { it.name == "onClick" @@ -98,7 +98,7 @@ class SettingsPatch : BytecodePatch( it.opcode == Opcode.INVOKE_SUPER } + 1 - val thisRegister = instruction(initializeSettingsIndex - 1).registerC + val thisRegister = getInstruction(initializeSettingsIndex - 1).registerC addInstructions( initializeSettingsIndex, diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/patch/SpoofSimPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/patch/SpoofSimPatch.kt index d193ab61d..a11e84042 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/patch/SpoofSimPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/patch/SpoofSimPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -97,14 +97,14 @@ class SpoofSimPatch : BytecodePatch() { // Patch Android API and return fake sim information private fun MutableMethod.replaceReference(index: Int, replacement: String) { - val resultReg = instruction(index + 1).registerA + val resultReg = getInstruction(index + 1).registerA addInstructions( index + 2, - """ - invoke-static {v$resultReg}, Lapp/revanced/tiktok/spoof/sim/SpoofSimPatch;->$replacement(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$resultReg - """ + """ + invoke-static {v$resultReg}, Lapp/revanced/tiktok/spoof/sim/SpoofSimPatch;->$replacement(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$resultReg + """ ) } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt index 362b91335..1e6fdbb34 100644 --- a/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt index 16455a4c5..f639644a7 100644 --- a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt @@ -3,8 +3,8 @@ package app.revanced.patches.twelvewidgets.unlock.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -40,11 +40,12 @@ class UnlockPaidWidgetsPatch : BytecodePatch( method.apply { removeInstructions(4, 3) addInstructions( - implementation?.instructions?.size!!, """ - const/4 v1, 0x0 - invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V - return-object v0 - """ + implementation?.instructions?.size!!, + """ + const/4 v1, 0x0 + invoke-virtual {v0, v1}, Landroid/view/View;->setVisibility(I)V + return-object v0 + """ ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/patch/AudioAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/patch/AudioAdsPatch.kt index 74cbff08b..db42f3e87 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/patch/AudioAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/patch/AudioAdsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -31,7 +31,7 @@ class AudioAdsPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { // Block playAds call with(AudioAdsPresenterPlayFingerprint.result!!) { - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/twitch/patches/AudioAdsPatch;->shouldBlockAudioAds()Z @@ -39,7 +39,7 @@ class AudioAdsPatch : BytecodePatch( if-eqz v0, :show_audio_ads return-void """, - listOf(ExternalLabel("show_audio_ads", mutableMethod.instruction(0))) + ExternalLabel("show_audio_ads", mutableMethod.getInstruction(0)) ) } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/patch/EmbeddedAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/patch/EmbeddedAdsPatch.kt index 23debc540..a0305b7be 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/patch/EmbeddedAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/patch/EmbeddedAdsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt index dca265bc7..041570b20 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt @@ -1,8 +1,8 @@ package app.revanced.patches.twitch.ad.shared.util import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.util.smali.ExternalLabel @@ -27,7 +27,7 @@ abstract class AbstractAdPatch( this ?: return false this.methods.filter { methodNames.contains(it.name) }.forEach { - val retIntructions = when(returnMethod.returnType) { + val retInstruction = when (returnMethod.returnType) { 'V' -> "return-void" 'Z' -> """ const/4 v0, ${returnMethod.value} @@ -35,13 +35,13 @@ abstract class AbstractAdPatch( """ else -> throw NotImplementedError() } - it.addInstructions( + it.addInstructionsWithLabels( 0, """ ${createConditionInstructions("v0")} - $retIntructions + $retInstruction """, - listOf(ExternalLabel(skipLabelName, it.instruction(0))) + ExternalLabel(skipLabelName, it.getInstruction(0)) ) } true diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt index 8094c03f5..11096a21d 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt @@ -4,8 +4,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn @@ -86,7 +87,7 @@ class VideoAdsPatch : AbstractAdPatch( // Pretend our player is ineligible for all ads with(CheckAdEligibilityLambdaFingerprint.result!!) { - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( 0, """ ${createConditionInstructions()} @@ -95,13 +96,13 @@ class VideoAdsPatch : AbstractAdPatch( move-result-object p0 return-object p0 """, - listOf(ExternalLabel(skipLabelName, mutableMethod.instruction(0))) + ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) } with(GetReadyToShowAdFingerprint.result!!) { val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;" - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( 0, """ ${createConditionInstructions()} @@ -110,7 +111,7 @@ class VideoAdsPatch : AbstractAdPatch( move-result-object p1 return-object p1 """, - listOf(ExternalLabel(skipLabelName, mutableMethod.instruction(0))) + ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) } diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt index dd69b4da1..7d3b841c6 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt @@ -4,9 +4,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -44,26 +44,25 @@ class ShowDeletedMessagesPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { // Spoiler mode: Force set hasModAccess member to true in constructor - with(DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod) { - addInstructions( + DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod.apply { + addInstructionsWithLabels( implementation!!.instructions.lastIndex, /* place in front of return-void */ """ ${createSpoilerConditionInstructions()} const/4 v0, 1 iput-boolean v0, p0, $definingClass->hasModAccess:Z """, - listOf(ExternalLabel("no_spoiler", instruction(implementation!!.instructions.lastIndex))) + ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex)) ) } // Spoiler mode: Disable setHasModAccess setter - with(SetHasModAccessFingerprint.result!!) { - mutableMethod.addInstruction(0, "return-void") - } + SetHasModAccessFingerprint.result!!.mutableMethod.addInstruction(0, "return-void") + // Cross-out mode: Reformat span of deleted message - with(ChatUtilCreateDeletedSpanFingerprint.result!!) { - mutableMethod.addInstructions( + ChatUtilCreateDeletedSpanFingerprint.result!!.mutableMethod.apply { + addInstructionsWithLabels( 0, """ invoke-static {p2}, Lapp/revanced/twitch/patches/ShowDeletedMessagesPatch;->reformatDeletedMessage(Landroid/text/Spanned;)Landroid/text/Spanned; @@ -71,7 +70,7 @@ class ShowDeletedMessagesPatch : BytecodePatch( if-eqz v0, :no_reformat return-object v0 """, - listOf(ExternalLabel("no_reformat", mutableMethod.instruction(0))) + ExternalLabel("no_reformat", getInstruction(0)) ) } diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt index 210a4950b..e77b2b580 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -50,7 +50,7 @@ class AutoClaimChannelPointPatch : BytecodePatch( CommunityPointsButtonViewDelegateFingerprint.result?.mutableMethod?.apply { val lastIndex = implementation!!.instructions.lastIndex - addInstructions( + addInstructionsWithLabels( lastIndex, // place in front of return-void """ invoke-static {}, Lapp/revanced/twitch/patches/AutoClaimChannelPointsPatch;->shouldAutoClaim()Z @@ -62,7 +62,7 @@ class AutoClaimChannelPointPatch : BytecodePatch( iget-object v0, p0, Ltv/twitch/android/shared/community/points/viewdelegate/CommunityPointsButtonViewDelegate;->buttonLayout:Landroid/view/ViewGroup; invoke-virtual { v0 }, Landroid/view/View;->callOnClick()Z """, - listOf(ExternalLabel("auto_claim", instruction(lastIndex))) + ExternalLabel("auto_claim", getInstruction(lastIndex)) ) } ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult() return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt index 5c864ba8b..749c07363 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt index f700354f7..ef114798b 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt @@ -4,8 +4,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch @@ -46,15 +47,15 @@ class SettingsPatch : BytecodePatch( // Hook onCreate to handle fragment creation with(SettingsActivityOnCreateFingerprint.result!!) { val insertIndex = mutableMethod.implementation!!.instructions.size - 2 - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( insertIndex, """ - invoke-static {p0}, $SETTINGS_HOOKS_CLASS->handleSettingsCreation(Landroidx/appcompat/app/AppCompatActivity;)Z - move-result v0 - if-eqz v0, :no_rv_settings_init - return-void + invoke-static {p0}, $SETTINGS_HOOKS_CLASS->handleSettingsCreation(Landroidx/appcompat/app/AppCompatActivity;)Z + move-result v0 + if-eqz v0, :no_rv_settings_init + return-void """, - listOf(ExternalLabel("no_rv_settings_init", mutableMethod.instruction(insertIndex))) + ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex)) ) } @@ -83,7 +84,7 @@ class SettingsPatch : BytecodePatch( // Intercept onclick events for the settings menu with(MenuGroupsOnClickFingerprint.result!!) { val insertIndex = 0 - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( insertIndex, """ invoke-static {p1}, $SETTINGS_HOOKS_CLASS->handleSettingMenuOnClick(Ljava/lang/Enum;)Z @@ -93,7 +94,7 @@ class SettingsPatch : BytecodePatch( invoke-virtual {p0, p1}, Ltv/twitch/android/core/mvp/viewdelegate/RxViewDelegate;->pushEvent(Ltv/twitch/android/core/mvp/viewdelegate/ViewDelegateEvent;)V return-void """, - listOf(ExternalLabel("no_rv_settings_onclick", mutableMethod.instruction(insertIndex))) + ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ) } diff --git a/src/main/kotlin/app/revanced/patches/twitter/layout/hideviews/patch/HideViewsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/twitter/layout/hideviews/patch/HideViewsBytecodePatch.kt index b8cb63652..1d75e08ad 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/layout/hideviews/patch/HideViewsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/layout/hideviews/patch/HideViewsBytecodePatch.kt @@ -1,8 +1,8 @@ package app.revanced.patches.twitter.layout.hideviews.patch import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/patch/JsonHookPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/patch/JsonHookPatch.kt index 8a14dc9ce..fe9b514ad 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/patch/JsonHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/patch/JsonHookPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch diff --git a/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt index 1b428ba4b..e58773e95 100644 --- a/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.vsco.misc.pro.patch import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -22,7 +22,7 @@ class UnlockProPatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { RevCatSubscriptionFingerprint.result?.mutableMethod?.apply { // Set isSubscribed to true. - addInstructions( + addInstructionsWithLabels( 0, """ const p1, 0x1 diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt index c7dd384d4..40f704b76 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/patch/FirebaseGetCertPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt index 68ee1de05..d1b30a23e 100644 --- a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt index fac915b59..a781e3ff7 100644 --- a/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt @@ -4,8 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt index c6abb9a2d..06afff15d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt @@ -4,8 +4,8 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -45,13 +45,13 @@ class HideGetPremiumPatch : BytecodePatch(listOf(GetPremiumViewFingerprint,)) { GetPremiumViewFingerprint.result?.let { it.mutableMethod.apply { val startIndex = it.scanResult.patternScanResult!!.startIndex - val measuredWidthRegister = instruction(startIndex).registerA - val measuredHeightInstruction = instruction(startIndex + 1) + val measuredWidthRegister = getInstruction(startIndex).registerA + val measuredHeightInstruction = getInstruction(startIndex + 1) val measuredHeightRegister = measuredHeightInstruction.registerA val tempRegister = measuredHeightInstruction.registerB - addInstructions( + addInstructionsWithLabels( startIndex + 2, """ # Override the internal measurement of the layout with zero values. diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt index 000b4b54b..42b0ecc99 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -42,13 +42,14 @@ class VideoAdsPatch : BytecodePatch( val loadVideoAdsFingerprintMethod = LoadVideoAdsFingerprint.result!!.mutableMethod - loadVideoAdsFingerprintMethod.addInstructions( + loadVideoAdsFingerprintMethod.addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z move-result v0 if-nez v0, :show_video_ads return-void - """, listOf(ExternalLabel("show_video_ads", loadVideoAdsFingerprintMethod.instruction(0))) + """, + ExternalLabel("show_video_ads", loadVideoAdsFingerprintMethod.getInstruction(0)) ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt index b9d0dc097..541cb0165 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -65,7 +65,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 it.mutableMethod.apply { - val thisInstanceRegister = instruction(insertIndex - 1).registerC + val thisInstanceRegister = getInstruction(insertIndex - 1).registerC val freeRegister = 0 val xAxisRegister = 2 @@ -76,7 +76,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( fun Method.toInvokeInstructionString() = "invoke-virtual { v$thisInstanceRegister, v$xAxisRegister }, $definingClass->$name(I)V" - addInstructions( + addInstructionsWithLabels( insertIndex, """ invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->seekbarTappingEnabled()Z @@ -84,8 +84,8 @@ class EnableSeekbarTappingPatch : BytecodePatch( if-eqz v$freeRegister, :disabled ${oMethod.toInvokeInstructionString()} ${pMethod.toInvokeInstructionString()} - """, - listOf(ExternalLabel("disabled", instruction(insertIndex))) + """, + ExternalLabel("disabled", getInstruction(insertIndex)) ) } } ?: return SeekbarTappingFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt index 675a7369b..f8ceee178 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/patch/AutoCaptionsPatch.kt @@ -4,7 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -60,7 +61,7 @@ class AutoCaptionsPatch : BytecodePatch( val subtitleTrackMethod = SubtitleTrackFingerprint.result!!.mutableMethod - subtitleTrackMethod.addInstructions( + subtitleTrackMethod.addInstructionsWithLabels( 0, """ invoke-static {}, Lapp/revanced/integrations/patches/DisableAutoCaptionsPatch;->autoCaptionsEnabled()Z move-result v0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt index ff10f48f9..788c3b3d6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -68,15 +68,16 @@ class HideAutoplayButtonPatch : BytecodePatch( val jumpInstruction = layoutGenMethodInstructions[insertIndex + branchIndex] as Instruction // can be clobbered because this register is overwritten after the injected code - val clobberRegister = instruction(insertIndex).registerA + val clobberRegister = getInstruction(insertIndex).registerA - addInstructions( + addInstructionsWithLabels( insertIndex, """ - invoke-static {}, Lapp/revanced/integrations/patches/HideAutoplayButtonPatch;->isButtonShown()Z - move-result v$clobberRegister - if-eqz v$clobberRegister, :hidden - """, listOf(ExternalLabel("hidden", jumpInstruction)) + invoke-static {}, Lapp/revanced/integrations/patches/HideAutoplayButtonPatch;->isButtonShown()Z + move-result v$clobberRegister + if-eqz v$clobberRegister, :hidden + """, + ExternalLabel("hidden", jumpInstruction) ) } ?: return LayoutConstructorFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/patch/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/patch/HideCaptionsButtonPatch.kt index a8aa8dbd3..e90c041ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/patch/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/patch/HideCaptionsButtonPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -44,8 +44,9 @@ class HideCaptionsButtonPatch : BytecodePatch(listOf( it.opcode == Opcode.IGET_BOOLEAN } - subtitleButtonControllerMethod.addInstructions( - igetBooleanIndex + 1, """ + subtitleButtonControllerMethod.addInstruction( + igetBooleanIndex + 1, + """ invoke-static {v0}, Lapp/revanced/integrations/patches/HideCaptionsButtonPatch;->hideCaptionsButton(Landroid/widget/ImageView;)V """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/patch/HideCastButtonPatch.kt index 03f57266a..711f4c456 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/patch/HideCastButtonPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError @@ -34,22 +34,18 @@ class HideCastButtonPatch : BytecodePatch() { ) ) - with( - context.findClass("MediaRouteButton") - ?: return PatchResultError("MediaRouteButton class not found.") - ) { - with( - mutableClass.methods.find { it.name == "setVisibility" } - ?: return PatchResultError("setVisibility method not found.") - ) { - addInstructions( - 0, """ - invoke-static {p1}, Lapp/revanced/integrations/patches/HideCastButtonPatch;->getCastButtonOverrideV2(I)I - move-result p1 - """ - ) - } - } + val buttonClass = context.findClass("MediaRouteButton") + ?: return PatchResultError("MediaRouteButton class not found.") + + buttonClass.mutableClass.methods.find { it.name == "setVisibility" }?.apply { + addInstructions( + 0, + """ + invoke-static {p1}, Lapp/revanced/integrations/patches/HideCastButtonPatch;->getCastButtonOverrideV2(I)I + move-result p1 + """ + ) + } ?: return PatchResultError("setVisibility method not found.") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt index c7ef6e562..f08a85a05 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -144,7 +144,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri }!!.index val conditionalCheckIndex = stringIndex - 1 - val conditionRegister = instruction(conditionalCheckIndex).registerA + val conditionRegister = getInstruction(conditionalCheckIndex).registerA addInstructions( conditionalCheckIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/utils/InjectionUtils.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/utils/InjectionUtils.kt index 98036c67e..4b0c9f4ca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/utils/InjectionUtils.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/utils/InjectionUtils.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.layout.buttons.navigation.utils -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import org.jf.dexlib2.Opcode.MOVE_RESULT_OBJECT import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @@ -20,7 +20,7 @@ internal object InjectionUtils { // Register to pass to the hook val registerIndex = insertIndex - 1 // MOVE_RESULT_OBJECT is always the previous instruction - val register = injectTarget.instruction(registerIndex).registerA + val register = injectTarget.getInstruction(registerIndex).registerA injectTarget.addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt index 8a7d51347..8e40eae47 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -55,7 +55,7 @@ class HidePlayerButtonsPatch : BytecodePatch( PlayerControlsVisibilityModelFingerprint.result?.apply { val callIndex = scanResult.patternScanResult!!.endIndex - val callInstruction = mutableMethod.instruction(callIndex) + val callInstruction = mutableMethod.getInstruction(callIndex) // overriding this parameter register hides the previous and next buttons val hasNextParameterRegister = callInstruction.startRegister + ParameterOffsets.HAS_NEXT diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt index bebceae5f..c02d16111 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -35,7 +35,7 @@ class AlbumCardsPatch : BytecodePatch( val checkCastAnchorIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = checkCastAnchorIndex + 1 - val albumCardViewRegister = instruction(checkCastAnchorIndex).registerA + val albumCardViewRegister = getInstruction(checkCastAnchorIndex).registerA addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt index d11423ed3..b38a4bed8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -33,7 +33,7 @@ class BreakingNewsPatch : BytecodePatch( val moveResultIndex = insertIndex - 1 it.mutableMethod.apply { - val breakingNewsViewRegister = instruction(moveResultIndex).registerA + val breakingNewsViewRegister = getInstruction(moveResultIndex).registerA addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt index c6373f635..09ad54ef4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -33,7 +33,7 @@ class CrowdfundingBoxPatch : BytecodePatch( CrowdfundingBoxFingerprint.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.endIndex - val objectRegister = instruction(insertIndex).registerA + val objectRegister = getInstruction(insertIndex).registerA addInstruction(insertIndex, "invoke-static {v$objectRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt index 624e3c4eb..89704c617 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -39,7 +39,7 @@ class HideEndscreenCardsPatch : BytecodePatch( val layoutResult = result ?: throw toErrorResult() layoutResult.mutableMethod.apply { val insertIndex = layoutResult.scanResult.patternScanResult!!.endIndex + 1 - val viewRegister = instruction(insertIndex - 1).registerA + val viewRegister = getInstruction(insertIndex - 1).registerA addInstruction( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt index ea69ddbe3..168db44dc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -78,7 +78,7 @@ class HideFilterBarPatch : BytecodePatch( val endIndex = it.scanResult.patternScanResult!!.endIndex val insertIndex = endIndex + insertIndexOffset - val register = instruction(endIndex + hookRegisterOffset).registerA + val register = getInstruction(endIndex + hookRegisterOffset).registerA addInstructions(insertIndex, instructions(register)) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt index 1d50b18db..c6bd10c29 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -29,7 +29,7 @@ class HideFloatingMicrophoneButtonPatch : BytecodePatch( ShowFloatingMicrophoneButtonFingerprint.result?.let { result -> with(result.mutableMethod) { val insertIndex = result.scanResult.patternScanResult!!.startIndex + 1 - val showButtonRegister = instruction(insertIndex - 1).registerA + val showButtonRegister = getInstruction(insertIndex - 1).registerA addInstructions( insertIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/patch/HideInfoCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/patch/HideInfoCardsPatch.kt index d47584343..2bc606513 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/patch/HideInfoCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/patch/HideInfoCardsPatch.kt @@ -4,8 +4,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -44,29 +45,28 @@ class HideInfoCardsPatch : BytecodePatch( ((it as ReferenceInstruction).reference.toString() == "Landroid/view/View;->setVisibility(I)V") } - addInstructions( - invokeInstructionIndex, - "invoke-static {v${instruction(invokeInstructionIndex).registerC}}," + - " Lapp/revanced/integrations/patches/HideInfoCardsPatch;->hideInfoCardsIncognito(Landroid/view/View;)V" - ) + addInstruction( + invokeInstructionIndex, + "invoke-static {v${getInstruction(invokeInstructionIndex).registerC}}," + + " Lapp/revanced/integrations/patches/HideInfoCardsPatch;->hideInfoCardsIncognito(Landroid/view/View;)V" + ) } with(InfocardsMethodCallFingerprint.result!!) { - val hideInfocardsCallMethod = mutableMethod + val hideInfoCardsCallMethod = mutableMethod val invokeInterfaceIndex = scanResult.patternScanResult!!.endIndex - val toggleRegister = hideInfocardsCallMethod.implementation!!.registerCount - 1 + val toggleRegister = hideInfoCardsCallMethod.implementation!!.registerCount - 1 - hideInfocardsCallMethod.addInstructions( - invokeInterfaceIndex, """ + hideInfoCardsCallMethod.addInstructionsWithLabels( + invokeInterfaceIndex, + """ invoke-static {}, Lapp/revanced/integrations/patches/HideInfoCardsPatch;->hideInfoCardsMethodCall()Z move-result v$toggleRegister if-nez v$toggleRegister, :hide_info_cards """, - listOf( - ExternalLabel( - "hide_info_cards", hideInfocardsCallMethod.instruction(invokeInterfaceIndex + 1) - ) + ExternalLabel( + "hide_info_cards", hideInfoCardsCallMethod.getInstruction(invokeInterfaceIndex + 1) ) ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt index b63f52302..3e9213f8d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -16,7 +16,6 @@ import app.revanced.patches.youtube.layout.hide.loadmorebutton.bytecode.fingerpr import app.revanced.patches.youtube.layout.hide.loadmorebutton.resource.patch.HideLoadMoreButtonResourcePatch import app.revanced.patches.youtube.layout.hide.loadmorebutton.annotations.HideLoadMoreButtonCompatibility import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction @Patch @Name("hide-load-more-button") @@ -29,7 +28,7 @@ class HideLoadMoreButtonPatch : BytecodePatch(listOf(HideLoadMoreButtonFingerpri HideLoadMoreButtonFingerprint.result?.let { it.mutableMethod.apply { val moveRegisterIndex = it.scanResult.patternScanResult!!.endIndex - val viewRegister = instruction(moveRegisterIndex).registerA + val viewRegister = getInstruction(moveRegisterIndex).registerA val insertIndex = moveRegisterIndex + 1 addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt index 79d0e8542..cb2398993 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -35,7 +35,7 @@ class HideEmailAddressPatch : BytecodePatch( val setVisibilityConstIndex = it.scanResult.patternScanResult!!.endIndex val setVisibilityConstRegister = - instruction(setVisibilityConstIndex - 2).registerA + getInstruction(setVisibilityConstIndex - 2).registerA addInstructions( setVisibilityConstIndex, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt index d5b7bd9f4..a0170c0eb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -33,7 +33,7 @@ class HidePlayerOverlayPatch : BytecodePatch(listOf(CreatePlayerOverviewFingerpr literal == HidePlayerOverlayResourcePatch.scrimOverlayId } + 3 - val viewRegister = instruction(viewRegisterIndex).registerA + val viewRegister = getInstruction(viewRegisterIndex).registerA val insertIndex = viewRegisterIndex + 1 addInstruction( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/patch/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/patch/HideSeekbarPatch.kt index 7a3fde5a5..1c4ca115b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/patch/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/patch/HideSeekbarPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -55,16 +55,17 @@ class HideSeekbarPatch : BytecodePatch( SeekbarFingerprint.result!!.let { SeekbarOnDrawFingerprint.apply { resolve(context, it.mutableClass) } - }.result!!.mutableMethod.addInstructions( - 0, """ - const/4 v0, 0x0 - invoke-static { }, Lapp/revanced/integrations/patches/HideSeekbarPatch;->hideSeekbar()Z - move-result v0 - if-eqz v0, :hide_seekbar - return-void - :hide_seekbar - nop - """ + }.result!!.mutableMethod.addInstructionsWithLabels( + 0, + """ + const/4 v0, 0x0 + invoke-static { }, Lapp/revanced/integrations/patches/HideSeekbarPatch;->hideSeekbar()Z + move-result v0 + if-eqz v0, :hide_seekbar + return-void + :hide_seekbar + nop + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt index dcad8f43a..91fe39b84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt @@ -7,8 +7,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -54,7 +54,7 @@ class HideShortsComponentsPatch : BytecodePatch( ReelConstructorFingerprint.result?.let { it.mutableMethod.apply { val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2 - val viewRegister = instruction(insertIndex).registerA + val viewRegister = getInstruction(insertIndex).registerA injectHideViewCall( insertIndex, @@ -86,7 +86,7 @@ class HideShortsComponentsPatch : BytecodePatch( SetPivotBarVisibilityFingerprint.result!!.let { result -> result.mutableMethod.apply { val checkCastIndex = result.scanResult.patternScanResult!!.endIndex - val viewRegister = instruction(checkCastIndex).registerA + val viewRegister = getInstruction(checkCastIndex).registerA addInstruction( checkCastIndex + 1, "sput-object v$viewRegister, $CLASS_DESCRIPTOR->pivotBar:" + @@ -110,7 +110,7 @@ class HideShortsComponentsPatch : BytecodePatch( BottomNavigationBarFingerprint.result?.let { it.mutableMethod.apply { val moveResultIndex = it.scanResult.patternScanResult!!.startIndex - val viewRegister = instruction(moveResultIndex).registerA + val viewRegister = getInstruction(moveResultIndex).registerA val insertIndex = moveResultIndex + 1 addInstruction( @@ -138,7 +138,7 @@ class HideShortsComponentsPatch : BytecodePatch( val referencedIndex = method.findIndexForIdResource(resourceName) val setIdIndex = referencedIndex + 1 - val viewRegister = method.instruction(setIdIndex).registerC + val viewRegister = method.getInstruction(setIdIndex).registerC method.injectHideViewCall(setIdIndex, viewRegister, CLASS_DESCRIPTOR, methodName) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt index 635578a64..bb7270d55 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -38,15 +38,16 @@ class HideTimestampPatch : BytecodePatch( ) ) - TimeCounterFingerprint.result!!.mutableMethod.addInstructions( - 0, """ - invoke-static { }, Lapp/revanced/integrations/patches/HideTimestampPatch;->hideTimestamp()Z - move-result v0 - if-eqz v0, :hide_time - return-void - :hide_time - nop - """ + TimeCounterFingerprint.result!!.mutableMethod.addInstructionsWithLabels( + 0, + """ + invoke-static { }, Lapp/revanced/integrations/patches/HideTimestampPatch;->hideTimestamp()Z + move-result v0 + if-eqz v0, :hide_time + return-void + :hide_time + nop + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/patch/WatchInVRPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/patch/WatchInVRPatch.kt index 89b278620..cc3ae1775 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/patch/WatchInVRPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watchinvr/patch/WatchInVRPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -38,14 +38,15 @@ class WatchInVRPatch : BytecodePatch( ) ) - WatchInVRFingerprint.result!!.mutableMethod.addInstructions( - 0, """ - invoke-static {}, Lapp/revanced/integrations/patches/HideWatchInVRPatch;->hideWatchInVR()Z - move-result v0 - if-eqz v0, :shown - return-void - :shown - nop + WatchInVRFingerprint.result!!.mutableMethod.addInstructionsWithLabels( + 0, + """ + invoke-static {}, Lapp/revanced/integrations/patches/HideWatchInVRPatch;->hideWatchInVR()Z + move-result v0 + if-eqz v0, :shown + return-void + :shown + nop """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/patch/HideWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/patch/HideWatermarkPatch.kt index c6c2b3b06..d8624910c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/patch/HideWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/watermark/patch/HideWatermarkPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -51,10 +51,11 @@ class HideWatermarkPatch : BytecodePatch( method.removeInstruction(line) method.addInstructions( - line, """ - invoke-static {}, Lapp/revanced/integrations/patches/BrandingWaterMarkPatch;->isBrandingWatermarkShown()Z - move-result p2 - """ + line, + """ + invoke-static {}, Lapp/revanced/integrations/patches/BrandingWaterMarkPatch;->isBrandingWatermarkShown()Z + move-result p2 + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/patch/FullscreenPanelsRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/patch/FullscreenPanelsRemoverPatch.kt index 791273ad6..b527b51b4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/patch/FullscreenPanelsRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/fullscreen/remove/patch/FullscreenPanelsRemoverPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -53,10 +53,11 @@ class FullscreenPanelsRemoverPatch : BytecodePatch( method.removeInstruction(ifIndex) method.addInstructions( - ifIndex, """ - invoke-static {}, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullscreenPanelsVisibility()I - move-result p1 - """ + ifIndex, + """ + invoke-static {}, Lapp/revanced/integrations/patches/FullscreenPanelsRemoverPatch;->getFullscreenPanelsVisibility()I + move-result p1 + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt index bf2447c4e..9d991dd35 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -42,17 +42,18 @@ class PlayerPopupPanelsPatch : BytecodePatch( val engagementPanelControllerMethod = EngagementPanelControllerFingerprint .result?.mutableMethod ?: return EngagementPanelControllerFingerprint.toErrorResult() - engagementPanelControllerMethod.addInstructions( - 0, """ - invoke-static { }, Lapp/revanced/integrations/patches/DisablePlayerPopupPanelsPatch;->disablePlayerPopupPanels()Z - move-result v0 - if-eqz v0, :player_popup_panels - if-eqz p4, :player_popup_panels - const/4 v0, 0x0 - return-object v0 - :player_popup_panels - nop - """ + engagementPanelControllerMethod.addInstructionsWithLabels( + 0, + """ + invoke-static { }, Lapp/revanced/integrations/patches/DisablePlayerPopupPanelsPatch;->disablePlayerPopupPanels()Z + move-result v0 + if-eqz v0, :player_popup_panels + if-eqz p4, :player_popup_panels + const/4 v0, 0x0 + return-object v0 + :player_popup_panels + nop + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index b75fddfcf..08f8bb56e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -5,11 +5,12 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -70,8 +71,8 @@ class ReturnYouTubeDislikePatch : BytecodePatch( addInstructions( 0, """ - const/4 v0, ${vote.value} - invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->sendVote(I)V + const/4 v0, ${vote.value} + invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->sendVote(I)V """ ) } ?: return PatchResultError("Failed to find ${fingerprint.name} method.") @@ -104,23 +105,24 @@ class ReturnYouTubeDislikePatch : BytecodePatch( textComponentContextFingerprintResult.mutableMethod.apply { // Get the conversion context obfuscated field name, and the registers for the AtomicReference and CharSequence val conversionContextFieldReference = - instruction(conversionContextIndex).reference + getInstruction(conversionContextIndex).reference // any free register val contextRegister = - instruction(atomicReferenceStartIndex).registerB + getInstruction(atomicReferenceStartIndex).registerB val atomicReferenceRegister = - instruction(atomicReferenceStartIndex + 4).registerC + getInstruction(atomicReferenceStartIndex + 4).registerC - val moveCharSequenceInstruction = instruction(insertIndex) + val moveCharSequenceInstruction = getInstruction(insertIndex) val charSequenceRegister = moveCharSequenceInstruction.registerB // Insert as first instructions at the control flow label. // Must replace the existing instruction to preserve the label, and then insert the remaining instructions. replaceInstruction(insertIndex, "move-object/from16 v$contextRegister, p0") addInstructions( - insertIndex + 1, """ + insertIndex + 1, + """ iget-object v$contextRegister, v$contextRegister, $conversionContextFieldReference # copy obfuscated context field into free register invoke-static {v$contextRegister, v$atomicReferenceRegister, v$charSequenceRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onLithoTextLoaded(Ljava/lang/Object;Ljava/util/concurrent/atomic/AtomicReference;Ljava/lang/CharSequence;)Ljava/lang/CharSequence; move-result-object v$charSequenceRegister @@ -139,32 +141,33 @@ class ReturnYouTubeDislikePatch : BytecodePatch( val patternResult = it.scanResult.patternScanResult!! // If the field is true, the TextView is for a dislike button. - val isDisLikesBooleanReference = instruction(patternResult.endIndex).reference + val isDisLikesBooleanReference = getInstruction(patternResult.endIndex).reference val textViewFieldReference = // Like/Dislike button TextView field - instruction(patternResult.endIndex - 2).reference + getInstruction(patternResult.endIndex - 2).reference // 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 = patternResult.startIndex + 6 - addInstructions( - insertIndex, """ - # Check, if the TextView is for a dislike button - iget-boolean v0, p0, $isDisLikesBooleanReference - if-eqz v0, :is_like - - # Hook the TextView, if it is for the dislike button - iget-object v0, p0, $textViewFieldReference - invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setShortsDislikes(Landroid/view/View;)Z - move-result v0 - if-eqz v0, :ryd_disabled - return-void - - :is_like - :ryd_disabled - nop - """ + addInstructionsWithLabels( + insertIndex, + """ + # Check, if the TextView is for a dislike button + iget-boolean v0, p0, $isDisLikesBooleanReference + if-eqz v0, :is_like + + # Hook the TextView, if it is for the dislike button + iget-object v0, p0, $textViewFieldReference + invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setShortsDislikes(Landroid/view/View;)Z + move-result v0 + if-eqz v0, :ryd_disabled + return-void + + :is_like + :ryd_disabled + nop + """ ) } } ?: return ShortsTextViewFingerprint.toErrorResult() @@ -177,8 +180,8 @@ class ReturnYouTubeDislikePatch : BytecodePatch( it.mutableMethod.apply { val startIndex = it.scanResult.patternScanResult!!.startIndex - val resourceIdentifierRegister = instruction(startIndex).registerA - val textViewRegister = instruction(startIndex + 4).registerA + val resourceIdentifierRegister = getInstruction(startIndex).registerA + val textViewRegister = getInstruction(startIndex + 4).registerA addInstruction( startIndex + 4, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt index 2894e8d63..e4e498a8a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -72,7 +72,6 @@ class WideSearchbarPatch : BytecodePatch( /** * Injects instructions required for certain methods. - * */ fun MutableMethod.injectSearchBarHook() { addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt index bf3d4cea3..e57079a14 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -33,23 +33,23 @@ class SeekbarColorBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext): PatchResult { CreateDarkThemeSeekbarFingerprint.result?.mutableMethod?.apply { var registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) + 2 - var colorRegister = (instruction(registerIndex) as OneRegisterInstruction).registerA + var colorRegister = (getInstruction(registerIndex) as OneRegisterInstruction).registerA addInstructions( registerIndex + 1, """ - invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I - move-result v$colorRegister - """ + invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I + move-result v$colorRegister + """ ) registerIndex = indexOfFirstConstantInstruction(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) + 2 - colorRegister = (instruction(registerIndex) as OneRegisterInstruction).registerA + colorRegister = (getInstruction(registerIndex) as OneRegisterInstruction).registerA addInstructions( registerIndex + 1, """ - invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I - move-result v$colorRegister - """ + invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I + move-result v$colorRegister + """ ) } ?: return CreateDarkThemeSeekbarFingerprint.toErrorResult() @@ -62,7 +62,7 @@ class SeekbarColorBytecodePatch : BytecodePatch( .getMethod() as MutableMethod method.apply { - val colorRegister = (method.instruction(0) as TwoRegisterInstruction).registerA + val colorRegister = (method.getInstruction(0) as TwoRegisterInstruction).registerA addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 84112ff82..f070dc325 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -6,10 +6,10 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -188,7 +188,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( context.toMethodWalker(method).nextMethod(index - 6, true).getMethod() as MutableMethod // change visibility of the buttons invertVisibilityMethod.addInstructions( - 0, """ + 0, + """ invoke-static {p1}, $INTEGRATIONS_CREATE_SEGMENT_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->changeVisibilityNegatedImmediate(Z)V invoke-static {p1}, $INTEGRATIONS_VOTING_BUTTON_CONTROLLER_CLASS_DESCRIPTOR->changeVisibilityNegatedImmediate(Z)V """.trimIndent() @@ -209,9 +210,10 @@ class SponsorBlockBytecodePatch : BytecodePatch( (appendTimeFingerprintResult.method.implementation!!.instructions.elementAt(appendTimePatternScanStartIndex + 1) as OneRegisterInstruction).registerA appendTimeFingerprintResult.mutableMethod.addInstructions( - appendTimePatternScanStartIndex + 2, """ - invoke-static {v$targetRegister}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->appendTimeWithoutSegments(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$targetRegister + appendTimePatternScanStartIndex + 2, + """ + invoke-static {v$targetRegister}, $INTEGRATIONS_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->appendTimeWithoutSegments(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$targetRegister """ ) @@ -222,7 +224,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( ControlsOverlayFingerprint.result?.let { val startIndex = it.scanResult.patternScanResult!!.startIndex it.mutableMethod.apply { - val frameLayoutRegister = (instruction(startIndex + 2) as OneRegisterInstruction).registerA + val frameLayoutRegister = (getInstruction(startIndex + 2) as OneRegisterInstruction).registerA addInstruction( startIndex + 3, "invoke-static {v$frameLayoutRegister}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/ViewGroup;)V" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt index 2567f3fc1..3d7f7c758 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -79,9 +79,9 @@ class SpoofAppVersionPatch : BytecodePatch( mutableMethod.addInstructions( insertIndex, """ - invoke-static {v$buildOverrideNameRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR;->getYouTubeVersionOverride(Ljava/lang/String;)Ljava/lang/String; - move-result-object v$buildOverrideNameRegister - """ + invoke-static {v$buildOverrideNameRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR;->getYouTubeVersionOverride(Ljava/lang/String;)Ljava/lang/String; + move-result-object v$buildOverrideNameRegister + """ ) } ?: return SpoofAppVersionFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt index 8be60b6a9..08d64c179 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/patch/DisableShortsOnStartupPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -42,15 +42,16 @@ class DisableShortsOnStartupPatch : BytecodePatch( val userWasInShortsMethod = userWasInShortsResult.mutableMethod val moveResultIndex = userWasInShortsResult.scanResult.patternScanResult!!.endIndex - userWasInShortsMethod.addInstructions( - moveResultIndex + 1, """ - invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z - move-result v5 - if-eqz v5, :disable_shorts_player - return-void - :disable_shorts_player - nop - """ + userWasInShortsMethod.addInstructionsWithLabels( + moveResultIndex + 1, + """ + invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z + move-result v5 + if-eqz v5, :disable_shorts_player + return-void + :disable_shorts_player + nop + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index 26994af50..0fdc1bccb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -114,7 +114,7 @@ class TabletMiniPlayerPatch : BytecodePatch( """ invoke-static {v$overrideRegister}, Lapp/revanced/integrations/patches/TabletMiniPlayerOverridePatch;->getTabletMiniPlayerOverride(Z)Z move-result v$overrideRegister - """ + """ ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt index 0568876ef..d55e62905 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -36,9 +36,9 @@ class LithoColorHookPatch : BytecodePatch(listOf(LithoThemeFingerprint)) { insertionMethod.addInstructions( insertionIndex, """ - invoke-static {$colorRegister}, $targetMethodClass->$targetMethodName(I)I - move-result $colorRegister - """ + invoke-static {$colorRegister}, $targetMethodClass->$targetMethodName(I)I + move-result $colorRegister + """ ) insertionIndex += 2 } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt index 08b2798da..1accc9387 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/patch/AutoRepeatPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -13,13 +13,13 @@ import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.autorepeat.annotations.AutoRepeatCompatibility import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatFingerprint import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference @Patch @DependsOn([IntegrationsPatch::class]) @@ -79,7 +79,7 @@ class AutoRepeatPatch : BytecodePatch( //remove last instruction which is return-void method.removeInstruction(index) // Add our own instructions there - method.addInstructions(index, instructions) + method.addInstructionsWithLabels(index, instructions) //Everything worked as expected, return Success return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt index a24b5db16..fa6d5eeb5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt @@ -4,7 +4,7 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt index b06a4bfa0..36f24f3fd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -29,7 +29,7 @@ class ClientSpoofPatch : BytecodePatch( UserAgentHeaderBuilderFingerprint.result?.let { result -> val insertIndex = result.scanResult.patternScanResult!!.endIndex result.mutableMethod.apply { - val packageNameRegister = instruction(insertIndex).registerD + val packageNameRegister = getInstruction(insertIndex).registerD addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt index db5229f94..04d488ac2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt @@ -6,8 +6,8 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -83,7 +83,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch( it.mutableMethod.apply { val getHeadersInstructionIndex = it.scanResult.patternScanResult!!.endIndex val responseCodeRegister = - (instruction(getHeadersInstructionIndex - 2) as OneRegisterInstruction).registerA + (getInstruction(getHeadersInstructionIndex - 2) as OneRegisterInstruction).registerA addInstructions( getHeadersInstructionIndex + 1, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt index 64750c53c..ddbeea665 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -51,7 +51,8 @@ class OpenLinksExternallyPatch : BytecodePatch( with(result.mutableMethod) { val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA addInstructions( - insertIndex, """ + insertIndex, + """ invoke-static {v$register}, Lapp/revanced/integrations/patches/OpenLinksExternallyPatch;->enableExternalBrowser(Ljava/lang/String;)Ljava/lang/String; move-result-object v$register """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt index 84c53504c..a93e35b30 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt @@ -4,8 +4,8 @@ import app.revanced.extensions.toErrorResult import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch @@ -45,11 +45,11 @@ class LithoFilterPatch : BytecodePatch( result.mutableMethod.apply { val insertHookIndex = result.scanResult.patternScanResult!!.endIndex - val builderMethodDescriptor = instruction(builderMethodIndex).descriptor - val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).descriptor + val builderMethodDescriptor = getInstruction(builderMethodIndex).descriptor + val emptyComponentFieldDescriptor = getInstruction(emptyComponentFieldIndex).descriptor // Register is overwritten right after it is used in this patch, therefore free to clobber. - val free = instruction(insertHookIndex - 1).registerA - val free2 = instruction(insertHookIndex).registerA + val free = getInstruction(insertHookIndex - 1).registerA + val free2 = getInstruction(insertHookIndex).registerA @Suppress("UnnecessaryVariable") // The register, this patch clobbers, is previously used for the StringBuilder, @@ -57,19 +57,19 @@ class LithoFilterPatch : BytecodePatch( val stringBuilderRegister = free val identifierRegister = - instruction(ReadComponentIdentifierFingerprint.patternScanEndIndex).registerA + getInstruction(ReadComponentIdentifierFingerprint.patternScanEndIndex).registerA // Parameter that holds a ref to a type with a field that ref the protobuf buffer object. val protobufParameterNumber = 3 // Get the field that stores an protobuf buffer required below. val protobufBufferRefTypeRefFieldDescriptor = - instruction(ProtobufBufferFingerprint.patternScanStartIndex).descriptor + getInstruction(ProtobufBufferFingerprint.patternScanStartIndex).descriptor val protobufBufferRefTypeDescriptor = - instruction(ProtobufBufferFingerprint.patternScanEndIndex - 1).descriptor + getInstruction(ProtobufBufferFingerprint.patternScanEndIndex - 1).descriptor val protobufBufferFieldDescriptor = "$protobufBufferRefTypeDescriptor->b:Ljava/nio/ByteBuffer;" - addInstructions( + addInstructionsWithLabels( insertHookIndex, // right after setting the component.pathBuilder field. """ # Get the protobuf buffer object. @@ -97,7 +97,7 @@ class LithoFilterPatch : BytecodePatch( iget-object v$free, v$free, $emptyComponentFieldDescriptor return-object v$free """, - listOf(ExternalLabel("not_an_ad", instruction(insertHookIndex))) + ExternalLabel("not_an_ad", getInstruction(insertHookIndex)) ) } } ?: return ComponentContextParserFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index ba8d9be8d..3848df841 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -6,8 +6,8 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -50,10 +50,11 @@ class MinimizedPlaybackPatch : BytecodePatch( MinimizedPlaybackManagerFingerprint.result?.apply { mutableMethod.addInstructions( - 0, """ - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->isPlaybackNotShort()Z - move-result v0 - return v0 + 0, + """ + invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->isPlaybackNotShort()Z + move-result v0 + return v0 """ ) } ?: return MinimizedPlaybackManagerFingerprint.toErrorResult() @@ -68,10 +69,11 @@ class MinimizedPlaybackPatch : BytecodePatch( context.toMethodWalker(method).nextMethod(settingsBooleanIndex, true).getMethod() as MutableMethod settingsBooleanMethod.addInstructions( - 0, """ - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideMinimizedPlaybackAvailable()Z - move-result v0 - return v0 + 0, + """ + invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideMinimizedPlaybackAvailable()Z + move-result v0 + return v0 """ ) } ?: return MinimizedPlaybackSettingsFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt index 50b3d5cf1..7de6849bf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt index 9b1c95bc4..a777b5610 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playeroverlay/patch/PlayerOverlaysHookPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt index 999356376..7a036790a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -40,9 +40,10 @@ class PlayerTypeHookPatch : BytecodePatch( VideoStateFingerprint.result?.let { it.mutableMethod.apply { val endIndex = it.scanResult.patternScanResult!!.endIndex - val videoStateFieldName = instruction(endIndex).reference + val videoStateFieldName = getInstruction(endIndex).reference addInstructions( - 0, """ + 0, + """ iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt index 8804f02c5..393a20e6b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt @@ -5,10 +5,10 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -51,7 +51,7 @@ class SettingsPatch : BytecodePatch( setThemeMethod.apply { // This register is returned by the setTheme method. - val register = instruction(returnIndex).registerA + val register = getInstruction(returnIndex).registerA val setThemeInstruction = getSetThemeInstructionString("v$register") replaceInstruction(returnIndex, setThemeInstruction) @@ -75,7 +75,8 @@ class SettingsPatch : BytecodePatch( // initialize the settings addInstructions( - 1, """ + 1, + """ ${buildSettingsActivityInvokeString()} return-void """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/patch/ZoomHapticsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/patch/ZoomHapticsPatch.kt index a3e5eedfe..b7a952f69 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/patch/ZoomHapticsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/patch/ZoomHapticsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -39,13 +39,15 @@ class ZoomHapticsPatch : BytecodePatch( val zoomHapticsFingerprintMethod = ZoomHapticsFingerprint.result!!.mutableMethod - zoomHapticsFingerprintMethod.addInstructions( - 0, """ + zoomHapticsFingerprintMethod.addInstructionsWithLabels( + 0, + """ invoke-static { }, Lapp/revanced/integrations/patches/ZoomHapticsPatch;->shouldVibrate()Z move-result v0 if-nez v0, :vibrate return-void - """, listOf(ExternalLabel("vibrate", zoomHapticsFingerprintMethod.instruction(0))) + """, + ExternalLabel("vibrate", zoomHapticsFingerprintMethod.getInstruction(0)) ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/patch/HDRBrightnessPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/patch/HDRBrightnessPatch.kt index 6b8ae5b01..6abbedcd5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/patch/HDRBrightnessPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/patch/HDRBrightnessPatch.kt @@ -4,18 +4,18 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.video.hdrbrightness.annotations.HDRBrightnessCompatibility -import app.revanced.patches.youtube.video.hdrbrightness.fingerprints.HDRBrightnessFingerprint -import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch +import app.revanced.patches.youtube.video.hdrbrightness.annotations.HDRBrightnessCompatibility +import app.revanced.patches.youtube.video.hdrbrightness.fingerprints.HDRBrightnessFingerprint import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction import org.jf.dexlib2.iface.reference.FieldReference diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt index 1df612641..a3aa79a54 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt @@ -6,9 +6,9 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve @@ -76,11 +76,11 @@ class VideoInformationPatch : BytecodePatch( seekHelperMethod.addInstructions( 0, """ - sget-object v0, $seekSourceEnumType->a:$seekSourceEnumType - invoke-virtual {p0, p1, p2, v0}, ${seekFingerprintResultMethod.definingClass}->${seekFingerprintResultMethod.name}(J$seekSourceEnumType)Z - move-result p1 - return p1 - """ + sget-object v0, $seekSourceEnumType->a:$seekSourceEnumType + invoke-virtual {p0, p1, p2, v0}, ${seekFingerprintResultMethod.definingClass}->${seekFingerprintResultMethod.name}(J$seekSourceEnumType)Z + move-result p1 + return p1 + """ ) // add the seekTo method to the class for the integrations to call @@ -92,7 +92,7 @@ class VideoInformationPatch : BytecodePatch( with(videoLengthMethodResult.mutableMethod) { val videoLengthRegisterIndex = videoLengthMethodResult.scanResult.patternScanResult!!.endIndex - 2 - val videoLengthRegister = instruction(videoLengthRegisterIndex).registerA + val videoLengthRegister = getInstruction(videoLengthRegisterIndex).registerA val dummyRegisterForLong = videoLengthRegister + 1 // required for long values since they are wide addInstruction( @@ -139,7 +139,7 @@ class VideoInformationPatch : BytecodePatch( speedSelectionInsertMethod = mutableMethod speedSelectionInsertIndex = scanResult.patternScanResult!!.startIndex - 3 speedSelectionValueRegister = - mutableMethod.instruction(speedSelectionInsertIndex).registerD + mutableMethod.getInstruction(speedSelectionInsertIndex).registerD val speedSelectionMethodInstructions = mutableMethod.implementation!!.instructions setPlaybackSpeedContainerClassFieldReference = diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 1dcdf0303..7f9d1b77f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt index 609230e86..2877f39a1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt index ae5e53d83..73d02788c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt @@ -4,9 +4,12 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.patch.* +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patches.shared.settings.preference.impl.InputType import app.revanced.patches.shared.settings.preference.impl.StringResource @@ -73,8 +76,8 @@ class CustomVideoSpeedPatch : BytecodePatch( arrayGenMethod.addInstructions( arrayLengthConstIndex + 1, """ - sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType - array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination + sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType + array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt index 625d773df..de228935e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -79,10 +79,10 @@ class RememberPlaybackSpeedPatch : BytecodePatch( InitializePlaybackSpeedValuesFingerprint.result?.apply { // Infer everything necessary for calling the method setPlaybackSpeed(). val onItemClickListenerClassFieldReference = - mutableMethod.instruction(0).reference + mutableMethod.getInstruction(0).reference // Registers are not used at index 0, so they can be freely used. - mutableMethod.addInstructions( + mutableMethod.addInstructionsWithLabels( 0, """ invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->getPlaybackSpeedOverride()F @@ -105,7 +105,7 @@ class RememberPlaybackSpeedPatch : BytecodePatch( # Invoke setPlaybackSpeed on that class. invoke-virtual {v2, v0}, ${VideoInformationPatch.setPlaybackSpeedMethodReference} """.trimIndent(), - listOf(ExternalLabel("do_not_override", mutableMethod.instruction(0))) + ExternalLabel("do_not_override", mutableMethod.getInstruction(0)) ) } ?: return InitializePlaybackSpeedValuesFingerprint.toErrorResult() diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt index 4b8fbcc47..f33914854 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -33,7 +33,7 @@ class VideoIdPatch : BytecodePatch( result.mutableMethod.also { insertMethod = it }.apply { - videoIdRegister = instruction(videoIdRegisterInstructionIndex).registerA + videoIdRegister = getInstruction(videoIdRegisterInstructionIndex).registerA insertIndex = videoIdRegisterInstructionIndex + 1 } } ?: return VideoIdFingerprint.toErrorResult() @@ -44,7 +44,7 @@ class VideoIdPatch : BytecodePatch( result.mutableMethod.also { backgroundPlaybackMethod = it }.apply { - backgroundPlaybackVideoIdRegister = instruction(endIndex + 1).registerA + backgroundPlaybackVideoIdRegister = getInstruction(endIndex + 1).registerA backgroundPlaybackInsertIndex = endIndex + 2 } } ?: return VideoIdFingerprintBackgroundPlay.toErrorResult() @@ -74,7 +74,7 @@ class VideoIdPatch : BytecodePatch( */ fun injectCall( methodDescriptor: String - ) = insertMethod.addInstructions( + ) = insertMethod.addInstruction( // Keep injection calls in the order they're added: // Increment index. So if additional injection calls are added, those calls run after this injection call. insertIndex++, @@ -93,7 +93,7 @@ class VideoIdPatch : BytecodePatch( */ fun injectCallBackgroundPlay( methodDescriptor: String - ) = backgroundPlaybackMethod.addInstructions( + ) = backgroundPlaybackMethod.addInstruction( backgroundPlaybackInsertIndex++, // move-result-object offset "invoke-static {v$backgroundPlaybackVideoIdRegister}, $methodDescriptor" ) diff --git a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt index e704e983d..7ebceff26 100644 --- a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess @@ -32,7 +32,7 @@ class HideAdsPatch : BytecodePatch( ContainsAdFingerprint.result?.let { result -> result.mutableMethod.apply { val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1 - val adsListRegister = instruction(insertIndex - 2).registerA + val adsListRegister = getInstruction(insertIndex - 2).registerA listOf( "_buttoned_layout", @@ -50,7 +50,8 @@ class HideAdsPatch : BytecodePatch( "carousel_footered_layout" ).forEach { component -> addInstructions( - insertIndex, """ + insertIndex, + """ const-string v$adsListRegister, "$component" invoke-interface {v0, v$adsListRegister}, Ljava/util/List;->add(Ljava/lang/Object;)Z """ diff --git a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt index afdcdd2f7..4f42ea0ba 100644 --- a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt +++ b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index e780aafed..ccc57627b 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,9 +1,9 @@ package app.revanced.util.microg import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.addInstruction -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.util.proxy.mutableTypes.MutableClass diff --git a/src/main/kotlin/app/revanced/util/patch/MethodCall.kt b/src/main/kotlin/app/revanced/util/patch/MethodCall.kt index fe21f4fc1..9bd1bd447 100644 --- a/src/main/kotlin/app/revanced/util/patch/MethodCall.kt +++ b/src/main/kotlin/app/revanced/util/patch/MethodCall.kt @@ -1,6 +1,6 @@ package app.revanced.util.patch -import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.ClassDef