feat(yuka): unlock-premium patch (#1608)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
nik2143 2023-02-11 01:44:47 +01:00 committed by GitHub
parent f8ba61ccc6
commit 71e15945c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 0 deletions

View file

@ -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

View file

@ -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,
)
)

View file

@ -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"
)
)

View file

@ -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()
}
}