From 167b4c70a93e475a1e8d9b55fb6dcf946f3b36e8 Mon Sep 17 00:00:00 2001 From: Jonathan <63370021+FineFindus@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:46:55 +0100 Subject: [PATCH] feat(nyx): `unlock-pro` patch (#1004) --- .../pro/annotations/UnlockProCompatibility.kt | 9 +++++ .../pro/fingerprints/CheckProFingerprint.kt | 15 ++++++++ .../nyx/misc/pro/patch/UnlockProPatch.kt | 38 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/nyx/misc/pro/annotations/UnlockProCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/nyx/misc/pro/fingerprints/CheckProFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/nyx/misc/pro/annotations/UnlockProCompatibility.kt b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/annotations/UnlockProCompatibility.kt new file mode 100644 index 00000000..39c94347 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/annotations/UnlockProCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.nyx.misc.pro.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("com.awedea.nyx")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class UnlockProCompatibility diff --git a/src/main/kotlin/app/revanced/patches/nyx/misc/pro/fingerprints/CheckProFingerprint.kt b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/fingerprints/CheckProFingerprint.kt new file mode 100644 index 00000000..4d2d13a7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/fingerprints/CheckProFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.nyx.misc.pro.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.nyx.misc.pro.annotations.UnlockProCompatibility + +@Name("check-pro-fingerprint") +@UnlockProCompatibility +@Version("0.0.1") +object CheckProFingerprint : MethodFingerprint( + customFingerprint = { methodDef -> + methodDef.definingClass.endsWith("BillingManager;") && methodDef.name == "isProVersion" + } +) diff --git a/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt new file mode 100644 index 00000000..bb0ee596 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/nyx/misc/pro/patch/UnlockProPatch.kt @@ -0,0 +1,38 @@ +package app.revanced.patches.nyx.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.nyx.misc.pro.annotations.UnlockProCompatibility +import app.revanced.patches.nyx.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/4 v0, 0x1 + return v0 + """ + ) + + return PatchResultSuccess() + } +}