Skip to content

Commit

Permalink
Update LockPremiumFeatures.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Keeperorowner authored Nov 10, 2024
1 parent 0e1563e commit 0b17c71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/src/main/java/cc/ioctl/tmoe/hook/func/LockPremiumFeatures.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ class LockPremiumFeatures : CommonDynamicHook() {

companion object : BaseDynamicHook {
private val INSTANCE = LockPremiumFeatures()
private var initialized = false

@JvmStatic
override fun getInstance(): BaseDynamicHook = INSTANCE

@JvmStatic
override fun initialize(): Boolean {
return INSTANCE.initOnce()
if (!initialized) {
initialized = INSTANCE.initOnce()
}
return initialized
}

@JvmStatic
override fun isInitialized(): Boolean {
return initialized
}
}

Expand All @@ -43,14 +52,12 @@ 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() {
Expand Down

0 comments on commit 0b17c71

Please sign in to comment.