Skip to content

Commit

Permalink
feat(yuka): unlock-premium patch (#1608)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
nik2143 and oSumAtrIX committed Feb 11, 2023
1 parent f8ba61c commit 71e1594
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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,
)
)
Original file line number Diff line number Diff line change
@@ -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"
)
)
Original file line number Diff line number Diff line change
@@ -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()
}

}

0 comments on commit 71e1594

Please sign in to comment.