From 193635d4971720164c76c1a2be25a8cbd1299a5c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 21 Sep 2022 04:11:16 +0200 Subject: [PATCH] build: bump patcher dependency version to v5.0.0 --- build.gradle.kts | 2 +- .../ad/video/patch/MusicVideoAdsPatch.kt | 4 +-- .../audio/codecs/patch/CodecsUnlockPatch.kt | 4 +-- .../patch/ExclusiveAudioPatch.kt | 2 -- .../compactheader/patch/CompactHeaderPatch.kt | 2 +- .../premium/patch/HideGetPremiumPatch.kt | 8 +++-- .../patch/RemoveTasteBuilderPatch.kt | 2 +- .../patch/RemoveUpgradeButtonPatch.kt | 12 ++++--- .../ad/timeline/patch/TimelineAdsPatch.kt | 2 +- .../patch/HideInfocardSuggestionsPatch.kt | 2 +- .../youtube/ad/video/patch/VideoAdsPatch.kt | 2 +- .../patch/EnableSeekbarTappingPatch.kt | 12 ++++--- .../patch/FullscreenPanelsRemoverPatch.kt | 4 +-- .../patch/CreateButtonRemoverPatch.kt | 4 +-- .../patch/ShortsButtonRemoverPatch.kt | 4 +-- .../layout/reels/patch/HideReelsPatch.kt | 2 +- .../patch/SponsorBlockBytecodePatch.kt | 10 +++--- .../patch/TabletMiniPlayerPatch.kt | 4 +-- .../watermark/patch/HideWatermarkPatch.kt | 2 +- .../widesearchbar/patch/WideSearchbarPatch.kt | 6 ++-- .../misc/autorepeat/patch/AutoRepeatPatch.kt | 2 +- .../clientspoof/patch/ClientSpoofPatch.kt | 2 +- .../patch/PlayerControlsBytecodePatch.kt | 4 +-- .../patch/RememberVideoQualityPatch.kt | 2 +- .../settings/bytecode/patch/SettingsPatch.kt | 2 +- .../patch/CustomVideoBufferPatch.kt | 33 ++++++++++++------- .../misc/videoid/patch/VideoIdPatch.kt | 4 +-- 27 files changed, 76 insertions(+), 63 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 227fba009..417689ce7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ repositories { } dependencies { - implementation("app.revanced:revanced-patcher:4.4.2") + implementation("app.revanced:revanced-patcher:5.0.0") implementation("app.revanced:multidexlib2:2.5.2.r2") // Required for meta implementation("com.google.code.gson:gson:2.9.1") 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 c65d0286c..96e1b09a1 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 @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch @@ -30,7 +30,7 @@ class MusicVideoAdsPatch : BytecodePatch( val result = ShowMusicVideoAdsFingerprint.result!! result.mutableMethod.addInstructions( - result.patternScanResult!!.startIndex, """ + result.scanResult.patternScanResult!!.startIndex, """ const/4 p1, 0x0 """ ) 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 a9f0e1a22..3e91ab1a7 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 @@ -30,7 +30,7 @@ class CodecsUnlockPatch : BytecodePatch( val implementation = codecsLockResult.mutableMethod.implementation!! - val scanResultStartIndex = codecsLockResult.patternScanResult!!.startIndex + val scanResultStartIndex = codecsLockResult.scanResult.patternScanResult!!.startIndex val instructionIndex = scanResultStartIndex + if (implementation.instructions[scanResultStartIndex - 1].opcode == Opcode.CHECK_CAST) { // for 5.16.xx and lower @@ -43,7 +43,7 @@ class CodecsUnlockPatch : BytecodePatch( val allCodecsResult = AllCodecsReferenceFingerprint.result!! val allCodecsMethod = data.toMethodWalker(allCodecsResult.method) - .nextMethod(allCodecsResult.patternScanResult!!.startIndex) + .nextMethod(allCodecsResult.scanResult.patternScanResult!!.startIndex) .getMethod() implementation.replaceInstruction( 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 4f7ad175a..ace902685 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 @@ -6,14 +6,12 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint -import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.ExclusiveAudioFingerprint @Patch @Name("exclusive-audio-playback") 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 f58d8875f..ae05a5c85 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 @@ -27,7 +27,7 @@ class CompactHeaderPatch : BytecodePatch( val result = CompactHeaderConstructorFingerprint.result!! val method = result.mutableMethod - val insertIndex = result.patternScanResult!!.endIndex + val insertIndex = result.scanResult.patternScanResult!!.endIndex val register = (method.implementation!!.instructions[insertIndex - 1] as BuilderInstruction11x).registerA method.addInstructions( insertIndex, """ 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 b8121bccf..a85ee5b7e 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 @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.patch.PatchResult @@ -29,9 +29,11 @@ class HideGetPremiumPatch : BytecodePatch( val parentResult = HideGetPremiumParentFingerprint.result!! HideGetPremiumFingerprint.resolve(data, parentResult.classDef) + val startIndex = parentResult.scanResult.patternScanResult!!.startIndex + val parentMethod = parentResult.mutableMethod parentMethod.replaceInstruction( - parentResult.patternScanResult!!.startIndex, """ + startIndex, """ const/4 v1, 0x0 """ ) @@ -39,7 +41,7 @@ class HideGetPremiumPatch : BytecodePatch( val result = HideGetPremiumFingerprint.result!! val method = result.mutableMethod method.addInstructions( - result.patternScanResult!!.startIndex, """ + startIndex, """ const/16 v0, 0x8 """ ) 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 77d5eacaa..934af5b40 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 @@ -27,7 +27,7 @@ class RemoveTasteBuilderPatch : BytecodePatch( val result = TasteBuilderConstructorFingerprint.result!! val method = result.mutableMethod - val insertIndex = result.patternScanResult!!.endIndex - 8 + val insertIndex = result.scanResult.patternScanResult!!.endIndex - 8 val register = (method.implementation!!.instructions[insertIndex] as Instruction22c).registerA method.addInstructions( insertIndex, """ 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 f1c0b0e05..df735e0e1 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 @@ -33,7 +33,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch( val implementation = result.mutableMethod.implementation!! val pivotBarElementFieldRef = - (implementation.instructions[result.patternScanResult!!.endIndex - 1] as Instruction22c).reference + (implementation.instructions[result.scanResult.patternScanResult!!.endIndex - 1] as Instruction22c).reference val register = (implementation.instructions.first() as Instruction35c).registerC // first compile all the needed instructions @@ -46,16 +46,18 @@ class RemoveUpgradeButtonPatch : BytecodePatch( """.toInstructions().toMutableList() + val endIndex = result.scanResult.patternScanResult!!.endIndex + // replace the instruction to retain the label at given index implementation.replaceInstruction( - result.patternScanResult!!.endIndex - 1, instructionList[0] // invoke-interface + endIndex - 1, instructionList[0] // invoke-interface ) // do not forget to remove this instruction since we added it already instructionList.removeFirst() val exitInstruction = instructionList.last() // iput-object implementation.addInstruction( - result.patternScanResult!!.endIndex, exitInstruction + endIndex, exitInstruction ) // do not forget to remove this instruction since we added it already instructionList.removeLast() @@ -64,12 +66,12 @@ class RemoveUpgradeButtonPatch : BytecodePatch( instructionList.add( 2, // if-le BuilderInstruction22t( - Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.patternScanResult!!.endIndex) + Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(endIndex) ) ) implementation.addInstructions( - result.patternScanResult!!.endIndex, instructionList + endIndex, instructionList ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt index ebc1478e6..425d80f8f 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/ad/timeline/patch/TimelineAdsPatch.kt @@ -58,7 +58,7 @@ class TimelineAdsPatch : BytecodePatch( // Set the tweetId field to null // This will cause twitter to not show the promoted ads, because we set it to null, when the tweet is promoted parserFingerprintResult.mutableMethod.addInstructions( - parserFingerprintResult.patternScanResult!!.startIndex + 1, + parserFingerprintResult.scanResult.patternScanResult!!.startIndex + 1, """ const/4 v2, 0x0 iput-object v2, p0, Lcom/twitter/model/json/timeline/urt/JsonTimelineTweet;->${tweetIdFieldReference.name}:Ljava/lang/String; diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt index 0d49d39bb..7a3e62ada 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/infocardsuggestions/patch/HideInfocardSuggestionsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.replaceInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess 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 334acc40e..cda422408 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 @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn 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 9b6b68893..b1c5a4d55 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 @@ -79,15 +79,17 @@ class EnableSeekbarTappingPatch : BytecodePatch( val pMethod = tapSeekMethods["P"]!! val oMethod = tapSeekMethods["O"]!! + val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1 + // get the required register - val instruction = implementation.instructions[result.patternScanResult!!.endIndex] + val instruction = implementation.instructions[insertIndex - 1] if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register") val register = (instruction as Instruction35c).registerC - val elseLabel = implementation.newLabelForIndex(result.patternScanResult!!.endIndex + 1) + val elseLabel = implementation.newLabelForIndex(insertIndex) // the instructions are written in reverse order. result.mutableMethod.addInstructions( - result.patternScanResult!!.endIndex + 1, """ + insertIndex, """ invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V """ @@ -95,10 +97,10 @@ class EnableSeekbarTappingPatch : BytecodePatch( // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label implementation.addInstruction( - result.patternScanResult!!.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) + insertIndex, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) ) result.mutableMethod.addInstructions( - result.patternScanResult!!.endIndex + 1, """ + insertIndex, """ invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->isTapSeekingEnabled()Z move-result v0 """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt index 4cd0a3c7d..1cbe85f5b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/fullscreenpanels/patch/FullscreenPanelsRemoverPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess @@ -50,7 +50,7 @@ class FullscreenPanelsRemoverPatch : BytecodePatch( val method = result.mutableMethod - val ifIndex = result.patternScanResult!!.startIndex + 2 + val ifIndex = result.scanResult.patternScanResult!!.startIndex + 2 method.removeInstruction(ifIndex) method.addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt index 8846be4b9..ee8536f2e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/createbutton/patch/CreateButtonRemoverPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess @@ -55,7 +55,7 @@ class CreateButtonRemoverPatch : BytecodePatch( return PatchResultError("${PivotBarCreateButtonViewFingerprint.name} failed") val createButtonResult = PivotBarCreateButtonViewFingerprint.result!! - val insertIndex = createButtonResult.patternScanResult!!.endIndex + val insertIndex = createButtonResult.scanResult.patternScanResult!!.endIndex /* * Inject hooks diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt index 45360d821..a795c26d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/pivotbar/shortsbutton/patch/ShortsButtonRemoverPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.MethodFingerprintExtensions.name -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess @@ -58,7 +58,7 @@ class ShortsButtonRemoverPatch : BytecodePatch( if (!resolutionSucceeded) return PatchResultError("${it.name} failed") } - .map { it.result!!.patternScanResult!! } + .map { it.result!!.scanResult.patternScanResult!! } val enumScanResult = fingerprintResults[0] val buttonViewResult = fingerprintResults[1] 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 7025d4e05..fd5c2370b 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 @@ -42,7 +42,7 @@ class HideReelsPatch : BytecodePatch( // HideReel will hide the reel view before it is being used, // so we pass the view to the HideReel method result.mutableMethod.addInstruction( - result.patternScanResult!!.endIndex, + result.scanResult.patternScanResult!!.endIndex, "invoke-static { v2 }, Lapp/revanced/integrations/patches/HideReelsPatch;->HideReel(Landroid/view/View;)V" ) 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 671877f4b..b9bd83267 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 @@ -10,7 +10,7 @@ import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn @@ -63,7 +63,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( */ val referenceResult = PlayerControllerSetTimeReferenceFingerprint.result!! val playerControllerSetTimeMethod = - data.toMethodWalker(referenceResult.method).nextMethod(referenceResult.patternScanResult!!.startIndex, true) + data.toMethodWalker(referenceResult.method).nextMethod(referenceResult.scanResult.patternScanResult!!.startIndex, true) .getMethod() as MutableMethod playerControllerSetTimeMethod.addInstruction( 2, @@ -163,11 +163,11 @@ class SponsorBlockBytecodePatch : BytecodePatch( val videoLengthMethodInstructions = videoLengthMethod.implementation!!.instructions val videoLengthRegister = - (videoLengthMethodInstructions[videoLengthMethodResult.patternScanResult!!.endIndex - 2] as OneRegisterInstruction).registerA + (videoLengthMethodInstructions[videoLengthMethodResult.scanResult.patternScanResult!!.endIndex - 2] as OneRegisterInstruction).registerA val dummyRegisterForLong = videoLengthRegister + 1 // this is required for long values since they are 64 bit wide videoLengthMethod.addInstruction( - videoLengthMethodResult.patternScanResult!!.endIndex, + videoLengthMethodResult.scanResult.patternScanResult!!.endIndex, "invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setVideoLength(J)V" ) @@ -231,7 +231,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( // append the new time to the player layout val appendTimeFingerprintResult = AppendTimeFingerprint.result!! - val appendTimePatternScanStartIndex = appendTimeFingerprintResult.patternScanResult!!.startIndex + val appendTimePatternScanStartIndex = appendTimeFingerprintResult.scanResult.patternScanResult!!.startIndex val targetRegister = (appendTimeFingerprintResult.method.implementation!!.instructions.elementAt(appendTimePatternScanStartIndex + 1) as OneRegisterInstruction).registerA 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 e1ae18df7..58d03157d 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 @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn @@ -92,7 +92,7 @@ class TabletMiniPlayerPatch : BytecodePatch( fun MethodFingerprint.unwrap(): Triple { val result = this.result!! - val scanIndex = result.patternScanResult!!.endIndex + val scanIndex = result.scanResult.patternScanResult!!.endIndex val method = result.mutableMethod val instructions = method.implementation!!.instructions val parameterRegister = (instructions[scanIndex] as OneRegisterInstruction).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt index 17eef1171..8518ad76f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/watermark/patch/HideWatermarkPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt index 3154f4ebc..bdd6ca83c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/widesearchbar/patch/WideSearchbarPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.data.impl.toMethodWalker import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn @@ -52,7 +52,7 @@ class WideSearchbarPatch : BytecodePatch( //This should be the method aF in class fbn val targetMethodOne = - data.toMethodWalker(resultOne!!.method).nextMethod(resultOne.patternScanResult!!.endIndex, true).getMethod() as MutableMethod + data.toMethodWalker(resultOne!!.method).nextMethod(resultOne.scanResult.patternScanResult!!.endIndex, true).getMethod() as MutableMethod //Since both methods have the same smali code, inject instructions using a method. addInstructions(targetMethodOne) @@ -61,7 +61,7 @@ class WideSearchbarPatch : BytecodePatch( //This should be the method aB in class fbn val targetMethodTwo = - data.toMethodWalker(resultTwo!!.method).nextMethod(resultTwo.patternScanResult!!.startIndex, true).getMethod() as MutableMethod + data.toMethodWalker(resultTwo!!.method).nextMethod(resultTwo.scanResult.patternScanResult!!.startIndex, true).getMethod() as MutableMethod //Since both methods have the same smali code, inject instructions using a method. addInstructions(targetMethodTwo) 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 992f3c30d..e229e95d6 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 @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.removeInstruction -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultSuccess diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt index f9ad8f42b..52dc1962e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/clientspoof/patch/ClientSpoofPatch.kt @@ -26,7 +26,7 @@ class ClientSpoofPatch : BytecodePatch( val result = UserAgentHeaderBuilderFingerprint.result!! val method = result.mutableMethod - val insertIndex = result.patternScanResult!!.endIndex + val insertIndex = result.scanResult.patternScanResult!!.endIndex val packageNameRegister = (method.instruction(insertIndex) as FiveRegisterInstruction).registerD val originalPackageName = "com.google.android.youtube" 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 e629ecbfc..5c064eb07 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 @@ -5,8 +5,8 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn @@ -47,7 +47,7 @@ class PlayerControlsBytecodePatch : BytecodePatch( private var inflateFingerprintResult: MethodFingerprintResult? = null set(fingerprint) { field = fingerprint!!.also { - moveToRegisterInstructionIndex = it.patternScanResult!!.endIndex + moveToRegisterInstructionIndex = it.scanResult.patternScanResult!!.endIndex viewRegister = (it.mutableMethod.implementation!!.instructions[moveToRegisterInstructionIndex] as OneRegisterInstruction).registerA } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt index 78ef2ed48..14e840391 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/quality/patch/RememberVideoQualityPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn 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 72eb3d048..bede3afda 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 @@ -61,7 +61,7 @@ class SettingsPatch : BytecodePatch( // add instructions to set the theme of the settings activity themeSetterResult.mutableMethod.implementation!!.let { it.addInstruction( - themeSetterResult.patternScanResult!!.startIndex, + themeSetterResult.scanResult.patternScanResult!!.startIndex, setThemeInstruction ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt index f0f8cb86b..d21803dd5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt @@ -5,11 +5,14 @@ import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint 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.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.framework.components.impl.InputType import app.revanced.patches.youtube.misc.settings.framework.components.impl.PreferenceScreen @@ -83,10 +86,9 @@ class CustomVideoBufferPatch : BytecodePatch( } private fun execMaxBuffer() { - val result = MaxBufferFingerprint.result!! - val method = result.mutableMethod - val index = result.patternScanResult!!.endIndex - 1 - val register = (method.implementation!!.instructions[index] as OneRegisterInstruction).registerA + val (method, result) = MaxBufferFingerprint.unwrap() + val (index, register) = result + method.addInstructions( index + 1, """ invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getMaxBuffer()I @@ -96,10 +98,9 @@ class CustomVideoBufferPatch : BytecodePatch( } private fun execPlaybackBuffer() { - val result = PlaybackBufferFingerprint.result!! - val method = result.mutableMethod - val index = result.patternScanResult!!.startIndex - val register = (method.implementation!!.instructions[index] as OneRegisterInstruction).registerA + val (method, result) = PlaybackBufferFingerprint.unwrap() + val (index, register) = result + method.addInstructions( index + 1, """ invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getPlaybackBuffer()I @@ -109,10 +110,9 @@ class CustomVideoBufferPatch : BytecodePatch( } private fun execReBuffer() { - val result = ReBufferFingerprint.result!! - val method = result.mutableMethod - val index = result.patternScanResult!!.startIndex - val register = (method.implementation!!.instructions.get(index) as OneRegisterInstruction).registerA + val (method, result) = ReBufferFingerprint.unwrap() + val (index, register) = result + method.addInstructions( index + 1, """ invoke-static {}, Lapp/revanced/integrations/patches/VideoBufferPatch;->getReBuffer()I @@ -120,4 +120,13 @@ class CustomVideoBufferPatch : BytecodePatch( """ ) } + + private fun MethodFingerprint.unwrap(): Pair> { + val result = this.result!! + val method = result.mutableMethod + val index = result.scanResult.patternScanResult!!.startIndex + val register = (method.instruction(index) as OneRegisterInstruction).registerA + + return method to (index to register) + } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt index cd371fc22..4ca4a14ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt @@ -31,7 +31,7 @@ class VideoIdPatch : BytecodePatch( insertMethod = result.mutableMethod videoIdRegister = - (insertMethod.implementation!!.instructions[result.patternScanResult!!.endIndex + 1] as OneRegisterInstruction).registerA + (insertMethod.implementation!!.instructions[result.scanResult.patternScanResult!!.endIndex + 1] as OneRegisterInstruction).registerA injectCall("Lapp/revanced/integrations/videoplayer/VideoInformation;->setCurrentVideoId(Ljava/lang/String;)V") @@ -55,7 +55,7 @@ class VideoIdPatch : BytecodePatch( methodDescriptor: String ) { insertMethod.addInstructions( - result.patternScanResult!!.endIndex + offset, // move-result-object offset + result.scanResult.patternScanResult!!.endIndex + offset, // move-result-object offset "invoke-static {v$videoIdRegister}, $methodDescriptor" ) }