From 0e1563ed0f2200a3bed76da59d581da25d5efde3 Mon Sep 17 00:00:00 2001 From: Keeperorowner Date: Sun, 10 Nov 2024 11:07:28 +0800 Subject: [PATCH] Update LockPremiumFeatures.kt --- .../cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt b/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt index 10c35ba1..3238bf42 100644 --- a/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt +++ b/app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt @@ -11,13 +11,15 @@ import de.robv.android.xposed.XposedHelpers class LockPremiumFeatures : CommonDynamicHook() { companion object : BaseDynamicHook { - @JvmStatic - fun getInstance(): LockPremiumFeatures = INSTANCE - private val INSTANCE = LockPremiumFeatures() @JvmStatic override fun getInstance(): BaseDynamicHook = INSTANCE + + @JvmStatic + override fun initialize(): Boolean { + return INSTANCE.initOnce() + } } override fun initOnce(): Boolean { @@ -41,12 +43,14 @@ class LockPremiumFeatures : CommonDynamicHook() { private fun hookPremiumFeatures() { try { val messagesControllerClass = Initiator.load("org.telegram.messenger.MessagesController") + // Hook constructor XposedHelpers.findAndHookConstructor(messagesControllerClass, object : XC_MethodHook() { @Throws(Throwable::class) override fun afterHookedMethod(param: MethodHookParam) { XposedHelpers.setBooleanField(param.thisObject, "premiumLocked", true) } }) + // Hook applyAppConfig method XposedHelpers.findAndHookMethod(messagesControllerClass, "applyAppConfig", object : XC_MethodHook() {