From 084078e7f1852ccd2045e3fa8aedc25a7fd5faa8 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 26 Jun 2022 15:15:59 +0200 Subject: [PATCH] refactor: migrate from `Signature` to `Fingerprint` BREAKING CHANGE: Not backwards compatible, since a lot of classes where renamed. --- build.gradle.kts | 11 +++- .../AllCodecsReferenceFingerprint.kt} | 12 ++-- .../CodecsLockFingerprint.kt} | 12 ++-- .../audio/codecs/patch/CodecsUnlockPatch.kt | 26 ++++---- .../AudioOnlyEnablerFingerprint.kt | 41 +++++++++++++ .../ExclusiveAudioFingerprint.kt} | 12 ++-- .../patch/ExclusiveAudioPatch.kt | 61 +++++-------------- .../TasteBuilderConstructorFingerprint.kt} | 12 ++-- .../patch/RemoveTasteBuilderPatch.kt | 24 ++++---- .../PivotBarConstructorFingerprint.kt} | 12 ++-- .../patch/RemoveUpgradeButtonPatch.kt | 28 ++++----- .../BackgroundPlaybackDisableFingerprint.kt} | 12 ++-- .../patch/BackgroundPlayPatch.kt | 14 ++--- .../bytecode/extensions/MethodExtensions.kt | 2 +- .../bytecode/patch/GeneralBytecodeAdsPatch.kt | 12 ++-- .../resource/patch/GeneralResourceAdsPatch.kt | 8 +-- .../ShowVideoAdsConstructorFingerprint.kt} | 12 ++-- .../fingerprints/ShowVideoAdsFingerprint.kt | 19 ++++++ .../youtube/ad/video/patch/VideoAdsPatch.kt | 29 +++------ .../SeekbarTappingFingerprint.kt} | 12 ++-- .../SeekbarTappingParentFingerprint.kt} | 12 ++-- .../patch/EnableSeekbarTappingPatch.kt | 40 ++++++------ .../layout/amoled/patch/AmoledPatch.kt | 8 +-- .../header/patch/PremiumHeadingPatch.kt | 10 +-- .../icon/patch/CustomBrandingPatch.kt | 10 +-- .../castbutton/patch/HideCastButtonPatch.kt | 10 +-- .../CreateButtonFingerprint.kt} | 12 ++-- .../patch/CreateButtonRemoverPatch.kt | 27 ++++---- .../patch/FullscreenPanelsRemoverPatch.kt | 10 +-- .../MinimizedPlaybackManagerFingerprint.kt} | 12 ++-- .../patch/MinimizedPlaybackPatch.kt | 14 ++--- .../fingerprints/OldQualityFingerprint.kt | 27 ++++++++ .../OldQualityParentFingerprint.kt} | 12 ++-- .../patch/OldQualityLayoutPatch.kt | 44 +++++-------- .../HideReelsFingerprint.kt} | 12 ++-- .../layout/reels/patch/HideReelsPatch.kt | 20 +++--- .../PivotBarButtonTabEnumFingerprint.kt} | 14 ++--- .../PivotBarButtonsViewFingerprint.kt} | 14 ++--- .../button/patch/ShortsButtonRemoverPatch.kt | 42 ++++++------- .../InitFingerprint.kt} | 10 +-- .../integrations/patch/IntegrationsPatch.kt | 25 ++++---- .../patch/FixLocaleConfigErrorPatch.kt | 8 +-- .../ResourceIdMappingProviderResourcePatch.kt | 8 +-- .../CastContextFetchFingerprint.kt | 20 ++++++ .../CastDynamiteModuleFingerprint.kt | 20 ++++++ .../CastDynamiteModuleV2Fingerprint.kt | 20 ++++++ .../GooglePlayUtilityFingerprint.kt} | 12 ++-- .../IntegrityCheckFingerprint.kt} | 14 ++--- .../microg/fingerprints/PrimeFingerprint.kt | 19 ++++++ .../ServiceCheckFingerprint.kt} | 12 ++-- .../patch/bytecode/MicroGBytecodePatch.kt | 55 +++++++++-------- .../patch/resource/MicroGResourcePatch.kt | 8 +-- .../signatures/CastContextFetchSignature.kt | 20 ------ .../signatures/CastDynamiteModuleSignature.kt | 20 ------ .../CastDynamiteModuleV2Signature.kt | 20 ------ .../misc/microg/signatures/PrimeSignature.kt | 19 ------ 56 files changed, 535 insertions(+), 496 deletions(-) rename src/main/kotlin/app/revanced/patches/music/audio/codecs/{signatures/AllCodecsReferenceSignature.kt => fingerprints/AllCodecsReferenceFingerprint.kt} (80%) rename src/main/kotlin/app/revanced/patches/music/audio/codecs/{signatures/CodecsLockSignature.kt => fingerprints/CodecsLockFingerprint.kt} (75%) create mode 100644 src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt rename src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/{signatures/ExclusiveAudioSignature.kt => fingerprints/ExclusiveAudioFingerprint.kt} (78%) rename src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/{signatures/TasteBuilderConstructorSignature.kt => fingerprints/TasteBuilderConstructorFingerprint.kt} (73%) rename src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/{signatures/PivotBarConstructorSignature.kt => fingerprints/PivotBarConstructorFingerprint.kt} (81%) rename src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/{signatures/BackgroundPlaybackDisableSignature.kt => fingerprints/BackgroundPlaybackDisableFingerprint.kt} (74%) rename src/main/kotlin/app/revanced/patches/youtube/ad/video/{signatures/ShowVideoAdsConstructorSignature.kt => fingerprints/ShowVideoAdsConstructorFingerprint.kt} (70%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/{signatures/SeekbarTappingSignature.kt => fingerprints/SeekbarTappingFingerprint.kt} (72%) rename src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/{signatures/SeekbarTappingParentSignature.kt => fingerprints/SeekbarTappingParentFingerprint.kt} (77%) rename src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/{signatures/CreateButtonSignature.kt => fingerprints/CreateButtonFingerprint.kt} (78%) rename src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/{signatures/MinimizedPlaybackManagerSignature.kt => fingerprints/MinimizedPlaybackManagerFingerprint.kt} (72%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityFingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/{signatures/OldQualityParentSignature.kt => fingerprints/OldQualityParentFingerprint.kt} (74%) rename src/main/kotlin/app/revanced/patches/youtube/layout/reels/{signatures/HideReelsSignature.kt => fingerprints/HideReelsFingerprint.kt} (59%) rename src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/{signatures/PivotBarButtonTabenumSignature.kt => fingerprints/PivotBarButtonTabEnumFingerprint.kt} (71%) rename src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/{signatures/PivotBarButtonsViewSignature.kt => fingerprints/PivotBarButtonsViewFingerprint.kt} (74%) rename src/main/kotlin/app/revanced/patches/youtube/misc/integrations/{signatures/InitSignature.kt => fingerprints/InitFingerprint.kt} (53%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/misc/microg/{signatures/GooglePlayUtilitySignature.kt => fingerprints/GooglePlayUtilityFingerprint.kt} (94%) rename src/main/kotlin/app/revanced/patches/youtube/misc/microg/{signatures/IntegrityCheckSignature.kt => fingerprints/IntegrityCheckFingerprint.kt} (83%) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt rename src/main/kotlin/app/revanced/patches/youtube/misc/microg/{signatures/ServiceCheckSignature.kt => fingerprints/ServiceCheckFingerprint.kt} (76%) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastContextFetchSignature.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleSignature.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleV2Signature.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/PrimeSignature.kt diff --git a/build.gradle.kts b/build.gradle.kts index 8664a14c8..c6e28e315 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,13 +4,17 @@ plugins { group = "app.revanced" +val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR") +val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN") + repositories { mavenCentral() + mavenLocal() maven { url = uri("https://maven.pkg.github.com/revanced/revanced-patcher") credentials { - username = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR") - password = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN") + username = githubUsername + password = githubPassword } } } @@ -18,7 +22,8 @@ repositories { dependencies { implementation(kotlin("stdlib")) - implementation("app.revanced:revanced-patcher:1.10.2") + implementation("app.revanced:revanced-patcher:2.0.0") + implementation("app.revanced:multidexlib2:2.5.2.r2") } tasks { diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/AllCodecsReferenceSignature.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/AllCodecsReferenceSignature.kt rename to src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt index 2ff563ad9..7ab93ee3d 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/AllCodecsReferenceSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/AllCodecsReferenceFingerprint.kt @@ -1,16 +1,16 @@ -package app.revanced.patches.music.audio.codecs.signatures +package app.revanced.patches.music.audio.codecs.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher. fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("all-codecs-reference-signature") +@Name("all-codecs-reference-fingerprint") @MatchingMethod( "Laari;", "b", @@ -18,7 +18,7 @@ import org.jf.dexlib2.Opcode @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CodecsUnlockCompatibility @Version("0.0.1") -object AllCodecsReferenceSignature : MethodSignature( +object AllCodecsReferenceFingerprint : MethodFingerprint( "J", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/CodecsLockSignature.kt b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/CodecsLockSignature.kt rename to src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt index ff3f56de7..12ab3dd25 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/codecs/signatures/CodecsLockSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/codecs/fingerprints/CodecsLockFingerprint.kt @@ -1,16 +1,16 @@ -package app.revanced.patches.music.audio.codecs.signatures +package app.revanced.patches.music.audio.codecs.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("codec-lock-signature") +@Name("codec-lock-fingerprint") @MatchingMethod( "Labwj;", "a", @@ -18,7 +18,7 @@ import org.jf.dexlib2.Opcode @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CodecsUnlockCompatibility @Version("0.0.1") -object CodecsLockSignature : MethodSignature( +object CodecsLockFingerprint : MethodFingerprint( "L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L", "L", "L"), listOf( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT_OBJECT, 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 bd80e2369..ed832e084 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 @@ -3,16 +3,16 @@ package app.revanced.patches.music.audio.codecs.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.data.implementation.toMethodWalker +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.impl.toMethodWalker 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.music.audio.codecs.annotations.CodecsUnlockCompatibility -import app.revanced.patches.music.audio.codecs.signatures.AllCodecsReferenceSignature -import app.revanced.patches.music.audio.codecs.signatures.CodecsLockSignature +import app.revanced.patches.music.audio.codecs.fingerprints.AllCodecsReferenceFingerprint +import app.revanced.patches.music.audio.codecs.fingerprints.CodecsLockFingerprint @Patch @Name("codecs-unlock") @@ -21,19 +21,19 @@ import app.revanced.patches.music.audio.codecs.signatures.CodecsLockSignature @Version("0.0.1") class CodecsUnlockPatch : BytecodePatch( listOf( - CodecsLockSignature, AllCodecsReferenceSignature + CodecsLockFingerprint, AllCodecsReferenceFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - var result = CodecsLockSignature.result!! + var result = CodecsLockFingerprint.result!! - val implementation = result.method.implementation!! + val implementation = result.mutableMethod.implementation!! - val instructionIndex = result.scanResult.startIndex + val instructionIndex = result.patternScanResult!!.startIndex - result = AllCodecsReferenceSignature.result!! + result = AllCodecsReferenceFingerprint.result!! val codecMethod = - data.toMethodWalker(result.immutableMethod).nextMethod(result.scanResult.startIndex).getMethod() + data.toMethodWalker(result.method).nextMethod(result.patternScanResult!!.startIndex).getMethod() implementation.replaceInstruction( instructionIndex, diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt new file mode 100644 index 000000000..e9ad0e5fa --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/AudioOnlyEnablerFingerprint.kt @@ -0,0 +1,41 @@ +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +@Name("audio-only-enabler-fingerprint") +@MatchingMethod( + "Lgmd;", + "d" +) +@DirectPatternScanMethod +@ExclusiveAudioCompatibility +@Version( + "0.0.1" +) +object AudioOnlyEnablerFingerprint: MethodFingerprint( + "Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.CHECK_CAST, + Opcode.IF_NEZ, + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.GOTO, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT, + Opcode.RETURN + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/signatures/ExclusiveAudioSignature.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/signatures/ExclusiveAudioSignature.kt rename to src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt index 4e384c0ae..f4965890d 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/signatures/ExclusiveAudioSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/fingerprints/ExclusiveAudioFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.music.audio.exclusiveaudio.signatures +package app.revanced.patches.music.audio.exclusiveaudio.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("exclusive-audio-signature") +@Name("exclusive-audio-fingerprints") @MatchingMethod( "Lgmd;", "c" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @ExclusiveAudioCompatibility @Version("0.0.1") -object ExclusiveAudioSignature : MethodSignature( +object ExclusiveAudioFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "Z"), 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 6c112fad1..752045779 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 @@ -1,23 +1,19 @@ package app.revanced.patches.music.audio.exclusiveaudio.patch +import AudioOnlyEnablerFingerprint import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.extensions.or +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.implementation.BytecodePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patcher.util.smali.toInstruction +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.music.audio.exclusiveaudio.annotations.ExclusiveAudioCompatibility -import app.revanced.patches.music.audio.exclusiveaudio.signatures.ExclusiveAudioSignature -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode +import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.ExclusiveAudioFingerprint @Patch @Name("exclusive-audio-playback") @@ -26,44 +22,15 @@ import org.jf.dexlib2.Opcode @Version("0.0.1") class ExclusiveAudioPatch : BytecodePatch( listOf( - ExclusiveAudioSignature + ExclusiveAudioFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = ExclusiveAudioSignature.result!!.findParentMethod(@Name("audio-only-enabler-method") @MatchingMethod( - "Lgmd;", - "d" - ) @DirectPatternScanMethod @ExclusiveAudioCompatibility @Version( - "0.0.1" - ) object : MethodSignature( - "Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_INTERFACE, - Opcode.MOVE_RESULT_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.IF_NEZ, - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT, - Opcode.GOTO, - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT, - Opcode.RETURN - ) - ) {}) ?: return PatchResultError("Required parent method could not be found.") + ExclusiveAudioFingerprint.resolve(data, AudioOnlyEnablerFingerprint.result!!.classDef) - val implementation = result.method.implementation!! - implementation.replaceInstruction( - implementation.instructions.count() - 1, "const/4 v0, 0x1".toInstruction() - ) - implementation.addInstruction( - "return v0".toInstruction() - ) + val method = ExclusiveAudioFingerprint.result!!.mutableMethod + method.replaceInstruction(method.implementation!!.instructions.count() - 1, "const/4 v0, 0x1") + method.addInstruction("return v0") return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/signatures/TasteBuilderConstructorSignature.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/signatures/TasteBuilderConstructorSignature.kt rename to src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt index f00284b07..d68ef1b13 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/signatures/TasteBuilderConstructorSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/fingerprints/TasteBuilderConstructorFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.music.layout.tastebuilder.signatures +package app.revanced.patches.music.layout.tastebuilder.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("taste-builder-constructor") +@Name("taste-builder-constructor-fingerprint") @MatchingMethod( "Lkyu;", "" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @RemoveTasteBuilderCompatibility @Version("0.0.1") -object TasteBuilderConstructorSignature : MethodSignature( +object TasteBuilderConstructorFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L", "L"), listOf( Opcode.INVOKE_DIRECT, Opcode.INVOKE_VIRTUAL, 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 c5cd8f94a..3830433fe 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 @@ -3,14 +3,14 @@ package app.revanced.patches.music.layout.tastebuilder.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility -import app.revanced.patches.music.layout.tastebuilder.signatures.TasteBuilderConstructorSignature +import app.revanced.patches.music.layout.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint import org.jf.dexlib2.iface.instruction.formats.Instruction22c @Patch @@ -20,18 +20,16 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction22c @Version("0.0.1") class RemoveTasteBuilderPatch : BytecodePatch( listOf( - TasteBuilderConstructorSignature + TasteBuilderConstructorFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = TasteBuilderConstructorSignature.result!! - val implementation = result.method.implementation!! + val result = TasteBuilderConstructorFingerprint.result!! + val method = result.mutableMethod - val insertIndex = result.scanResult.endIndex - 8 - - val register = (implementation.instructions[insertIndex] as Instruction22c).registerA - - result.method.addInstructions( + val insertIndex = result.patternScanResult!!.endIndex - 8 + val register = (method.implementation!!.instructions[insertIndex] as Instruction22c).registerA + method.addInstructions( 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/signatures/PivotBarConstructorSignature.kt b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt similarity index 81% rename from src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/signatures/PivotBarConstructorSignature.kt rename to src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt index 238340d50..20e7a5371 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/signatures/PivotBarConstructorSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/fingerprints/PivotBarConstructorFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.music.layout.upgradebutton.signatures +package app.revanced.patches.music.layout.upgradebutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.layout.upgradebutton.annotations.RemoveUpgradeButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("pivot-bar-constructor") +@Name("pivot-bar-constructor-fingerprint") @MatchingMethod( "Lhfu;", "" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @RemoveUpgradeButtonCompatibility @Version("0.0.1") -object PivotBarConstructorSignature : MethodSignature( +object PivotBarConstructorFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "Z"), 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 3018ac817..f6145bf9b 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 @@ -3,15 +3,15 @@ package app.revanced.patches.music.layout.upgradebutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.music.layout.upgradebutton.annotations.RemoveUpgradeButtonCompatibility -import app.revanced.patches.music.layout.upgradebutton.signatures.PivotBarConstructorSignature +import app.revanced.patches.music.layout.upgradebutton.fingerprints.PivotBarConstructorFingerprint import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction22t import org.jf.dexlib2.iface.instruction.formats.Instruction22c @@ -25,15 +25,15 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Version("0.0.1") class RemoveUpgradeButtonPatch : BytecodePatch( listOf( - PivotBarConstructorSignature + PivotBarConstructorFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = PivotBarConstructorSignature.result!! - val implementation = result.method.implementation!! + val result = PivotBarConstructorFingerprint.result!! + val implementation = result.mutableMethod.implementation!! val pivotBarElementFieldRef = - (implementation.instructions[result.scanResult.endIndex - 1] as Instruction22c).reference + (implementation.instructions[result.patternScanResult!!.endIndex - 1] as Instruction22c).reference val register = (implementation.instructions.first() as Instruction35c).registerC // first compile all the needed instructions @@ -43,19 +43,19 @@ class RemoveUpgradeButtonPatch : BytecodePatch( const/4 v2, 0x3 invoke-interface {v0, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object; iput-object v0, v$register, $pivotBarElementFieldRef - """.trimIndent().toInstructions().toMutableList() + """.toInstructions().toMutableList() // replace the instruction to retain the label at given index implementation.replaceInstruction( - result.scanResult.endIndex - 1, instructionList[0] // invoke-interface + result.patternScanResult!!.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.scanResult.endIndex, exitInstruction + result.patternScanResult!!.endIndex, exitInstruction ) // do not forget to remove this instruction since we added it already instructionList.removeLast() @@ -64,12 +64,12 @@ class RemoveUpgradeButtonPatch : BytecodePatch( instructionList.add( 2, // if-le BuilderInstruction22t( - Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.scanResult.endIndex) + Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.patternScanResult!!.endIndex) ) ) implementation.addInstructions( - result.scanResult.endIndex, instructionList + result.patternScanResult!!.endIndex, instructionList ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/signatures/BackgroundPlaybackDisableSignature.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/signatures/BackgroundPlaybackDisableSignature.kt rename to src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt index 98ed88508..4f498732d 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/signatures/BackgroundPlaybackDisableSignature.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/fingerprints/BackgroundPlaybackDisableFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.music.premium.backgroundplay.signatures +package app.revanced.patches.music.premium.backgroundplay.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("background-playback-disabler-signature") +@Name("background-playback-disabler-fingerprint") @MatchingMethod( "Lafgf;", "e" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @BackgroundPlayCompatibility @Version("0.0.1") -object BackgroundPlaybackDisableSignature : MethodSignature( +object BackgroundPlaybackDisableFingerprint : MethodFingerprint( "Z", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L"), listOf( Opcode.CONST_4, Opcode.IF_EQZ, 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 6e9445d61..8f9ada959 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 @@ -3,14 +3,14 @@ package app.revanced.patches.music.premium.backgroundplay.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility -import app.revanced.patches.music.premium.backgroundplay.signatures.BackgroundPlaybackDisableSignature +import app.revanced.patches.music.premium.backgroundplay.fingerprints.BackgroundPlaybackDisableFingerprint @Patch @Name("background-play") @@ -19,11 +19,11 @@ import app.revanced.patches.music.premium.backgroundplay.signatures.BackgroundPl @Version("0.0.1") class BackgroundPlayPatch : BytecodePatch( listOf( - BackgroundPlaybackDisableSignature + BackgroundPlaybackDisableFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - BackgroundPlaybackDisableSignature.result!!.method.addInstructions( + BackgroundPlaybackDisableFingerprint.result!!.mutableMethod.addInstructions( 0, """ const/4 v0, 0x1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/extensions/MethodExtensions.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/extensions/MethodExtensions.kt index 383700dd4..d4082d78c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/extensions/MethodExtensions.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/extensions/MethodExtensions.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.ad.general.bytecode.extensions import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.softCompareTo -import app.revanced.patcher.patch.implementation.misc.PatchResultError +import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import org.jf.dexlib2.builder.BuilderInstruction 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 a2a59f1b0..d1dcc40b3 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 @@ -4,15 +4,15 @@ import app.revanced.extensions.injectHideCall import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.data.implementation.proxy +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.impl.proxy import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.toInstructions diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralResourceAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralResourceAdsPatch.kt index 024dfdfe1..0366ece89 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralResourceAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/resource/patch/GeneralResourceAdsPatch.kt @@ -5,11 +5,11 @@ import app.revanced.extensions.startsWithAny 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.data.impl.ResourceData import app.revanced.patcher.patch.annotations.Dependencies -import app.revanced.patcher.patch.implementation.ResourcePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/signatures/ShowVideoAdsConstructorSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/youtube/ad/video/signatures/ShowVideoAdsConstructorSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt index 912bc6bba..009379a6b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/signatures/ShowVideoAdsConstructorSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsConstructorFingerprint.kt @@ -1,16 +1,16 @@ -package app.revanced.patches.youtube.ad.video.signatures +package app.revanced.patches.youtube.ad.video.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("show-video-ads-constructor-signature") +@Name("show-video-ads-constructor-fingerprint") @MatchingMethod( "Laair", "", @@ -18,7 +18,7 @@ import org.jf.dexlib2.Opcode @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @VideoAdsCompatibility @Version("0.0.1") -object ShowVideoAdsConstructorSignature : MethodSignature( +object ShowVideoAdsConstructorFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf( Opcode.INVOKE_DIRECT, Opcode.NEW_INSTANCE, diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt new file mode 100644 index 000000000..67e70ecf3 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/ShowVideoAdsFingerprint.kt @@ -0,0 +1,19 @@ +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("show-video-ads-method-fingerprint") +@MatchingMethod( + definingClass = "zai" +) +@DirectPatternScanMethod +@VideoAdsCompatibility +@Version("0.0.1") +object ShowVideoAdsFingerprint : MethodFingerprint( + "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null +) \ No newline at end of file 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 d05aee40e..789e0d081 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 @@ -1,24 +1,20 @@ package app.revanced.patches.youtube.ad.video.patch +import ShowVideoAdsFingerprint import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.or +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.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility -import app.revanced.patches.youtube.ad.video.signatures.ShowVideoAdsConstructorSignature +import app.revanced.patches.youtube.ad.video.fingerprints.ShowVideoAdsConstructorFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import org.jf.dexlib2.AccessFlags @Patch @Dependencies(dependencies = [IntegrationsPatch::class]) @@ -28,19 +24,14 @@ import org.jf.dexlib2.AccessFlags @Version("0.0.1") class VideoAdsPatch : BytecodePatch( listOf( - ShowVideoAdsConstructorSignature + ShowVideoAdsConstructorFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = - 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 - ) {}) ?: return PatchResultError("Required parent method could not be found.") + ShowVideoAdsFingerprint.resolve(data, ShowVideoAdsConstructorFingerprint.result!!.classDef) // Override the parameter by calling shouldShowAds and setting the parameter to the result - result.method.addInstructions( + ShowVideoAdsFingerprint.result!!.mutableMethod.addInstructions( 0, """ invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z move-result v1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt index f649b2670..c26c7a524 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingFingerprint.kt @@ -1,21 +1,21 @@ -package app.revanced.patches.youtube.interaction.seekbar.signatures +package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("enable-seekbar-tapping-signature") +@Name("enable-seekbar-tapping-fingerprint") @MatchingMethod("Lfbl;", "onTouchEvent") @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @SeekbarTappingCompatibility @Version("0.0.1") -object SeekbarTappingSignature : MethodSignature( +object SeekbarTappingFingerprint : MethodFingerprint( "Z", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_WIDE, diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingParentSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt similarity index 77% rename from src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingParentSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt index c35be408d..f2d467090 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/signatures/SeekbarTappingParentSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SeekbarTappingParentFingerprint.kt @@ -1,21 +1,21 @@ -package app.revanced.patches.youtube.interaction.seekbar.signatures +package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("enable-seekbar-tapping-parent") +@Name("enable-seekbar-tapping-parent-fingerprint") @MatchingMethod("Lzmx;", "I") @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @SeekbarTappingCompatibility @Version("0.0.1") -object SeekbarTappingParentSignature : MethodSignature( +object SeekbarTappingParentFingerprint : MethodFingerprint( "L", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf(), listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, 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 ecd29fde8..b59907a30 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 @@ -3,17 +3,17 @@ package app.revanced.patches.youtube.interaction.seekbar.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility -import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingParentSignature -import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingSignature +import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint +import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t @@ -29,16 +29,16 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c @Version("0.0.1") class EnableSeekbarTappingPatch : BytecodePatch( listOf( - SeekbarTappingParentSignature, SeekbarTappingSignature + SeekbarTappingParentFingerprint, SeekbarTappingFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - var result = SeekbarTappingParentSignature.result!! + var result = SeekbarTappingParentFingerprint.result!! val tapSeekMethods = mutableMapOf() // find the methods which tap the seekbar - for (it in result.definingClassProxy.immutableClass.methods) { + for (it in result.classDef.methods) { if (it.implementation == null) continue val instructions = it.implementation!!.instructions @@ -57,35 +57,35 @@ class EnableSeekbarTappingPatch : BytecodePatch( if (literal == 2) tapSeekMethods["O"] = it } - // replace map because we dont need the upper one anymore - result = SeekbarTappingSignature.result!! + // replace map because we don't need the upper one anymore + result = SeekbarTappingFingerprint.result!! - val implementation = result.method.implementation!! + val implementation = result.mutableMethod.implementation!! // if tap-seeking is enabled, do not invoke the two methods below val pMethod = tapSeekMethods["P"]!! val oMethod = tapSeekMethods["O"]!! // get the required register - val instruction = implementation.instructions[result.scanResult.endIndex] + val instruction = implementation.instructions[result.patternScanResult!!.endIndex] if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register") val register = (instruction as Instruction35c).registerC // the instructions are written in reverse order. - result.method.addInstructions( - result.scanResult.endIndex + 1, """ + result.mutableMethod.addInstructions( + result.patternScanResult!!.endIndex + 1, """ invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V """ ) // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label - val elseLabel = implementation.newLabelForIndex(result.scanResult.endIndex + 1) + val elseLabel = implementation.newLabelForIndex(result.patternScanResult!!.endIndex + 1) implementation.addInstruction( - result.scanResult.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) + result.patternScanResult!!.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) ) - result.method.addInstructions( - result.scanResult.endIndex + 1, """ + result.mutableMethod.addInstructions( + result.patternScanResult!!.endIndex + 1, """ invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->isTapSeekingEnabled()Z move-result v0 """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/amoled/patch/AmoledPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/amoled/patch/AmoledPatch.kt index a4f28d56b..eea0146bc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/amoled/patch/AmoledPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/amoled/patch/AmoledPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.layout.amoled.patch 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.data.impl.ResourceData import app.revanced.patcher.patch.annotations.Dependencies 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 +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.amoled.annotations.AmoledCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt index 00eade3da..d852bd844 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/header/patch/PremiumHeadingPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.branding.header.patch 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.data.impl.ResourceData import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.branding.header.annotations.PremiumHeadingCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import java.nio.file.Files diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt index 65392ad8c..bccde067c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/icon/patch/CustomBrandingPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.branding.icon.patch 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.data.impl.ResourceData import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.branding.icon.annotations.CustomBrandingCompatibility import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch import java.nio.file.Files 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 bd45b6b42..e63a46f8e 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 @@ -3,14 +3,14 @@ package app.revanced.patches.youtube.layout.castbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.data.implementation.proxy +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.impl.proxy import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.annotations.Dependencies 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/signatures/CreateButtonSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/fingerprints/CreateButtonFingerprint.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/signatures/CreateButtonSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/fingerprints/CreateButtonFingerprint.kt index 6f1a91e52..b6d11b785 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/signatures/CreateButtonSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/fingerprints/CreateButtonFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.layout.createbutton.signatures +package app.revanced.patches.youtube.layout.createbutton.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("create-button-signature") +@Name("create-button-fingerprint") @MatchingMethod( "Lknw", "z" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @CreateButtonCompatibility @Version("0.0.1") -object CreateButtonSignature : MethodSignature( +object CreateButtonFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), 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 19311b5e3..bd3e3ebc7 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 @@ -3,16 +3,16 @@ package app.revanced.patches.youtube.layout.createbutton.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility -import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature +import app.revanced.patches.youtube.layout.createbutton.fingerprints.CreateButtonFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch import org.jf.dexlib2.Opcode @@ -29,14 +29,14 @@ import org.jf.dexlib2.iface.reference.MethodReference @Version("0.0.1") class CreateButtonRemoverPatch : BytecodePatch( listOf( - CreateButtonSignature + CreateButtonFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = CreateButtonSignature.result!! + val result = CreateButtonFingerprint.result!! // Get the required register which holds the view object we need to pass to the method hideCreateButton - val implementation = result.method.implementation!! + val implementation = result.mutableMethod.implementation!! val imageOnlyLayout = ResourceIdMappingProviderResourcePatch.resourceMappings["image_only_tab"] ?: return PatchResultError("Required resource could not be found in the map") @@ -45,7 +45,10 @@ class CreateButtonRemoverPatch : BytecodePatch( implementation.instructions.indexOfFirst { (it as? WideLiteralInstruction)?.wideLiteral == imageOnlyLayout } val (instructionIndex, instruction) = implementation.instructions.drop(imageOnlyLayoutConstIndex).withIndex() - .first { (((it.value as? ReferenceInstruction)?.reference) as? MethodReference)?.definingClass?.contains("PivotBar") ?: false } + .first { + (((it.value as? ReferenceInstruction)?.reference) as? MethodReference)?.definingClass?.contains("PivotBar") + ?: false + } if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct instruction") @@ -53,11 +56,11 @@ class CreateButtonRemoverPatch : BytecodePatch( val moveResultInstruction = implementation.instructions[moveResultIndex] as OneRegisterInstruction // Hide the button view via proxy by passing it to the hideCreateButton method - result.method.addInstruction( + result.mutableMethod.addInstruction( moveResultIndex + 1, "invoke-static { v${moveResultInstruction.registerA} }, Lapp/revanced/integrations/patches/HideCreateButtonPatch;->hideCreateButton(Landroid/view/View;)V" ) return PatchResultSuccess() } -} +} \ No newline at end of file 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 556dd8573..f8798ba49 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 @@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.fullscreenpanels.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.data.implementation.proxy +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.impl.proxy import app.revanced.patcher.extensions.addInstructions 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.fullscreenpanels.annotations.FullscreenPanelsCompatibility @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/signatures/MinimizedPlaybackManagerSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt similarity index 72% rename from src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/signatures/MinimizedPlaybackManagerSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt index 097d0dc82..a8cd631c9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/signatures/MinimizedPlaybackManagerSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/fingerprints/MinimizedPlaybackManagerFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.layout.minimizedplayback.signatures +package app.revanced.patches.youtube.layout.minimizedplayback.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("minimized-playback-manager-signature") +@Name("minimized-playback-manager-fingerprint") @MatchingMethod( "Lyuf", "n" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MinimizedPlaybackCompatibility @Version("0.0.1") -object MinimizedPlaybackManagerSignature : MethodSignature( +object MinimizedPlaybackManagerFingerprint : MethodFingerprint( "Z", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L"), 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 1569e3012..33a257ee3 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 @@ -4,13 +4,13 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility -import app.revanced.patches.youtube.layout.minimizedplayback.signatures.MinimizedPlaybackManagerSignature +import app.revanced.patches.youtube.layout.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint @Patch @@ -20,13 +20,13 @@ import app.revanced.patches.youtube.layout.minimizedplayback.signatures.Minimize @Version("0.0.1") class MinimizedPlaybackPatch : BytecodePatch( listOf( - MinimizedPlaybackManagerSignature + MinimizedPlaybackManagerFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { // Instead of removing all instructions like Vanced, // we return the method at the beginning instead - MinimizedPlaybackManagerSignature.result!!.method.addInstructions( + MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstructions( 0, """ const/4 v0, 0x1 return v0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityFingerprint.kt new file mode 100644 index 000000000..e972153fd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityFingerprint.kt @@ -0,0 +1,27 @@ +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +@Name("old-quality-fingerprint") +@MatchingMethod(definingClass = "Libh") +@FuzzyPatternScanMethod(2) +@OldQualityLayoutCompatibility +@Version("0.0.1") +object OldQualityFingerprint : MethodFingerprint( + "L", AccessFlags.FINAL or AccessFlags.PRIVATE, listOf("Z"), listOf( + Opcode.CONST_4, + Opcode.INVOKE_VIRTUAL, + Opcode.IGET_OBJECT, + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.IGET_OBJECT, + Opcode.GOTO, + Opcode.IGET_OBJECT, + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/signatures/OldQualityParentSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityParentFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/signatures/OldQualityParentSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityParentFingerprint.kt index c9dd15a28..268904cbe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/signatures/OldQualityParentSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/fingerprints/OldQualityParentFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.layout.oldqualitylayout.signatures +package app.revanced.patches.youtube.layout.oldqualitylayout.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("old-quality-parent-method-signature") +@Name("old-quality-parent-method-fingerprint") @MatchingMethod( "Libh", "" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @OldQualityLayoutCompatibility @Version("0.0.1") -object OldQualityParentSignature : MethodSignature( +object OldQualityParentFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L", "L", "L", "L", "L"), 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 17039e931..7bcab9ee2 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 @@ -1,24 +1,21 @@ package app.revanced.patches.youtube.layout.oldqualitylayout.patch +import OldQualityFingerprint import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve import app.revanced.patcher.patch.annotations.Dependencies 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.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility -import app.revanced.patches.youtube.layout.oldqualitylayout.signatures.OldQualityParentSignature +import app.revanced.patches.youtube.layout.oldqualitylayout.fingerprints.OldQualityParentFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.instruction.BuilderInstruction21t @@ -30,33 +27,22 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction21t @Version("0.0.1") class OldQualityLayoutPatch : BytecodePatch( listOf( - OldQualityParentSignature + OldQualityParentFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - 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( - Opcode.CONST_4, - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, - Opcode.GOTO, - Opcode.IGET_OBJECT, - ) - ) {}) ?: return PatchResultError("Required parent method could not be found.") + OldQualityFingerprint.resolve(data, OldQualityParentFingerprint.result!!.classDef) + val result = OldQualityFingerprint.result + ?: return PatchResultError("Required parent method could not be found.") - val implementation = result.method.implementation!! + val implementation = result.mutableMethod.implementation!! // if useOldStyleQualitySettings == true, jump over all instructions val jmpInstruction = BuilderInstruction21t( - Opcode.IF_NEZ, 0, implementation.instructions[result.scanResult.endIndex].location.labels.first() + Opcode.IF_NEZ, 0, implementation.instructions[result.patternScanResult!!.endIndex].location.labels.first() ) implementation.addInstruction(5, jmpInstruction) - result.method.addInstructions( + result.mutableMethod.addInstructions( 0, """ invoke-static { }, Lapp/revanced/integrations/patches/OldStyleQualityPatch;->useOldStyleQualitySettings()Z move-result v0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/signatures/HideReelsSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt similarity index 59% rename from src/main/kotlin/app/revanced/patches/youtube/layout/reels/signatures/HideReelsSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt index 61353b272..90986665b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/signatures/HideReelsSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/fingerprints/HideReelsFingerprint.kt @@ -1,22 +1,22 @@ -package app.revanced.patches.youtube.layout.reels.signatures +package app.revanced.patches.youtube.layout.reels.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import org.jf.dexlib2.AccessFlags -@Name("hide-reels-signature") +@Name("hide-reels-fingerprint") @MatchingMethod( "Ljvy", "" ) @FuzzyPatternScanMethod(3) // FIXME: Test this threshold and find the best value. @HideReelsCompatibility @Version("0.0.1") -object HideReelsSignature : MethodSignature( +object HideReelsFingerprint : MethodFingerprint( null, AccessFlags.PROTECTED or AccessFlags.FINAL, listOf("L", "L"), null, listOf("multiReelDismissalCallback", "reelItemRenderers", "reelDismissalInfo") ) \ No newline at end of file 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 b9df95734..7a0f56cb9 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 @@ -2,14 +2,14 @@ package app.revanced.patches.youtube.layout.reels.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstruction -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.annotation.Version +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility -import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature +import app.revanced.patches.youtube.layout.reels.fingerprints.HideReelsFingerprint //@Patch TODO: this is currently in the general-bytecode-ads patch due to the integrations having a preference for including reels or not. Move it here. @Name("hide-reels") @@ -18,16 +18,16 @@ import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature @Version("0.0.1") class HideReelsPatch : BytecodePatch( listOf( - HideReelsSignature + HideReelsFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result = HideReelsSignature.result!! + val result = HideReelsFingerprint.result!! // HideReel will hide the reel view before it is being used, // so we pass the view to the HideReel method - result.method.addInstruction( - result.scanResult.endIndex, + result.mutableMethod.addInstruction( + result.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/shorts/button/signatures/PivotBarButtonTabenumSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonTabEnumFingerprint.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/signatures/PivotBarButtonTabenumSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonTabEnumFingerprint.kt index 71f2406c6..ec6aade3f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/signatures/PivotBarButtonTabenumSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonTabEnumFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.layout.shorts.button.signatures +package app.revanced.patches.youtube.layout.shorts.button.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("pivotbar-buttons-tabenum-signature") +@Name("pivotbar-buttons-tabenum-fingerprint") @MatchingMethod( - "Lknw", "z" + "Lknw;", "z" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @ShortsButtonCompatibility @Version("0.0.1") -object PivotBarButtonTabenumSignature : MethodSignature( +object PivotBarButtonTabEnumFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/signatures/PivotBarButtonsViewSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonsViewFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/signatures/PivotBarButtonsViewSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonsViewFingerprint.kt index cfde6a334..b999f4dbf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/signatures/PivotBarButtonsViewSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/fingerprints/PivotBarButtonsViewFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.layout.shorts.button.signatures +package app.revanced.patches.youtube.layout.shorts.button.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("pivotbar-buttons-view-signature") +@Name("pivotbar-buttons-view-fingerprint") @MatchingMethod( - "Lknw", "z" + "Lknw;", "z" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @ShortsButtonCompatibility @Version("0.0.1") -object PivotBarButtonsViewSignature : MethodSignature( +object PivotBarButtonsViewFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), 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 cb66050b8..cd28fa545 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 @@ -3,18 +3,18 @@ package app.revanced.patches.youtube.layout.shorts.button.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstruction +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Dependencies 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.patch.impl.BytecodePatch import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility -import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonTabenumSignature -import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonsViewSignature +import app.revanced.patches.youtube.layout.shorts.button.fingerprints.PivotBarButtonTabEnumFingerprint +import app.revanced.patches.youtube.layout.shorts.button.fingerprints.PivotBarButtonsViewFingerprint import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch -import org.jf.dexlib2.iface.instruction.formats.Instruction11x +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Patch @Dependencies(dependencies = [IntegrationsPatch::class]) @@ -24,33 +24,33 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11x @Version("0.0.1") class ShortsButtonRemoverPatch : BytecodePatch( listOf( - PivotBarButtonTabenumSignature, PivotBarButtonsViewSignature + PivotBarButtonTabEnumFingerprint, PivotBarButtonsViewFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { - val result1 = PivotBarButtonTabenumSignature.result!! - val implementation1 = result1.method.implementation!! - val moveEnumInstruction = implementation1.instructions[result1.scanResult.endIndex] - val enumRegister = (moveEnumInstruction as Instruction11x).registerA + val tabEnumResult = PivotBarButtonTabEnumFingerprint.result!! + val tabEnumImplementation = tabEnumResult.mutableMethod.implementation!! + val moveEnumInstruction = tabEnumImplementation.instructions[tabEnumResult.patternScanResult!!.endIndex] + val enumRegister = (moveEnumInstruction as OneRegisterInstruction).registerA - val result2 = PivotBarButtonsViewSignature.result!! - val implementation2 = result2.method.implementation!! - val moveViewInstruction = implementation2.instructions[result2.scanResult.endIndex] - val viewRegister = (moveViewInstruction as Instruction11x).registerA + val buttonsViewResult = PivotBarButtonsViewFingerprint.result!! + val buttonsViewImplementation = buttonsViewResult.mutableMethod.implementation!! + val moveViewInstruction = buttonsViewImplementation.instructions[buttonsViewResult.patternScanResult!!.endIndex] + val viewRegister = (moveViewInstruction as OneRegisterInstruction).registerA // Save the tab enum in XGlobals to avoid smali/register workarounds - result1.method.addInstruction( - result1.scanResult.endIndex + 1, + tabEnumResult.mutableMethod.addInstruction( + tabEnumResult.patternScanResult!!.endIndex + 1, "sput-object v$enumRegister, Lapp/revanced/integrations/patches/HideShortsButtonPatch;->lastPivotTab:Ljava/lang/Enum;" ) // Hide the button view via proxy by passing it to the hideShortsButton method // It only hides it if the last tab name is "TAB_SHORTS" - result2.method.addInstruction( - result2.scanResult.endIndex + 2, + buttonsViewResult.mutableMethod.addInstruction( + buttonsViewResult.patternScanResult!!.endIndex + 2, "invoke-static { v$viewRegister }, Lapp/revanced/integrations/patches/HideShortsButtonPatch;->hideShortsButton(Landroid/view/View;)V" ) return PatchResultSuccess() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/signatures/InitSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/youtube/misc/integrations/signatures/InitSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt index 450b7570d..ddd0439a4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/signatures/InitSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/InitFingerprint.kt @@ -1,18 +1,18 @@ -package app.revanced.patches.youtube.misc.integrations.signatures +package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility -@Name("init-signature") +@Name("init-fingerprint") @MatchingMethod( "Lacuu", "onCreate" ) @IntegrationsCompatibility @Version("0.0.1") -object InitSignature : MethodSignature( +object InitFingerprint : MethodFingerprint( null, null, null, null, listOf("Application creation") ) \ No newline at end of file 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 a357835e5..fc653f25a 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 @@ -3,17 +3,17 @@ package app.revanced.patches.youtube.misc.integrations.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.impl.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.implementation.BytecodePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultError -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.impl.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility -import app.revanced.patches.youtube.misc.integrations.signatures.InitSignature +import app.revanced.patches.youtube.misc.integrations.fingerprints.InitFingerprint import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.immutable.ImmutableMethod import org.jf.dexlib2.immutable.ImmutableMethodImplementation @@ -24,26 +24,27 @@ import org.jf.dexlib2.immutable.ImmutableMethodImplementation @Version("0.0.1") class IntegrationsPatch : BytecodePatch( listOf( - InitSignature + InitFingerprint ) ) { override fun execute(data: BytecodeData): PatchResult { if (data.findClass("Lapp/revanced/integrations/utils/Globals") == null) return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") - val result = InitSignature.result!! + val result = InitFingerprint.result!! - val implementation = result.method.implementation!! + val method = result.mutableMethod + val implementation = method.implementation!! val count = implementation.registerCount - 1 - result.method.addInstructions( - result.scanResult.endIndex + 1, """ + method.addInstructions( + 0, """ invoke-static {v$count}, Lapp/revanced/integrations/sponsorblock/StringRef;->setContext(Landroid/content/Context;)V sput-object v$count, Lapp/revanced/integrations/utils/Globals;->context:Landroid/content/Context; """ ) - val classDef = result.definingClassProxy.resolve() + val classDef = result.mutableClass classDef.methods.add( ImmutableMethod( classDef.type, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt index 7a7a357ff..3f3e55d3c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/manifest/patch/FixLocaleConfigErrorPatch.kt @@ -3,10 +3,10 @@ package app.revanced.patches.youtube.misc.manifest.patch 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.implementation.ResourcePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.misc.manifest.annotations.FixLocaleConfigErrorCompatibility import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceIdMappingProviderResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceIdMappingProviderResourcePatch.kt index 567fb5969..dc1d3f8f1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceIdMappingProviderResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/mapping/patch/ResourceIdMappingProviderResourcePatch.kt @@ -4,10 +4,10 @@ import app.revanced.extensions.doRecursively 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.implementation.ResourcePatch -import app.revanced.patcher.patch.implementation.misc.PatchResult -import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import app.revanced.patcher.data.impl.ResourceData +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import org.w3c.dom.Element @Name("resource-id-mapping-provider-resource-patch-dependency") diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt new file mode 100644 index 000000000..58e49167a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastContextFetchFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.misc.microg.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility + +@Name("cast-context-fetch-fingerprint") +@MatchingMethod( + "Lvvz;", "a" +) +@DirectPatternScanMethod +@MicroGPatchCompatibility +@Version("0.0.1") +object CastContextFetchFingerprint : MethodFingerprint( + null, null, null, null, + listOf("Error fetching CastContext.") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt new file mode 100644 index 000000000..ae5d9a380 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.misc.microg.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility + +@Name("cast-module-fingerprint") +@MatchingMethod( + "Llqh;", "c" +) +@DirectPatternScanMethod +@MicroGPatchCompatibility +@Version("0.0.1") +object CastDynamiteModuleFingerprint : MethodFingerprint( + null, null, null, null, + listOf("com.google.android.gms.cast.framework.internal.CastDynamiteModuleImpl") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt new file mode 100644 index 000000000..67d8c3fa7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.youtube.misc.microg.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility + +@Name("cast-context-fetch-fingerprint") +@MatchingMethod( + "Lmcf;", "c" +) +@DirectPatternScanMethod +@MicroGPatchCompatibility +@Version("0.0.1") +object CastDynamiteModuleV2Fingerprint : MethodFingerprint( + null, null, null, null, + listOf("Failed to load module via V2: ") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/GooglePlayUtilitySignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/GooglePlayUtilitySignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt index c1a2664d8..497d85aab 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/GooglePlayUtilitySignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/GooglePlayUtilityFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.misc.microg.signatures +package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("google-play-utility-signature") +@Name("google-play-utility-fingerprint") @MatchingMethod( "Llss;", "b" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") -object GooglePlayUtilitySignature : MethodSignature( +object GooglePlayUtilityFingerprint : MethodFingerprint( "I", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L"), listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT_OBJECT, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/IntegrityCheckSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/IntegrityCheckSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt index 697c744d9..ee73eb5c3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/IntegrityCheckSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/IntegrityCheckFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.misc.microg.signatures +package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("google-play-sig-check-signature") +@Name("google-play-sig-check-fingerprint") @MatchingMethod( "Ldwn;", "d" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") -object IntegrityCheckSignature : MethodSignature( +object IntegrityCheckFingerprint : MethodFingerprint( "L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L"), listOf( Opcode.MOVE_OBJECT_FROM16, Opcode.CONST_STRING, @@ -78,5 +78,5 @@ object IntegrityCheckSignature : MethodSignature( Opcode.CONST_STRING, Opcode.GOTO, Opcode.NEW_ARRAY - ), listOf("This should never happen.", "GooglePlayServicesUtil", "Google Play Store signature invalid.") + ), listOf("This should never happen.", "GooglePlayServicesUtil", "Google Play Store fingerprint invalid.") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt new file mode 100644 index 000000000..71aa8d747 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/PrimeFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.youtube.misc.microg.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility + +@Name("google-play-prime-fingerprint") +@MatchingMethod( + "Lpag;", "d" +) +@DirectPatternScanMethod +@MicroGPatchCompatibility +@Version("0.0.1") +object PrimeFingerprint : MethodFingerprint( + null, null, null, null, listOf("com.google.android.GoogleCamera", "com.android.vending") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/ServiceCheckSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt similarity index 76% rename from src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/ServiceCheckSignature.kt rename to src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt index 0731e2457..4ead72cf4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/ServiceCheckSignature.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/fingerprints/ServiceCheckFingerprint.kt @@ -1,23 +1,23 @@ -package app.revanced.patches.youtube.misc.microg.signatures +package app.revanced.patches.youtube.misc.microg.fingerprints import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.extensions.or -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode -@Name("google-play-service-checker-signature") +@Name("google-play-service-checker-fingerprint") @MatchingMethod( "Llss;", "d" ) @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @MicroGPatchCompatibility @Version("0.0.1") -object ServiceCheckSignature : MethodSignature( +object ServiceCheckFingerprint : MethodFingerprint( "V", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "I"), listOf( Opcode.SGET_OBJECT, Opcode.INVOKE_VIRTUAL, 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 c5d5c79d6..023f6871f 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 @@ -4,17 +4,17 @@ import app.revanced.extensions.equalsAny import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData -import app.revanced.patcher.data.implementation.proxy +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.data.impl.proxy import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.annotations.Dependencies 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.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess 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 @@ -22,7 +22,7 @@ import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePat import app.revanced.patches.youtube.misc.microg.patch.resource.enum.StringReplaceMode import app.revanced.patches.youtube.misc.microg.shared.Constants.BASE_MICROG_PACKAGE_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.REVANCED_PACKAGE_NAME -import app.revanced.patches.youtube.misc.microg.signatures.* +import app.revanced.patches.youtube.misc.microg.fingerprints.* import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.MutableMethodImplementation import org.jf.dexlib2.builder.instruction.BuilderInstruction21c @@ -44,13 +44,13 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference @Version("0.0.1") class MicroGBytecodePatch : BytecodePatch( listOf( - IntegrityCheckSignature, - ServiceCheckSignature, - GooglePlayUtilitySignature, - CastDynamiteModuleSignature, - CastDynamiteModuleV2Signature, - CastContextFetchSignature, - PrimeSignature, + IntegrityCheckFingerprint, + ServiceCheckFingerprint, + GooglePlayUtilityFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, + CastContextFetchFingerprint, + PrimeFingerprint, ) ) { override fun execute(data: BytecodeData): PatchResult { @@ -125,15 +125,15 @@ class MicroGBytecodePatch : BytecodePatch( private fun disablePlayServiceChecksAndFixCastIssues() { listOf( - IntegrityCheckSignature, - ServiceCheckSignature, - GooglePlayUtilitySignature, - CastDynamiteModuleSignature, - CastDynamiteModuleV2Signature, - CastContextFetchSignature - ).forEach { signature -> - val result = signature.result!! - val stringInstructions = when (result.immutableMethod.returnType.first()) { + IntegrityCheckFingerprint, + ServiceCheckFingerprint, + GooglePlayUtilityFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, + CastContextFetchFingerprint + ).forEach { fingerprint -> + val result = fingerprint.result!! + val stringInstructions = when (result.method.returnType.first()) { 'L' -> """ const/4 v0, 0x0 return-object v0 @@ -147,12 +147,13 @@ class MicroGBytecodePatch : BytecodePatch( else -> throw Exception("This case should never happen.") } - result.method.addInstructions( + result.mutableMethod.addInstructions( 0, stringInstructions ) } - val implementation = PrimeSignature.result!!.method.implementation!! + val primeMethod = PrimeFingerprint.result!!.mutableMethod + val implementation = primeMethod.implementation!! var register = 2 val index = implementation.instructions.indexOfFirst { @@ -165,8 +166,8 @@ class MicroGBytecodePatch : BytecodePatch( return@indexOfFirst true } - implementation.replaceInstruction( - index, "const-string v$register, \"$REVANCED_PACKAGE_NAME\"".toInstruction() + primeMethod.replaceInstruction( + index, "const-string v$register, \"$REVANCED_PACKAGE_NAME\"" ) } } \ No newline at end of file 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 810fc9aee..7a0241b76 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 @@ -3,11 +3,11 @@ package app.revanced.patches.youtube.misc.microg.patch.resource 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.data.impl.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 +import app.revanced.patcher.patch.impl.ResourcePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.shared.Constants.BASE_MICROG_PACKAGE_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.REVANCED_APP_NAME diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastContextFetchSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastContextFetchSignature.kt deleted file mode 100644 index cb1d94399..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastContextFetchSignature.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.misc.microg.signatures - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility - -@Name("cast-context-fetch-signature") -@MatchingMethod( - "Lvvz;", "a" -) -@DirectPatternScanMethod -@MicroGPatchCompatibility -@Version("0.0.1") -object CastContextFetchSignature : MethodSignature( - null, null, null, null, - listOf("Error fetching CastContext.") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleSignature.kt deleted file mode 100644 index 25cecd32c..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleSignature.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.misc.microg.signatures - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility - -@Name("cast-module-signature") -@MatchingMethod( - "Llqh;", "c" -) -@DirectPatternScanMethod -@MicroGPatchCompatibility -@Version("0.0.1") -object CastDynamiteModuleSignature : MethodSignature( - null, null, null, null, - listOf("com.google.android.gms.cast.framework.internal.CastDynamiteModuleImpl") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleV2Signature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleV2Signature.kt deleted file mode 100644 index 5fda66f00..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/CastDynamiteModuleV2Signature.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.misc.microg.signatures - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility - -@Name("cast-context-fetch-signature") -@MatchingMethod( - "Lmcf;", "c" -) -@DirectPatternScanMethod -@MicroGPatchCompatibility -@Version("0.0.1") -object CastDynamiteModuleV2Signature : MethodSignature( - null, null, null, null, - listOf("Failed to load module via V2: ") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/PrimeSignature.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/PrimeSignature.kt deleted file mode 100644 index ed5903cce..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/signatures/PrimeSignature.kt +++ /dev/null @@ -1,19 +0,0 @@ -package app.revanced.patches.youtube.misc.microg.signatures - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.signature.implementation.method.MethodSignature -import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod -import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility - -@Name("google-play-prime-signature") -@MatchingMethod( - "Lpag;", "d" -) -@DirectPatternScanMethod -@MicroGPatchCompatibility -@Version("0.0.1") -object PrimeSignature : MethodSignature( - null, null, null, null, listOf("com.google.android.GoogleCamera", "com.android.vending") -) \ No newline at end of file