From ab32ae2f007d0d62b2577682d6140f4842d044e0 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 9 Nov 2024 14:43:00 +0100 Subject: [PATCH 1/3] synchronize iterations --- .../TransformInstructionsPatch.kt | 30 +++++++++++-------- .../layout/theme/LithoColorHookPatch.kt | 1 - .../youtube/misc/settings/SettingsPatch.kt | 4 ++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt index 6564f4f26a..0d423e3b65 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt @@ -14,24 +14,26 @@ fun transformInstructionsPatch( // Returns the patch indices as a Sequence, which will execute lazily. fun findPatchIndices(classDef: ClassDef, method: Method): Sequence? = method.implementation?.instructions?.asSequence()?.withIndex()?.mapNotNull { (index, instruction) -> - filterMap(classDef, method, instruction, index) - } + filterMap(classDef, method, instruction, index) + } execute { // Find all methods to patch buildMap { - classes.forEach { classDef -> - val methods = buildList { - classDef.methods.forEach { method -> - // Since the Sequence executes lazily, - // using any() results in only calling - // filterMap until the first index has been found. - if (findPatchIndices(classDef, method)?.any() == true) add(method) + synchronized(classes) { + classes.forEach { classDef -> + val methods = buildList { + classDef.methods.forEach { method -> + // Since the Sequence executes lazily, + // using any() results in only calling + // filterMap until the first index has been found. + if (findPatchIndices(classDef, method)?.any() == true) add(method) + } } - } - if (methods.isNotEmpty()) { - put(classDef, methods) + if (methods.isNotEmpty()) { + put(classDef, methods) + } } } }.forEach { (classDef, methods) -> @@ -42,7 +44,9 @@ fun transformInstructionsPatch( val patchIndices = findPatchIndices(mutableClass, mutableMethod)?.toCollection(ArrayDeque()) ?: return@methods - while (!patchIndices.isEmpty()) transform(mutableMethod, patchIndices.removeLast()) + while (!patchIndices.isEmpty()) { + transform(mutableMethod, patchIndices.removeLast()) + } } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt index fdab6c4b8b..f3bc31e2f9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt @@ -11,7 +11,6 @@ val lithoColorHookPatch = bytecodePatch( ) { execute { - var insertionIndex = lithoThemeFingerprint.patternMatch!!.endIndex - 1 lithoColorOverrideHook = { targetMethodClass, targetMethodName -> diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 627a70f91a..0741e4c64c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -185,7 +185,9 @@ val settingsPatch = bytecodePatch( // Remove other methods as they will break as the onCreate method is modified above. licenseActivityOnCreateFingerprint.classDef.apply { - methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } + synchronized(methods) { + methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } + } } } From 111cf43b1660b1d1436308d6036af6a66ff2a46d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 10 Nov 2024 01:37:23 +0100 Subject: [PATCH 2/3] use coroutine for transform instruction patch 2,7s -> 1,5s --- patches/build.gradle.kts | 1 + .../TransformInstructionsPatch.kt | 37 ++++++++++++------- .../youtube/misc/settings/SettingsPatch.kt | 4 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/patches/build.gradle.kts b/patches/build.gradle.kts index 459d50a0ce..fcc90510aa 100644 --- a/patches/build.gradle.kts +++ b/patches/build.gradle.kts @@ -13,6 +13,7 @@ patches { } dependencies { + implementation(libs.kotlinx.coroutines.core) // Used by JsonGenerator. implementation(libs.gson) // Required due to smali, or build fails. Can be removed once smali is bumped. diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt index 0d423e3b65..24bff4535d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/transformation/TransformInstructionsPatch.kt @@ -6,6 +6,9 @@ import app.revanced.util.findMutableMethodOf import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.Instruction +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.joinAll +import kotlinx.coroutines.launch fun transformInstructionsPatch( filterMap: (ClassDef, Method, Instruction, Int) -> T?, @@ -20,20 +23,28 @@ fun transformInstructionsPatch( execute { // Find all methods to patch buildMap { - synchronized(classes) { - classes.forEach { classDef -> - val methods = buildList { - classDef.methods.forEach { method -> - // Since the Sequence executes lazily, - // using any() results in only calling - // filterMap until the first index has been found. - if (findPatchIndices(classDef, method)?.any() == true) add(method) - } - } + suspend { + coroutineScope { + classes.map { classDef -> + launch { + val methods = buildList { + coroutineScope { + classDef.methods.map { method -> + launch { + // Since the Sequence executes lazily, + // using any() results in only calling + // filterMap until the first index has been found. + if (findPatchIndices(classDef, method)?.any() == true) add(method) + } + } + }.joinAll() + } - if (methods.isNotEmpty()) { - put(classDef, methods) - } + if (methods.isNotEmpty()) { + put(classDef, methods) + } + } + }.joinAll() } } }.forEach { (classDef, methods) -> diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 0741e4c64c..627a70f91a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -185,9 +185,7 @@ val settingsPatch = bytecodePatch( // Remove other methods as they will break as the onCreate method is modified above. licenseActivityOnCreateFingerprint.classDef.apply { - synchronized(methods) { - methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } - } + methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } } } From d7a129613c658c30e9af5f643c257488105e1d52 Mon Sep 17 00:00:00 2001 From: Ax333l Date: Sun, 10 Nov 2024 17:35:09 +0100 Subject: [PATCH 3/3] parallelism PoC --- gradle/libs.versions.toml | 2 ++ patches/api/patches.api | 16 +++++----- patches/build.gradle.kts | 14 ++++++++ .../patches/amazon/DeepLinkingPatch.kt | 2 +- .../backdrops/misc/pro/ProUnlockPatch.kt | 6 ++-- .../limitations/RemovePlayLimitsPatch.kt | 2 +- .../root/BypassRootChecksPatch.kt | 2 +- .../patches/duolingo/ad/DisableAdsPatch.kt | 4 +-- .../duolingo/debug/EnableDebugMenuPatch.kt | 4 +-- .../ads/mainfeed/HideSponsoredStoriesPatch.kt | 12 +++---- .../facebook/ads/story/HideStoryAdsPatch.kt | 2 +- .../bootloader/BootloaderDetectionPatch.kt | 2 +- .../detection/root/RootDetectionPatch.kt | 2 +- .../customtabs/EnableCustomTabsPatch.kt | 4 +-- .../misc/features/SpoofFeaturesPatch.kt | 2 +- ...oreHiddenBackUpWhileChargingTogglePatch.kt | 4 +-- .../restrictions/RemoveDeviceRestrictions.kt | 4 +-- .../patches/hexeditor/ad/DisableAdsPatch.kt | 2 +- .../iconpackstudio/misc/pro/UnlockProPatch.kt | 2 +- .../detection/root/RootDetectionPatch.kt | 2 +- .../signature/SpoofSignaturePatch.kt | 2 +- .../patches/inshorts/ad/InshortsAdsPatch.kt | 2 +- .../patches/instagram/ads/HideAdsPatch.kt | 2 +- .../patches/irplus/ad/RemoveAdsPatch.kt | 2 +- .../misc/login/DisableMandatoryLoginPatch.kt | 2 +- .../misc/premium/UnlockPremiumPatch.kt | 2 +- .../license/LicenseValidationPatch.kt | 2 +- .../signature/SignatureVerificationPatch.kt | 2 +- .../misc/pro/UnlockProVersionPatch.kt | 2 +- .../messenger/inbox/HideInboxAdsPatch.kt | 2 +- .../messenger/inbox/HideInboxSubtabsPatch.kt | 2 +- .../DisableSwitchingEmojiToStickerPatch.kt | 4 +-- .../inputfield/DisableTypingIndicatorPatch.kt | 2 +- .../misc/locale/ForceEnglishLocalePatch.kt | 4 +-- .../mifitness/misc/login/FixLoginPatch.kt | 2 +- .../patches/music/ad/video/HideVideoAds.kt | 4 +-- .../EnableExclusiveAudioPlayback.kt | 2 +- .../permanentrepeat/PermanentRepeatPatch.kt | 4 +-- .../permanentshuffle/PermanentShufflePatch.kt | 2 +- .../layout/compactheader/HideCategoryBar.kt | 4 +-- .../layout/premium/HideGetPremiumPatch.kt | 6 ++-- .../upgradebutton/RemoveUpgradeButtonPatch.kt | 6 ++-- .../BypassCertificateChecksPatch.kt | 2 +- .../BackgroundPlaybackPatch.kt | 4 +-- .../myexpenses/misc/pro/UnlockProPatch.kt | 2 +- .../patches/myfitnesspal/ads/HideAdsPatch.kt | 4 +-- .../nfctoolsse/misc/pro/UnlockProPatch.kt | 2 +- .../patches/nyx/misc/pro/UnlockProPatch.kt | 2 +- .../misc/fix/crash/FixCrashPatch.kt | 8 ++--- .../detection/deviceid/SpoofDeviceIdPatch.kt | 2 +- .../signature/SignatureDetectionPatch.kt | 6 ++-- .../misc/annoyances/HideUpdatePopupPatch.kt | 2 +- .../unlock/bookpoint/EnableBookpointPatch.kt | 2 +- .../misc/unlock/plus/UnlockPlusPatch.kt | 2 +- .../misc/SpoofAndroidDeviceIdPatch.kt | 2 +- .../tracking/DisableTrackingPatch.kt | 6 ++-- .../patches/pixiv/ads/HideAdsPatch.kt | 2 +- .../HidePurchaseReminderPatch.kt | 2 +- .../reddit/ad/comments/HideCommentAdsPatch.kt | 2 +- .../patches/reddit/ad/general/HideAdsPatch.kt | 6 ++-- .../baconreader/api/SpoofClientPatch.kt | 6 ++-- .../boostforreddit/ads/DisableAdsPatch.kt | 2 +- .../boostforreddit/api/SpoofClientPatch.kt | 4 +-- .../FixAudioMissingInDownloadsPatch.kt | 4 +-- .../fix/slink/FixSLinksPatch.kt | 4 +-- .../infinityforreddit/api/SpoofClientPatch.kt | 2 +- .../subscription/UnlockSubscriptionPatch.kt | 2 +- .../joeyforreddit/ads/DisableAdsPatch.kt | 2 +- .../joeyforreddit/api/SpoofClientPatch.kt | 4 +-- .../piracy/DisablePiracyDetectionPatch.kt | 2 +- .../redditisfun/api/SpoofClientPatch.kt | 10 +++--- .../relayforreddit/api/SpoofClientPatch.kt | 12 +++---- .../slide/api/SpoofClientPatch.kt | 2 +- .../customclients/sync/ads/DisableAdsPatch.kt | 2 +- .../piracy/DisablePiracyDetectionPatch.kt | 2 +- .../DisableSyncForLemmyBottomSheetPatch.kt | 2 +- .../syncforreddit/api/SpoofClientPatch.kt | 12 +++---- .../syncforreddit/fix/slink/FixSLinksPatch.kt | 4 +-- .../fix/user/UseUserEndpointPatch.kt | 2 +- .../fix/video/FixVideoDownloadsPatch.kt | 6 ++-- .../DisableScreenshotPopupPatch.kt | 2 +- .../premiumicon/UnlockPremiumIconPatch.kt | 2 +- .../tracking/url/SanitizeUrlQueryPatch.kt | 2 +- .../detection/root/RootDetectionPatch.kt | 2 +- .../misc/checks/BaseCheckEnvironmentPatch.kt | 10 +++--- .../misc/extension/SharedExtensionPatch.kt | 10 +++--- .../fix/verticalscroll/VerticalScrollPatch.kt | 4 +-- .../shared/misc/gms/GmsCoreSupportPatch.kt | 32 ++++++++++++------- .../filesize/RemoveFileSizeLimitPatch.kt | 4 +-- .../patches/songpal/badge/BadgeTabPatch.kt | 2 +- .../badge/RemoveNotificationBadgePatch.kt | 2 +- .../patches/soundcloud/ad/HideAdsPatch.kt | 8 ++--- .../analytics/DisableTelemetryPatch.kt | 2 +- .../offlinesync/EnableOfflineSyncPatch.kt | 6 ++-- .../spotify/lite/ondemand/OnDemandPatch.kt | 4 +-- .../spotify/navbar/PremiumNavbarTabPatch.kt | 2 +- .../subscription/UnlockSubscriptionPatch.kt | 4 +-- .../DisableSubscriptionSuggestionsPatch.kt | 8 ++--- .../RemoveGooglePlayIntegrityCheckPatch.kt | 2 +- .../misc/themeunlock/UnlockThemePatch.kt | 4 +-- .../tiktok/feedfilter/FeedFilterPatch.kt | 4 +-- .../cleardisplay/RememberClearDisplayPatch.kt | 6 ++-- .../interaction/downloads/DownloadsPatch.kt | 10 +++--- .../interaction/seekbar/ShowSeekbarPatch.kt | 4 +-- .../interaction/speed/PlaybackSpeedPatch.kt | 10 +++--- .../DisableLoginRequirementPatch.kt | 2 +- .../login/fixgoogle/FixGoogleLoginPatch.kt | 4 +-- .../tiktok/misc/settings/SettingsPatch.kt | 10 +++--- .../tiktok/misc/spoof/sim/SpoofSimPatch.kt | 2 +- .../revanced/patches/trakt/UnlockProPatch.kt | 4 +-- .../lockscreen/ShowOnLockscreenPatch.kt | 2 +- .../DisableBlogNotificationReminderPatch.kt | 2 +- .../popups/DisableGiftMessagePopupPatch.kt | 2 +- .../featureflags/OverrideFeatureFlagsPatch.kt | 12 +++---- .../tumblr/fixes/FixOldVersionsPatch.kt | 6 ++-- .../FilterTimelineObjectsPatch.kt | 6 ++-- .../patches/twitch/ad/audio/AudioAdsPatch.kt | 4 +-- .../twitch/ad/embedded/EmbeddedAdsPatch.kt | 2 +- .../patches/twitch/ad/shared/util/AdPatch.kt | 4 +-- .../patches/twitch/ad/video/VideoAdsPatch.kt | 10 +++--- .../antidelete/ShowDeletedMessagesPatch.kt | 6 ++-- .../autoclaim/AutoClaimChannelPointsPatch.kt | 2 +- .../patches/twitch/debug/DebugModePatch.kt | 2 +- .../twitch/misc/settings/SettingsPatch.kt | 22 ++++++------- .../downloads/UnlockDownloadsPatch.kt | 16 +++++----- .../layout/viewcount/HideViewCountPatch.kt | 2 +- .../twitter/misc/hook/json/JsonHookPatch.kt | 15 +++++---- .../links/ChangeLinkSharingDomainPatch.kt | 10 +++--- .../links/OpenLinksWithAppChooserPatch.kt | 2 +- .../misc/links/SanitizeSharingLinksPatch.kt | 2 +- .../patches/vsco/misc/pro/UnlockProPatch.kt | 2 +- .../firebasegetcert/FirebaseGetCertPatch.kt | 2 +- .../misc/promocode/PromoCodeUnlockPatch.kt | 2 +- .../patches/willhaben/ads/HideAdsPatch.kt | 4 +-- .../windyapp/misc/unlockpro/UnlockProPatch.kt | 2 +- .../ad/getpremium/HideGetPremiumPatch.kt | 4 +-- .../patches/youtube/ad/video/VideoAdsPatch.kt | 4 +-- .../RemoveViewerDiscretionDialogPatch.kt | 2 +- .../interaction/downloads/DownloadsPatch.kt | 4 +-- .../DisablePreciseSeekingGesturePatch.kt | 4 +-- .../seekbar/EnableSeekbarTappingPatch.kt | 8 ++--- .../seekbar/EnableSlideToSeekPatch.kt | 14 ++++---- .../seekbar/SeekbarThumbnailsPatch.kt | 4 +-- .../swipecontrols/SwipeControlsPatch.kt | 4 +-- .../layout/autocaptions/AutoCaptionsPatch.kt | 4 +-- .../navigation/NavigationButtonsPatch.kt | 6 ++-- .../overlay/HidePlayerOverlayButtonsPatch.kt | 8 ++--- .../endscreencards/HideEndscreenCardsPatch.kt | 4 +-- .../DisableFullscreenAmbientModePatch.kt | 2 +- .../hide/general/HideLayoutComponentsPatch.kt | 30 ++++++++--------- .../hide/infocards/HideInfoCardsPatch.kt | 8 ++--- .../DisableRollingNumberAnimationPatch.kt | 4 +-- .../layout/hide/seekbar/HideSeekbarPatch.kt | 2 +- .../hide/shorts/HideShortsComponentsPatch.kt | 14 ++++---- .../DisableSuggestedVideoEndScreenPatch.kt | 4 +-- .../layout/hide/time/HideTimestampPatch.kt | 2 +- .../layout/miniplayer/MiniplayerPatch.kt | 30 ++++++++--------- .../panels/popup/PlayerPopupPanelsPatch.kt | 2 +- .../CustomPlayerOverlayOpacityPatch.kt | 2 +- .../ReturnYouTubeDislikePatch.kt | 30 ++++++++--------- .../layout/searchbar/WideSearchbarPatch.kt | 6 ++-- .../layout/seekbar/SeekbarColorPatch.kt | 12 +++---- .../shortsautoplay/ShortsAutoplayPatch.kt | 10 +++--- .../layout/sponsorblock/SponsorBlockPatch.kt | 12 +++---- .../spoofappversion/SpoofAppVersionPatch.kt | 6 ++-- .../layout/startpage/ChangeStartPagePatch.kt | 4 +-- .../DisableResumingShortsOnStartupPatch.kt | 4 +-- .../layout/tablet/EnableTabletLayoutPatch.kt | 2 +- .../layout/theme/LithoColorHookPatch.kt | 6 ++-- .../youtube/layout/theme/ThemePatch.kt | 4 +-- .../misc/announcements/AnnouncementsPatch.kt | 2 +- .../misc/autorepeat/AutoRepeatPatch.kt | 4 +-- .../BackgroundPlaybackPatch.kt | 8 ++--- .../misc/debugging/EnableDebuggingPatch.kt | 6 ++-- .../spoof/SpoofDeviceDimensionsPatch.kt | 2 +- ...ckWatchHistoryDomainNameResolutionPatch.kt | 2 +- .../FixBackToExitGesturePatch.kt | 6 ++-- .../fix/cairo/DisableCairoSettingsPatch.kt | 2 +- .../fix/playback/SpoofVideoStreamsPatch.kt | 24 +++++++------- .../misc/imageurlhook/CronetImageUrlHook.kt | 10 +++--- .../misc/links/BypassURLRedirectsPatch.kt | 2 +- .../misc/litho/filter/LithoFilterPatch.kt | 18 +++++------ .../misc/navigation/NavigationBarHookPatch.kt | 18 +++++------ .../playercontrols/PlayerControlsPatch.kt | 12 +++---- .../misc/playertype/PlayerTypeHookPatch.kt | 6 ++-- .../RemoveTrackingQueryParameterPatch.kt | 8 ++--- .../hook/RecyclerViewTreeHookPatch.kt | 4 +-- .../youtube/misc/settings/SettingsPatch.kt | 6 ++-- .../misc/zoomhaptics/ZoomHapticsPatch.kt | 2 +- .../information/VideoInformationPatch.kt | 26 +++++++-------- .../PlayerResponseMethodHookPatch.kt | 2 +- .../quality/RememberVideoQualityPatch.kt | 10 +++--- .../speed/custom/CustomPlaybackSpeedPatch.kt | 16 +++++----- .../remember/RememberPlaybackSpeedPatch.kt | 2 +- .../youtube/video/videoid/VideoIdPatch.kt | 4 +-- .../RestoreOldVideoQualityMenuPatch.kt | 8 ++--- .../misc/unlockpremium/UnlockPremiumPatch.kt | 2 +- .../kotlin/app/revanced/util/BytecodeUtils.kt | 4 +-- 198 files changed, 556 insertions(+), 531 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index af87b2376d..06d293344b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,6 +12,7 @@ appcompat = "1.7.0" okhttp = "5.0.0-alpha.14" retrofit = "2.11.0" guava = "33.2.1-jre" +kotlinx-corouiines = "1.9.0" [libraries] gson = { module = "com.google.code.gson:gson", version.ref = "gson" } @@ -20,6 +21,7 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } guava = { module = "com.google.guava:guava", version.ref = "guava" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-corouiines" } [plugins] diff --git a/patches/api/patches.api b/patches/api/patches.api index 04e8b64e2b..eabb3c4500 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -533,7 +533,7 @@ public final class app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentP public final class app/revanced/patches/shared/misc/extension/ExtensionHook { public final fun getFingerprint ()Lapp/revanced/patcher/Fingerprint; - public final fun invoke (Lapp/revanced/patcher/patch/BytecodePatchContext;Ljava/lang/String;)V + public final fun invoke (Lapp/revanced/patcher/patch/BytecodePatchContext;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class app/revanced/patches/shared/misc/extension/SharedExtensionPatchKt { @@ -980,7 +980,7 @@ public final class app/revanced/patches/twitter/misc/hook/json/JsonHook { } public final class app/revanced/patches/twitter/misc/hook/json/JsonHookPatchKt { - public static final fun addJsonHook (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patches/twitter/misc/hook/json/JsonHook;)V + public static final fun addJsonHook (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patches/twitter/misc/hook/json/JsonHook;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun getJsonHookPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } @@ -1207,7 +1207,7 @@ public final class app/revanced/patches/youtube/layout/tablet/EnableTabletLayout public final class app/revanced/patches/youtube/layout/theme/LithoColorHookPatchKt { public static final fun getLithoColorHookPatch ()Lapp/revanced/patcher/patch/BytecodePatch; - public static final fun getLithoColorOverrideHook ()Lkotlin/jvm/functions/Function2; + public static final fun getLithoColorOverrideHook ()Lkotlin/jvm/functions/Function3; } public final class app/revanced/patches/youtube/layout/theme/ThemePatchKt { @@ -1288,10 +1288,10 @@ public final class app/revanced/patches/youtube/misc/litho/filter/LithoFilterPat } public final class app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatchKt { - public static field hookNavigationButtonCreated Lkotlin/jvm/functions/Function1; - public static final fun getHookNavigationButtonCreated ()Lkotlin/jvm/functions/Function1; + public static field hookNavigationButtonCreated Lkotlin/jvm/functions/Function2; + public static final fun getHookNavigationButtonCreated ()Lkotlin/jvm/functions/Function2; public static final fun getNavigationBarHookPatch ()Lapp/revanced/patcher/patch/BytecodePatch; - public static final fun setHookNavigationButtonCreated (Lkotlin/jvm/functions/Function1;)V + public static final fun setHookNavigationButtonCreated (Lkotlin/jvm/functions/Function2;)V } public final class app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatchKt { @@ -1433,7 +1433,7 @@ public final class app/revanced/util/BytecodeUtilsKt { public static final fun findInstructionIndicesReversedOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/Opcode;)Ljava/util/List; public static final fun findInstructionIndicesReversedOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)Ljava/util/List; public static final fun findMutableMethodOf (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod; - public static final fun forEachLiteralValueInstruction (Lapp/revanced/patcher/patch/BytecodePatchContext;JLkotlin/jvm/functions/Function2;)V + public static final fun forEachLiteralValueInstruction (Lapp/revanced/patcher/patch/BytecodePatchContext;JLkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;ILcom/android/tools/smali/dexlib2/Opcode;)I public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;ILkotlin/jvm/functions/Function1;)I public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/Opcode;)I @@ -1463,7 +1463,7 @@ public final class app/revanced/util/BytecodeUtilsKt { public static final fun returnEarly (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Z)V public static synthetic fun returnEarly$default (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ZILjava/lang/Object;)V public static final fun transformMethods (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lkotlin/jvm/functions/Function1;)V - public static final fun traverseClassHierarchy (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lkotlin/jvm/functions/Function1;)V + public static final fun traverseClassHierarchy (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class app/revanced/util/ResourceGroup { diff --git a/patches/build.gradle.kts b/patches/build.gradle.kts index fcc90510aa..4b45c8db57 100644 --- a/patches/build.gradle.kts +++ b/patches/build.gradle.kts @@ -12,6 +12,20 @@ patches { } } +repositories { + mavenLocal() + mavenCentral() + google() + maven { + // A repository must be specified for some reason. "registry" is a dummy. + url = uri("https://maven.pkg.github.com/revanced/registry") + credentials { + username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") + password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") + } + } +} + dependencies { implementation(libs.kotlinx.coroutines.core) // Used by JsonGenerator. diff --git a/patches/src/main/kotlin/app/revanced/patches/amazon/DeepLinkingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/amazon/DeepLinkingPatch.kt index bf53d86220..4dcd024ee9 100644 --- a/patches/src/main/kotlin/app/revanced/patches/amazon/DeepLinkingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/amazon/DeepLinkingPatch.kt @@ -11,7 +11,7 @@ val deepLinkingPatch = bytecodePatch( compatibleWith("com.amazon.mShop.android.shopping") execute { - deepLinkingFingerprint.method.addInstructions( + deepLinkingFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/ProUnlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/ProUnlockPatch.kt index 70bbcd9fdf..5276fb787a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/ProUnlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/ProUnlockPatch.kt @@ -12,12 +12,12 @@ val proUnlockPatch = bytecodePatch( compatibleWith("com.backdrops.wallpapers") execute { - val registerIndex = proUnlockFingerprint.patternMatch!!.endIndex - 1 + val registerIndex = proUnlockFingerprint.patternMatch()!!.endIndex - 1 - proUnlockFingerprint.method.apply { + proUnlockFingerprint.method().apply { val register = getInstruction(registerIndex).registerA addInstruction( - proUnlockFingerprint.patternMatch!!.endIndex, + proUnlockFingerprint.patternMatch()!!.endIndex, "const/4 v$register, 0x1", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt index 9ba60935f4..8b572c05e8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/bandcamp/limitations/RemovePlayLimitsPatch.kt @@ -11,6 +11,6 @@ val removePlayLimitsPatch = bytecodePatch( compatibleWith("com.bandcamp.android") execute { - handlePlaybackLimitsFingerprint.method.addInstructions(0, "return-void") + handlePlaybackLimitsFingerprint.method().addInstructions(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/cieid/restrictions/root/BypassRootChecksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/cieid/restrictions/root/BypassRootChecksPatch.kt index c2abcc5b6f..a3ccd5770c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/cieid/restrictions/root/BypassRootChecksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/cieid/restrictions/root/BypassRootChecksPatch.kt @@ -11,6 +11,6 @@ val bypassRootChecksPatch = bytecodePatch( compatibleWith("it.ipzs.cieid") execute { - checkRootFingerprint.method.addInstruction(1, "return-void") + checkRootFingerprint.method().addInstruction(1, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/duolingo/ad/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/duolingo/ad/DisableAdsPatch.kt index a5c56ddb05..08987faa48 100644 --- a/patches/src/main/kotlin/app/revanced/patches/duolingo/ad/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/duolingo/ad/DisableAdsPatch.kt @@ -19,8 +19,8 @@ val disableAdsPatch = bytecodePatch( // SharedPreferences has a debug boolean value with key "disable_ads", which maps to "DebugCategory.DISABLE_ADS". // // MonetizationDebugSettings seems to be the most general setting to work fine. - initializeMonetizationDebugSettingsFingerprint.method.apply { - val insertIndex = initializeMonetizationDebugSettingsFingerprint.patternMatch!!.startIndex + initializeMonetizationDebugSettingsFingerprint.method().apply { + val insertIndex = initializeMonetizationDebugSettingsFingerprint.patternMatch()!!.startIndex val register = getInstruction(insertIndex).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/duolingo/debug/EnableDebugMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/duolingo/debug/EnableDebugMenuPatch.kt index 833f9dd7da..3d0eb84ec3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/duolingo/debug/EnableDebugMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/duolingo/debug/EnableDebugMenuPatch.kt @@ -13,8 +13,8 @@ val enableDebugMenuPatch = bytecodePatch( compatibleWith("com.duolingo"("5.158.4")) execute { - initializeBuildConfigProviderFingerprint.method.apply { - val insertIndex = initializeBuildConfigProviderFingerprint.patternMatch!!.startIndex + initializeBuildConfigProviderFingerprint.method().apply { + val insertIndex = initializeBuildConfigProviderFingerprint.patternMatch()!!.startIndex val register = getInstruction(insertIndex).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatch.kt index e8a4065879..da50bbc213 100644 --- a/patches/src/main/kotlin/app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/facebook/ads/mainfeed/HideSponsoredStoriesPatch.kt @@ -20,8 +20,8 @@ val hideSponsoredStoriesPatch = bytecodePatch( compatibleWith("com.facebook.katana") execute { - val sponsoredDataModelTemplateMethod = getSponsoredDataModelTemplateFingerprint.originalMethod - val baseModelMapperMethod = baseModelMapperFingerprint.originalMethod + val sponsoredDataModelTemplateMethod = getSponsoredDataModelTemplateFingerprint.originalMethod() + val baseModelMapperMethod = baseModelMapperFingerprint.originalMethod() val baseModelWithTreeType = baseModelMapperMethod.returnType val graphQlStoryClassDescriptor = "Lcom/facebook/graphql/model/GraphQLStory;" @@ -31,7 +31,7 @@ val hideSponsoredStoriesPatch = bytecodePatch( // could change in future version, we need to extract them and call the base implementation directly. val getSponsoredDataHelperMethod = ImmutableMethod( - getStoryVisibilityFingerprint.originalClassDef.type, + getStoryVisibilityFingerprint.originalClassDef().type, "getSponsoredData", listOf(ImmutableMethodParameter(graphQlStoryClassDescriptor, null, null)), baseModelWithTreeType, @@ -65,12 +65,12 @@ val hideSponsoredStoriesPatch = bytecodePatch( ) } - getStoryVisibilityFingerprint.classDef.methods.add(getSponsoredDataHelperMethod) + getStoryVisibilityFingerprint.classDef().methods.add(getSponsoredDataHelperMethod) // Check if the parameter type is GraphQLStory and if sponsoredDataModelGetter returns a non-null value. // If so, hide the story by setting the visibility to StoryVisibility.GONE. - getStoryVisibilityFingerprint.method.addInstructionsWithLabels( - getStoryVisibilityFingerprint.patternMatch!!.startIndex, + getStoryVisibilityFingerprint.method().addInstructionsWithLabels( + getStoryVisibilityFingerprint.patternMatch()!!.startIndex, """ instance-of v0, p0, $graphQlStoryClassDescriptor if-eqz v0, :resume_normal diff --git a/patches/src/main/kotlin/app/revanced/patches/facebook/ads/story/HideStoryAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/facebook/ads/story/HideStoryAdsPatch.kt index ec811fc3c3..1546c9f8c2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/facebook/ads/story/HideStoryAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/facebook/ads/story/HideStoryAdsPatch.kt @@ -15,7 +15,7 @@ val hideStoryAdsPatch = bytecodePatch( fetchMoreAdsFingerprint, adsInsertionFingerprint, ).forEach { fingerprint -> - fingerprint.method.replaceInstruction(0, "return-void") + fingerprint.method().replaceInstruction(0, "return-void") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/BootloaderDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/BootloaderDetectionPatch.kt index 76dc2413fa..eb2a9512a8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/BootloaderDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/BootloaderDetectionPatch.kt @@ -12,7 +12,7 @@ val bootloaderDetectionPatch = bytecodePatch( execute { setOf(createKeyFingerprint, bootStateFingerprint).forEach { fingerprint -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt index e2b7b06167..ad2feeaedc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/RootDetectionPatch.kt @@ -11,7 +11,7 @@ val rootDetectionPatch = bytecodePatch( compatibleWith("at.gv.bmf.bmf2go") execute { - rootDetectionFingerprint.method.addInstructions( + rootDetectionFingerprint.method().addInstructions( 0, """ sget-object v0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean; diff --git a/patches/src/main/kotlin/app/revanced/patches/googlenews/customtabs/EnableCustomTabsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/googlenews/customtabs/EnableCustomTabsPatch.kt index 0e84ec6dfa..f3d5bda9a0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlenews/customtabs/EnableCustomTabsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlenews/customtabs/EnableCustomTabsPatch.kt @@ -14,8 +14,8 @@ val enableCustomTabsPatch = bytecodePatch( compatibleWith("com.google.android.apps.magazines") execute { - launchCustomTabFingerprint.method.apply { - val checkIndex = launchCustomTabFingerprint.patternMatch!!.endIndex + 1 + launchCustomTabFingerprint.method().apply { + val checkIndex = launchCustomTabFingerprint.patternMatch()!!.endIndex + 1 val register = getInstruction(checkIndex).registerA replaceInstruction(checkIndex, "const/4 v$register, 0x1") diff --git a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt index 4c0be2b77b..f478f17d8e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/features/SpoofFeaturesPatch.kt @@ -61,7 +61,7 @@ val spoofFeaturesPatch = bytecodePatch( @Suppress("NAME_SHADOWING") val featuresToDisable = featuresToDisable!!.toSet() - initializeFeaturesEnumFingerprint.method.apply { + initializeFeaturesEnumFingerprint.method().apply { instructions.filter { it.opcode == Opcode.CONST_STRING }.forEach { val feature = it.getReference()!!.string diff --git a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/preferences/RestoreHiddenBackUpWhileChargingTogglePatch.kt b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/preferences/RestoreHiddenBackUpWhileChargingTogglePatch.kt index 1d87171154..4e4dc83cd0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/preferences/RestoreHiddenBackUpWhileChargingTogglePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlephotos/misc/preferences/RestoreHiddenBackUpWhileChargingTogglePatch.kt @@ -15,8 +15,8 @@ val restoreHiddenBackUpWhileChargingTogglePatch = bytecodePatch( execute { // Patches 'backup_prefs_had_backup_only_when_charging_enabled' to always be true. - val chargingPrefStringIndex = backupPreferencesFingerprint.stringMatches!!.first().index - backupPreferencesFingerprint.method.apply { + val chargingPrefStringIndex = backupPreferencesFingerprint.stringMatches()!!.first().index + backupPreferencesFingerprint.method().apply { // Get the register of move-result. val resultRegister = getInstruction(chargingPrefStringIndex + 2).registerA // Insert const after move-result to override register as true. diff --git a/patches/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions.kt b/patches/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions.kt index 2cf32adefb..476fc88814 100644 --- a/patches/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions.kt +++ b/patches/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions.kt @@ -15,9 +15,9 @@ val removeDeviceRestrictionsPatch = bytecodePatch( compatibleWith("com.google.android.apps.recorder") execute { - val featureStringIndex = onApplicationCreateFingerprint.stringMatches!!.first().index + val featureStringIndex = onApplicationCreateFingerprint.stringMatches()!!.first().index - onApplicationCreateFingerprint.method.apply { + onApplicationCreateFingerprint.method().apply { // Remove check for device restrictions. removeInstructions(featureStringIndex - 2, 5) diff --git a/patches/src/main/kotlin/app/revanced/patches/hexeditor/ad/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/hexeditor/ad/DisableAdsPatch.kt index 1132a5ad97..f2181ae431 100644 --- a/patches/src/main/kotlin/app/revanced/patches/hexeditor/ad/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/hexeditor/ad/DisableAdsPatch.kt @@ -10,7 +10,7 @@ val disableAdsPatch = bytecodePatch( compatibleWith("com.myprog.hexedit") execute { - primaryAdsFingerprint.method.replaceInstructions( + primaryAdsFingerprint.method().replaceInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/UnlockProPatch.kt index c1e4719b7a..9761868c45 100644 --- a/patches/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/iconpackstudio/misc/pro/UnlockProPatch.kt @@ -10,7 +10,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("ginlemon.iconpackstudio"("2.2 build 016")) execute { - checkProFingerprint.method.addInstructions( + checkProFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt index 6c79650d98..68b7cbf85b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt @@ -15,6 +15,6 @@ val rootDetectionPatch = bytecodePatch( attestationSupportedCheckFingerprint, bootloaderCheckFingerprint, rootCheckFingerprint, - ).forEach { it.method.returnEarly(true) } + ).forEach { it.method().returnEarly(true) } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt index e6b312792c..ceba40f5b1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt @@ -24,7 +24,7 @@ val spoofSignaturePatch = bytecodePatch( "77ef1be61b2c01ebdabddcbf53cc4b6fd9a3c445606ee77b3758162c80ad8f8137b3c6864e92db904807dcb2be9d7717dd21" + "bf42c121d620ddfb7914f7a95c713d9e1c1b7bdb4a03d618e40cf7e9e235c0b5687e03b7ab3,publicExponent=10001}" - spoofSignatureFingerprint.method.addInstructions( + spoofSignatureFingerprint.method().addInstructions( 0, """ const-string v0, "$expectedSignature" diff --git a/patches/src/main/kotlin/app/revanced/patches/inshorts/ad/InshortsAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/inshorts/ad/InshortsAdsPatch.kt index 87fddcb78a..9604c2236c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/inshorts/ad/InshortsAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/inshorts/ad/InshortsAdsPatch.kt @@ -10,7 +10,7 @@ val hideAdsPatch = bytecodePatch( compatibleWith("com.nis.app") execute { - inshortsAdsFingerprint.method.addInstruction( + inshortsAdsFingerprint.method().addInstruction( 0, """ return-void diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/ads/HideAdsPatch.kt index 29aeccc1bf..79096fe5cb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/ads/HideAdsPatch.kt @@ -12,7 +12,7 @@ val hideAdsPatch = bytecodePatch( compatibleWith("com.instagram.android") execute { - adInjectorFingerprint.method.addInstructions( + adInjectorFingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/irplus/ad/RemoveAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/irplus/ad/RemoveAdsPatch.kt index 44b76f5fc4..a583d47b3f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/irplus/ad/RemoveAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/irplus/ad/RemoveAdsPatch.kt @@ -12,6 +12,6 @@ val removeAdsPatch = bytecodePatch( execute { // By overwriting the second parameter of the method, // the view which holds the advertisement is removed. - irplusAdsFingerprint.method.addInstruction(0, "const/4 p2, 0x0") + irplusAdsFingerprint.method().addInstruction(0, "const/4 p2, 0x0") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/login/DisableMandatoryLoginPatch.kt b/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/login/DisableMandatoryLoginPatch.kt index a5a1cf8f30..bbd8f0f0d8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/login/DisableMandatoryLoginPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/login/DisableMandatoryLoginPatch.kt @@ -10,7 +10,7 @@ val disableMandatoryLoginPatch = bytecodePatch( compatibleWith("com.adobe.lrmobile") execute { - isLoggedInFingerprint.method.apply { + isLoggedInFingerprint.method().apply { val index = implementation!!.instructions.lastIndex - 1 // Set isLoggedIn = true. replaceInstruction(index, "const/4 v0, 0x1") diff --git a/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/UnlockPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/UnlockPremiumPatch.kt index b9187af27a..e9a87f7c3b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/UnlockPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/UnlockPremiumPatch.kt @@ -11,6 +11,6 @@ val unlockPremiumPatch = bytecodePatch( execute { // Set hasPremium = true. - hasPurchasedFingerprint.method.replaceInstruction(2, "const/4 v2, 0x1") + hasPurchasedFingerprint.method().replaceInstruction(2, "const/4 v2, 0x1") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/LicenseValidationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/LicenseValidationPatch.kt index 8b4a417348..53cd2d5748 100644 --- a/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/LicenseValidationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/LicenseValidationPatch.kt @@ -8,7 +8,7 @@ val licenseValidationPatch = bytecodePatch( ) { execute { - licenseValidationFingerprint.method.replaceInstructions( + licenseValidationFingerprint.method().replaceInstructions( 0, """ const/4 p0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/SignatureVerificationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/SignatureVerificationPatch.kt index c6b05ae8db..b10f7493b0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/SignatureVerificationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/SignatureVerificationPatch.kt @@ -8,7 +8,7 @@ val signatureVerificationPatch = bytecodePatch( ) { execute { - verifySignatureFingerprint.method.replaceInstructions( + verifySignatureFingerprint.method().replaceInstructions( 0, """ const/4 p0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/UnlockProVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/UnlockProVersionPatch.kt index b74e2d3a8d..5565d16947 100644 --- a/patches/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/UnlockProVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/UnlockProVersionPatch.kt @@ -14,7 +14,7 @@ val unlockProVersionPatch = bytecodePatch( compatibleWith("com.zombodroid.MemeGenerator"("4.6364", "4.6370", "4.6375", "4.6377")) execute { - isFreeVersionFingerprint.method.replaceInstructions( + isFreeVersionFingerprint.method().replaceInstructions( 0, """ sget-object p0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean; diff --git a/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxAdsPatch.kt index 090ffd9f82..870ab0e47a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxAdsPatch.kt @@ -11,6 +11,6 @@ val hideInboxAdsPatch = bytecodePatch( compatibleWith("com.facebook.orca") execute { - loadInboxAdsFingerprint.method.replaceInstruction(0, "return-void") + loadInboxAdsFingerprint.method().replaceInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxSubtabsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxSubtabsPatch.kt index 2d190615f3..c08ea88e6b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxSubtabsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/messenger/inbox/HideInboxSubtabsPatch.kt @@ -11,6 +11,6 @@ val hideInboxSubtabsPatch = bytecodePatch( compatibleWith("com.facebook.orca") execute { - createInboxSubTabsFingerprint.method.replaceInstruction(2, "const/4 v0, 0x0") + createInboxSubTabsFingerprint.method().replaceInstruction(2, "const/4 v0, 0x0") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch.kt index 716b40e1d7..ccabc12724 100644 --- a/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch.kt @@ -14,8 +14,8 @@ val disableSwitchingEmojiToStickerPatch = bytecodePatch( compatibleWith("com.facebook.orca"("439.0.0.29.119")) execute { - switchMessengeInputEmojiButtonFingerprint.method.apply { - val setStringIndex = switchMessengeInputEmojiButtonFingerprint.patternMatch!!.startIndex + 2 + switchMessengeInputEmojiButtonFingerprint.method().apply { + val setStringIndex = switchMessengeInputEmojiButtonFingerprint.patternMatch()!!.startIndex + 2 val targetRegister = getInstruction(setStringIndex).registerA replaceInstruction(setStringIndex, "const-string v$targetRegister, \"expression\"") diff --git a/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch.kt index 0d5bfd58cd..a48cde0245 100644 --- a/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch.kt @@ -11,6 +11,6 @@ val disableTypingIndicatorPatch = bytecodePatch( compatibleWith("com.facebook.orca") execute { - sendTypingIndicatorFingerprint.method.replaceInstruction(0, "return-void") + sendTypingIndicatorFingerprint.method().replaceInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/locale/ForceEnglishLocalePatch.kt b/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/locale/ForceEnglishLocalePatch.kt index a2a53cabaf..e55f90c000 100644 --- a/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/locale/ForceEnglishLocalePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/locale/ForceEnglishLocalePatch.kt @@ -16,8 +16,8 @@ val forceEnglishLocalePatch = bytecodePatch( dependsOn(fixLoginPatch) execute { - syncBluetoothLanguageFingerprint.method.apply { - val resolvePhoneLocaleInstruction = syncBluetoothLanguageFingerprint.patternMatch!!.startIndex + syncBluetoothLanguageFingerprint.method().apply { + val resolvePhoneLocaleInstruction = syncBluetoothLanguageFingerprint.patternMatch()!!.startIndex val registerIndexToUpdate = getInstruction(resolvePhoneLocaleInstruction).registerA replaceInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/login/FixLoginPatch.kt b/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/login/FixLoginPatch.kt index 093a5d4f14..03d2542ec3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/login/FixLoginPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/mifitness/misc/login/FixLoginPatch.kt @@ -10,6 +10,6 @@ val fixLoginPatch = bytecodePatch( compatibleWith("com.xiaomi.wearable") execute { - xiaomiAccountManagerConstructorFingerprint.method.addInstruction(0, "const/16 p2, 0x0") + xiaomiAccountManagerConstructorFingerprint.method().addInstruction(0, "const/16 p2, 0x0") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt b/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt index 27c9812569..c7ced43696 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt @@ -11,8 +11,8 @@ val hideVideoAdsPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - navigate(showVideoAdsParentFingerprint.originalMethod) - .to(showVideoAdsParentFingerprint.patternMatch!!.startIndex + 1) + navigate(showVideoAdsParentFingerprint.originalMethod()) + .to(showVideoAdsParentFingerprint.patternMatch()!!.startIndex + 1) .stop() .addInstruction(0, "const/4 p1, 0x0") } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback.kt b/patches/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback.kt index 466e81aeb8..6376176ba6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/EnableExclusiveAudioPlayback.kt @@ -11,7 +11,7 @@ val enableExclusiveAudioPlaybackPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - allowExclusiveAudioPlaybackFingerprint.method.apply { + allowExclusiveAudioPlaybackFingerprint.method().apply { addInstructions( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt index c6617664fc..8df5926479 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/PermanentRepeatPatch.kt @@ -15,10 +15,10 @@ val permanentRepeatPatch = bytecodePatch( execute { - val startIndex = repeatTrackFingerprint.patternMatch!!.endIndex + val startIndex = repeatTrackFingerprint.patternMatch()!!.endIndex val repeatIndex = startIndex + 1 - repeatTrackFingerprint.method.apply { + repeatTrackFingerprint.method().apply { addInstructionsWithLabels( startIndex, "goto :repeat", diff --git a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch.kt index 8d044de2c2..f1cbd1fc62 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/PermanentShufflePatch.kt @@ -21,6 +21,6 @@ val permanentShufflePatch = bytecodePatch( ) execute { - disableShuffleFingerprint.method.addInstruction(0, "return-void") + disableShuffleFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt index b0021b966f..c56563171e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt @@ -14,8 +14,8 @@ val hideCategoryBar = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - constructCategoryBarFingerprint.method.apply { - val insertIndex = constructCategoryBarFingerprint.patternMatch!!.startIndex + constructCategoryBarFingerprint.method().apply { + val insertIndex = constructCategoryBarFingerprint.patternMatch()!!.startIndex val register = getInstruction(insertIndex - 1).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt index 892dac76a1..074085fbd3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt @@ -15,8 +15,8 @@ val hideGetPremiumPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - hideGetPremiumFingerprint.method.apply { - val insertIndex = hideGetPremiumFingerprint.patternMatch!!.endIndex + hideGetPremiumFingerprint.method().apply { + val insertIndex = hideGetPremiumFingerprint.patternMatch()!!.endIndex val setVisibilityInstruction = getInstruction(insertIndex) val getPremiumViewRegister = setVisibilityInstruction.registerC @@ -34,7 +34,7 @@ val hideGetPremiumPatch = bytecodePatch( ) } - membershipSettingsFingerprint.method.addInstructions( + membershipSettingsFingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/RemoveUpgradeButtonPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/RemoveUpgradeButtonPatch.kt index 22878b05f5..73624274dc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/RemoveUpgradeButtonPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/upgradebutton/RemoveUpgradeButtonPatch.kt @@ -21,9 +21,9 @@ val removeUpgradeButtonPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - pivotBarConstructorFingerprint.method.apply { + pivotBarConstructorFingerprint.method().apply { val pivotBarElementFieldReference = - getInstruction(pivotBarConstructorFingerprint.patternMatch!!.endIndex - 1) + getInstruction(pivotBarConstructorFingerprint.patternMatch()!!.endIndex - 1) .getReference() val register = getInstruction(0).registerC @@ -37,7 +37,7 @@ val removeUpgradeButtonPatch = bytecodePatch( iput-object v0, v$register, $pivotBarElementFieldReference """.toInstructions().toMutableList() - val endIndex = pivotBarConstructorFingerprint.patternMatch!!.endIndex + val endIndex = pivotBarConstructorFingerprint.patternMatch()!!.endIndex // Replace the instruction to retain the label at given index. replaceInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt index d53691886a..2300e193ff 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt @@ -11,7 +11,7 @@ val bypassCertificateChecksPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - checkCertificateFingerprint.method.addInstructions( + checkCertificateFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 9561d9ff88..00c3697b1c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -12,12 +12,12 @@ val backgroundPlaybackPatch = bytecodePatch( compatibleWith("com.google.android.apps.youtube.music") execute { - kidsBackgroundPlaybackPolicyControllerFingerprint.method.addInstruction( + kidsBackgroundPlaybackPolicyControllerFingerprint.method().addInstruction( 0, "return-void", ) - backgroundPlaybackDisableFingerprint.method.addInstructions( + backgroundPlaybackDisableFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt index 4365c2c2cf..ffd4b3655d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myexpenses/misc/pro/UnlockProPatch.kt @@ -10,7 +10,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("org.totschnig.myexpenses") execute { - isEnabledFingerprint.method.addInstructions( + isEnabledFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt index a9428b29ee..9d18196c70 100644 --- a/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/myfitnesspal/ads/HideAdsPatch.kt @@ -12,7 +12,7 @@ val hideAdsPatch = bytecodePatch( execute { // Overwrite the premium status specifically for ads. - isPremiumUseCaseImplFingerprint.method.replaceInstructions( + isPremiumUseCaseImplFingerprint.method().replaceInstructions( 0, """ sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean; @@ -22,7 +22,7 @@ val hideAdsPatch = bytecodePatch( // Prevent the premium upsell dialog from showing when the main activity is launched. // In other places that are premium-only the dialog will still show. - mainActivityNavigateToNativePremiumUpsellFingerprint.method.replaceInstructions( + mainActivityNavigateToNativePremiumUpsellFingerprint.method().replaceInstructions( 0, "return-void", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatch.kt index 55276126e8..2d5538c7ab 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatch.kt @@ -10,7 +10,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("com.wakdev.apps.nfctools.se") execute { - isLicenseRegisteredFingerprint.method.addInstructions( + isLicenseRegisteredFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/nyx/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/nyx/misc/pro/UnlockProPatch.kt index 65040b32a3..f857980ca6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/nyx/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/nyx/misc/pro/UnlockProPatch.kt @@ -10,7 +10,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("com.awedea.nyx") execute { - checkProFingerprint.method.addInstructions( + checkProFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt index db38e6161e..75733f6b73 100644 --- a/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/openinghours/misc/fix/crash/FixCrashPatch.kt @@ -18,7 +18,7 @@ val fixCrashPatch = bytecodePatch( compatibleWith("de.simon.openinghours"("1.0")) execute { - val indexedInstructions = setPlaceFingerprint.method.instructions.withIndex().toList() + val indexedInstructions = setPlaceFingerprint.method().instructions.withIndex().toList() /** * This function replaces all `checkNotNull` instructions in the integer interval @@ -26,8 +26,8 @@ val fixCrashPatch = bytecodePatch( * instruction an if-null check is inserted. If the if-null check yields that * the value is indeed null, we jump to a newly created label at `endIndex + 1`. */ - fun avoidNullPointerException(startIndex: Int, endIndex: Int) { - val continueLabel = setPlaceFingerprint.method.newLabel(endIndex + 1) + suspend fun avoidNullPointerException(startIndex: Int, endIndex: Int) { + val continueLabel = setPlaceFingerprint.method().newLabel(endIndex + 1) for (index in startIndex..endIndex) { val instruction = indexedInstructions[index].value @@ -39,7 +39,7 @@ val fixCrashPatch = bytecodePatch( val checkNotNullInstruction = instruction as FiveRegisterInstruction val originalRegister = checkNotNullInstruction.registerC - setPlaceFingerprint.method.replaceInstruction( + setPlaceFingerprint.method().replaceInstruction( index, BuilderInstruction21t( Opcode.IF_EQZ, diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt index 16c84b0564..aeba0113c5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/deviceid/SpoofDeviceIdPatch.kt @@ -15,7 +15,7 @@ val getDeviceIdPatch = bytecodePatch( compatibleWith("com.microblink.photomath"("8.37.0")) execute { - getDeviceIdFingerprint.method.replaceInstructions( + getDeviceIdFingerprint.method().replaceInstructions( 0, """ const-string v0, "${Random.nextLong().toString(16)}" diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt index 00b47e5161..26396dca09 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/detection/signature/SignatureDetectionPatch.kt @@ -10,9 +10,9 @@ val signatureDetectionPatch = bytecodePatch( ) { execute { - val replacementIndex = checkSignatureFingerprint.patternMatch!!.endIndex + val replacementIndex = checkSignatureFingerprint.patternMatch()!!.endIndex val checkRegister = - checkSignatureFingerprint.method.getInstruction(replacementIndex).registerA - checkSignatureFingerprint.method.replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") + checkSignatureFingerprint.method().getInstruction(replacementIndex).registerA + checkSignatureFingerprint.method().replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt index a3586de1c5..0e504e4503 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/annoyances/HideUpdatePopupPatch.kt @@ -14,7 +14,7 @@ val hideUpdatePopupPatch = bytecodePatch( compatibleWith("com.microblink.photomath"("8.32.0")) execute { - hideUpdatePopupFingerprint.method.addInstructions( + hideUpdatePopupFingerprint.method().addInstructions( 2, // Insert after the null check. "return-void", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt index 6e3da98026..084a520cc1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/bookpoint/EnableBookpointPatch.kt @@ -8,7 +8,7 @@ val enableBookpointPatch = bytecodePatch( ) { execute { - isBookpointEnabledFingerprint.method.replaceInstructions( + isBookpointEnabledFingerprint.method().replaceInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt index 8cc80c72e3..a41b2421a5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/photomath/misc/unlock/plus/UnlockPlusPatch.kt @@ -14,7 +14,7 @@ val unlockPlusPatch = bytecodePatch( compatibleWith("com.microblink.photomath"("8.37.0")) execute { - isPlusUnlockedFingerprint.method.addInstructions( + isPlusUnlockedFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt index a2b327135b..1d939247dc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/misc/SpoofAndroidDeviceIdPatch.kt @@ -39,7 +39,7 @@ val spoofAndroidDeviceIdPatch = bytecodePatch( ) { it!!.matches("[A-Fa-f0-9]{16}".toRegex()) } execute { - getAndroidIdFingerprint.method.addInstructions( + getAndroidIdFingerprint.method().addInstructions( 0, """ const-string v0, "$androidDeviceId" diff --git a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt index 32e02f37aa..770b2ec68a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/piccomafr/tracking/DisableTrackingPatch.kt @@ -34,7 +34,7 @@ val disableTrackingPatch = bytecodePatch( ) execute { - facebookSDKFingerprint.method.apply { + facebookSDKFingerprint.method().apply { instructions.filter { instruction -> instruction.opcode == Opcode.CONST_STRING }.forEach { instruction -> @@ -47,7 +47,7 @@ val disableTrackingPatch = bytecodePatch( } } - firebaseInstallFingerprint.method.apply { + firebaseInstallFingerprint.method().apply { instructions.filter { it.opcode == Opcode.CONST_STRING }.filter { @@ -62,6 +62,6 @@ val disableTrackingPatch = bytecodePatch( } } - appMeasurementFingerprint.method.addInstruction(0, "return-void") + appMeasurementFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt index 29f63e9cf2..e4712b6d5b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/pixiv/ads/HideAdsPatch.kt @@ -10,7 +10,7 @@ val hideAdsPatch = bytecodePatch( compatibleWith("jp.pxv.android") execute { - shouldShowAdsFingerprint.method.addInstructions( + shouldShowAdsFingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt index 885c2400f4..363f7e1823 100644 --- a/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/rar/misc/annoyances/purchasereminder/HidePurchaseReminderPatch.kt @@ -12,6 +12,6 @@ val hidePurchaseReminderPatch = bytecodePatch( compatibleWith("com.rarlab.rar") execute { - showReminderFingerprint.method.addInstruction(0, "return-void") + showReminderFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt index e2c53d3326..479cc3655e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt @@ -8,7 +8,7 @@ val hideCommentAdsPatch = bytecodePatch( ) { execute { - hideCommentAdsFingerprint.method.addInstructions( + hideCommentAdsFingerprint.method().addInstructions( 0, """ new-instance v0, Ljava/lang/Object; diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index c3e47f8f83..b00b07127e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -32,7 +32,7 @@ val hideAdsPatch = bytecodePatch( "Lapp/revanced/extension/reddit/patches/FilterPromotedLinksPatch;" + "->filterChildren(Ljava/lang/Iterable;)Ljava/util/List;" - adPostFingerprint.method.apply { + adPostFingerprint.method().apply { val setPostsListChildren = implementation!!.instructions.first { instruction -> if (instruction.opcode != Opcode.IPUT_OBJECT) return@first false @@ -64,7 +64,7 @@ val hideAdsPatch = bytecodePatch( // AdElementConverter is conveniently responsible for inserting all feed ads. // By removing the appending instruction no ad posts gets appended to the feed. - val index = newAdPostFingerprint.originalMethod.implementation!!.instructions.indexOfFirst { + val index = newAdPostFingerprint.originalMethod().implementation!!.instructions.indexOfFirst { if (it.opcode != Opcode.INVOKE_VIRTUAL) return@indexOfFirst false val reference = (it as ReferenceInstruction).reference as MethodReference @@ -72,7 +72,7 @@ val hideAdsPatch = bytecodePatch( reference.name == "add" && reference.definingClass == "Ljava/util/ArrayList;" } - newAdPostFingerprint.method.removeInstruction(index) + newAdPostFingerprint.method().removeInstruction(index) } // endregion diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt index d9cfa994f5..d4542d921e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt @@ -15,10 +15,10 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://baconreader.com/au val clientId by clientIdOption execute { - fun Fingerprint.patch(replacementString: String) { - val clientIdIndex = stringMatches!!.first().index + suspend fun Fingerprint.patch(replacementString: String) { + val clientIdIndex = stringMatches()!!.first().index - method.apply { + method().apply { val clientIdRegister = getInstruction(clientIdIndex).registerA replaceInstruction( clientIdIndex, diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt index fc5cabd218..9c092669e6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/ads/DisableAdsPatch.kt @@ -11,7 +11,7 @@ val disableAdsPatch = bytecodePatch( execute { arrayOf(maxMediationFingerprint, admobMediationFingerprint).forEach { fingerprint -> - fingerprint.method.addInstructions(0, "return-void") + fingerprint.method().addInstructions(0, "return-void") } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index 389facb950..d94a886db0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -11,7 +11,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") execute { // region Patch client id. - getClientIdFingerprint.method.addInstructions( + getClientIdFingerprint.method().addInstructions( 0, """ const-string v0, "$clientId" @@ -27,7 +27,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") val platformName = (0..100000).random() val platformParameter = 0 - buildUserAgentFingerprint.method.addInstructions( + buildUserAgentFingerprint.method().addInstructions( 0, "const-string p$platformParameter, \"$platformName\"", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt index 8cb3f55186..f0b6a5b882 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/downloads/FixAudioMissingInDownloadsPatch.kt @@ -18,8 +18,8 @@ val fixAudioMissingInDownloadsPatch = bytecodePatch( "/audio" to "/DASH_AUDIO_64.mp4", ) - downloadAudioFingerprint.method.apply { - downloadAudioFingerprint.stringMatches!!.forEach { match -> + downloadAudioFingerprint.method().apply { + downloadAudioFingerprint.stringMatches()!!.forEach { match -> val replacement = endpointReplacements[match.string] val register = getInstruction(match.index).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt index 076221e473..b1764d55cf 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/fix/slink/FixSLinksPatch.kt @@ -20,7 +20,7 @@ val fixSlinksPatch = fixSLinksPatch( execute { // region Patch navigation handler. - handleNavigationFingerprint.method.apply { + handleNavigationFingerprint.method().apply { val urlRegister = "p1" val tempRegister = "v1" @@ -40,7 +40,7 @@ val fixSlinksPatch = fixSLinksPatch( // region Patch set access token. - getOAuthAccessTokenFingerprint.method.addInstruction( + getOAuthAccessTokenFingerprint.method().addInstruction( 3, "invoke-static { v0 }, $EXTENSION_CLASS_DESCRIPTOR->$SET_ACCESS_TOKEN_METHOD", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt index d19ddbfede..849169a7e0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt @@ -13,7 +13,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "infinity://localhost") { val clientId by clientIdOption execute { - apiUtilsFingerprint.classDef.methods.apply { + apiUtilsFingerprint.classDef().methods.apply { val getClientIdMethod = single { it.name == "getId" }.also(::remove) val newGetClientIdMethod = ImmutableMethod( diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt index ab9b07c1b4..39fab1e578 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/subscription/UnlockSubscriptionPatch.kt @@ -17,6 +17,6 @@ val unlockSubscriptionPatch = bytecodePatch( setOf( startSubscriptionActivityFingerprint, billingClientOnServiceConnectedFingerprint, - ).forEach { it.method.returnEarly() } + ).forEach { it.method().returnEarly() } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt index 0c75087581..4b01ebaccb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/DisableAdsPatch.kt @@ -13,7 +13,7 @@ val disableAdsPatch = bytecodePatch( compatibleWith("o.o.joey") execute { - isAdFreeUserFingerprint.method.addInstructions( + isAdFreeUserFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 44d7f6e3e2..a6c7a1c7c2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -19,7 +19,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a execute { // region Patch client id. - getClientIdFingerprint.method.addInstructions( + getClientIdFingerprint.method().addInstructions( 0, """ const-string v0, "$clientId" @@ -35,7 +35,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - authUtilityUserAgentFingerprint.method.replaceInstructions( + authUtilityUserAgentFingerprint.method().replaceInstructions( 0, """ const-string v0, "$userAgent" diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt index a6871dbc0e..d1c4e933e5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/DisablePiracyDetectionPatch.kt @@ -6,6 +6,6 @@ import app.revanced.patcher.patch.bytecodePatch val disablePiracyDetectionPatch = bytecodePatch { execute { - piracyDetectionFingerprint.method.addInstruction(0, "return-void") + piracyDetectionFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index 440b1fe2a9..757b4f56e6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -30,11 +30,11 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl * @param getReplacementIndex A function that returns the index of the instruction to replace * using the [Match.StringMatch] list from the [Match]. */ - fun Fingerprint.replaceWith( + suspend fun Fingerprint.replaceWith( string: String, getReplacementIndex: List.() -> Int, - ) = method.apply { - val replacementIndex = stringMatches!!.getReplacementIndex() + ) = method().apply { + val replacementIndex = stringMatches()!!.getReplacementIndex() val clientIdRegister = getInstruction(replacementIndex).registerA replaceInstruction(replacementIndex, "const-string v$clientIdRegister, \"$string\"") @@ -54,7 +54,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - getUserAgentFingerprint.method.addInstructions( + getUserAgentFingerprint.method().addInstructions( 0, """ const-string v0, "$userAgent" @@ -68,7 +68,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl // Reddit messed up and does not append a redirect uri to the authorization url to old.reddit.com/login. // Replace old.reddit.com with ssl.reddit.com to fix this. - buildAuthorizationStringFingerprint.method.apply { + buildAuthorizationStringFingerprint.method().apply { val index = indexOfFirstInstructionOrThrow { getReference()?.contains("old.reddit.com") == true } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt index 854b7cfa5b..db11c38aec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch.kt @@ -26,11 +26,11 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { getLoggedOutBearerTokenFingerprint, getRefreshTokenFingerprint, ).forEach { fingerprint -> - val clientIdIndex = fingerprint.stringMatches!!.first().index - fingerprint.method.apply { + val clientIdIndex = fingerprint.stringMatches()!!.first().index + fingerprint.method().apply { val clientIdRegister = getInstruction(clientIdIndex).registerA - fingerprint.method.replaceInstruction( + fingerprint.method().replaceInstruction( clientIdIndex, "const-string v$clientIdRegister, \"$clientId\"", ) @@ -42,12 +42,12 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "dbrady://relay") { // region Patch miscellaneous. // Do not load remote config which disables OAuth login remotely. - setRemoteConfigFingerprint.method.addInstructions(0, "return-void") + setRemoteConfigFingerprint.method().addInstructions(0, "return-void") // Prevent OAuth login being disabled remotely. - val checkIsOAuthRequestIndex = redditCheckDisableAPIFingerprint.patternMatch!!.startIndex + val checkIsOAuthRequestIndex = redditCheckDisableAPIFingerprint.patternMatch()!!.startIndex - redditCheckDisableAPIFingerprint.method.apply { + redditCheckDisableAPIFingerprint.method().apply { val returnNextChain = getInstruction(checkIsOAuthRequestIndex).target replaceInstruction(checkIsOAuthRequestIndex, BuilderInstruction10t(Opcode.GOTO, returnNextChain)) } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt index 62f0ccf384..457268fb4d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch.kt @@ -9,7 +9,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://www.ccrama.me") { val clientId by clientIdOption execute { - getClientIdFingerprint.method.addInstructions( + getClientIdFingerprint.method().addInstructions( 0, """ const-string v0, "$clientId" diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/ads/DisableAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/ads/DisableAdsPatch.kt index f210a6adbe..1923f0ee6c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/ads/DisableAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/ads/DisableAdsPatch.kt @@ -8,7 +8,7 @@ fun disableAdsPatch(block: BytecodePatchBuilder.() -> Unit = {}) = bytecodePatch name = "Disable ads", ) { execute { - isAdsEnabledFingerprint.method.returnEarly() + isAdsEnabledFingerprint.method().returnEarly() } block() diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt index fa797c693d..cf9344afcc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/detection/piracy/DisablePiracyDetectionPatch.kt @@ -10,6 +10,6 @@ val disablePiracyDetectionPatch = bytecodePatch( execute { // Do not throw an error if the fingerprint is not resolved. // This is fine because new versions of the target app do not need this patch. - piracyDetectionFingerprint.method.addInstruction(0, "return-void") + piracyDetectionFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt index 0bfbe74d0c..51fbfe2085 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch.kt @@ -15,7 +15,7 @@ val disableSyncForLemmyBottomSheetPatch = bytecodePatch( ) execute { - mainActivityOnCreateFingerprint.method.apply { + mainActivityOnCreateFingerprint.method().apply { val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1 removeInstruction(showBottomSheetIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt index 3f9cbf9e91..c2392a3d2c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/api/SpoofClientPatch.kt @@ -26,7 +26,7 @@ val spoofClientPatch = spoofClientPatch( execute { // region Patch client id. - getBearerTokenFingerprint.match(getAuthorizationStringFingerprint.originalClassDef).method.apply { + getBearerTokenFingerprint.match(getAuthorizationStringFingerprint.originalClassDef()).method.apply { val auth = Base64.getEncoder().encodeToString("$clientId:".toByteArray(Charsets.UTF_8)) addInstructions( 0, @@ -36,9 +36,9 @@ val spoofClientPatch = spoofClientPatch( """, ) val occurrenceIndex = - getAuthorizationStringFingerprint.stringMatches!!.first().index + getAuthorizationStringFingerprint.stringMatches()!!.first().index - getAuthorizationStringFingerprint.method.apply { + getAuthorizationStringFingerprint.method().apply { val authorizationStringInstruction = getInstruction(occurrenceIndex) val targetRegister = (authorizationStringInstruction as OneRegisterInstruction).registerA val reference = authorizationStringInstruction.reference as StringReference @@ -63,7 +63,7 @@ val spoofClientPatch = spoofClientPatch( val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - imgurImageAPIFingerprint.method.replaceInstruction( + imgurImageAPIFingerprint.method().replaceInstruction( 0, """ const-string v0, "$userAgent" @@ -75,8 +75,8 @@ val spoofClientPatch = spoofClientPatch( // region Patch Imgur API URL. - val apiUrlIndex = getUserAgentFingerprint.stringMatches!!.first().index - getUserAgentFingerprint.method.replaceInstruction( + val apiUrlIndex = getUserAgentFingerprint.stringMatches()!!.first().index + getUserAgentFingerprint.method().replaceInstruction( apiUrlIndex, "const-string v1, \"https://api.imgur.com/3/image\"", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/slink/FixSLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/slink/FixSLinksPatch.kt index a640936a21..a802362b7e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/slink/FixSLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/slink/FixSLinksPatch.kt @@ -26,7 +26,7 @@ val fixSLinksPatch = fixSLinksPatch( execute { // region Patch navigation handler. - handleNavigationFingerprint.method.apply { + handleNavigationFingerprint.method().apply { val urlRegister = "p3" val tempRegister = "v2" @@ -46,7 +46,7 @@ val fixSLinksPatch = fixSLinksPatch( // region Patch set access token. - getOAuthAccessTokenFingerprint.method.addInstruction( + getOAuthAccessTokenFingerprint.method().addInstruction( 0, "invoke-static { p0 }, $EXTENSION_CLASS_DESCRIPTOR->$SET_ACCESS_TOKEN_METHOD", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatch.kt index 2d46c284c5..0ae1c8f40c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/sync/syncforreddit/fix/user/UseUserEndpointPatch.kt @@ -29,7 +29,7 @@ val useUserEndpointPatch = bytecodePatch( oAuthUserIdRequestFingerprint, oAuthUserInfoRequestFingerprint, ).map { fingerprint -> - fingerprint.stringMatches!!.first().index to fingerprint.method + fingerprint.stringMatches()!!.first().index to fingerprint.method() }.forEach { (userPathStringIndex, method) -> val userPathStringInstruction = method.getInstruction(userPathStringIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt index 9990af83fb..a301dd2f3b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/fix/video/FixVideoDownloadsPatch.kt @@ -24,14 +24,14 @@ val fixVideoDownloadsPatch = bytecodePatch( ) execute { - val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch!! + val scanResult = parseRedditVideoNetworkResponseFingerprint.patternMatch()!! val newInstanceIndex = scanResult.startIndex val invokeDirectIndex = scanResult.endIndex - 1 val buildResponseInstruction = - parseRedditVideoNetworkResponseFingerprint.method.getInstruction(invokeDirectIndex) + parseRedditVideoNetworkResponseFingerprint.method().getInstruction(invokeDirectIndex) - parseRedditVideoNetworkResponseFingerprint.method.addInstructions( + parseRedditVideoNetworkResponseFingerprint.method().addInstructions( newInstanceIndex + 1, """ # Get byte array from response. diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch.kt index 84ee7e2fd3..dcb64f0378 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/DisableScreenshotPopupPatch.kt @@ -11,6 +11,6 @@ val disableScreenshotPopupPatch = bytecodePatch( compatibleWith("com.reddit.frontpage") execute { - disableScreenshotPopupFingerprint.method.addInstruction(0, "return-void") + disableScreenshotPopupFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/UnlockPremiumIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/UnlockPremiumIconPatch.kt index bde2b52b94..ff5307a6f3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/UnlockPremiumIconPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/UnlockPremiumIconPatch.kt @@ -11,7 +11,7 @@ val unlockPremiumIconPatch = bytecodePatch( compatibleWith("com.reddit.frontpage") execute { - hasPremiumIconAccessFingerprint.method.addInstructions( + hasPremiumIconAccessFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt index 26ed42660b..10eec735b4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt @@ -11,7 +11,7 @@ val sanitizeUrlQueryPatch = bytecodePatch( compatibleWith("com.reddit.frontpage") execute { - shareLinkFormatterFingerprint.method.addInstructions( + shareLinkFormatterFingerprint.method().addInstructions( 0, "return-object p0", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt index 43ebaa19f1..3dd0399cca 100644 --- a/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/serviceportalbund/detection/root/RootDetectionPatch.kt @@ -11,6 +11,6 @@ val rootDetectionPatch = bytecodePatch( compatibleWith("at.gv.bka.serviceportal") execute { - rootDetectionFingerprint.method.addInstruction(0, "return-void") + rootDetectionFingerprint.method().addInstruction(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt index 3ede5d48af..0f3baaec93 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentPatch.kt @@ -37,11 +37,11 @@ fun checkEnvironmentPatch( execute { addResources("shared", "misc.checks.checkEnvironmentPatch") - fun setPatchInfo() { - fun Fingerprint.setClassFields(vararg fieldNameValues: Pair) { + suspend fun setPatchInfo() { + suspend fun Fingerprint.setClassFields(vararg fieldNameValues: Pair) { val fieldNameValueMap = mapOf(*fieldNameValues) - classDef.fields.forEach { field -> + classDef().fields.forEach { field -> field.initialValue = fieldNameValueMap[field.name] ?: return@forEach } } @@ -50,7 +50,7 @@ fun checkEnvironmentPatch( "PATCH_TIME" to System.currentTimeMillis().encoded, ) - fun setBuildInfo() { + suspend fun setBuildInfo() { patchInfoBuildFingerprint.setClassFields( "PATCH_BOARD" to BOARD.encodedAndHashed, "PATCH_BOOTLOADER" to BOOTLOADER.encodedAndHashed, @@ -82,7 +82,7 @@ fun checkEnvironmentPatch( } } - fun invokeCheck() = mainActivityOnCreateFingerprint.method.addInstructions( + suspend fun invokeCheck() = mainActivityOnCreateFingerprint.method().addInstructions( 0, "invoke-static/range { p0 .. p0 },$EXTENSION_CLASS_DESCRIPTOR->check(Landroid/app/Activity;)V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/extension/SharedExtensionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/extension/SharedExtensionPatch.kt index 33c3ddf154..8703439795 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/extension/SharedExtensionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/extension/SharedExtensionPatch.kt @@ -29,7 +29,7 @@ fun sharedExtensionPatch( hooks.forEach { hook -> hook(EXTENSION_CLASS_DESCRIPTOR) } // Modify Utils method to include the patches release version. - revancedUtilsPatchesVersionFingerprint.method.apply { + revancedUtilsPatchesVersionFingerprint.method().apply { /** * @return The file path for the jar this classfile is contained inside. */ @@ -77,11 +77,11 @@ class ExtensionHook internal constructor( private val contextRegisterResolver: (Method) -> String, ) { context(BytecodePatchContext) - operator fun invoke(extensionClassDescriptor: String) { - val insertIndex = insertIndexResolver(fingerprint.method) - val contextRegister = contextRegisterResolver(fingerprint.method) + suspend operator fun invoke(extensionClassDescriptor: String) { + val insertIndex = insertIndexResolver(fingerprint.method()) + val contextRegister = contextRegisterResolver(fingerprint.method()) - fingerprint.method.addInstruction( + fingerprint.method().addInstruction( insertIndex, "invoke-static/range { $contextRegister .. $contextRegister }, " + "$extensionClassDescriptor->setContext(Landroid/content/Context;)V", diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt index a01839c100..b92ec69f28 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch.kt @@ -10,8 +10,8 @@ val verticalScrollPatch = bytecodePatch( ) { execute { - canScrollVerticallyFingerprint.method.apply { - val moveResultIndex = canScrollVerticallyFingerprint.patternMatch!!.endIndex + canScrollVerticallyFingerprint.method().apply { + val moveResultIndex = canScrollVerticallyFingerprint.patternMatch()!!.endIndex val moveResultRegister = getInstruction(moveResultIndex).registerA val insertIndex = moveResultIndex + 1 diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt index 0e54bb6919..83b9b5bb01 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/gms/GmsCoreSupportPatch.kt @@ -5,6 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.instructions import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.* +import app.revanced.patcher.util.proxy.mutableTypes.MutableClass +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.all.misc.packagename.changePackageNamePatch import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName import app.revanced.patches.all.misc.resources.addResources @@ -77,17 +79,23 @@ fun gmsCoreSupportPatch( val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption execute { - fun transformStringReferences(transform: (str: String) -> String?) = classes.forEach { + suspend fun transformStringReferences(transform: (str: String) -> String?) = classes.forEach { + var _mutableClass: MutableClass? = null + suspend fun mutableClass() = _mutableClass ?: proxy(it).mutableClass.also { mutableClass -> _mutableClass = mutableClass } + /* val mutableClass by lazy { proxy(it).mutableClass - } + }*/ it.methods.forEach classLoop@{ method -> val implementation = method.implementation ?: return@classLoop + /* val mutableMethod by lazy { mutableClass.methods.first { MethodUtil.methodSignaturesMatch(it, method) } - } + }*/ + var _mutableMethod: MutableMethod? = null + suspend fun mutableMethod() = _mutableMethod ?: mutableClass().methods.first { MethodUtil.methodSignaturesMatch(it, method) } implementation.instructions.forEachIndexed insnLoop@{ index, instruction -> val string = ((instruction as? Instruction21c)?.reference as? StringReference)?.string @@ -96,7 +104,7 @@ fun gmsCoreSupportPatch( // Apply transformation. val transformedString = transform(string) ?: return@insnLoop - mutableMethod.replaceInstruction( + mutableMethod().replaceInstruction( index, BuilderInstruction21c( Opcode.CONST_STRING, @@ -158,8 +166,8 @@ fun gmsCoreSupportPatch( } } - fun transformPrimeMethod(packageName: String) { - primeMethodFingerprint!!.method.apply { + suspend fun transformPrimeMethod(packageName: String) { + primeMethodFingerprint!!.method().apply { var register = 2 val index = instructions.indexOfFirst { @@ -195,16 +203,16 @@ fun gmsCoreSupportPatch( primeMethodFingerprint?.let { transformPrimeMethod(packageName) } // Return these methods early to prevent the app from crashing. - earlyReturnFingerprints.forEach { it.method.returnEarly() } - serviceCheckFingerprint.method.returnEarly() + earlyReturnFingerprints.forEach { it.method().returnEarly() } + serviceCheckFingerprint.method().returnEarly() // Google Play Utility is not present in all apps, so we need to check if it's present. - if (googlePlayUtilityFingerprint.methodOrNull != null) { - googlePlayUtilityFingerprint.method.returnEarly() + if (googlePlayUtilityFingerprint.methodOrNull() != null) { + googlePlayUtilityFingerprint.method().returnEarly() } // Verify GmsCore is installed and whitelisted for power optimizations and background usage. - mainActivityOnCreateFingerprint.method.apply { + mainActivityOnCreateFingerprint.method().apply { // Temporary fix for patches with an extension patch that hook the onCreate method as well. val setContextIndex = indexOfFirstInstruction { val reference = getReference() ?: return@indexOfFirstInstruction false @@ -221,7 +229,7 @@ fun gmsCoreSupportPatch( } // Change the vendor of GmsCore in the extension. - gmsCoreSupportFingerprint.classDef.methods + gmsCoreSupportFingerprint.classDef().methods .single { it.name == GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME } .replaceInstruction(0, "const-string v0, \"$gmsCoreVendorGroupId\"") diff --git a/patches/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/RemoveFileSizeLimitPatch.kt b/patches/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/RemoveFileSizeLimitPatch.kt index 7ef5093015..1c9cd442e1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/RemoveFileSizeLimitPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/RemoveFileSizeLimitPatch.kt @@ -13,8 +13,8 @@ val removeFileSizeLimitPatch = bytecodePatch( compatibleWith("pl.solidexplorer2") execute { - onReadyFingerprint.method.apply { - val cmpIndex = onReadyFingerprint.patternMatch!!.startIndex + 1 + onReadyFingerprint.method().apply { + val cmpIndex = onReadyFingerprint.patternMatch()!!.startIndex + 1 val cmpResultRegister = getInstruction(cmpIndex).registerA replaceInstruction(cmpIndex, "const/4 v$cmpResultRegister, 0x0") diff --git a/patches/src/main/kotlin/app/revanced/patches/songpal/badge/BadgeTabPatch.kt b/patches/src/main/kotlin/app/revanced/patches/songpal/badge/BadgeTabPatch.kt index f37ebe71ee..6678f84a24 100644 --- a/patches/src/main/kotlin/app/revanced/patches/songpal/badge/BadgeTabPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/songpal/badge/BadgeTabPatch.kt @@ -16,7 +16,7 @@ val badgeTabPatch = bytecodePatch( val arrayTabs = listOf("Log", "HealthCare") execute { - createTabsFingerprint.method.apply { + createTabsFingerprint.method().apply { removeInstructions(0, 2) val arrayRegister = 0 diff --git a/patches/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt b/patches/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt index eae07fc918..a5200df55c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt @@ -11,6 +11,6 @@ val removeNotificationBadgePatch = bytecodePatch( compatibleWith("com.sony.songpal.mdr"("10.1.0")) execute { - showNotificationFingerprint.method.addInstructions(0, "return-void") + showNotificationFingerprint.method().addInstructions(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/soundcloud/ad/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/soundcloud/ad/HideAdsPatch.kt index 3e56ed7275..34e645d713 100644 --- a/patches/src/main/kotlin/app/revanced/patches/soundcloud/ad/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/soundcloud/ad/HideAdsPatch.kt @@ -19,7 +19,7 @@ val hideAdsPatch = bytecodePatch( // This method is the constructor of a class representing a "Feature" object parsed from JSON data. // p1 is the name of the feature. // p2 is true if the feature is enabled, false otherwise. - featureConstructorFingerprint.method.apply { + featureConstructorFingerprint.method().apply { val afterCheckNotNullIndex = 2 addInstructionsWithLabels( afterCheckNotNullIndex, @@ -41,7 +41,7 @@ val hideAdsPatch = bytecodePatch( // p4 is the "consumerPlanUpsells" value, a list of plans to try to sell to the user. // p5 is the "currentConsumerPlan" value, the type of plan currently subscribed to. // p6 is the "currentConsumerPlanTitle" value, the name of the plan currently subscribed to, shown to the user. - userConsumerPlanConstructorFingerprint.method.addInstructions( + userConsumerPlanConstructorFingerprint.method().addInstructions( 0, """ const-string p1, "high_tier" @@ -54,8 +54,8 @@ val hideAdsPatch = bytecodePatch( // Prevent verification of an HTTP header containing the user's current plan, which would contradict the previous patch. - val conditionIndex = interceptFingerprint.patternMatch!!.endIndex + 1 - interceptFingerprint.method.addInstruction( + val conditionIndex = interceptFingerprint.patternMatch()!!.endIndex + 1 + interceptFingerprint.method().addInstruction( conditionIndex, "return-object p1", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/soundcloud/analytics/DisableTelemetryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/soundcloud/analytics/DisableTelemetryPatch.kt index 8614aca3be..aa3178d60c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/soundcloud/analytics/DisableTelemetryPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/soundcloud/analytics/DisableTelemetryPatch.kt @@ -12,6 +12,6 @@ val disableTelemetryPatch = bytecodePatch( execute { // Empty the "backend" argument to abort the initializer. - createTrackingApiFingerprint.method.addInstruction(0, "const-string p1, \"\"") + createTrackingApiFingerprint.method().addInstruction(0, "const-string p1, \"\"") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt b/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt index ff54b06dcd..a8fcbdf4e3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/soundcloud/offlinesync/EnableOfflineSyncPatch.kt @@ -24,7 +24,7 @@ val enableOfflineSync = bytecodePatch( // This method is the constructor of a class representing a "Feature" object parsed from JSON data. // p1 is the name of the feature. // p2 is true if the feature is enabled, false otherwise. - featureConstructorFingerprint.method.apply { + featureConstructorFingerprint.method().apply { val afterCheckNotNullIndex = 2 addInstructionsWithLabels( @@ -42,7 +42,7 @@ val enableOfflineSync = bytecodePatch( // Patch the URL builder to use the HTTPS_STREAM endpoint // instead of the offline sync endpoint to downloading the track. - downloadOperationsURLBuilderFingerprint.method.apply { + downloadOperationsURLBuilderFingerprint.method().apply { val getEndpointsEnumFieldIndex = 1 val getEndpointsEnumFieldInstruction = getInstruction(getEndpointsEnumFieldIndex) @@ -58,7 +58,7 @@ val enableOfflineSync = bytecodePatch( // The HTTPS_STREAM endpoint does not return the necessary headers for offline sync. // Mock the headers to prevent the app from crashing by setting them to empty strings. // The headers are all cosmetic and do not affect the functionality of the app. - downloadOperationsHeaderVerificationFingerprint.method.apply { + downloadOperationsHeaderVerificationFingerprint.method().apply { // The first three null checks need to be patched. instructions.asSequence().filter { it.opcode == Opcode.IF_EQZ diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/OnDemandPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/OnDemandPatch.kt index 6444ff7fb5..c66ab2ba14 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/OnDemandPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/OnDemandPatch.kt @@ -13,8 +13,8 @@ val onDemandPatch = bytecodePatch( execute { // Spoof a premium account - onDemandFingerprint.method.addInstruction( - onDemandFingerprint.patternMatch!!.endIndex - 1, + onDemandFingerprint.method().addInstruction( + onDemandFingerprint.patternMatch()!!.endIndex - 1, "const/4 v0, 0x2", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabPatch.kt index c191c676b7..deae3cada2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabPatch.kt @@ -36,7 +36,7 @@ val premiumNavbarTabPatch = bytecodePatch( // If the navigation bar item is the premium tab, do not add it. execute { - addNavBarItemFingerprint.method.addInstructions( + addNavBarItemFingerprint.method().addInstructions( 0, """ const v1, $premiumTabId diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/subscription/UnlockSubscriptionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/subscription/UnlockSubscriptionPatch.kt index e59660472d..9e5f3ad0d1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/strava/subscription/UnlockSubscriptionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/strava/subscription/UnlockSubscriptionPatch.kt @@ -11,8 +11,8 @@ val unlockSubscriptionPatch = bytecodePatch( compatibleWith("com.strava") execute { - getSubscribedFingerprint.method.replaceInstruction( - getSubscribedFingerprint.patternMatch!!.startIndex, + getSubscribedFingerprint.method().replaceInstruction( + getSubscribedFingerprint.patternMatch()!!.startIndex, "const/4 v0, 0x1", ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt index 73246fa216..09ea9a8d9b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt @@ -19,11 +19,11 @@ val disableSubscriptionSuggestionsPatch = bytecodePatch( val pageSuffix = "_upsell" val label = "original" - val className = getModulesFingerprint.originalClassDef.type - val originalMethod = getModulesFingerprint.method + val className = getModulesFingerprint.originalClassDef().type + val originalMethod = getModulesFingerprint.method() val returnType = originalMethod.returnType - getModulesFingerprint.classDef.methods.add( + getModulesFingerprint.classDef().methods.add( ImmutableMethod( className, helperMethodName, @@ -52,7 +52,7 @@ val disableSubscriptionSuggestionsPatch = bytecodePatch( }, ) - val getModulesIndex = getModulesFingerprint.patternMatch!!.startIndex + val getModulesIndex = getModulesFingerprint.patternMatch()!!.startIndex with(originalMethod) { removeInstruction(getModulesIndex) addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheckPatch.kt b/patches/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheckPatch.kt index 85ae4a2a89..0de062082b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheckPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/swissid/integritycheck/RemoveGooglePlayIntegrityCheckPatch.kt @@ -18,7 +18,7 @@ val removeGooglePlayIntegrityCheckPatch = bytecodePatch( compatibleWith("com.swisssign.swissid.mobile") execute { - checkIntegrityFingerprint.method.addInstructions( + checkIntegrityFingerprint.method().addInstructions( 0, """ iget-object p1, p0, $RESULT_METHOD_REFERENCE diff --git a/patches/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/UnlockThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/UnlockThemePatch.kt index c9d777904a..f570da899b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/UnlockThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/ticktick/misc/themeunlock/UnlockThemePatch.kt @@ -12,7 +12,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("com.ticktick.task") execute { - checkLockedThemesFingerprint.method.addInstructions( + checkLockedThemesFingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 @@ -20,6 +20,6 @@ val unlockProPatch = bytecodePatch( """, ) - setThemeFingerprint.method.removeInstructions(0, 10) + setThemeFingerprint.method().removeInstructions(0, 10) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt index 9ea783f957..6fad1fd50f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/feedfilter/FeedFilterPatch.kt @@ -26,7 +26,7 @@ val feedFilterPatch = bytecodePatch( ) execute { - feedApiServiceLIZFingerprint.method.apply { + feedApiServiceLIZFingerprint.method().apply { val returnFeedItemInstruction = instructions.first { it.opcode == Opcode.RETURN_OBJECT } val feedItemsRegister = (returnFeedItemInstruction as OneRegisterInstruction).registerA @@ -37,7 +37,7 @@ val feedFilterPatch = bytecodePatch( ) } - settingsStatusLoadFingerprint.method.addInstruction( + settingsStatusLoadFingerprint.method().addInstruction( 0, "invoke-static {}, Lapp/revanced/extension/tiktok/settings/SettingsStatus;->enableFeedFilter()V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt index 13c829e625..710dbb2976 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/cleardisplay/RememberClearDisplayPatch.kt @@ -21,7 +21,7 @@ val rememberClearDisplayPatch = bytecodePatch( ) execute { - onClearDisplayEventFingerprint.method.let { + onClearDisplayEventFingerprint.method().let { // region Hook the "Clear display" configuration save event to remember the state of clear display. val isEnabledIndex = it.indexOfFirstInstructionOrThrow(Opcode.IGET_BOOLEAN) + 1 @@ -38,7 +38,7 @@ val rememberClearDisplayPatch = bytecodePatch( // region Override the "Clear display" configuration load event to load the state of clear display. val clearDisplayEventClass = it.parameters[0].type - onRenderFirstFrameFingerprint.method.addInstructionsWithLabels( + onRenderFirstFrameFingerprint.method().addInstructionsWithLabels( 0, """ # Create a new clearDisplayEvent and post it to the EventBus (https://github.com/greenrobot/EventBus) @@ -61,7 +61,7 @@ val rememberClearDisplayPatch = bytecodePatch( invoke-direct { v0, v1, v2, v3, v4 }, $clearDisplayEventClass->(ILjava/lang/String;Ljava/lang/String;Z)V invoke-virtual { v0 }, $clearDisplayEventClass->post()Lcom/ss/android/ugc/governance/eventbus/IEvent; """, - ExternalLabel("clear_display_disabled", onRenderFirstFrameFingerprint.method.getInstruction(0)), + ExternalLabel("clear_display_disabled", onRenderFirstFrameFingerprint.method().getInstruction(0)), ) // endregion diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt index b80ceaed06..0f2227c305 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/downloads/DownloadsPatch.kt @@ -28,7 +28,7 @@ val downloadsPatch = bytecodePatch( ) execute { - aclCommonShareFingerprint.method.replaceInstructions( + aclCommonShareFingerprint.method().replaceInstructions( 0, """ const/4 v0, 0x0 @@ -36,7 +36,7 @@ val downloadsPatch = bytecodePatch( """, ) - aclCommonShare2Fingerprint.method.replaceInstructions( + aclCommonShare2Fingerprint.method().replaceInstructions( 0, """ const/4 v0, 0x2 @@ -45,7 +45,7 @@ val downloadsPatch = bytecodePatch( ) // Download videos without watermark. - aclCommonShare3Fingerprint.method.addInstructionsWithLabels( + aclCommonShare3Fingerprint.method().addInstructionsWithLabels( 0, """ invoke-static {}, Lapp/revanced/extension/tiktok/download/DownloadsPatch;->shouldRemoveWatermark()Z @@ -59,7 +59,7 @@ val downloadsPatch = bytecodePatch( ) // Change the download path patch. - downloadUriFingerprint.method.apply { + downloadUriFingerprint.method().apply { val firstIndex = indexOfFirstInstructionOrThrow { getReference()?.name == "" } @@ -84,7 +84,7 @@ val downloadsPatch = bytecodePatch( ) } - settingsStatusLoadFingerprint.method.addInstruction( + settingsStatusLoadFingerprint.method().addInstruction( 0, "invoke-static {}, Lapp/revanced/extension/tiktok/settings/SettingsStatus;->enableDownload()V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/ShowSeekbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/ShowSeekbarPatch.kt index 417095b339..a79dc131a6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/ShowSeekbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/ShowSeekbarPatch.kt @@ -14,14 +14,14 @@ val showSeekbarPatch = bytecodePatch( ) execute { - shouldShowSeekBarFingerprint.method.addInstructions( + shouldShowSeekBarFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 return v0 """, ) - setSeekBarShowTypeFingerprint.method.apply { + setSeekBarShowTypeFingerprint.method().apply { val typeRegister = implementation!!.registerCount - 1 addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt index d59626ee76..1db3db9c2e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPatch.kt @@ -24,7 +24,7 @@ val playbackSpeedPatch = bytecodePatch( execute { setSpeedFingerprint.let { onVideoSwiped -> - getSpeedFingerprint.method.apply { + getSpeedFingerprint.method().apply { val injectIndex = indexOfFirstInstructionOrThrow { getReference()?.returnType == "F" } + 2 val register = getInstruction(injectIndex - 1).registerA @@ -38,12 +38,12 @@ val playbackSpeedPatch = bytecodePatch( // By default, the playback speed will reset to 1.0 at the start of each video. // Instead, override it with the desired playback speed. - onRenderFirstFrameFingerprint.method.addInstructions( + onRenderFirstFrameFingerprint.method().addInstructions( 0, """ # Video playback location (e.g. home page, following page or search result page) retrieved using getEnterFrom method. const/4 v0, 0x1 - invoke-virtual { p0, v0 }, ${getEnterFromFingerprint.originalMethod} + invoke-virtual { p0, v0 }, ${getEnterFromFingerprint.originalMethod()} move-result-object v0 # Model of current video retrieved using getCurrentAweme method. @@ -53,12 +53,12 @@ val playbackSpeedPatch = bytecodePatch( # Desired playback speed retrieved using getPlaybackSpeed method. invoke-static { }, Lapp/revanced/extension/tiktok/speed/PlaybackSpeedPatch;->getPlaybackSpeed()F move-result v2 - invoke-static { v0, v1, v2 }, ${onVideoSwiped.originalMethod} + invoke-static { v0, v1, v2 }, ${onVideoSwiped.originalMethod()} """, ) // Force enable the playback speed option for all videos. - onVideoSwiped.classDef.methods.find { method -> method.returnType == "Z" }?.addInstructions( + onVideoSwiped.classDef().methods.find { method -> method.returnType == "Z" }?.addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/DisableLoginRequirementPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/DisableLoginRequirementPatch.kt index 2976abe5e5..07ec95c502 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/DisableLoginRequirementPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/disablerequirement/DisableLoginRequirementPatch.kt @@ -17,7 +17,7 @@ val disableLoginRequirementPatch = bytecodePatch( mandatoryLoginServiceFingerprint, mandatoryLoginService2Fingerprint, ).forEach { fingerprint -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/FixGoogleLoginPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/FixGoogleLoginPatch.kt index 7ab636c095..6bba87ea0a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/FixGoogleLoginPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/login/fixgoogle/FixGoogleLoginPatch.kt @@ -15,8 +15,8 @@ val fixGoogleLoginPatch = bytecodePatch( execute { listOf( - googleOneTapAuthAvailableFingerprint.method, - googleAuthAvailableFingerprint.method, + googleOneTapAuthAvailableFingerprint.method(), + googleAuthAvailableFingerprint.method(), ).forEach { method -> method.addInstructions( 0, diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt index a48305177a..62929f3b0e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/SettingsPatch.kt @@ -40,11 +40,11 @@ val settingsPatch = bytecodePatch( fun String.toClassName(): String = substring(1, this.length - 1).replace("/", ".") // Find the class name of classes which construct a settings entry - val settingsButtonClass = settingsEntryFingerprint.originalClassDef.type.toClassName() - val settingsButtonInfoClass = settingsEntryInfoFingerprint.originalClassDef.type.toClassName() + val settingsButtonClass = settingsEntryFingerprint.originalClassDef().type.toClassName() + val settingsButtonInfoClass = settingsEntryInfoFingerprint.originalClassDef().type.toClassName() // Create a settings entry for 'revanced settings' and add it to settings fragment - addSettingsEntryFingerprint.method.apply { + addSettingsEntryFingerprint.method().apply { val markIndex = implementation!!.instructions.indexOfFirst { it.opcode == Opcode.IGET_OBJECT && ((it as Instruction22c).reference as FieldReference).name == "headerUnit" } @@ -67,13 +67,13 @@ val settingsPatch = bytecodePatch( const-string v1, "$settingsButtonInfoClass" invoke-static {v0, v1}, $createSettingsEntryMethodDescriptor move-result-object v0 - check-cast v0, ${settingsEntryFingerprint.originalClassDef.type} + check-cast v0, ${settingsEntryFingerprint.originalClassDef().type} """, ) } // Initialize the settings menu once the replaced setting entry is clicked. - adPersonalizationActivityOnCreateFingerprint.method.apply { + adPersonalizationActivityOnCreateFingerprint.method().apply { val initializeSettingsIndex = implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_SUPER } + 1 diff --git a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt index 593241d15b..ab1f96b73b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tiktok/misc/spoof/sim/SpoofSimPatch.kt @@ -92,7 +92,7 @@ val spoofSimPatch = bytecodePatch( } // Enable patch in settings. - settingsStatusLoadFingerprint.method.addInstruction( + settingsStatusLoadFingerprint.method().addInstruction( 0, "invoke-static {}, Lapp/revanced/extension/tiktok/settings/SettingsStatus;->enableSimSpoof()V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/trakt/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/trakt/UnlockProPatch.kt index bf10b9f40e..4896b30998 100644 --- a/patches/src/main/kotlin/app/revanced/patches/trakt/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/trakt/UnlockProPatch.kt @@ -12,10 +12,10 @@ val unlockProPatch = bytecodePatch( execute { arrayOf(isVIPFingerprint, isVIPEPFingerprint).onEach { fingerprint -> // Resolve both fingerprints on the same class. - fingerprint.match(remoteUserFingerprint.originalClassDef) + fingerprint.match(remoteUserFingerprint.originalClassDef()) }.forEach { fingerprint -> // Return true for both VIP check methods. - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/tudortmund/lockscreen/ShowOnLockscreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tudortmund/lockscreen/ShowOnLockscreenPatch.kt index 2d33251901..6570c82bb7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tudortmund/lockscreen/ShowOnLockscreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tudortmund/lockscreen/ShowOnLockscreenPatch.kt @@ -25,7 +25,7 @@ val showOnLockscreenPatch = bytecodePatch( compatibleWith("de.tudortmund.app") execute { - brightnessFingerprint.method.apply { + brightnessFingerprint.method().apply { // Find the instruction where the brightness value is loaded into a register val brightnessInstruction = instructions.firstNotNullOf { instruction -> if (instruction.opcode != Opcode.IGET_OBJECT) return@firstNotNullOf null diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/DisableBlogNotificationReminderPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/DisableBlogNotificationReminderPatch.kt index fc3d1fc8eb..7fa424e2e8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/DisableBlogNotificationReminderPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/notifications/DisableBlogNotificationReminderPatch.kt @@ -11,7 +11,7 @@ val disableBlogNotificationReminderPatch = bytecodePatch( compatibleWith("com.tumblr") execute { - isBlogNotifyEnabledFingerprint.method.addInstructions( + isBlogNotifyEnabledFingerprint.method().addInstructions( 0, """ # Return false for BlogNotifyCtaDialog.isEnabled() method. diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/DisableGiftMessagePopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/DisableGiftMessagePopupPatch.kt index 09faa17346..72f878b894 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/DisableGiftMessagePopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/DisableGiftMessagePopupPatch.kt @@ -11,6 +11,6 @@ val disableGiftMessagePopupPatch = bytecodePatch( compatibleWith("com.tumblr") execute { - showGiftMessagePopupFingerprint.method.addInstructions(0, "return-void") + showGiftMessagePopupFingerprint.method().addInstructions(0, "return-void") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt index c2da658aad..10a5109745 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt @@ -24,15 +24,15 @@ val overrideFeatureFlagsPatch = bytecodePatch( ) { execute { - val configurationClass = getFeatureValueFingerprint.originalMethod.definingClass - val featureClass = getFeatureValueFingerprint.originalMethod.parameterTypes[0].toString() + val configurationClass = getFeatureValueFingerprint.originalMethod().definingClass + val featureClass = getFeatureValueFingerprint.originalMethod().parameterTypes[0].toString() // The method we want to inject into does not have enough registers, so we inject a helper method // and inject more instructions into it later, see addOverride. // This is not in an extension since the unused variable would get compiled away and the method would // get compiled to only have one register, which is not enough for our later injected instructions. val helperMethod = ImmutableMethod( - getFeatureValueFingerprint.originalMethod.definingClass, + getFeatureValueFingerprint.originalMethod().definingClass, "getValueOverride", listOf(ImmutableMethodParameter(featureClass, null, "feature")), "Ljava/lang/String;", @@ -62,15 +62,15 @@ val overrideFeatureFlagsPatch = bytecodePatch( """, ) }.also { helperMethod -> - getFeatureValueFingerprint.classDef.methods.add(helperMethod) + getFeatureValueFingerprint.classDef().methods.add(helperMethod) } // Here we actually insert the hook to call our helper method and return its value if it returns not null // This is equivalent to // String forcedValue = getValueOverride(feature) // if (forcedValue != null) return forcedValue - val getFeatureIndex = getFeatureValueFingerprint.patternMatch!!.startIndex - getFeatureValueFingerprint.method.addInstructionsWithLabels( + val getFeatureIndex = getFeatureValueFingerprint.patternMatch()!!.startIndex + getFeatureValueFingerprint.method().addInstructionsWithLabels( getFeatureIndex, """ # Call the Helper Method with the Feature diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt index dbe75d5f8b..9d15315c19 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/fixes/FixOldVersionsPatch.kt @@ -20,8 +20,8 @@ val fixOldVersionsPatch = bytecodePatch( // Remove the live query parameters from the path when it's specified via a @METHOD annotation. for (liveQueryParameter in liveQueryParameters) { - httpPathParserFingerprint.method.addInstructions( - httpPathParserFingerprint.patternMatch!!.endIndex + 1, + httpPathParserFingerprint.method().addInstructions( + httpPathParserFingerprint.patternMatch()!!.endIndex + 1, """ # urlPath = urlPath.replace(liveQueryParameter, "") const-string p1, "$liveQueryParameter" @@ -39,7 +39,7 @@ val fixOldVersionsPatch = bytecodePatch( // which would result in the path "api/me/inf0?fields[blog]=${value}" // Here we make sure that this value doesn't contain the broken query parameters. for (liveQueryParameter in liveQueryParameters) { - addQueryParamFingerprint.method.addInstructions( + addQueryParamFingerprint.method().addInstructions( 0, """ # queryParameterValue = queryParameterValue.replace(liveQueryParameter, "") diff --git a/patches/src/main/kotlin/app/revanced/patches/tumblr/timelinefilter/FilterTimelineObjectsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/tumblr/timelinefilter/FilterTimelineObjectsPatch.kt index c4ab799e85..d2458358e2 100644 --- a/patches/src/main/kotlin/app/revanced/patches/tumblr/timelinefilter/FilterTimelineObjectsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/tumblr/timelinefilter/FilterTimelineObjectsPatch.kt @@ -24,9 +24,9 @@ val filterTimelineObjectsPatch = bytecodePatch( dependsOn(sharedExtensionPatch) execute { - val filterInsertIndex = timelineFilterExtensionFingerprint.patternMatch!!.startIndex + val filterInsertIndex = timelineFilterExtensionFingerprint.patternMatch()!!.startIndex - timelineFilterExtensionFingerprint.method.apply { + timelineFilterExtensionFingerprint.method().apply { val addInstruction = getInstruction(filterInsertIndex + 1) val filterListRegister = addInstruction.registerC @@ -51,7 +51,7 @@ val filterTimelineObjectsPatch = bytecodePatch( timelineConstructorFingerprint to 1, postsResponseConstructorFingerprint to 2, ).forEach { (fingerprint, timelineObjectsRegister) -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, "invoke-static {p$timelineObjectsRegister}, " + "Lapp/revanced/extension/tumblr/patches/TimelineFilterPatch;->" + diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt index 4b57bddbd9..16044a8cba 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt @@ -32,7 +32,7 @@ val audioAdsPatch = bytecodePatch( ) // Block playAds call - audioAdsPresenterPlayFingerprint.method.addInstructionsWithLabels( + audioAdsPresenterPlayFingerprint.method().addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/extension/twitch/patches/AudioAdsPatch;->shouldBlockAudioAds()Z @@ -40,7 +40,7 @@ val audioAdsPatch = bytecodePatch( if-eqz v0, :show_audio_ads return-void """, - ExternalLabel("show_audio_ads", audioAdsPresenterPlayFingerprint.method.getInstruction(0)), + ExternalLabel("show_audio_ads", audioAdsPresenterPlayFingerprint.method().getInstruction(0)), ) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt index 973ccefe00..7220cc1f77 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt @@ -30,7 +30,7 @@ val embeddedAdsPatch = bytecodePatch( ) // Inject OkHttp3 application interceptor - createsUsherClientFingerprint.method.addInstructions( + createsUsherClientFingerprint.method().addInstructions( 3, """ invoke-static {}, Lapp/revanced/extension/twitch/patches/EmbeddedAdsPatch;->createRequestInterceptor()Lapp/revanced/extension/twitch/api/RequestInterceptor; diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AdPatch.kt index 48ecefba8e..a52b1e2e70 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AdPatch.kt @@ -12,7 +12,7 @@ fun adPatch( skipLabelName: String, block: BytecodePatchBuilder.( createConditionInstructions: (register: String) -> String, - blockMethods: BytecodePatchContext.( + blockMethods: suspend BytecodePatchContext.( clazz: String, methodNames: Set, returnMethod: ReturnMethod, @@ -25,7 +25,7 @@ fun adPatch( if-eqz $register, :$skipLabelName """ - fun BytecodePatchContext.blockMethods( + suspend fun BytecodePatchContext.blockMethods( classDefType: String, methodNames: Set, returnMethod: ReturnMethod, diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt index 49b715fce7..f10605ecfe 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt @@ -111,7 +111,7 @@ val videoAdsPatch = bytecodePatch( ) // Pretend our player is ineligible for all ads. - checkAdEligibilityLambdaFingerprint.method.addInstructionsWithLabels( + checkAdEligibilityLambdaFingerprint.method().addInstructionsWithLabels( 0, """ ${createConditionInstructions("v0")} @@ -122,13 +122,13 @@ val videoAdsPatch = bytecodePatch( """, ExternalLabel( skipLabelName, - checkAdEligibilityLambdaFingerprint.method.getInstruction(0), + checkAdEligibilityLambdaFingerprint.method().getInstruction(0), ), ) val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;" - getReadyToShowAdFingerprint.method.addInstructionsWithLabels( + getReadyToShowAdFingerprint.method().addInstructionsWithLabels( 0, """ ${createConditionInstructions("v0")} @@ -137,11 +137,11 @@ val videoAdsPatch = bytecodePatch( move-result-object p1 return-object p1 """, - ExternalLabel(skipLabelName, getReadyToShowAdFingerprint.method.getInstruction(0)), + ExternalLabel(skipLabelName, getReadyToShowAdFingerprint.method().getInstruction(0)), ) // Spoof showAds JSON field. - contentConfigShowAdsFingerprint.method.addInstructions( + contentConfigShowAdsFingerprint.method().addInstructions( 0, """ ${createConditionInstructions("v0")} diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt index f607d1b05b..a0e0452ad7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt @@ -42,7 +42,7 @@ val showDeletedMessagesPatch = bytecodePatch( ) // Spoiler mode: Force set hasModAccess member to true in constructor - deletedMessageClickableSpanCtorFingerprint.method.apply { + deletedMessageClickableSpanCtorFingerprint.method().apply { addInstructionsWithLabels( implementation!!.instructions.lastIndex, /* place in front of return-void */ """ @@ -55,10 +55,10 @@ val showDeletedMessagesPatch = bytecodePatch( } // Spoiler mode: Disable setHasModAccess setter - setHasModAccessFingerprint.method.addInstruction(0, "return-void") + setHasModAccessFingerprint.method().addInstruction(0, "return-void") // Cross-out mode: Reformat span of deleted message - chatUtilCreateDeletedSpanFingerprint.method.apply { + chatUtilCreateDeletedSpanFingerprint.method().apply { addInstructionsWithLabels( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt index fd5b81011f..7fff37ed16 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt @@ -30,7 +30,7 @@ val autoClaimChannelPointsPatch = bytecodePatch( SwitchPreference("revanced_auto_claim_channel_points"), ) - communityPointsButtonViewDelegateFingerprint.method.apply { + communityPointsButtonViewDelegateFingerprint.method().apply { val lastIndex = instructions.lastIndex addInstructionsWithLabels( lastIndex, // place in front of return-void diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt index d5cbd81aa5..6c0250cf5d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt @@ -35,7 +35,7 @@ val debugModePatch = bytecodePatch( isOmVerificationEnabledFingerprint, shouldShowDebugOptionsFingerprint, ).forEach { fingerprint -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ invoke-static {}, Lapp/revanced/extension/twitch/patches/DebugModePatch;->isDebugModeEnabled()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt index 71bc5f54a1..340af536fd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt @@ -73,8 +73,8 @@ val settingsPatch = bytecodePatch( ) // Hook onCreate to handle fragment creation. - val insertIndex = settingsActivityOnCreateFingerprint.method.implementation!!.instructions.size - 2 - settingsActivityOnCreateFingerprint.method.addInstructionsWithLabels( + val insertIndex = settingsActivityOnCreateFingerprint.method().implementation!!.instructions.size - 2 + settingsActivityOnCreateFingerprint.method().addInstructionsWithLabels( insertIndex, """ invoke-static { p0 }, $ACTIVITY_HOOKS_CLASS_DESCRIPTOR->handleSettingsCreation(Landroidx/appcompat/app/AppCompatActivity;)Z @@ -84,21 +84,21 @@ val settingsPatch = bytecodePatch( """, ExternalLabel( "no_rv_settings_init", - settingsActivityOnCreateFingerprint.method.getInstruction(insertIndex), + settingsActivityOnCreateFingerprint.method().getInstruction(insertIndex), ), ) // Create new menu item for settings menu. - fun Fingerprint.injectMenuItem( + suspend fun Fingerprint.injectMenuItem( name: String, value: Int, titleResourceName: String, iconResourceName: String, ) { // Add new static enum member field - classDef.staticFields.add( + classDef().staticFields.add( ImmutableField( - method.definingClass, + method().definingClass, name, MENU_ITEM_ENUM_CLASS_DESCRIPTOR, AccessFlags.PUBLIC.value or @@ -112,8 +112,8 @@ val settingsPatch = bytecodePatch( ) // Add initializer for the new enum member - method.addInstructions( - method.implementation!!.instructions.size - 4, + method().addInstructions( + method().implementation!!.instructions.size - 4, """ new-instance v0, $MENU_ITEM_ENUM_CLASS_DESCRIPTOR const-string v1, "$titleResourceName" @@ -138,7 +138,7 @@ val settingsPatch = bytecodePatch( ) // Intercept settings menu creation and add new menu item. - menuGroupsUpdatedFingerprint.method.addInstructions( + menuGroupsUpdatedFingerprint.method().addInstructions( 0, """ sget-object v0, $MENU_ITEM_ENUM_CLASS_DESCRIPTOR->$REVANCED_SETTINGS_MENU_ITEM_NAME:$MENU_ITEM_ENUM_CLASS_DESCRIPTOR @@ -148,7 +148,7 @@ val settingsPatch = bytecodePatch( ) // Intercept onclick events for the settings menu - menuGroupsOnClickFingerprint.method.addInstructionsWithLabels( + menuGroupsOnClickFingerprint.method().addInstructionsWithLabels( 0, """ invoke-static {p1}, $ACTIVITY_HOOKS_CLASS_DESCRIPTOR->handleSettingMenuOnClick(Ljava/lang/Enum;)Z @@ -160,7 +160,7 @@ val settingsPatch = bytecodePatch( """, ExternalLabel( "no_rv_settings_onclick", - menuGroupsOnClickFingerprint.method.getInstruction(0), + menuGroupsOnClickFingerprint.method().getInstruction(0), ), ) } diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt index 6f2b9c12c7..435d8a974b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/interaction/downloads/UnlockDownloadsPatch.kt @@ -20,30 +20,30 @@ val unlockDownloadsPatch = bytecodePatch( compatibleWith("com.twitter.android") execute { - fun Fingerprint.patch(getRegisterAndIndex: Fingerprint.() -> Pair) { + suspend fun Fingerprint.patch(getRegisterAndIndex: suspend Fingerprint.() -> Pair) { val (index, register) = getRegisterAndIndex() - method.addInstruction(index, "const/4 v$register, 0x1") + method().addInstruction(index, "const/4 v$register, 0x1") } // Allow downloads for non-premium users. showDownloadVideoUpsellBottomSheetFingerprint.patch { - val checkIndex = patternMatch!!.startIndex - val register = method.getInstruction(checkIndex).registerA + val checkIndex = patternMatch()!!.startIndex + val register = method().getInstruction(checkIndex).registerA checkIndex to register } // Force show the download menu item. constructMediaOptionsSheetFingerprint.patch { - val showDownloadButtonIndex = method.instructions.lastIndex - 1 - val register = method.getInstruction(showDownloadButtonIndex).registerA + val showDownloadButtonIndex = method().instructions.lastIndex - 1 + val register = method().getInstruction(showDownloadButtonIndex).registerA showDownloadButtonIndex to register } // Make GIFs downloadable. - val patternMatch = buildMediaOptionsSheetFingerprint.patternMatch!! - buildMediaOptionsSheetFingerprint.method.apply { + val patternMatch = buildMediaOptionsSheetFingerprint.patternMatch()!! + buildMediaOptionsSheetFingerprint.method().apply { val checkMediaTypeIndex = patternMatch.startIndex val checkMediaTypeInstruction = getInstruction(checkMediaTypeIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt index deee9749fa..d6a7d7c456 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/layout/viewcount/HideViewCountPatch.kt @@ -12,7 +12,7 @@ val hideViewCountPatch = bytecodePatch( compatibleWith("com.twitter.android") execute { - viewCountsEnabledFingerprint.method.addInstructions( + viewCountsEnabledFingerprint.method().addInstructions( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt index 0933053792..688a6f4820 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/hook/json/JsonHookPatch.kt @@ -15,14 +15,14 @@ import java.io.InvalidClassException * @param jsonHook The [JsonHook] to add. */ context(BytecodePatchContext) -fun addJsonHook( +suspend fun addJsonHook( jsonHook: JsonHook, ) { if (jsonHook.added) return - jsonHookPatchFingerprint.method.apply { + jsonHookPatchFingerprint.method().apply { // Insert hooks right before calling buildList. - val insertIndex = jsonHookPatchFingerprint.patternMatch!!.endIndex + val insertIndex = jsonHookPatchFingerprint.patternMatch()!!.endIndex addInstructions( insertIndex, @@ -54,7 +54,7 @@ val jsonHookPatch = bytecodePatch( matchOrNull(jsonHookPatch.immutableClass) ?: throw PatchException("Unexpected extension.") - }.originalClassDef // Conveniently find the type to hook a method in, via a named field. + }.originalClassDef() // Conveniently find the type to hook a method in, via a named field. .fields .firstOrNull { it.name == "JSON_FACTORY" } ?.type @@ -72,8 +72,8 @@ val jsonHookPatch = bytecodePatch( finalize { // Remove hooks.add(dummyHook). - jsonHookPatchFingerprint.method.apply { - val addDummyHookIndex = jsonHookPatchFingerprint.patternMatch!!.endIndex - 2 + jsonHookPatchFingerprint.method().apply { + val addDummyHookIndex = jsonHookPatchFingerprint.patternMatch()!!.endIndex - 2 removeInstructions(addDummyHookIndex, 2) } @@ -95,6 +95,7 @@ class JsonHook( internal var added = false init { + /* classBy { it.type == descriptor }?.let { it.mutableClass.also { classDef -> if ( @@ -104,6 +105,6 @@ class JsonHook( throw InvalidClassException(classDef.type, "Not a hook class") } } - } ?: throw ClassNotFoundException("Failed to find hook class $descriptor") + } ?: throw ClassNotFoundException("Failed to find hook class $descriptor")*/ } } diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt index 35131aa03c..c7bb8ace0a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt @@ -54,17 +54,17 @@ val changeLinkSharingDomainPatch = bytecodePatch( execute { val replacementIndex = - linkSharingDomainFingerprint.stringMatches!!.first().index + linkSharingDomainFingerprint.stringMatches()!!.first().index val domainRegister = - linkSharingDomainFingerprint.method.getInstruction(replacementIndex).registerA + linkSharingDomainFingerprint.method().getInstruction(replacementIndex).registerA - linkSharingDomainFingerprint.method.replaceInstruction( + linkSharingDomainFingerprint.method().replaceInstruction( replacementIndex, "const-string v$domainRegister, \"https://$domainName\"", ) // Replace the domain name when copying a link with "Copy link" button. - linkBuilderFingerprint.method.apply { + linkBuilderFingerprint.method().apply { addInstructions( 0, """ @@ -76,7 +76,7 @@ val changeLinkSharingDomainPatch = bytecodePatch( } // Used in the Share via... dialog. - linkResourceGetterFingerprint.method.apply { + linkResourceGetterFingerprint.method().apply { val templateIdConstIndex = indexOfFirstLiteralInstructionOrThrow(tweetShareLinkTemplateId) // Format the link with the new domain name register (1 instruction below the const). diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/OpenLinksWithAppChooserPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/OpenLinksWithAppChooserPatch.kt index 03033e7d5b..7c3591cf40 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/OpenLinksWithAppChooserPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/OpenLinksWithAppChooserPatch.kt @@ -17,7 +17,7 @@ val openLinksWithAppChooserPatch = bytecodePatch( "Lapp/revanced/extension/twitter/patches/links/OpenLinksWithAppChooserPatch;->" + "openWithChooser(Landroid/content/Context;Landroid/content/Intent;)V" - openLinkFingerprint.method.addInstructions( + openLinkFingerprint.method().addInstructions( 0, """ invoke-static { p0, p1 }, $methodReference diff --git a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt index 1cde6fc82f..35f2480eab 100644 --- a/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt @@ -11,7 +11,7 @@ val sanitizeSharingLinksPatch = bytecodePatch( compatibleWith("com.twitter.android") execute { - sanitizeSharingLinksFingerprint.method.addInstructions( + sanitizeSharingLinksFingerprint.method().addInstructions( 0, """ # Method takes in a link (string, param 0) and then appends the tracking query params, diff --git a/patches/src/main/kotlin/app/revanced/patches/vsco/misc/pro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/vsco/misc/pro/UnlockProPatch.kt index 2135b1ec4a..0587ab3326 100644 --- a/patches/src/main/kotlin/app/revanced/patches/vsco/misc/pro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/vsco/misc/pro/UnlockProPatch.kt @@ -12,6 +12,6 @@ val unlockProPatch = bytecodePatch( execute { // Set isSubscribed to true. - revCatSubscriptionFingerprint.method.addInstruction(0, "const p1, 0x1") + revCatSubscriptionFingerprint.method().addInstruction(0, "const p1, 0x1") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/FirebaseGetCertPatch.kt b/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/FirebaseGetCertPatch.kt index 82a9008a42..ba64855d45 100644 --- a/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/FirebaseGetCertPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/firebasegetcert/FirebaseGetCertPatch.kt @@ -10,7 +10,7 @@ val firebaseGetCertPatch = bytecodePatch( execute { listOf(getRegistrationCertFingerprint, getMessagingCertFingerprint).forEach { match -> - match.method.addInstructions( + match.method().addInstructions( 0, """ const-string v0, "0799DDF0414D3B3475E88743C91C0676793ED450" diff --git a/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/PromoCodeUnlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/PromoCodeUnlockPatch.kt index 8acb8a650b..0129b12e1a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/PromoCodeUnlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/PromoCodeUnlockPatch.kt @@ -14,7 +14,7 @@ val promoCodeUnlockPatch = bytecodePatch( compatibleWith("de.dwd.warnapp"("4.2.2")) execute { - promoCodeUnlockFingerprint.method.addInstructions( + promoCodeUnlockFingerprint.method().addInstructions( 0, """ const/4 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt index b3dd1a3fcf..88129b36b1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/willhaben/ads/HideAdsPatch.kt @@ -11,7 +11,7 @@ internal val hideAdsPatch = bytecodePatch( compatibleWith("at.willhaben") execute { - adResolverFingerprint.method.returnEarly() - whAdViewInjectorFingerprint.method.returnEarly() + adResolverFingerprint.method().returnEarly() + whAdViewInjectorFingerprint.method().returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch.kt b/patches/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch.kt index 2478b235dd..1757fff213 100644 --- a/patches/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/UnlockProPatch.kt @@ -11,7 +11,7 @@ val unlockProPatch = bytecodePatch( compatibleWith("co.windyapp.android") execute { - checkProFingerprint.method.addInstructions( + checkProFingerprint.method().addInstructions( 0, """ const/16 v0, 0x1 diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index b4f0442286..ff0504977d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -41,8 +41,8 @@ val hideGetPremiumPatch = bytecodePatch( SwitchPreference("revanced_hide_get_premium"), ) - getPremiumViewFingerprint.method.apply { - val startIndex = getPremiumViewFingerprint.patternMatch!!.startIndex + getPremiumViewFingerprint.method().apply { + val startIndex = getPremiumViewFingerprint.patternMatch()!!.startIndex val measuredWidthRegister = getInstruction(startIndex).registerA val measuredHeightInstruction = getInstruction(startIndex + 1) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index b073814bf1..dc112133ad 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -40,7 +40,7 @@ val videoAdsPatch = bytecodePatch( SwitchPreference("revanced_hide_video_ads"), ) - loadVideoAdsFingerprint.method.addInstructionsWithLabels( + loadVideoAdsFingerprint.method().addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/extension/youtube/patches/VideoAdsPatch;->shouldShowAds()Z @@ -48,7 +48,7 @@ val videoAdsPatch = bytecodePatch( if-nez v0, :show_video_ads return-void """, - ExternalLabel("show_video_ads", loadVideoAdsFingerprint.method.getInstruction(0)), + ExternalLabel("show_video_ads", loadVideoAdsFingerprint.method().getInstruction(0)), ) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index cf000474f6..7801c052bb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -45,7 +45,7 @@ val removeViewerDiscretionDialogPatch = bytecodePatch( SwitchPreference("revanced_remove_viewer_discretion_dialog"), ) - createDialogFingerprint.method.apply { + createDialogFingerprint.method().apply { val showDialogIndex = implementation!!.instructions.lastIndex - 2 val dialogRegister = getInstruction(showDialogIndex).registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt index 7022706830..f7216527f3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/DownloadsPatch.kt @@ -82,14 +82,14 @@ val downloadsPatch = bytecodePatch( injectVisibilityCheckCall(BUTTON_DESCRIPTOR) // Main activity is used to launch downloader intent. - mainActivityFingerprint.method.apply { + mainActivityFingerprint.method().apply { addInstruction( implementation!!.instructions.lastIndex, "invoke-static { p0 }, $EXTENSION_CLASS_DESCRIPTOR->activityCreated(Landroid/app/Activity;)V", ) } - offlineVideoEndpointFingerprint.method.apply { + offlineVideoEndpointFingerprint.method().apply { addInstructionsWithLabels( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index a8ec77ebf1..f2f33716c1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -43,7 +43,7 @@ val disablePreciseSeekingGesturePatch = bytecodePatch( "Lapp/revanced/extension/youtube/patches/DisablePreciseSeekingGesturePatch;" allowSwipingUpGestureFingerprint.match( - swipingUpGestureParentFingerprint.originalClassDef, + swipingUpGestureParentFingerprint.originalClassDef(), ).method.apply { addInstructionsWithLabels( 0, @@ -58,7 +58,7 @@ val disablePreciseSeekingGesturePatch = bytecodePatch( } showSwipingUpGuideFingerprint.match( - swipingUpGestureParentFingerprint.originalClassDef, + swipingUpGestureParentFingerprint.originalClassDef(), ).method.apply { addInstructionsWithLabels( 0, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index afc2eddaef..ac9781e709 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -44,9 +44,9 @@ val enableSeekbarTappingPatch = bytecodePatch( ) // Find the required methods to tap the seekbar. - val patternMatch = onTouchEventHandlerFingerprint.patternMatch!! + val patternMatch = onTouchEventHandlerFingerprint.patternMatch()!! - fun getReference(index: Int) = onTouchEventHandlerFingerprint.method.getInstruction(index) + suspend fun getReference(index: Int) = onTouchEventHandlerFingerprint.method().getInstruction(index) .reference as MethodReference val seekbarTappingMethods = buildMap { @@ -54,9 +54,9 @@ val enableSeekbarTappingPatch = bytecodePatch( put("O", getReference(patternMatch.endIndex)) } - val insertIndex = seekbarTappingFingerprint.patternMatch!!.endIndex - 1 + val insertIndex = seekbarTappingFingerprint.patternMatch()!!.endIndex - 1 - seekbarTappingFingerprint.method.apply { + seekbarTappingFingerprint.method().apply { val thisInstanceRegister = getInstruction(insertIndex - 1).registerC val freeRegister = 0 diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index 12d7451d68..7dfb12f6e6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -58,12 +58,12 @@ val enableSlideToSeekPatch = bytecodePatch( // Restore the behaviour to slide to seek. - val checkIndex = slideToSeekFingerprint.patternMatch!!.startIndex - val checkReference = slideToSeekFingerprint.method.getInstruction(checkIndex) + val checkIndex = slideToSeekFingerprint.patternMatch()!!.startIndex + val checkReference = slideToSeekFingerprint.method().getInstruction(checkIndex) .getReference()!! // A/B check method was only called on this class. - slideToSeekFingerprint.classDef.methods.forEach { method -> + slideToSeekFingerprint.classDef().methods.forEach { method -> method.findInstructionIndicesReversed { opcode == Opcode.INVOKE_VIRTUAL && getReference() == checkReference }.forEach { index -> @@ -91,8 +91,8 @@ val enableSlideToSeekPatch = bytecodePatch( disableFastForwardGestureFingerprint, disableFastForwardNoticeFingerprint, ).forEach { fingerprint -> - fingerprint.method.apply { - val targetIndex = fingerprint.patternMatch!!.endIndex + fingerprint.method().apply { + val targetIndex = fingerprint.patternMatch()!!.endIndex val targetRegister = getInstruction(targetIndex).registerA addInstructions( @@ -105,8 +105,8 @@ val enableSlideToSeekPatch = bytecodePatch( } } } else { - disableFastForwardLegacyFingerprint.method.apply { - val insertIndex = disableFastForwardLegacyFingerprint.patternMatch!!.endIndex + 1 + disableFastForwardLegacyFingerprint.method().apply { + val insertIndex = disableFastForwardLegacyFingerprint.patternMatch()!!.endIndex + 1 val targetRegister = getInstruction(insertIndex).registerA addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt index a9ad7563b5..4e1fca305a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/SeekbarThumbnailsPatch.kt @@ -56,7 +56,7 @@ val seekbarThumbnailsPatch = bytecodePatch( ) ) - fullscreenSeekbarThumbnailsFingerprint.method.apply { + fullscreenSeekbarThumbnailsFingerprint.method().apply { val moveResultIndex = instructions.lastIndex - 1 addInstruction( @@ -66,7 +66,7 @@ val seekbarThumbnailsPatch = bytecodePatch( } } - fullscreenSeekbarThumbnailsQualityFingerprint.method.addInstructions( + fullscreenSeekbarThumbnailsQualityFingerprint.method().addInstructions( 0, """ invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->useHighQualityFullscreenThumbnails()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt index 6b6668420c..824c18594a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt @@ -75,8 +75,8 @@ val swipeControlsPatch = bytecodePatch( ) execute { - val wrapperClass = swipeControlsHostActivityFingerprint.classDef - val targetClass = mainActivityFingerprint.classDef + val wrapperClass = swipeControlsHostActivityFingerprint.classDef() + val targetClass = mainActivityFingerprint.classDef() // Inject the wrapper class from the extension into the class hierarchy of MainActivity. wrapperClass.setSuperClass(targetClass.superclass) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 4dfa092f0d..cc1adb33fd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -43,7 +43,7 @@ val autoCaptionsPatch = bytecodePatch( startVideoInformerFingerprint to 0, subtitleButtonControllerFingerprint to 1, ).forEach { (fingerprint, enabled) -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ const/4 v0, 0x$enabled @@ -52,7 +52,7 @@ val autoCaptionsPatch = bytecodePatch( ) } - subtitleTrackFingerprint.method.addInstructions( + subtitleTrackFingerprint.method().addInstructions( 0, """ invoke-static {}, Lapp/revanced/extension/youtube/patches/DisableAutoCaptionsPatch;->autoCaptionsEnabled()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index e25eb0f551..9805029ccd 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -65,8 +65,8 @@ val navigationButtonsPatch = bytecodePatch( ) // Switch create with notifications button. - addCreateButtonViewFingerprint.method.apply { - val stringIndex = addCreateButtonViewFingerprint.stringMatches!!.find { match -> + addCreateButtonViewFingerprint.method().apply { + val stringIndex = addCreateButtonViewFingerprint.stringMatches()!!.find { match -> match.string == ANDROID_AUTOMOTIVE_STRING }!!.index @@ -84,7 +84,7 @@ val navigationButtonsPatch = bytecodePatch( } // Hide navigation button labels. - createPivotBarFingerprint.method.apply { + createPivotBarFingerprint.method().apply { val setTextIndex = indexOfFirstInstructionOrThrow { getReference()?.name == "setText" } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt index 63c4af749f..d31633b250 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -75,7 +75,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( // region Hide player next/previous button. - playerControlsPreviousNextOverlayTouchFingerprint.method.apply { + playerControlsPreviousNextOverlayTouchFingerprint.method().apply { val resourceIndex = indexOfFirstLiteralInstructionOrThrow(playerControlPreviousButtonTouchArea) val insertIndex = indexOfFirstInstructionOrThrow(resourceIndex) { @@ -96,7 +96,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( // region Hide cast button. - mediaRouteButtonFingerprint.method.addInstructions( + mediaRouteButtonFingerprint.method().addInstructions( 0, """ invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->getCastButtonOverrideV2(I)I @@ -108,7 +108,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( // region Hide captions button. - subtitleButtonControllerFingerprint.method.apply { + subtitleButtonControllerFingerprint.method().apply { // Due to previously applied patches, scanResult index cannot be used in this context val insertIndex = indexOfFirstInstructionOrThrow(Opcode.IGET_BOOLEAN) + 1 @@ -122,7 +122,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch( // region Hide autoplay button. - layoutConstructorFingerprint.method.apply { + layoutConstructorFingerprint.method().apply { val constIndex = indexOfFirstResourceIdOrThrow("autonav_toggle") val constRegister = getInstruction(constIndex).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt index 56a97f2412..78d6d64645 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsPatch.kt @@ -71,8 +71,8 @@ val hideEndscreenCardsPatch = bytecodePatch( layoutIconFingerprint, layoutVideoFingerprint, ).forEach { fingerprint -> - fingerprint.method.apply { - val insertIndex = fingerprint.patternMatch!!.endIndex + 1 + fingerprint.method().apply { + val insertIndex = fingerprint.patternMatch()!!.endIndex + 1 val viewRegister = getInstruction(insertIndex - 1).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 7c7de97a2a..bc44c07620 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -46,7 +46,7 @@ val disableFullscreenAmbientModePatch = bytecodePatch( SwitchPreference("revanced_disable_fullscreen_ambient_mode"), ) - setFullScreenBackgroundColorFingerprint.method.apply { + setFullScreenBackgroundColorFingerprint.method().apply { val insertIndex = indexOfFirstInstructionReversedOrThrow { getReference()?.name == "setBackgroundColor" } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 39cbc48086..dbac5f81cb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -242,9 +242,9 @@ val hideLayoutComponentsPatch = bytecodePatch( // region Mix playlists - val startIndex = parseElementFromBufferFingerprint.patternMatch!!.startIndex + val startIndex = parseElementFromBufferFingerprint.patternMatch()!!.startIndex - parseElementFromBufferFingerprint.method.apply { + parseElementFromBufferFingerprint.method().apply { val freeRegister = "v0" val byteArrayParameter = "p3" val conversionContextRegister = getInstruction(startIndex).registerA @@ -267,7 +267,7 @@ val hideLayoutComponentsPatch = bytecodePatch( // region Watermark (legacy code for old versions of YouTube) showWatermarkFingerprint.match( - playerOverlayFingerprint.originalClassDef, + playerOverlayFingerprint.originalClassDef(), ).method.apply { val index = implementation!!.instructions.size - 5 @@ -285,8 +285,8 @@ val hideLayoutComponentsPatch = bytecodePatch( // region Show more button - hideShowMoreButtonFingerprint.method.apply { - val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch!!.endIndex + hideShowMoreButtonFingerprint.method().apply { + val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch()!!.endIndex val viewRegister = getInstruction(moveRegisterIndex).registerA val insertIndex = moveRegisterIndex + 1 @@ -301,8 +301,8 @@ val hideLayoutComponentsPatch = bytecodePatch( // region crowdfunding box crowdfundingBoxFingerprint.let { - it.method.apply { - val insertIndex = it.patternMatch!!.endIndex + it.method().apply { + val insertIndex = it.patternMatch()!!.endIndex val objectRegister = getInstruction(insertIndex).registerA addInstruction( @@ -318,8 +318,8 @@ val hideLayoutComponentsPatch = bytecodePatch( // region hide album cards albumCardsFingerprint.let { - it.method.apply { - val checkCastAnchorIndex = it.patternMatch!!.endIndex + it.method().apply { + val checkCastAnchorIndex = it.patternMatch()!!.endIndex val insertIndex = checkCastAnchorIndex + 1 val register = getInstruction(checkCastAnchorIndex).registerA @@ -336,8 +336,8 @@ val hideLayoutComponentsPatch = bytecodePatch( // region hide floating microphone showFloatingMicrophoneButtonFingerprint.let { - it.method.apply { - val startIndex = it.patternMatch!!.startIndex + it.method().apply { + val startIndex = it.patternMatch()!!.startIndex val register = getInstruction(startIndex).registerA addInstructions( @@ -354,7 +354,7 @@ val hideLayoutComponentsPatch = bytecodePatch( // region 'Yoodles' - yoodlesImageViewFingerprint.method.apply { + yoodlesImageViewFingerprint.method().apply { findInstructionIndicesReversedOrThrow { getReference()?.name == "setImageDrawable" }.forEach { insertIndex -> @@ -384,12 +384,12 @@ val hideLayoutComponentsPatch = bytecodePatch( * @param hookRegisterOffset The offset to add to the register of the hook. * @param instructions The instructions to add with the register as a parameter. */ - fun Fingerprint.patch( + suspend fun Fingerprint.patch( insertIndexOffset: Int = 0, hookRegisterOffset: Int = 0, instructions: (Int) -> String, - ) = method.apply { - val endIndex = patternMatch!!.endIndex + ) = method().apply { + val endIndex = patternMatch()!!.endIndex val insertIndex = endIndex + insertIndexOffset val register = diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt index 29eb8de6ba..9b87f97149 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfoCardsPatch.kt @@ -67,7 +67,7 @@ val hideInfoCardsPatch = bytecodePatch( ) execute { - infocardsIncognitoFingerprint.match(infocardsIncognitoParentFingerprint.originalClassDef).method.apply { + infocardsIncognitoFingerprint.match(infocardsIncognitoParentFingerprint.originalClassDef()).method.apply { val invokeInstructionIndex = implementation!!.instructions.indexOfFirst { it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal && ((it as ReferenceInstruction).reference.toString() == "Landroid/view/View;->setVisibility(I)V") @@ -80,10 +80,10 @@ val hideInfoCardsPatch = bytecodePatch( ) } - val hideInfoCardsCallMethod = infocardsMethodCallFingerprint.method + val hideInfoCardsCallMethod = infocardsMethodCallFingerprint.method() - val invokeInterfaceIndex = infocardsMethodCallFingerprint.patternMatch!!.endIndex - val toggleRegister = infocardsMethodCallFingerprint.method.implementation!!.registerCount - 1 + val invokeInterfaceIndex = infocardsMethodCallFingerprint.patternMatch()!!.endIndex + val toggleRegister = infocardsMethodCallFingerprint.method().implementation!!.registerCount - 1 hideInfoCardsCallMethod.addInstructionsWithLabels( invokeInterfaceIndex, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index bf1aba4fde..489cab07c1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -49,10 +49,10 @@ val disableRollingNumberAnimationPatch = bytecodePatch( // Animations are disabled by preventing an Image from being applied to the text span, // which prevents the animations from appearing. - val patternMatch = rollingNumberTextViewAnimationUpdateFingerprint.patternMatch!! + val patternMatch = rollingNumberTextViewAnimationUpdateFingerprint.patternMatch()!! val blockStartIndex = patternMatch.startIndex val blockEndIndex = patternMatch.endIndex + 1 - rollingNumberTextViewAnimationUpdateFingerprint.method.apply { + rollingNumberTextViewAnimationUpdateFingerprint.method().apply { val freeRegister = getInstruction(blockStartIndex).registerA // ReturnYouTubeDislike also makes changes to this same method, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 34c2310207..b4c8d25820 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -43,7 +43,7 @@ val hideSeekbarPatch = bytecodePatch( SwitchPreference("revanced_hide_seekbar_thumbnail"), ) - seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef).method.addInstructionsWithLabels( + seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef()).method.addInstructionsWithLabels( 0, """ const/4 v0, 0x0 diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 816e65d3b2..817e1cf9ec 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -196,9 +196,9 @@ val hideShortsComponentsPatch = bytecodePatch( // region Hide the Shorts shelf. // This patch point is not present in 19.03.x and greater. - if (!is_19_03_or_greater && reelConstructorFingerprint.methodOrNull != null) { - reelConstructorFingerprint.method.apply { - val insertIndex = reelConstructorFingerprint.patternMatch!!.startIndex + 2 + if (!is_19_03_or_greater && reelConstructorFingerprint.methodOrNull() != null) { + reelConstructorFingerprint.method().apply { + val insertIndex = reelConstructorFingerprint.patternMatch()!!.startIndex + 2 val viewRegister = getInstruction(insertIndex).registerA injectHideViewCall( @@ -215,7 +215,7 @@ val hideShortsComponentsPatch = bytecodePatch( // region Hide the Shorts buttons in older versions of YouTube. // Some Shorts buttons are views, hide them by setting their visibility to GONE. - ShortsButtons.entries.forEach { button -> button.injectHideCall(createShortsButtonsFingerprint.method) } + ShortsButtons.entries.forEach { button -> button.injectHideCall(createShortsButtonsFingerprint.method()) } // endregion @@ -247,7 +247,7 @@ val hideShortsComponentsPatch = bytecodePatch( // Hook to get the pivotBar view. setPivotBarVisibilityFingerprint.match( - setPivotBarVisibilityParentFingerprint.originalClassDef, + setPivotBarVisibilityParentFingerprint.originalClassDef(), ).let { result -> result.method.apply { val insertIndex = result.patternMatch!!.endIndex @@ -266,14 +266,14 @@ val hideShortsComponentsPatch = bytecodePatch( renderBottomNavigationBarParentFingerprint } else { legacyRenderBottomNavigationBarParentFingerprint - }.originalClassDef, + }.originalClassDef(), ).method.addInstruction( 0, "invoke-static { p1 }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar(Ljava/lang/String;)V", ) // Hide the bottom bar container of the Shorts player. - shortsBottomBarContainerFingerprint.method.apply { + shortsBottomBarContainerFingerprint.method().apply { val resourceIndex = indexOfFirstLiteralInstruction(bottomBarContainer) val targetIndex = indexOfFirstInstructionOrThrow(resourceIndex) { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt index 17a83f98ab..2745dfbcb1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenPatch.kt @@ -64,8 +64,8 @@ val disableSuggestedVideoEndScreenPatch = bytecodePatch( ) execute { - createEndScreenViewFingerprint.method.apply { - val addOnClickEventListenerIndex = createEndScreenViewFingerprint.patternMatch!!.endIndex - 1 + createEndScreenViewFingerprint.method().apply { + val addOnClickEventListenerIndex = createEndScreenViewFingerprint.patternMatch()!!.endIndex - 1 val viewRegister = getInstruction(addOnClickEventListenerIndex).registerC addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index acb5f9f196..dab255cde5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -38,7 +38,7 @@ val hideTimestampPatch = bytecodePatch( SwitchPreference("revanced_hide_timestamp"), ) - timeCounterFingerprint.method.addInstructionsWithLabels( + timeCounterFingerprint.method().addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/extension/youtube/patches/HideTimestampPatch;->hideTimestamp()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index cc2b9de919..f324c7911a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -265,11 +265,11 @@ val miniplayerPatch = bytecodePatch( insertBooleanOverride(index, "getModernMiniplayerOverride") } - fun Fingerprint.insertLiteralValueBooleanOverride( + suspend fun Fingerprint.insertLiteralValueBooleanOverride( literal: Long, extensionMethod: String, ) { - method.apply { + method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow(literal) val targetIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT) @@ -277,11 +277,11 @@ val miniplayerPatch = bytecodePatch( } } - fun Fingerprint.insertLiteralValueFloatOverride( + suspend fun Fingerprint.insertLiteralValueFloatOverride( literal: Long, extensionMethod: String, ) { - method.apply { + method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow(literal) val targetIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.DOUBLE_TO_FLOAT) val register = getInstruction(targetIndex).registerA @@ -332,7 +332,7 @@ val miniplayerPatch = bytecodePatch( // region Enable tablet miniplayer. miniplayerOverrideNoContextFingerprint.match( - miniplayerDimensionsCalculatorParentFingerprint.originalClassDef, + miniplayerDimensionsCalculatorParentFingerprint.originalClassDef(), ).method.apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride(index) } } @@ -340,13 +340,13 @@ val miniplayerPatch = bytecodePatch( // endregion // region Legacy tablet miniplayer hooks. - val appNameStringIndex = miniplayerOverrideFingerprint.stringMatches!!.first().index + 2 - navigate(miniplayerOverrideFingerprint.originalMethod).to(appNameStringIndex).stop().apply { + val appNameStringIndex = miniplayerOverrideFingerprint.stringMatches()!!.first().index + 2 + navigate(miniplayerOverrideFingerprint.originalMethod()).to(appNameStringIndex).stop().apply { findReturnIndicesReversed().forEach { index -> insertLegacyTabletMiniplayerOverride(index) } } miniplayerResponseModelSizeCheckFingerprint.let { - it.method.insertLegacyTabletMiniplayerOverride(it.patternMatch!!.endIndex) + it.method().insertLegacyTabletMiniplayerOverride(it.patternMatch()!!.endIndex) } if (!is_19_16_or_greater) { @@ -358,7 +358,7 @@ val miniplayerPatch = bytecodePatch( // region Enable modern miniplayer. - miniplayerModernConstructorFingerprint.classDef.methods.forEach { + miniplayerModernConstructorFingerprint.classDef().methods.forEach { it.apply { if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) { val iPutIndex = indexOfFirstInstructionOrThrow { @@ -404,7 +404,7 @@ val miniplayerPatch = bytecodePatch( } if (is_19_26_or_greater) { - miniplayerModernConstructorFingerprint.method.apply { + miniplayerModernConstructorFingerprint.method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow( MINIPLAYER_INITIAL_SIZE_FEATURE_KEY, ) @@ -422,7 +422,7 @@ val miniplayerPatch = bytecodePatch( } // Override a minimum size constant. - miniplayerMinimumSizeFingerprint.method.apply { + miniplayerMinimumSizeFingerprint.method().apply { val index = indexOfFirstInstructionOrThrow { opcode == Opcode.CONST_16 && (this as NarrowLiteralInstruction).narrowLiteral == 192 } @@ -449,7 +449,7 @@ val miniplayerPatch = bytecodePatch( // Fix this, by swapping the drawable resource values with each other. if (ytOutlinePictureInPictureWhite24 >= 0) { miniplayerModernExpandCloseDrawablesFingerprint.match( - miniplayerModernViewParentFingerprint.originalClassDef, + miniplayerModernViewParentFingerprint.originalClassDef(), ).method.apply { listOf( ytOutlinePictureInPictureWhite24 to ytOutlineXWhite24, @@ -495,7 +495,7 @@ val miniplayerPatch = bytecodePatch( ), ).forEach { (fingerprint, literalValue, methodName) -> fingerprint.match( - miniplayerModernViewParentFingerprint.classDef, + miniplayerModernViewParentFingerprint.classDef(), ).method.hookInflatedView( literalValue, "Landroid/widget/ImageView;", @@ -504,7 +504,7 @@ val miniplayerPatch = bytecodePatch( } miniplayerModernAddViewListenerFingerprint.match( - miniplayerModernViewParentFingerprint.classDef, + miniplayerModernViewParentFingerprint.classDef(), ).method.addInstruction( 0, "invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->" + @@ -518,7 +518,7 @@ val miniplayerPatch = bytecodePatch( // // NOTE: Modern 2 uses the same video UI as the regular player except resized to smaller. // This patch code could be used to hide other player overlays that do not use Litho. - playerOverlaysLayoutFingerprint.classDef.methods.add( + playerOverlaysLayoutFingerprint.classDef().methods.add( ImmutableMethod( YOUTUBE_PLAYER_OVERLAYS_LAYOUT_CLASS_NAME, "addView", diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index a245dc8a93..3925e38998 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -38,7 +38,7 @@ val playerPopupPanelsPatch = bytecodePatch( SwitchPreference("revanced_hide_player_popup_panels"), ) - engagementPanelControllerFingerprint.method.addInstructionsWithLabels( + engagementPanelControllerFingerprint.method().addInstructionsWithLabels( 0, """ invoke-static { }, Lapp/revanced/extension/youtube/patches/DisablePlayerPopupPanelsPatch;->disablePlayerPopupPanels()Z diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt index 91d39cd1f1..c9a3aa6da3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityPatch.kt @@ -62,7 +62,7 @@ val customPlayerOverlayOpacityPatch = bytecodePatch( ) execute { - createPlayerOverviewFingerprint.method.apply { + createPlayerOverviewFingerprint.method().apply { val viewRegisterIndex = indexOfFirstLiteralInstructionOrThrow(scrimOverlayId) + 3 val viewRegister = diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt index 51c8ccc246..8350e55f1f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikePatch.kt @@ -92,7 +92,7 @@ val returnYouTubeDislikePatch = bytecodePatch( dislikeFingerprint to Vote.DISLIKE, removeLikeFingerprint to Vote.REMOVE_LIKE, ).forEach { (fingerprint, vote) -> - fingerprint.method.addInstructions( + fingerprint.method().addInstructions( 0, """ const/4 v0, ${vote.value} @@ -110,14 +110,14 @@ val returnYouTubeDislikePatch = bytecodePatch( // And it works in all situations excepxt did not change. // This hook handles all situations, as it's where the created Spans are stored and later reused. // Find the field name of the conversion context. - val conversionContextField = textComponentConstructorFingerprint.originalClassDef.fields.find { - it.type == conversionContextFingerprint.originalClassDef.type + val conversionContextField = textComponentConstructorFingerprint.originalClassDef().fields.find { + it.type == conversionContextFingerprint.originalClassDef().type } ?: throw PatchException("Could not find conversion context field") - textComponentLookupFingerprint.match(textComponentConstructorFingerprint.originalClassDef) - textComponentLookupFingerprint.method.apply { + textComponentLookupFingerprint.match(textComponentConstructorFingerprint.originalClassDef()) + textComponentLookupFingerprint.method().apply { // Find the instruction for creating the text data object. - val textDataClassType = textComponentDataFingerprint.originalClassDef.type + val textDataClassType = textComponentDataFingerprint.originalClassDef().type val insertIndex: Int val tempRegister: Int @@ -170,8 +170,8 @@ val returnYouTubeDislikePatch = bytecodePatch( // endregion // region Hook for non-litho Short videos. - shortsTextViewFingerprint.method.apply { - val insertIndex = shortsTextViewFingerprint.patternMatch!!.endIndex + 1 + shortsTextViewFingerprint.method().apply { + val insertIndex = shortsTextViewFingerprint.patternMatch()!!.endIndex + 1 // If the field is true, the TextView is for a dislike button. val isDisLikesBooleanInstruction = instructions.first { instruction -> @@ -228,9 +228,9 @@ val returnYouTubeDislikePatch = bytecodePatch( // Do this last to allow patching old unsupported versions (if the user really wants), // On older unsupported version this will fail to match and throw an exception, // but everything will still work correctly anyway. - val dislikesIndex = rollingNumberSetterFingerprint.patternMatch!!.endIndex + val dislikesIndex = rollingNumberSetterFingerprint.patternMatch()!!.endIndex - rollingNumberSetterFingerprint.method.apply { + rollingNumberSetterFingerprint.method().apply { val insertIndex = 1 val charSequenceInstanceRegister = @@ -257,11 +257,11 @@ val returnYouTubeDislikePatch = bytecodePatch( // Rolling Number text views use the measured width of the raw string for layout. // Modify the measure text calculation to include the left drawable separator if needed. - val patternMatch = rollingNumberMeasureAnimatedTextFingerprint.patternMatch!! + val patternMatch = rollingNumberMeasureAnimatedTextFingerprint.patternMatch()!! // Additional check to verify the opcodes are at the start of the method if (patternMatch.startIndex != 0) throw PatchException("Unexpected opcode location") val endIndex = patternMatch.endIndex - rollingNumberMeasureAnimatedTextFingerprint.method.apply { + rollingNumberMeasureAnimatedTextFingerprint.method().apply { val measuredTextWidthRegister = getInstruction(endIndex).registerA addInstructions( @@ -276,7 +276,7 @@ val returnYouTubeDislikePatch = bytecodePatch( // Additional text measurement method. Used if YouTube decides not to animate the likes count // and sometimes used for initial video load. rollingNumberMeasureStaticLabelFingerprint.match( - rollingNumberMeasureStaticLabelParentFingerprint.originalClassDef, + rollingNumberMeasureStaticLabelParentFingerprint.originalClassDef(), ).let { val measureTextIndex = it.patternMatch!!.startIndex + 1 it.method.apply { @@ -294,13 +294,13 @@ val returnYouTubeDislikePatch = bytecodePatch( // The rolling number Span is missing styling since it's initially set as a String. // Modify the UI text view and use the styled like/dislike Span. // Initial TextView is set in this method. - val initiallyCreatedTextViewMethod = rollingNumberTextViewFingerprint.method + val initiallyCreatedTextViewMethod = rollingNumberTextViewFingerprint.method() // Videos less than 24 hours after uploaded, like counts will be updated in real time. // Whenever like counts are updated, TextView is set in this method. arrayOf( initiallyCreatedTextViewMethod, - rollingNumberTextViewAnimationUpdateFingerprint.method, + rollingNumberTextViewAnimationUpdateFingerprint.method(), ).forEach { insertMethod -> insertMethod.apply { val setTextIndex = indexOfFirstInstructionOrThrow { diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index 233d611cf8..18a19ea3fc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -53,8 +53,8 @@ val wideSearchbarPatch = bytecodePatch( * @param from The fingerprint to navigate the method on. * @return The [MutableMethod] which was navigated on. */ - fun BytecodePatchContext.walkMutable(index: Int, from: Fingerprint) = - navigate(from.originalMethod).to(index).stop() + suspend fun BytecodePatchContext.walkMutable(index: Int, from: Fingerprint) = + navigate(from.originalMethod()).to(index).stop() /** * Injects instructions required for certain methods. @@ -74,7 +74,7 @@ val wideSearchbarPatch = bytecodePatch( mapOf( setWordmarkHeaderFingerprint to 1, - createSearchSuggestionsFingerprint to createSearchSuggestionsFingerprint.patternMatch!!.startIndex, + createSearchSuggestionsFingerprint to createSearchSuggestionsFingerprint.patternMatch()!!.startIndex, ).forEach { (fingerprint, callIndex) -> walkMutable(callIndex, fingerprint).injectSearchBarHook() } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt index 49a5444ab1..29639f989d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorPatch.kt @@ -93,17 +93,17 @@ val seekbarColorPatch = bytecodePatch( ) } - playerSeekbarColorFingerprint.method.apply { + playerSeekbarColorFingerprint.method().apply { addColorChangeInstructions(inlineTimeBarColorizedBarPlayedColorDarkId) addColorChangeInstructions(inlineTimeBarPlayedNotHighlightedColorId) } - shortsSeekbarColorFingerprint.method.apply { + shortsSeekbarColorFingerprint.method().apply { addColorChangeInstructions(reelTimeBarPlayedColorId) } - setSeekbarClickedColorFingerprint.originalMethod.let { - val setColorMethodIndex = setSeekbarClickedColorFingerprint.patternMatch!!.startIndex + 1 + setSeekbarClickedColorFingerprint.originalMethod().let { + val setColorMethodIndex = setSeekbarClickedColorFingerprint.patternMatch()!!.startIndex + 1 navigate(it).to(setColorMethodIndex).stop().apply { val colorRegister = getInstruction(0).registerA @@ -118,7 +118,7 @@ val seekbarColorPatch = bytecodePatch( } if (is_19_23_or_greater) { - playerSeekbarGradientConfigFingerprint.method.apply { + playerSeekbarGradientConfigFingerprint.method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow(PLAYER_SEEKBAR_GRADIENT_FEATURE_FLAG) val resultIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT) val register = getInstruction(resultIndex).registerA @@ -132,7 +132,7 @@ val seekbarColorPatch = bytecodePatch( ) } - lithoLinearGradientFingerprint.method.addInstruction( + lithoLinearGradientFingerprint.method().addInstruction( 0, "invoke-static/range { p4 .. p5 }, $EXTENSION_CLASS_DESCRIPTOR->setLinearGradient([I[F)V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt index 04088be7ec..9834b66151 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/shortsautoplay/ShortsAutoplayPatch.kt @@ -55,16 +55,16 @@ val shortsAutoplayPatch = bytecodePatch( } // Main activity is used to check if app is in pip mode. - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method().addInstructions( 0, "invoke-static/range { p0 .. p0 }, $EXTENSION_CLASS_DESCRIPTOR->" + "setMainActivity(Landroid/app/Activity;)V", ) - val reelEnumClass = reelEnumConstructorFingerprint.originalClassDef.type + val reelEnumClass = reelEnumConstructorFingerprint.originalClassDef().type - reelEnumConstructorFingerprint.method.apply { - val insertIndex = reelEnumConstructorFingerprint.patternMatch!!.startIndex + reelEnumConstructorFingerprint.method().apply { + val insertIndex = reelEnumConstructorFingerprint.patternMatch()!!.startIndex addInstructions( insertIndex, @@ -77,7 +77,7 @@ val shortsAutoplayPatch = bytecodePatch( ) } - reelPlaybackRepeatFingerprint.method.apply { + reelPlaybackRepeatFingerprint.method().apply { // The behavior enums are looked up from an ordinal value to an enum type. findInstructionIndicesReversedOrThrow { val reference = getReference() diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt index 18c440d4ed..10ba87f00b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockPatch.kt @@ -133,7 +133,7 @@ val sponsorBlockPatch = bytecodePatch( ) // Seekbar drawing - seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef).method.apply { + seekbarOnDrawFingerprint.match(seekbarFingerprint.originalClassDef()).method.apply { // Get left and right of seekbar rectangle. val moveRectangleToRegisterIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_OBJECT_FROM16) @@ -178,8 +178,8 @@ val sponsorBlockPatch = bytecodePatch( injectVisibilityCheckCall(EXTENSION_VOTING_BUTTON_CONTROLLER_CLASS_DESCRIPTOR) // Append the new time to the player layout. - val appendTimePatternScanStartIndex = appendTimeFingerprint.patternMatch!!.startIndex - appendTimeFingerprint.method.apply { + val appendTimePatternScanStartIndex = appendTimeFingerprint.patternMatch()!!.startIndex + appendTimeFingerprint.method().apply { val register = getInstruction(appendTimePatternScanStartIndex + 1).registerA addInstructions( @@ -195,7 +195,7 @@ val sponsorBlockPatch = bytecodePatch( onCreateHook(EXTENSION_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR, "initialize") // Initialize the SponsorBlock view. - controlsOverlayFingerprint.match(layoutConstructorFingerprint.originalClassDef).let { + controlsOverlayFingerprint.match(layoutConstructorFingerprint.originalClassDef()).let { val startIndex = it.patternMatch!!.startIndex it.method.apply { val frameLayoutRegister = (getInstruction(startIndex + 2) as OneRegisterInstruction).registerA @@ -207,7 +207,7 @@ val sponsorBlockPatch = bytecodePatch( } // Set seekbar draw rectangle. - rectangleFieldInvalidatorFingerprint.match(seekbarOnDrawFingerprint.originalClassDef).method.apply { + rectangleFieldInvalidatorFingerprint.match(seekbarOnDrawFingerprint.originalClassDef()).method.apply { val fieldIndex = instructions.count() - 3 val fieldReference = getInstruction(fieldIndex).reference as FieldReference @@ -241,7 +241,7 @@ val sponsorBlockPatch = bytecodePatch( // The vote and create segment buttons automatically change their visibility when appropriate, // but if buttons are showing when the end of the video is reached then they will not automatically hide. // Add a hook to forcefully hide when the end of the video is reached. - autoRepeatFingerprint.match(autoRepeatParentFingerprint.originalClassDef).method.addInstruction( + autoRepeatFingerprint.match(autoRepeatParentFingerprint.originalClassDef()).method.addInstruction( 0, "invoke-static {}, $EXTENSION_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->endOfVideoReached()V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 60f84dd72a..b6549e0d6a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -49,11 +49,11 @@ val spoofAppVersionPatch = bytecodePatch( ), ) - val insertIndex = spoofAppVersionFingerprint.patternMatch!!.startIndex + 1 + val insertIndex = spoofAppVersionFingerprint.patternMatch()!!.startIndex + 1 val buildOverrideNameRegister = - spoofAppVersionFingerprint.method.getInstruction(insertIndex - 1).registerA + spoofAppVersionFingerprint.method().getInstruction(insertIndex - 1).registerA - spoofAppVersionFingerprint.method.addInstructions( + spoofAppVersionFingerprint.method().addInstructions( insertIndex, """ invoke-static {v$buildOverrideNameRegister}, $EXTENSION_CLASS_DESCRIPTOR->getYouTubeVersionOverride(Ljava/lang/String;)Ljava/lang/String; diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index 26c2633aea..096ef1ca03 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -50,7 +50,7 @@ val changeStartPagePatch = bytecodePatch( ) // Hook browseId. - browseIdFingerprint.method.apply { + browseIdFingerprint.method().apply { val browseIdIndex = indexOfFirstInstructionOrThrow { getReference()?.string == "FEwhat_to_watch" } @@ -67,7 +67,7 @@ val changeStartPagePatch = bytecodePatch( // There is no browserId assigned to Shorts and Search. // Just hook the Intent action. - intentActionFingerprint.method.addInstruction( + intentActionFingerprint.method().addInstruction( 0, "invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->overrideIntentAction(Landroid/content/Intent;)V", ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index 2f48ee67e5..8c8f8524ab 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -48,7 +48,7 @@ val disableResumingShortsOnStartupPatch = bytecodePatch( SwitchPreference("revanced_disable_resuming_shorts_player"), ) - userWasInShortsConfigFingerprint.originalMethod.apply { + userWasInShortsConfigFingerprint.originalMethod().apply { val startIndex = indexOfOptionalInstruction(this) val walkerIndex = indexOfFirstInstructionOrThrow(startIndex) { val reference = getReference() @@ -73,7 +73,7 @@ val disableResumingShortsOnStartupPatch = bytecodePatch( ) } - userWasInShortsFingerprint.method.apply { + userWasInShortsFingerprint.method().apply { val listenableInstructionIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_INTERFACE && getReference()?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" && diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index 181f5b920b..d37b33f884 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -43,7 +43,7 @@ val enableTabletLayoutPatch = bytecodePatch( SwitchPreference("revanced_tablet_layout"), ) - getFormFactorFingerprint.method.apply { + getFormFactorFingerprint.method().apply { val returnIsLargeFormFactorIndex = instructions.lastIndex - 4 val returnIsLargeFormFactorLabel = getInstruction(returnIsLargeFormFactorIndex) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt index f3bc31e2f9..df6add0f6a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/LithoColorHookPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.theme import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.bytecodePatch -lateinit var lithoColorOverrideHook: (targetMethodClass: String, targetMethodName: String) -> Unit +lateinit var lithoColorOverrideHook: suspend (targetMethodClass: String, targetMethodName: String) -> Unit private set val lithoColorHookPatch = bytecodePatch( @@ -11,10 +11,10 @@ val lithoColorHookPatch = bytecodePatch( ) { execute { - var insertionIndex = lithoThemeFingerprint.patternMatch!!.endIndex - 1 + var insertionIndex = lithoThemeFingerprint.patternMatch()!!.endIndex - 1 lithoColorOverrideHook = { targetMethodClass, targetMethodName -> - lithoThemeFingerprint.method.addInstructions( + lithoThemeFingerprint.method().addInstructions( insertionIndex, """ invoke-static { p1 }, $targetMethodClass->$targetMethodName(I)I diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt index 194c4dbba7..67a6badd86 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt @@ -211,7 +211,7 @@ val themePatch = bytecodePatch( SwitchPreference("revanced_gradient_loading_screen"), ) - useGradientLoadingScreenFingerprint.method.apply { + useGradientLoadingScreenFingerprint.method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow(GRADIENT_LOADING_SCREEN_AB_CONSTANT) val isEnabledIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.MOVE_RESULT) val isEnabledRegister = getInstruction(isEnabledIndex).registerA @@ -229,7 +229,7 @@ val themePatch = bytecodePatch( themeHelperLightColorFingerprint to lightThemeBackgroundColor, themeHelperDarkColorFingerprint to darkThemeBackgroundColor, ).forEach { (fingerprint, color) -> - fingerprint.method.apply { + fingerprint.method().apply { addInstructions( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index 5afa220b0a..46305c07d3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -40,7 +40,7 @@ val announcementsPatch = bytecodePatch( SwitchPreference("revanced_announcements"), ) - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method().addInstructions( // Insert index must be greater than the insert index used by GmsCoreSupport, // as both patch the same method and GmsCore check should be first. 1, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index e2c24ed5c5..2d05413bb1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -42,8 +42,8 @@ val autoRepeatPatch = bytecodePatch( SwitchPreference("revanced_auto_repeat"), ) - autoRepeatFingerprint.match(autoRepeatParentFingerprint.originalClassDef).method.apply { - val playMethod = autoRepeatParentFingerprint.method + autoRepeatFingerprint.match(autoRepeatParentFingerprint.originalClassDef()).method.apply { + val playMethod = autoRepeatParentFingerprint.method() val index = instructions.lastIndex // Remove return-void. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 36f7cfddd4..84046c4b2a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -68,7 +68,7 @@ val backgroundPlaybackPatch = bytecodePatch( backgroundPlaybackManagerFingerprint to "isBackgroundPlaybackAllowed", backgroundPlaybackManagerShortsFingerprint to "isBackgroundShortsPlaybackAllowed", ).forEach { (fingerprint, integrationsMethod) -> - fingerprint.method.apply { + fingerprint.method().apply { findInstructionIndicesReversedOrThrow(Opcode.RETURN).forEach { index -> val register = getInstruction(index).registerA @@ -84,7 +84,7 @@ val backgroundPlaybackPatch = bytecodePatch( } // Enable background playback option in YouTube settings - backgroundPlaybackSettingsFingerprint.originalMethod.apply { + backgroundPlaybackSettingsFingerprint.originalMethod().apply { val booleanCalls = instructions.withIndex().filter { it.value.getReference()?.returnType == "Z" } @@ -96,9 +96,9 @@ val backgroundPlaybackPatch = bytecodePatch( } // Force allowing background play for Shorts. - shortsBackgroundPlaybackFeatureFlagFingerprint.method.returnEarly(true) + shortsBackgroundPlaybackFeatureFlagFingerprint.method().returnEarly(true) // Force allowing background play for videos labeled for kids. - kidsBackgroundPlaybackPolicyControllerFingerprint.method.returnEarly() + kidsBackgroundPlaybackPolicyControllerFingerprint.method().returnEarly() } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt index 9696418eb9..cab5231fb4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/EnableDebuggingPatch.kt @@ -56,7 +56,7 @@ val enableDebuggingPatch = bytecodePatch( // Hook the methods that look up if a feature flag is active. experimentalBooleanFeatureFlagFingerprint.match( - experimentalFeatureFlagParentFingerprint.originalClassDef + experimentalFeatureFlagParentFingerprint.originalClassDef() ).method.apply { val insertIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT) @@ -74,7 +74,7 @@ val enableDebuggingPatch = bytecodePatch( } experimentalDoubleFeatureFlagFingerprint.match( - experimentalFeatureFlagParentFingerprint.originalClassDef + experimentalFeatureFlagParentFingerprint.originalClassDef() ).method.apply { val insertIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT_WIDE) @@ -90,7 +90,7 @@ val enableDebuggingPatch = bytecodePatch( } experimentalLongFeatureFlagFingerprint.match( - experimentalFeatureFlagParentFingerprint.originalClassDef + experimentalFeatureFlagParentFingerprint.originalClassDef() ).method.apply { val insertIndex = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT_WIDE) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index 66718480cb..dab471a6e5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -42,7 +42,7 @@ val spoofDeviceDimensionsPatch = bytecodePatch( ) deviceDimensionsModelToStringFingerprint - .classDef.methods.first { method -> method.name == "" } + .classDef().methods.first { method -> method.name == "" } // Override the parameters containing the dimensions. .addInstructions( 1, // Add after super call. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt index e84893ebbf..94b697ac5d 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/dns/CheckWatchHistoryDomainNameResolutionPatch.kt @@ -30,7 +30,7 @@ val checkWatchHistoryDomainNameResolutionPatch = bytecodePatch( execute { addResources("youtube", "misc.dns.checkWatchHistoryDomainNameResolutionPatch") - mainActivityOnCreateFingerprint.method.addInstructions( + mainActivityOnCreateFingerprint.method().addInstructions( // FIXME: Insert index must be greater than the insert index used by GmsCoreSupport, // as both patch the same method and GmsCoreSupport check should be first, // but the patch does not depend on GmsCoreSupport, so it should not be possible to enforce this diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt index 0778e814ff..756eaf1e5b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/FixBackToExitGesturePatch.kt @@ -14,14 +14,14 @@ internal val fixBackToExitGesturePatch = bytecodePatch( * * @param targetMethod The target method to call. */ - fun Fingerprint.injectCall(targetMethod: ExtensionMethod) = method.addInstruction( - patternMatch!!.endIndex, + suspend fun Fingerprint.injectCall(targetMethod: ExtensionMethod) = method().addInstruction( + patternMatch()!!.endIndex, targetMethod.toString(), ) mapOf( recyclerViewTopScrollingFingerprint.also { - it.match(recyclerViewTopScrollingParentFingerprint.originalClassDef) + it.match(recyclerViewTopScrollingParentFingerprint.originalClassDef()) } to ExtensionMethod( methodName = "onTopView", ), diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/cairo/DisableCairoSettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/cairo/DisableCairoSettingsPatch.kt index d6fafe5398..ae4a40355b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/cairo/DisableCairoSettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/cairo/DisableCairoSettingsPatch.kt @@ -33,7 +33,7 @@ internal val disableCairoSettingsPatch = bytecodePatch( * Screenshots of the Cairo Fragment: * uYouPlus#1468. */ - cairoFragmentConfigFingerprint.method.apply { + cairoFragmentConfigFingerprint.method().apply { val literalIndex = indexOfFirstLiteralInstructionOrThrow( CAIRO_CONFIG_LITERAL_VALUE, ) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt index 25b35c4479..7c2c28f3f7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofVideoStreamsPatch.kt @@ -77,9 +77,9 @@ val spoofVideoStreamsPatch = bytecodePatch( // region Block /initplayback requests to fall back to /get_watch requests. - val moveUriStringIndex = buildInitPlaybackRequestFingerprint.patternMatch!!.startIndex + val moveUriStringIndex = buildInitPlaybackRequestFingerprint.patternMatch()!!.startIndex - buildInitPlaybackRequestFingerprint.method.apply { + buildInitPlaybackRequestFingerprint.method().apply { val targetRegister = getInstruction(moveUriStringIndex).registerA addInstructions( @@ -95,9 +95,9 @@ val spoofVideoStreamsPatch = bytecodePatch( // region Block /get_watch requests to fall back to /player requests. - val invokeToStringIndex = buildPlayerRequestURIFingerprint.patternMatch!!.startIndex + val invokeToStringIndex = buildPlayerRequestURIFingerprint.patternMatch()!!.startIndex - buildPlayerRequestURIFingerprint.method.apply { + buildPlayerRequestURIFingerprint.method().apply { val uriRegister = getInstruction(invokeToStringIndex).registerC addInstructions( @@ -113,7 +113,7 @@ val spoofVideoStreamsPatch = bytecodePatch( // region Get replacement streams at player requests. - buildRequestFingerprint.method.apply { + buildRequestFingerprint.method().apply { val newRequestBuilderIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_VIRTUAL && getReference()?.name == "newUrlRequestBuilder" @@ -134,10 +134,10 @@ val spoofVideoStreamsPatch = bytecodePatch( // region Replace the streaming data with the replacement streams. - createStreamingDataFingerprint.method.apply { + createStreamingDataFingerprint.method().apply { val setStreamDataMethodName = "patch_setStreamingData" - val resultMethodType = createStreamingDataFingerprint.classDef.type - val videoDetailsIndex = createStreamingDataFingerprint.patternMatch!!.endIndex + val resultMethodType = createStreamingDataFingerprint.classDef().type + val videoDetailsIndex = createStreamingDataFingerprint.patternMatch()!!.endIndex val videoDetailsRegister = getInstruction(videoDetailsIndex).registerA val videoDetailsClass = getInstruction(videoDetailsIndex).getReference()!!.type @@ -147,8 +147,8 @@ val spoofVideoStreamsPatch = bytecodePatch( "$resultMethodType->$setStreamDataMethodName($videoDetailsClass)V", ) - val protobufClass = protobufClassParseByteBufferFingerprint.method.definingClass - val setStreamingDataIndex = createStreamingDataFingerprint.patternMatch!!.startIndex + val protobufClass = protobufClassParseByteBufferFingerprint.method().definingClass + val setStreamingDataIndex = createStreamingDataFingerprint.patternMatch()!!.startIndex val playerProtoClass = getInstruction(setStreamingDataIndex + 1) .getReference()!!.definingClass @@ -162,7 +162,7 @@ val spoofVideoStreamsPatch = bytecodePatch( ).getReference() // Use a helper method to avoid the need of picking out multiple free registers from the hooked code. - createStreamingDataFingerprint.classDef.methods.add( + createStreamingDataFingerprint.classDef().methods.add( ImmutableMethod( resultMethodType, setStreamDataMethodName, @@ -215,7 +215,7 @@ val spoofVideoStreamsPatch = bytecodePatch( // Requesting streams intended for other platforms with a body tuned for Android could be the cause of 400 errors. // A proper fix may include modifying the request body to match the platforms expected body. - buildMediaDataSourceFingerprint.method.apply { + buildMediaDataSourceFingerprint.method().apply { val targetIndex = instructions.lastIndex // Instructions are added just before the method returns, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt index b9292ef84b..0366626812 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/imageurlhook/CronetImageUrlHook.kt @@ -31,17 +31,17 @@ val cronetImageUrlHookPatch = bytecodePatch( execute { loadImageUrlMethod = messageDigestImageUrlFingerprint - .match(messageDigestImageUrlParentFingerprint.originalClassDef).method + .match(messageDigestImageUrlParentFingerprint.originalClassDef()).method loadImageSuccessCallbackMethod = onSucceededFingerprint - .match(onResponseStartedFingerprint.originalClassDef).method + .match(onResponseStartedFingerprint.originalClassDef()).method loadImageErrorCallbackMethod = onFailureFingerprint - .match(onResponseStartedFingerprint.originalClassDef).method + .match(onResponseStartedFingerprint.originalClassDef()).method // The URL is required for the failure callback hook, but the URL field is obfuscated. // Add a helper get method that returns the URL field. - val urlFieldInstruction = requestFingerprint.method.instructions.first { + val urlFieldInstruction = requestFingerprint.method().instructions.first { val reference = it.getReference() it.opcode == Opcode.IPUT_OBJECT && reference?.type == "Ljava/lang/String;" } as ReferenceInstruction @@ -49,7 +49,7 @@ val cronetImageUrlHookPatch = bytecodePatch( val urlFieldName = (urlFieldInstruction.reference as FieldReference).name val definingClass = CRONET_URL_REQUEST_CLASS_DESCRIPTOR val addedMethodName = "getHookedUrl" - requestFingerprint.classDef.methods.add( + requestFingerprint.classDef().methods.add( ImmutableMethod( definingClass, addedMethodName, diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index d2c06292c6..a856db49c6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -60,7 +60,7 @@ val bypassURLRedirectsPatch = bytecodePatch( } fingerprints.forEach { - it.method.apply { + it.method().apply { val insertIndex = findUriParseIndex() val uriStringRegister = getInstruction(insertIndex).registerC diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt index 16a8340830..ad2578bc65 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/LithoFilterPatch.kt @@ -93,7 +93,7 @@ val lithoFilterPatch = bytecodePatch( execute { // Remove dummy filter from extenion static field // and add the filters included during patching. - lithoFilterFingerprint.method.apply { + lithoFilterFingerprint.method().apply { removeInstructions(2, 4) // Remove dummy filter. addLithoFilter = { classDescriptor -> @@ -111,7 +111,7 @@ val lithoFilterPatch = bytecodePatch( // region Pass the buffer into extension. - protobufBufferReferenceFingerprint.method.addInstruction( + protobufBufferReferenceFingerprint.method().addInstruction( 0, " invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V", ) @@ -120,9 +120,9 @@ val lithoFilterPatch = bytecodePatch( // region Hook the method that parses bytes into a ComponentContext. - val readComponentMethod = readComponentIdentifierFingerprint.originalMethod + val readComponentMethod = readComponentIdentifierFingerprint.originalMethod() // Get the only static method in the class. - val builderMethodDescriptor = emptyComponentFingerprint.classDef.methods.first { method -> + val builderMethodDescriptor = emptyComponentFingerprint.classDef().methods.first { method -> AccessFlags.STATIC.isSet(method.accessFlags) } // Only one field. @@ -140,7 +140,7 @@ val lithoFilterPatch = bytecodePatch( return-object v$register """ - componentContextParserFingerprint.method.apply { + componentContextParserFingerprint.method().apply { // 19.18 and later require patching 2 methods instead of one. // Otherwise the modifications done here are the same for all targets. if (is_19_18_or_greater) { @@ -175,7 +175,7 @@ val lithoFilterPatch = bytecodePatch( // region Read component then store the result. - readComponentIdentifierFingerprint.method.apply { + readComponentIdentifierFingerprint.method().apply { val insertHookIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.IPUT_OBJECT && getReference()?.type == "Ljava/lang/StringBuilder;" @@ -236,7 +236,7 @@ val lithoFilterPatch = bytecodePatch( // Turn off native code that handles litho component names. If this feature is on then nearly // all litho components have a null name and identifier/path filtering is completely broken. if (is_19_25_or_greater) { - lithoComponentNameUpbFeatureFlagFingerprint.method.apply { + lithoComponentNameUpbFeatureFlagFingerprint.method().apply { // Don't use return early, so the debug patch logs if this was originally on. val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN) val register = getInstruction(insertIndex).registerA @@ -248,7 +248,7 @@ val lithoFilterPatch = bytecodePatch( // Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf). // If this is enabled, then the litho protobuffer hook will always show an empty buffer // since it's no longer handled by the hooked Java code. - lithoConverterBufferUpbFeatureFlagFingerprint.method.apply { + lithoConverterBufferUpbFeatureFlagFingerprint.method().apply { val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT) val register = getInstruction(index).registerA @@ -259,6 +259,6 @@ val lithoFilterPatch = bytecodePatch( } finalize { - lithoFilterFingerprint.method.replaceInstruction(0, "const/16 v0, $filterCount") + lithoFilterFingerprint.method().replaceInstruction(0, "const/16 v0, $filterCount") } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt index 503eb91d41..0a4c102ac4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/navigation/NavigationBarHookPatch.kt @@ -41,7 +41,7 @@ internal const val EXTENSION_CLASS_DESCRIPTOR = internal const val EXTENSION_NAVIGATION_BUTTON_DESCRIPTOR = "Lapp/revanced/extension/youtube/shared/NavigationBar\$NavigationButton;" -lateinit var hookNavigationButtonCreated: (String) -> Unit +lateinit var hookNavigationButtonCreated: suspend (String) -> Unit val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navigation or search bar.") { dependsOn( @@ -66,16 +66,16 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig } } - initializeButtonsFingerprint.match(pivotBarConstructorFingerprint.originalClassDef).method.apply { + initializeButtonsFingerprint.match(pivotBarConstructorFingerprint.originalClassDef()).method.apply { // Hook the current navigation bar enum value. Note, the 'You' tab does not have an enum value. - val navigationEnumClassName = navigationEnumFingerprint.classDef.type + val navigationEnumClassName = navigationEnumFingerprint.classDef().type addHook(Hook.SET_LAST_APP_NAVIGATION_ENUM) { opcode == Opcode.INVOKE_STATIC && getReference()?.definingClass == navigationEnumClassName } // Hook the creation of navigation tab views. - val drawableTabMethod = pivotBarButtonsCreateDrawableViewFingerprint.method + val drawableTabMethod = pivotBarButtonsCreateDrawableViewFingerprint.method() addHook(Hook.NAVIGATION_TAB_LOADED) predicate@{ MethodUtil.methodSignaturesMatch( getReference() ?: return@predicate false, @@ -83,7 +83,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig ) } - val imageResourceTabMethod = pivotBarButtonsCreateResourceViewFingerprint.originalMethod + val imageResourceTabMethod = pivotBarButtonsCreateResourceViewFingerprint.originalMethod() addHook(Hook.NAVIGATION_IMAGE_RESOURCE_TAB_LOADED) predicate@{ MethodUtil.methodSignaturesMatch( getReference() ?: return@predicate false, @@ -92,7 +92,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig } } - pivotBarButtonsViewSetSelectedFingerprint.method.apply { + pivotBarButtonsViewSetSelectedFingerprint.method().apply { val index = indexOfSetViewSelectedInstruction(this) val instruction = getInstruction(index) val viewRegister = instruction.registerC @@ -107,7 +107,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig // Hook onto back button pressed. Needed to fix race problem with // Litho filtering based on navigation tab before the tab is updated. - mainActivityOnBackPressedFingerprint.method.addInstruction( + mainActivityOnBackPressedFingerprint.method().addInstruction( 0, "invoke-static { p0 }, " + "$EXTENSION_CLASS_DESCRIPTOR->onBackPressed(Landroid/app/Activity;)V", @@ -118,7 +118,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig // Two different layouts are used at the hooked code. // Insert before the first ViewGroup method call after inflating, // so this works regardless which layout is used. - actionBarSearchResultsFingerprint.method.apply { + actionBarSearchResultsFingerprint.method().apply { val searchBarResourceId = indexOfFirstLiteralInstructionOrThrow( actionBarSearchResultsViewMicId, ) @@ -137,7 +137,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig } hookNavigationButtonCreated = { extensionClassDescriptor -> - navigationBarHookCallbackFingerprint.method.addInstruction( + navigationBarHookCallbackFingerprint.method().addInstruction( 0, "invoke-static { p0, p1 }, " + "$extensionClassDescriptor->navigationTabCreated" + diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt index d2a20deb09..98700566cc 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsPatch.kt @@ -222,7 +222,7 @@ val playerControlsPatch = bytecodePatch( reference.name == "inflate" } - playerBottomControlsInflateFingerprint.method.apply { + playerBottomControlsInflateFingerprint.method().apply { inflateBottomControlMethod = this val inflateReturnObjectIndex = indexOfFirstViewInflateOrThrow() + 1 @@ -230,7 +230,7 @@ val playerControlsPatch = bytecodePatch( inflateBottomControlInsertIndex = inflateReturnObjectIndex + 1 } - playerTopControlsInflateFingerprint.method.apply { + playerTopControlsInflateFingerprint.method().apply { inflateTopControlMethod = this val inflateReturnObjectIndex = indexOfFirstViewInflateOrThrow() + 1 @@ -239,12 +239,12 @@ val playerControlsPatch = bytecodePatch( } visibilityMethod = controlsOverlayVisibilityFingerprint.match( - playerTopControlsInflateFingerprint.originalClassDef, + playerTopControlsInflateFingerprint.originalClassDef(), ).method // Hook the fullscreen close button. Used to fix visibility // when seeking and other situations. - overlayViewInflateFingerprint.method.apply { + overlayViewInflateFingerprint.method().apply { val resourceIndex = indexOfFirstLiteralInstructionReversedOrThrow(fullscreenButton) val index = indexOfFirstInstructionOrThrow(resourceIndex) { @@ -261,14 +261,14 @@ val playerControlsPatch = bytecodePatch( ) } - visibilityImmediateMethod = playerControlsExtensionHookFingerprint.method + visibilityImmediateMethod = playerControlsExtensionHookFingerprint.method() // A/B test for a slightly different overlay controls, // that uses layout file youtube_video_exploder_controls_bottom_ui_container.xml // The change to support this is simple and only requires adding buttons to both layout files, // but for now force this different layout off since it's still an experimental test. if (is_19_35_or_greater) { - playerControlsExploderFeatureFlagFingerprint.method.returnEarly() + playerControlsExploderFeatureFlagFingerprint.method().returnEarly() } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt index e021928a8b..e1bf24b8f6 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/PlayerTypeHookPatch.kt @@ -15,13 +15,13 @@ val playerTypeHookPatch = bytecodePatch( dependsOn(sharedExtensionPatch) execute { - playerTypeFingerprint.method.addInstruction( + playerTypeFingerprint.method().addInstruction( 0, "invoke-static {p1}, $EXTENSION_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V", ) - videoStateFingerprint.method.apply { - val endIndex = videoStateFingerprint.patternMatch!!.endIndex + videoStateFingerprint.method().apply { + val endIndex = videoStateFingerprint.patternMatch()!!.endIndex val videoStateFieldName = getInstruction(endIndex).reference addInstructions( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 7a6d519e48..f8df888ec4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -47,14 +47,14 @@ val removeTrackingQueryParameterPatch = bytecodePatch( SwitchPreference("revanced_remove_tracking_query_parameter"), ) - fun Fingerprint.hook( + suspend fun Fingerprint.hook( getInsertIndex: Match.PatternMatch.() -> Int, getUrlRegister: MutableMethod.(insertIndex: Int) -> Int, ) { - val insertIndex = patternMatch!!.getInsertIndex() - val urlRegister = method.getUrlRegister(insertIndex) + val insertIndex = patternMatch()!!.getInsertIndex() + val urlRegister = method().getUrlRegister(insertIndex) - method.addInstructions( + method().addInstructions( insertIndex, """ invoke-static {v$urlRegister}, $EXTENSION_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String; diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/recyclerviewtree/hook/RecyclerViewTreeHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/recyclerviewtree/hook/RecyclerViewTreeHookPatch.kt index 86588df099..f93464556b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/recyclerviewtree/hook/RecyclerViewTreeHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/recyclerviewtree/hook/RecyclerViewTreeHookPatch.kt @@ -12,8 +12,8 @@ val recyclerViewTreeHookPatch = bytecodePatch { execute { - recyclerViewTreeObserverFingerprint.method.apply { - val insertIndex = recyclerViewTreeObserverFingerprint.patternMatch!!.startIndex + 1 + recyclerViewTreeObserverFingerprint.method().apply { + val insertIndex = recyclerViewTreeObserverFingerprint.patternMatch()!!.startIndex + 1 val recyclerViewParameter = 2 addRecyclerViewTreeHook = { classDescriptor -> diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 627a70f91a..316b64ab92 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -150,7 +150,7 @@ val settingsPatch = bytecodePatch( ), ) - setThemeFingerprint.method.let { setThemeMethod -> + setThemeFingerprint.method().let { setThemeMethod -> setThemeMethod.implementation!!.instructions.mapIndexedNotNull { i, instruction -> if (instruction.opcode == Opcode.RETURN_OBJECT) i else null }.asReversed().forEach { returnIndex -> @@ -175,7 +175,7 @@ val settingsPatch = bytecodePatch( // Must modify an existing activity and cannot add a new activity to the manifest, // as that fails for root installations. - licenseActivityOnCreateFingerprint.method.addInstructions( + licenseActivityOnCreateFingerprint.method().addInstructions( 1, """ invoke-static { p0 }, $activityHookClassDescriptor->initialize(Landroid/app/Activity;)V @@ -184,7 +184,7 @@ val settingsPatch = bytecodePatch( ) // Remove other methods as they will break as the onCreate method is modified above. - licenseActivityOnCreateFingerprint.classDef.apply { + licenseActivityOnCreateFingerprint.classDef().apply { methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt index 77ec07f134..4b1de00b80 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt @@ -38,7 +38,7 @@ val zoomHapticsPatch = bytecodePatch( SwitchPreference("revanced_disable_zoom_haptics"), ) - zoomHapticsFingerprint.method.apply { + zoomHapticsFingerprint.method().apply { addInstructionsWithLabels( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt index 4b17551417..64edd5fb23 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt @@ -76,7 +76,7 @@ val videoInformationPatch = bytecodePatch( execute { - playerInitMethod = playerInitFingerprint.classDef.methods.first { MethodUtil.isConstructor(it) } + playerInitMethod = playerInitFingerprint.classDef().methods.first { MethodUtil.isConstructor(it) } // Find the location of the first invoke-direct call and extract the register storing the 'this' object reference. val initThisIndex = playerInitMethod.indexOfFirstInstructionOrThrow { @@ -88,19 +88,19 @@ val videoInformationPatch = bytecodePatch( // Hook the player controller for use through the extension. onCreateHook(EXTENSION_CLASS_DESCRIPTOR, "initialize") - val seekFingerprintResultMethod = seekFingerprint.match(playerInitFingerprint.originalClassDef).method + val seekFingerprintResultMethod = seekFingerprint.match(playerInitFingerprint.originalClassDef()).method val seekRelativeFingerprintResultMethod = - seekRelativeFingerprint.match(playerInitFingerprint.originalClassDef).method + seekRelativeFingerprint.match(playerInitFingerprint.originalClassDef()).method // Create extension interface methods. addSeekInterfaceMethods( - playerInitFingerprint.classDef, + playerInitFingerprint.classDef(), seekFingerprintResultMethod, seekRelativeFingerprintResultMethod, ) with(mdxPlayerDirectorSetVideoStageFingerprint) { - mdxInitMethod = classDef.methods.first { MethodUtil.isConstructor(it) } + mdxInitMethod = classDef().methods.first { MethodUtil.isConstructor(it) } val initThisIndex = mdxInitMethod.indexOfFirstInstructionOrThrow { opcode == Opcode.INVOKE_DIRECT && getReference()?.name == "" @@ -111,14 +111,14 @@ val videoInformationPatch = bytecodePatch( // Hook the MDX director for use through the extension. onCreateHookMdx(EXTENSION_CLASS_DESCRIPTOR, "initializeMdx") - val mdxSeekFingerprintResultMethod = mdxSeekFingerprint.match(classDef).method - val mdxSeekRelativeFingerprintResultMethod = mdxSeekRelativeFingerprint.match(classDef).method + val mdxSeekFingerprintResultMethod = mdxSeekFingerprint.match(classDef()).method + val mdxSeekRelativeFingerprintResultMethod = mdxSeekRelativeFingerprint.match(classDef()).method - addSeekInterfaceMethods(classDef, mdxSeekFingerprintResultMethod, mdxSeekRelativeFingerprintResultMethod) + addSeekInterfaceMethods(classDef(), mdxSeekFingerprintResultMethod, mdxSeekRelativeFingerprintResultMethod) } with(createVideoPlayerSeekbarFingerprint) { - val videoLengthMethodMatch = videoLengthFingerprint.match(originalClassDef) + val videoLengthMethodMatch = videoLengthFingerprint.match(originalClassDef()) videoLengthMethodMatch.method.apply { val videoLengthRegisterIndex = videoLengthMethodMatch.patternMatch!!.endIndex - 2 @@ -154,8 +154,8 @@ val videoInformationPatch = bytecodePatch( /* * Set the video time method */ - timeMethod = navigate(playerControllerSetTimeReferenceFingerprint.originalMethod) - .to(playerControllerSetTimeReferenceFingerprint.patternMatch!!.startIndex) + timeMethod = navigate(playerControllerSetTimeReferenceFingerprint.originalMethod()) + .to(playerControllerSetTimeReferenceFingerprint.patternMatch()!!.startIndex) .stop() /* @@ -166,7 +166,7 @@ val videoInformationPatch = bytecodePatch( /* * Hook the user playback speed selection */ - onPlaybackSpeedItemClickFingerprint.method.apply { + onPlaybackSpeedItemClickFingerprint.method().apply { val speedSelectionMethodInstructions = implementation!!.instructions val speedSelectionValueInstructionIndex = speedSelectionMethodInstructions.indexOfFirst { it.opcode == Opcode.IGET @@ -186,7 +186,7 @@ val videoInformationPatch = bytecodePatch( // Handle new playback speed menu. playbackSpeedMenuSpeedChangedFingerprint.match( - newVideoQualityChangedFingerprint.originalClassDef, + newVideoQualityChangedFingerprint.originalClassDef(), ).method.apply { val index = indexOfFirstInstructionOrThrow(Opcode.IGET) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt index 2a9a912455..6c880db89b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/playerresponse/PlayerResponseMethodHookPatch.kt @@ -43,7 +43,7 @@ val playerResponseMethodHookPatch = bytecodePatch { parameterIsShortAndOpeningOrPlaying = 11 playerParameterBuilderLegacyFingerprint - }.method + }.method() // On some app targets the method has too many registers pushing the parameters past v15. // If needed, move the parameters to 4-bit registers, so they can be passed to the extension. diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt index 8a2dfe4cc8..279c57d931 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt @@ -76,7 +76,7 @@ val rememberVideoQualityPatch = bytecodePatch( // Inject a call to set the remembered quality once a video loads. setQualityByIndexMethodClassFieldReferenceFingerprint.match( - videoQualitySetterFingerprint.originalClassDef, + videoQualitySetterFingerprint.originalClassDef(), ).let { match -> // This instruction refers to the field with the type that contains the setQualityByIndex method. val instructions = match.method.implementation!!.instructions @@ -97,7 +97,7 @@ val rememberVideoQualityPatch = bytecodePatch( .find { method -> method.parameterTypes.first() == "I" } ?: throw PatchException("Could not find setQualityByIndex method") - videoQualitySetterFingerprint.method.addInstructions( + videoQualitySetterFingerprint.method().addInstructions( 0, """ # Get the object instance to invoke the setQualityByIndex method on. @@ -119,7 +119,7 @@ val rememberVideoQualityPatch = bytecodePatch( } // Inject a call to remember the selected quality. - videoQualityItemOnClickParentFingerprint.classDef.methods.find { it.name == "onItemClick" } + videoQualityItemOnClickParentFingerprint.classDef().methods.find { it.name == "onItemClick" } ?.apply { val listItemIndexParameter = 3 @@ -131,8 +131,8 @@ val rememberVideoQualityPatch = bytecodePatch( } ?: throw PatchException("Failed to find onItemClick method") // Remember video quality if not using old layout menu. - newVideoQualityChangedFingerprint.method.apply { - val index = newVideoQualityChangedFingerprint.patternMatch!!.startIndex + newVideoQualityChangedFingerprint.method().apply { + val index = newVideoQualityChangedFingerprint.patternMatch()!!.startIndex val qualityRegister = getInstruction(index).registerA addInstruction( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt index bd6668993d..46d8eb30c7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt @@ -72,7 +72,7 @@ internal val customPlaybackSpeedPatch = bytecodePatch( ) // Replace the speeds float array with custom speeds. - speedArrayGeneratorFingerprint.method.apply { + speedArrayGeneratorFingerprint.method().apply { val sizeCallIndex = indexOfFirstInstructionOrThrow { getReference()?.name == "size" } val sizeCallResultRegister = getInstruction(sizeCallIndex + 1).registerA @@ -104,7 +104,7 @@ internal val customPlaybackSpeedPatch = bytecodePatch( } // Override the min/max speeds that can be used. - speedLimiterFingerprint.method.apply { + speedLimiterFingerprint.method().apply { val limitMinIndex = indexOfFirstLiteralInstructionOrThrow(0.25f.toRawBits().toLong()) var limitMaxIndex = indexOfFirstLiteralInstruction(2.0f.toRawBits().toLong()) // Newer targets have 4x max speed. @@ -123,28 +123,28 @@ internal val customPlaybackSpeedPatch = bytecodePatch( // This is later used to call "showOldPlaybackSpeedMenu" on the instance. val instanceField = ImmutableField( - getOldPlaybackSpeedsFingerprint.originalClassDef.type, + getOldPlaybackSpeedsFingerprint.originalClassDef().type, "INSTANCE", - getOldPlaybackSpeedsFingerprint.originalClassDef.type, + getOldPlaybackSpeedsFingerprint.originalClassDef().type, AccessFlags.PUBLIC.value or AccessFlags.STATIC.value, null, null, null, ).toMutable() - getOldPlaybackSpeedsFingerprint.classDef.staticFields.add(instanceField) + getOldPlaybackSpeedsFingerprint.classDef().staticFields.add(instanceField) // Set the INSTANCE field to the instance of the class. // In order to prevent a conflict with another patch, add the instruction at index 1. - getOldPlaybackSpeedsFingerprint.method.addInstruction(1, "sput-object p0, $instanceField") + getOldPlaybackSpeedsFingerprint.method().addInstruction(1, "sput-object p0, $instanceField") // Get the "showOldPlaybackSpeedMenu" method. // This is later called on the field INSTANCE. val showOldPlaybackSpeedMenuMethod = showOldPlaybackSpeedMenuFingerprint.match( - getOldPlaybackSpeedsFingerprint.classDef, + getOldPlaybackSpeedsFingerprint.classDef(), ).method.toString() // Insert the call to the "showOldPlaybackSpeedMenu" method on the field INSTANCE. - showOldPlaybackSpeedMenuExtensionFingerprint.method.apply { + showOldPlaybackSpeedMenuExtensionFingerprint.method().apply { addInstructionsWithLabels( instructions.lastIndex, """ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt index 3c51559ea8..252dff5864 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt @@ -50,7 +50,7 @@ internal val rememberPlaybackSpeedPatch = bytecodePatch { /* * Hook the code that is called when the playback speeds are initialized, and sets the playback speed */ - initializePlaybackSpeedValuesFingerprint.method.apply { + initializePlaybackSpeedValuesFingerprint.method().apply { // Infer everything necessary for calling the method setPlaybackSpeed(). val onItemClickListenerClassFieldReference = getInstruction(0).reference diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt index 6d69381cd3..c3a8c69966 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoid/VideoIdPatch.kt @@ -96,14 +96,14 @@ val videoIdPatch = bytecodePatch( ) execute { - videoIdFingerprint.match(videoIdParentFingerprint.originalClassDef).method.apply { + videoIdFingerprint.match(videoIdParentFingerprint.originalClassDef()).method.apply { videoIdMethod = this val index = indexOfPlayerResponseModelString() videoIdRegister = getInstruction(index + 1).registerA videoIdInsertIndex = index + 2 } - videoIdBackgroundPlayFingerprint.method.apply { + videoIdBackgroundPlayFingerprint.method().apply { backgroundPlaybackMethod = this val index = indexOfPlayerResponseModelString() backgroundPlaybackVideoIdRegister = getInstruction(index + 1).registerA diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt index 886db27df7..c77331a6f1 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuPatch.kt @@ -88,8 +88,8 @@ val restoreOldVideoQualityMenuPatch = bytecodePatch( // Used for regular videos when spoofing to old app version, // and for the Shorts quality flyout on newer app versions. - videoQualityMenuViewInflateFingerprint.method.apply { - val checkCastIndex = videoQualityMenuViewInflateFingerprint.patternMatch!!.endIndex + videoQualityMenuViewInflateFingerprint.method().apply { + val checkCastIndex = videoQualityMenuViewInflateFingerprint.patternMatch()!!.endIndex val listViewRegister = getInstruction(checkCastIndex).registerA addInstruction( @@ -101,12 +101,12 @@ val restoreOldVideoQualityMenuPatch = bytecodePatch( } // Force YT to add the 'advanced' quality menu for Shorts. - val patternMatch = videoQualityMenuOptionsFingerprint.patternMatch!! + val patternMatch = videoQualityMenuOptionsFingerprint.patternMatch()!! val startIndex = patternMatch.startIndex if (startIndex != 0) throw PatchException("Unexpected opcode start index: $startIndex") val insertIndex = patternMatch.endIndex - videoQualityMenuOptionsFingerprint.method.apply { + videoQualityMenuOptionsFingerprint.method().apply { val register = getInstruction(insertIndex).registerA // A condition controls whether to show the three or four items quality menu. diff --git a/patches/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPatch.kt b/patches/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPatch.kt index c6689540d7..f37f043957 100644 --- a/patches/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPatch.kt @@ -11,7 +11,7 @@ val unlockPremiumPatch = bytecodePatch( execute { isPremiumFingerprint.match( - yukaUserConstructorFingerprint.originalClassDef, + yukaUserConstructorFingerprint.originalClassDef(), ).method.addInstructions( 0, """ diff --git a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index db7d2664ba..da8ea3e5f8 100644 --- a/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -186,7 +186,7 @@ fun Method.containsLiteralInstruction(literal: Long) = * @param targetClass the class to start traversing the class hierarchy from. * @param callback function that is called for every class in the hierarchy. */ -fun BytecodePatchContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) { +suspend fun BytecodePatchContext.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) { callback(targetClass) targetClass.superclass ?: return @@ -384,7 +384,7 @@ fun Method.findInstructionIndicesReversedOrThrow(opcode: Opcode): List { /** * Called for _all_ instructions with the given literal value. */ -fun BytecodePatchContext.forEachLiteralValueInstruction( +suspend fun BytecodePatchContext.forEachLiteralValueInstruction( literal: Long, block: MutableMethod.(literalInstructionIndex: Int) -> Unit, ) {