Skip to content

Commit

Permalink
unhook classloader
Browse files Browse the repository at this point in the history
  • Loading branch information
hosizoraru committed Aug 15, 2023
1 parent c9242e4 commit 7446b62
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package star.sky.voyager.utils.voyager

import android.content.pm.ApplicationInfo
import com.github.kyuubiran.ezxhelper.ClassUtils
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import de.robv.android.xposed.XC_MethodHook

object PluginClassLoader {
/**
Expand All @@ -19,10 +20,11 @@ object PluginClassLoader {
* @author Voyager
* @return appInfo & classLoaderP
*/
var hook: XC_MethodHook.Unhook? = null
fun hookPluginClassLoader(onGetClassLoader: (appInfo: ApplicationInfo, classLoader: ClassLoader) -> Unit) {
val classLoaderClass =
ClassUtils.loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory")
classLoaderClass.methodFinder().first {
loadClass("com.android.systemui.shared.plugins.PluginInstance\$Factory")
hook = classLoaderClass.methodFinder().first {
name == "getClassLoader"
&& parameterCount == 2
&& parameterTypes[0] == ApplicationInfo::class.java
Expand All @@ -35,6 +37,7 @@ object PluginClassLoader {
if (appInfo.packageName == "miui.systemui.plugin") {
onGetClassLoader(appInfo, classLoaderP)
}
hook?.unhook()
}
}
}
Expand Down

0 comments on commit 7446b62

Please sign in to comment.