diff --git a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/annotations/UnlockPremiumCompatibility.kt b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/annotations/UnlockPremiumCompatibility.kt new file mode 100644 index 000000000..be364d827 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/annotations/UnlockPremiumCompatibility.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.yuka.misc.unlockpremium.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility([Package("io.yuka.android")]) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class UnlockPremiumCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/IsPremiumFingerprint.kt b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/IsPremiumFingerprint.kt new file mode 100644 index 000000000..0a7f01a25 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/IsPremiumFingerprint.kt @@ -0,0 +1,15 @@ +package app.revanced.patches.yuka.misc.unlockpremium.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags +import org.jf.dexlib2.Opcode + +object IsPremiumFingerprint : MethodFingerprint( + returnType = "Z", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + opcodes = listOf( + Opcode.IGET_BOOLEAN, + Opcode.RETURN, + ) +) diff --git a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/YukaUserConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/YukaUserConstructorFingerprint.kt new file mode 100644 index 000000000..85351e471 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/fingerprints/YukaUserConstructorFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.yuka.misc.unlockpremium.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object YukaUserConstructorFingerprint : MethodFingerprint( + returnType = "V", + access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, + strings = listOf( + "premiumProvider" + ) +) diff --git a/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt new file mode 100644 index 000000000..afdcdd2f7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/yuka/misc/unlockpremium/patch/UnlockPremiunPatch.kt @@ -0,0 +1,41 @@ +package app.revanced.patches.yuka.misc.unlockpremium.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.fingerprint.method.impl.MethodFingerprint.Companion.resolve +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.yuka.misc.unlockpremium.annotations.UnlockPremiumCompatibility +import app.revanced.patches.yuka.misc.unlockpremium.fingerprints.IsPremiumFingerprint +import app.revanced.patches.yuka.misc.unlockpremium.fingerprints.YukaUserConstructorFingerprint + +@Patch +@Name("unlock-premium") +@Description("Unlocks premium features.") +@UnlockPremiumCompatibility +@Version("0.0.1") +class UnlockPremiunPatch : BytecodePatch( + listOf( + YukaUserConstructorFingerprint + ) +) { + + override fun execute(context: BytecodeContext): PatchResult { + IsPremiumFingerprint.resolve(context,YukaUserConstructorFingerprint.result!!.classDef) + val method = IsPremiumFingerprint.result!!.mutableMethod + method.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) + return PatchResultSuccess() + } + +} \ No newline at end of file