diff --git a/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/Fingerprints.kt index c0af706e7..cf145e7b8 100644 --- a/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/cricbuzz/ads/Fingerprints.kt @@ -6,8 +6,8 @@ import com.android.tools.smali.dexlib2.Opcode internal val BytecodePatchContext.userStateSwitchMethod by gettingFirstMutableMethodDeclaratively("key.user.state", "NA") { opcodes(Opcode.SPARSE_SWITCH) - } + internal val BytecodePatchContext.cb11ConstructorMethod by gettingFirstMutableMethodDeclaratively { definingClass("CB11Details;"::endsWith) parameterTypes( @@ -20,10 +20,11 @@ internal val BytecodePatchContext.cb11ConstructorMethod by gettingFirstMutableMe "Z", "Ljava/lang/String;", "Ljava/lang/String;", - "L" + "L", ) } + internal val BytecodePatchContext.getBottomBarMethod by gettingFirstMutableMethodDeclaratively { name("getBottombar") definingClass("HomeMenu;"::endsWith) -} \ No newline at end of file +} 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 cbdb8742d..0172d6ccc 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 @@ -2,18 +2,13 @@ package app.revanced.patches.iconpackstudio.misc.pro import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.returnEarly @Suppress("unused") val `Unlock pro` by creatingBytecodePatch { compatibleWith("ginlemon.iconpackstudio"("2.2 build 016")) apply { - checkProMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + checkProMethod.returnEarly(true) } } 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 523a0ae65..e4679f4da 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 @@ -1,19 +1,13 @@ package app.revanced.patches.memegenerator.detection.signature -import app.revanced.patcher.extensions.replaceInstructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly val signatureVerificationPatch = bytecodePatch( description = "Disables detection of incorrect signature.", ) { apply { - verifySignatureMethod.replaceInstructions( - 0, - """ - const/4 p0, 0x1 - return p0 - """, - ) + verifySignatureMethod.returnEarly(true) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/buttons/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/buttons/Fingerprints.kt index bb097c00f..df28c5325 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/buttons/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/buttons/Fingerprints.kt @@ -1,28 +1,43 @@ package app.revanced.patches.music.layout.buttons -import app.revanced.patcher.fingerprint +import app.revanced.patcher.accessFlags +import app.revanced.patcher.custom +import app.revanced.patcher.definingClass +import app.revanced.patcher.extensions.instructions +import app.revanced.patcher.gettingFirstMethodDeclaratively +import app.revanced.patcher.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.immutableClassDef +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.literal +import app.revanced.patcher.matchIndexed +import app.revanced.patcher.method +import app.revanced.patcher.opcodes +import app.revanced.patcher.parameterTypes +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.predicate +import app.revanced.patcher.rememberMatchIndexed +import app.revanced.patcher.returnType +import app.revanced.patcher.unorderedAllOf import app.revanced.util.containsLiteralInstruction import app.revanced.util.literal import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -internal val mediaRouteButtonFingerprint = fingerprint { +internal val BytecodePatchContext.mediaRouteButtonMethod by gettingFirstMutableMethodDeclaratively("MediaRouteButton") { accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) - returns("Z") - strings("MediaRouteButton") + returnType("Z") } -internal val playerOverlayChipFingerprint = fingerprint { +internal val BytecodePatchContext.playerOverlayChipMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) - returns("L") - literal { playerOverlayChip } + returnType("L") + custom { + instructions { literal { playerOverlayChip() } } + } } internal val BytecodePatchContext.historyMenuItemMethod by gettingFirstMutableMethodDeclaratively { - definingClass { - it.methods.count() - methods.count() - } accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) returnType("V") parameterTypes("Landroid/view/Menu;") @@ -31,8 +46,8 @@ internal val BytecodePatchContext.historyMenuItemMethod by gettingFirstMutableMe Opcode.RETURN_VOID, ) historyMenuItem() - custom { _, classDef -> - classDef.methods.count() == 5 + custom { + immutableClassDef.methods.count() == 5 // TODO CONFIRM } } 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 11f1460cd..ab7348975 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 @@ -1,19 +1,13 @@ package app.revanced.patches.myexpenses.misc.pro -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Unlock pro` by creatingBytecodePatch { compatibleWith("org.totschnig.myexpenses"("3.4.9")) apply { - isEnabledMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + isEnabledMethod.returnEarly(true) } } 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 938d001b0..ee7972a17 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 @@ -1,7 +1,7 @@ package app.revanced.patches.photomath.misc.unlock.bookpoint -import app.revanced.patcher.extensions.replaceInstructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly @Suppress("unused") val enableBookpointPatch = bytecodePatch( @@ -9,12 +9,6 @@ val enableBookpointPatch = bytecodePatch( ) { apply { - isBookpointEnabledMethod.replaceInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + isBookpointEnabledMethod.returnEarly(true) // TODO: CHECK IF THIS IS FINE IN REPLACEMENT OF replaceInstructions } } 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 f113bed25..c5987f47b 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 @@ -1,9 +1,9 @@ package app.revanced.patches.photomath.misc.unlock.plus -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch import app.revanced.patches.photomath.misc.unlock.bookpoint.enableBookpointPatch +import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Unlock plus` by creatingBytecodePatch { @@ -12,12 +12,6 @@ val `Unlock plus` by creatingBytecodePatch { compatibleWith("com.microblink.photomath") apply { - isPlusUnlockedMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + isPlusUnlockedMethod.returnEarly(true) } } 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 cf19adc61..838c166b8 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 @@ -1,7 +1,7 @@ package app.revanced.patches.reddit.layout.premiumicon -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.returnEarly @Suppress("unused", "ObjectPropertyName") val `Unlock Premium icons` by creatingBytecodePatch( @@ -10,12 +10,6 @@ val `Unlock Premium icons` by creatingBytecodePatch( compatibleWith("com.reddit.frontpage") apply { - hasPremiumIconAccessMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + hasPremiumIconAccessMethod.returnEarly(true) } } 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 13b533e6e..cb3b43dbe 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 @@ -2,6 +2,7 @@ package app.revanced.patches.tiktok.interaction.seekbar import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch +import app.revanced.util.returnEarly @Suppress("unused") val `Show seekbar` by creatingBytecodePatch( @@ -13,13 +14,7 @@ val `Show seekbar` by creatingBytecodePatch( ) apply { - shouldShowSeekBarMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + shouldShowSeekBarMethod.returnEarly(true) setSeekBarShowTypeMethod.apply { val typeRegister = implementation!!.registerCount - 1 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 39d23df4e..8f4d23a79 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 @@ -9,13 +9,14 @@ import app.revanced.patches.tiktok.shared.getEnterFromFingerprint import app.revanced.patches.tiktok.shared.onRenderFirstFrameFingerprint import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow +import app.revanced.util.returnEarly import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction11x import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("unused") val `Playback speed` by creatingBytecodePatch( description = "Enables the playback speed option for all videos and " + - "retains the speed configurations in between videos.", + "retains the speed configurations in between videos.", ) { compatibleWith( "com.ss.android.ugc.trill"("36.5.4"), @@ -57,12 +58,6 @@ val `Playback speed` by creatingBytecodePatch( ) // Force enable the playback speed option for all videos. - setSpeedMethod.classDef.methods.find { method -> method.returnType == "Z" }?.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + setSpeedMethod.classDef.methods.find { method -> method.returnType == "Z" }?.returnEarly(true) } } 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 5c97fa348..ebcef3630 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 @@ -1,8 +1,8 @@ package app.revanced.patches.warnwetter.misc.promocode -import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.patch.creatingBytecodePatch import app.revanced.patches.warnwetter.misc.firebasegetcert.firebaseGetCertPatch +import app.revanced.util.returnEarly @Suppress("unused") val `Promo code unlock` by creatingBytecodePatch( @@ -13,12 +13,6 @@ val `Promo code unlock` by creatingBytecodePatch( compatibleWith("de.dwd.warnapp"("4.2.2")) apply { - promoCodeUnlockMethod.addInstructions( - 0, - """ - const/4 v0, 0x1 - return v0 - """, - ) + promoCodeUnlockMethod.returnEarly(true) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/HideSeekbarPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/HideSeekbarPatch.kt index a9cf4a411..63a6ae0d0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/HideSeekbarPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/HideSeekbarPatch.kt @@ -26,7 +26,7 @@ val hideSeekbarPatch = bytecodePatch( settingsPatch, seekbarColorPatch, addResourcesPatch, - versionCheckPatch + versionCheckPatch, ) apply { @@ -48,14 +48,14 @@ val hideSeekbarPatch = bytecodePatch( return-void :hide_seekbar nop - """ + """, ) if (is_20_28_or_greater) { fullscreenLargeSeekbarFeatureFlagMethodMatch.let { it.method.insertLiteralOverride( it.instructionMatches.first().index, - "$EXTENSION_CLASS_DESCRIPTOR->useFullscreenLargeSeekbar(Z)Z" + "$EXTENSION_CLASS_DESCRIPTOR->useFullscreenLargeSeekbar(Z)Z", ) } }