Fix module not loading on first run

This commit is contained in:
Nullptr 2022-05-27 23:01:06 +08:00
parent 4e41e141dd
commit 641ed369fa
No known key found for this signature in database
GPG Key ID: 0B9D02052FF536BD
4 changed files with 18 additions and 10 deletions

2
core

@ -1 +1 @@
Subproject commit dd8dcfbab1d8aa8a408ab57cb5e934684679533d
Subproject commit d36d284f3908e7f5eb8bcb873e637cac2db27b01

View File

@ -93,10 +93,11 @@ public class LSPApplication {
try {
disableProfile(context);
Startup.initXposed(false, ActivityThread.currentProcessName(), service);
Log.i(TAG, "Start loading modules");
Log.i(TAG, "Bootstrap Xposed");
Startup.bootstrapXposed();
// WARN: Since it uses `XResource`, the following class should not be initialized
// before forkPostCommon is invoke. Otherwise, you will get failure of XResources
Log.i(TAG, "Load modules");
LSPLoader.initModules(appLoadedApk);
Log.i(TAG, "Modules initialized");

View File

@ -71,11 +71,15 @@ namespace lspd {
env->DeleteLocalRef(dex_buffer);
}
void PatchLoader::InitHooks(JNIEnv* env, const lsplant::InitInfo& initInfo) {
void PatchLoader::InitArtHooker(JNIEnv* env, const InitInfo& initInfo) {
Context::InitArtHooker(env, initInfo);
handler = initInfo;
Context::InitHooks(env, handler);
art::DisableInline(handler);
art::DisableBackgroundVerification(handler);
art::DisableInline(initInfo);
art::DisableBackgroundVerification(initInfo);
}
void PatchLoader::InitHooks(JNIEnv* env) {
Context::InitHooks(env);
RegisterBypass(env);
}
@ -110,8 +114,9 @@ namespace lspd {
auto array = (jbyteArray) env->GetStaticObjectField(stub, dex_field);
auto dex = PreloadedDex {env->GetByteArrayElements(array, nullptr), static_cast<size_t>(JNI_GetArrayLength(env, array))};
InitArtHooker(env, initInfo);
LoadDex(env, std::move(dex));
InitHooks(env, initInfo);
InitHooks(env);
GetArt(true);

View File

@ -42,7 +42,9 @@ namespace lspd {
void Load(JNIEnv* env);
protected:
void InitHooks(JNIEnv* env, const lsplant::InitInfo& initInfo) override;
void InitArtHooker(JNIEnv* env, const lsplant::InitInfo& initInfo) override;
void InitHooks(JNIEnv* env) override;
void LoadDex(JNIEnv* env, PreloadedDex&& dex) override;