diff --git a/build.gradle.kts b/build.gradle.kts index f88cf372f..6b31fc735 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ repositories { dependencies { implementation(kotlin("stdlib")) - implementation("app.revanced:revanced-patcher:1.2.8") + implementation("app.revanced:revanced-patcher:1.3.0") } tasks { diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt index 69fef3f93..bd80e2369 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/patch/CodecsUnlockPatch.kt @@ -25,13 +25,13 @@ class CodecsUnlockPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - var result = signatures.first().result!! + var result = CodecsLockSignature.result!! val implementation = result.method.implementation!! val instructionIndex = result.scanResult.startIndex - result = signatures.last().result!! + result = AllCodecsReferenceSignature.result!! val codecMethod = data.toMethodWalker(result.immutableMethod).nextMethod(result.scanResult.startIndex).getMethod() 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 e1e67f521..c5694edc1 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 @@ -30,7 +30,7 @@ class ExclusiveAudioPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!!.findParentMethod(@Name("audio-only-enabler-method") @MatchingMethod( + val result = ExclusiveAudioSignature.result!!.findParentMethod(@Name("audio-only-enabler-method") @MatchingMethod( "Lgmd;", "d" ) @DirectPatternScanMethod @ExclusiveAudioCompatibility @Version( 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 b1be2a17c..5995370c9 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 @@ -25,20 +25,18 @@ class RemoveTasteBuilderPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!! + val result = TasteBuilderConstructorSignature.result!! val implementation = result.method.implementation!! val insertIndex = result.scanResult.endIndex - 8 val register = (implementation.instructions[insertIndex] as Instruction22c).registerA - val instructionList = """ + result.method.addInstructions( + insertIndex, """ const/16 v1, 0x8 invoke-virtual {v${register}, v1}, Landroid/view/View;->setVisibility(I)V - """.trimIndent().toInstructions().toMutableList() - - implementation.addInstructions( - insertIndex, instructionList + """ ) return PatchResultSuccess() 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 d682f767a..3018ac817 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 @@ -29,7 +29,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!! + val result = PivotBarConstructorSignature.result!! val implementation = result.method.implementation!! val pivotBarElementFieldRef = 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 84fe9a09f..a30492c76 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 @@ -24,7 +24,7 @@ class BackgroundPlayPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - signatures.first().result!!.method.implementation!!.addInstructions( + BackgroundPlaybackDisableSignature.result!!.method.implementation!!.addInstructions( 0, """ const/4 v0, 0x1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt index b9b8d2567..2ec0a66a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt @@ -242,25 +242,23 @@ class GeneralBytecodeAdsPatch : BytecodePatch( BuilderInstruction21t(Opcode.IF_EQZ, 1, lithoRemoveLabel) // create blocks - val parameters = lithoMethod.parameterTypes.joinToString("") { it } - val registers = lithoMethodImplementation.registerCount val block1 = """ invoke-static/range {p3}, $thisType->getTemplateName($templateNameParameterType)Ljava/lang/String; move-result-object v0 - """.trimIndent().toInstructions(parameters, registers, false) + """.trimIndent().toInstructions(lithoMethod) val block2 = """ move-object/from16 v1, p3 iget-object v2, v1, $templateNameParameterType->b:Ljava/nio/ByteBuffer; invoke-static {v0, v2}, Lfi/razerman/youtube/litho/LithoAdRemoval;->containsAd(Ljava/lang/String;Ljava/nio/ByteBuffer;)Z move-result v1 - """.trimIndent().toInstructions(parameters, registers, false) + """.trimIndent().toInstructions(lithoMethod) val block3 = """ move-object/from16 v2, p1 invoke-static {v2}, $descriptor1 move-result-object v0 iget-object v0, v0, $descriptor2 return-object v0 - """.trimIndent().toInstructions(parameters, registers, false) + """.trimIndent().toInstructions(lithoMethod) // insert blocks and branch instructions lithoMethodImplementation.insertBlocks( 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 293368fcd..1d7d5354b 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 @@ -34,7 +34,7 @@ class VideoAdsPatch : BytecodePatch( ) { override fun execute(data: BytecodeData): PatchResult { val result = - signatures.first().result!!.findParentMethod(@Name("show-video-ads-method-signature") @MatchingMethod( + ShowVideoAdsConstructorSignature.result!!.findParentMethod(@Name("show-video-ads-method-signature") @MatchingMethod( definingClass = "zai" ) @DirectPatternScanMethod @VideoAdsCompatibility @Version("0.0.1") object : MethodSignature( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null 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 d7c82e3df..bd7ed75bf 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 @@ -34,7 +34,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - var result = signatures.first().result!! + var result = SeekbarTappingParentSignature.result!! val tapSeekMethods = mutableMapOf() @@ -59,7 +59,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( } // replace map because we dont need the upper one anymore - result = signatures.last().result!! + result = SeekbarTappingSignature.result!! val implementation = result.method.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt index a4283c381..842e86eea 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/castbutton/patch/HideCastButtonPatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -26,14 +25,14 @@ class HideCastButtonPatch : BytecodePatch(listOf()) { data.classes.forEach { classDef -> classDef.methods.forEach { method -> if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") { - val implementation = - data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }.implementation!! + val setVisibilityMethod = + data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" } - implementation.addInstructions( + setVisibilityMethod.addInstructions( 0, """ - invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I - move-result p1 - """.trimIndent().toInstructions("I", 2, false) + invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I + move-result p1 + """ ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt index b72c85a33..8b1744d7b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt @@ -29,7 +29,7 @@ class CreateButtonRemoverPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!! + val result = CreateButtonSignature.result!! // Get the required register which holds the view object we need to pass to the method hideCreateButton val implementation = result.method.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt index bb28b6c8b..8378b8393 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -27,7 +27,7 @@ class MinimizedPlaybackPatch : BytecodePatch( override fun execute(data: BytecodeData): PatchResult { // Instead of removing all instructions like Vanced, // we return the method at the beginning instead - signatures.first().result!!.method.implementation!!.addInstructions( + MinimizedPlaybackManagerSignature.result!!.method.implementation!!.addInstructions( 0, """ const/4 v0, 0x1 return v0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 730f68e4c..5094a8cbb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -35,7 +35,7 @@ class OldQualityLayoutPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!!.findParentMethod(@Name("old-quality-signature") @MatchingMethod( + val result = OldQualityParentSignature.result!!.findParentMethod(@Name("old-quality-signature") @MatchingMethod( definingClass = "Libh" ) @FuzzyPatternScanMethod(2) @OldQualityLayoutCompatibility @Version("0.0.1") object : MethodSignature( "L", AccessFlags.FINAL or AccessFlags.PRIVATE, listOf("Z"), listOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt index 76bfba1dc..d516e5844 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt @@ -22,7 +22,7 @@ class HideReelsPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = signatures.first().result!! + val result = HideReelsSignature.result!! val implementation = result.method.implementation!! // HideReel will hide the reel view before it is being used, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt index aab7dd0d9..1bb3c9b9a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt @@ -28,12 +28,12 @@ class ShortsButtonRemoverPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - val result1 = signatures.first().result!! + val result1 = PivotBarButtonTabenumSignature.result!! val implementation1 = result1.method.implementation!! val moveEnumInstruction = implementation1.instructions[result1.scanResult.endIndex] val enumRegister = (moveEnumInstruction as Instruction11x).registerA - val result2 = signatures.last().result!! + val result2 = PivotBarButtonsViewSignature.result!! val implementation2 = result2.method.implementation!! val moveViewInstruction = implementation2.instructions[result2.scanResult.endIndex] val viewRegister = (moveViewInstruction as Instruction11x).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt index d21ef17cc..05205e244 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt @@ -31,7 +31,7 @@ class IntegrationsPatch : BytecodePatch( if (data.findClass("Lapp/revanced/integrations/Globals") == null) return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") - val result = signatures.first().result!! + val result = InitSignature.result!! val implementation = result.method.implementation!! val count = implementation.registerCount - 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index f1a5f8725..405851454 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -16,6 +16,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.smali.toInstruction import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch +import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePatch import app.revanced.patches.youtube.misc.microg.patch.resource.enum.StringReplaceMode @@ -31,7 +32,11 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference @Patch(include = false) @Dependencies( - dependencies = [MicroGResourcePatch::class, HideCastButtonPatch::class] + dependencies = [ + MicroGResourcePatch::class, + HideCastButtonPatch::class, + FixLocaleConfigErrorPatch::class + ] ) @Name("microg-support") @Description("Patch to allow YouTube ReVanced to run without root and under a different package name.") @@ -115,13 +120,19 @@ class MicroGBytecodePatch : BytecodePatch( } } - signatures.last() return PatchResultSuccess() } private fun disablePlayServiceChecksAndFixCastIssues() { - for (i in 0 until signatures.count() - 1) { - val result = signatures.elementAt(i).result!! + listOf( + IntegrityCheckSignature, + ServiceCheckSignature, + GooglePlayUtilitySignature, + CastDynamiteModuleSignature, + CastDynamiteModuleV2Signature, + CastContextFetchSignature + ).forEach { signature -> + val result = signature.result!! val stringInstructions = when (result.immutableMethod.returnType.first()) { 'L' -> """ const/4 v0, 0x0 @@ -141,7 +152,7 @@ class MicroGBytecodePatch : BytecodePatch( ) } - val implementation = signatures.last().result!!.method.implementation!! + val implementation = PrimeSignature.result!!.method.implementation!! var register = 2 val index = implementation.instructions.indexOfFirst { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt index 5636f7ff6..810fc9aee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/resource/MicroGResourcePatch.kt @@ -4,6 +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.implementation.ResourceData +import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.ResourcePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess