From d5df2e68f47cbb3d374b8ce24769872959014051 Mon Sep 17 00:00:00 2001 From: Technikte <49494924+Technikte@users.noreply.github.com> Date: Thu, 4 Aug 2022 19:03:56 +0200 Subject: [PATCH] feat: `promo-code-unlock` patch (#292) --- .../PromoCodeUnlockCompatibility.kt | 13 ++++++ .../PromoCodeUnlockFingerprint.kt | 26 ++++++++++++ .../promocode/patch/PromoCodeUnlockPatch.kt | 42 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/annotations/PromoCodeUnlockCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/annotations/PromoCodeUnlockCompatibility.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/annotations/PromoCodeUnlockCompatibility.kt new file mode 100644 index 000000000..b14201ecd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/annotations/PromoCodeUnlockCompatibility.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.warnwetter.misc.promocode.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [Package( + "de.dwd.warnapp", arrayOf() + )] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class PromoCodeUnlockCompatibility diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt new file mode 100644 index 000000000..41d980d05 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/fingerprints/PromoCodeUnlockFingerprint.kt @@ -0,0 +1,26 @@ +package app.revanced.patches.warnwetter.misc.promocode.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod +import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +@Name("promo-code-unlock-fingerprint") +@MatchingMethod( + "Lde/dwd/warnapp/model/PromoTokenVerification;", "isValid" +) +@CreateButtonCompatibility +@Version("0.0.1") +object PromoCodeUnlockFingerprint : MethodFingerprint( + null, + null, + null, + null, + null, + { methodDef -> + methodDef.definingClass.endsWith("PromoTokenVerification;") && methodDef.name == "isValid" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt new file mode 100644 index 000000000..3cae70b40 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/warnwetter/misc/promocode/patch/PromoCodeUnlockPatch.kt @@ -0,0 +1,42 @@ +package app.revanced.patches.warnwetter.misc.promocode.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.impl.BytecodeData +import app.revanced.patcher.extensions.removeInstruction +import app.revanced.patcher.extensions.removeInstructions +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patcher.patch.impl.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.warnwetter.misc.promocode.annotations.PromoCodeUnlockCompatibility +import app.revanced.patches.warnwetter.misc.promocode.fingerprints.PromoCodeUnlockFingerprint + +@Patch +@Name("promo-code-unlock") +@Description("Disables the validation of promo code. Any code will work to unlock all features.") +@PromoCodeUnlockCompatibility +@Version("0.0.1") +class PromoCodeUnlockPatch : BytecodePatch( + listOf( + PromoCodeUnlockFingerprint + ) +) { + + override fun execute(data: BytecodeData): PatchResult { + val method = PromoCodeUnlockFingerprint.result!!.mutableMethod + method.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + + return PatchResultSuccess() + } + + +} \ No newline at end of file