fix: get correct class for bridgeless
This commit is contained in:
parent
fe80ca398b
commit
2ef6807ac0
1 changed files with 14 additions and 16 deletions
|
|
@ -81,29 +81,23 @@ class Main : IXposedHookLoadPackage {
|
|||
param: XC_LoadPackage.LoadPackageParam,
|
||||
onActivityCreate: ((activity: Activity) -> Unit) -> Unit
|
||||
) = with (param) {
|
||||
val catalystInstanceImpl = classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl")
|
||||
val reactInstance = classLoader.loadClass("com.facebook.react.runtime.ReactInstance$1")
|
||||
|
||||
for (module in modules) module.onInit(param)
|
||||
|
||||
val loadScriptFromAssets = catalystInstanceImpl.getDeclaredMethod(
|
||||
val loadScriptFromAssets = reactInstance.getDeclaredMethod(
|
||||
"loadScriptFromAssets",
|
||||
AssetManager::class.java,
|
||||
String::class.java,
|
||||
Boolean::class.javaPrimitiveType
|
||||
).apply { isAccessible = true }
|
||||
)
|
||||
|
||||
val loadScriptFromFile = catalystInstanceImpl.getDeclaredMethod(
|
||||
val loadScriptFromFile = reactInstance.getDeclaredMethod(
|
||||
"loadScriptFromFile",
|
||||
String::class.java,
|
||||
String::class.java,
|
||||
Boolean::class.javaPrimitiveType
|
||||
).apply { isAccessible = true }
|
||||
|
||||
val setGlobalVariable = catalystInstanceImpl.getDeclaredMethod(
|
||||
"setGlobalVariable",
|
||||
String::class.java,
|
||||
String::class.java
|
||||
).apply { isAccessible = true }
|
||||
)
|
||||
|
||||
val cacheDir = File(appInfo.dataDir, "cache/pyoncord").apply { mkdirs() }
|
||||
val filesDir = File(appInfo.dataDir, "files/pyoncord").apply { mkdirs() }
|
||||
|
|
@ -184,11 +178,15 @@ class Main : IXposedHookLoadPackage {
|
|||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
runBlocking { httpJob.join() }
|
||||
|
||||
XposedBridge.invokeOriginalMethod(
|
||||
setGlobalVariable,
|
||||
param.thisObject,
|
||||
arrayOf("__PYON_LOADER__", buildLoaderJsonString())
|
||||
)
|
||||
// TODO: Make this work again
|
||||
// Solution: Inject a native module called RevengeGlobals that exposes a method that returns a Map
|
||||
// Then in JS, we can call the method and set the globals accordingly
|
||||
// Because setGlobalVariable no longer exists in bridgeless (unless we want to do CXX modules)
|
||||
// XposedBridge.invokeOriginalMethod(
|
||||
// setGlobalVariable,
|
||||
// param.thisObject,
|
||||
// arrayOf("__PYON_LOADER__", buildLoaderJsonString())
|
||||
// )
|
||||
|
||||
preloadsDir
|
||||
.walk()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue