From 6159b2661483d74eb9ca7202646081a0904378a6 Mon Sep 17 00:00:00 2001 From: Jonathan <63370021+FineFindus@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:06:15 +0100 Subject: [PATCH] feat(windyapp): `unlock-pro` patch (#1118) --- .../annotations/UnlockProCompatibility.kt | 9 +++++ .../fingerprints/CheckProFingerprint.kt | 10 +++++ .../misc/unlockpro/patch/UnlockProPatch.kt | 38 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/annotations/UnlockProCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/fingerprints/CheckProFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/annotations/UnlockProCompatibility.kt b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/annotations/UnlockProCompatibility.kt new file mode 100644 index 000000000..b4b99e43f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/annotations/UnlockProCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.windyapp.misc.pro.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("co.windyapp.android")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class UnlockProCompatibility diff --git a/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/fingerprints/CheckProFingerprint.kt b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/fingerprints/CheckProFingerprint.kt new file mode 100644 index 000000000..230f83a1e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/fingerprints/CheckProFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.windyapp.misc.pro.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object CheckProFingerprint : MethodFingerprint( + "I", + customFingerprint = { methodDef -> + methodDef.definingClass.endsWith("RawUserData;") && methodDef.name == "isPro" + } +) diff --git a/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt new file mode 100644 index 000000000..fac915b59 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/windyapp/misc/unlockpro/patch/UnlockProPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.windyapp.misc.pro.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.windyapp.misc.pro.annotations.UnlockProCompatibility +import app.revanced.patches.windyapp.misc.pro.fingerprints.CheckProFingerprint + +@Patch +@Name("unlock-pro") +@Description("Unlocks all pro features.") +@UnlockProCompatibility +@Version("0.0.1") +class UnlockProPatch : BytecodePatch( + listOf( + CheckProFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + val method = CheckProFingerprint.result!!.mutableMethod + method.addInstructions( + 0, + """ + const/16 v0, 0x1 + return v0 + """ + ) + + return PatchResultSuccess() + } +}