diff --git a/core/build.gradle.kts b/core/build.gradle.kts index d0a7c740..376e26e7 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -42,9 +42,9 @@ val moduleId = "riru_lsposed" val authors = "LSPosed Developers" val riruModuleId = "lsposed" -val moduleMinRiruApiVersion = 24 -val moduleMinRiruVersionName = "v24.1.0" -val moduleMaxRiruApiVersion = 24 +val moduleMinRiruApiVersion = 25 +val moduleMinRiruVersionName = "25.0.0" +val moduleMaxRiruApiVersion = 25 val defaultManagerPackageName: String by rootProject.extra val apiCode: Int by rootProject.extra @@ -63,7 +63,7 @@ val verCode: Int by rootProject.extra val verName: String by rootProject.extra dependencies { - implementation("dev.rikka.ndk:riru:24.0.0") + implementation("dev.rikka.ndk:riru:${moduleMinRiruVersionName}") implementation(files("libs/dobby_prefab.aar")) implementation("com.android.tools.build:apksig:4.1.2") compileOnly(project(":hiddenapi-stubs")) diff --git a/core/src/main/cpp/external/yahfa/include/trampoline.h b/core/src/main/cpp/external/yahfa/include/trampoline.h index 56611b81..5c18d939 100644 --- a/core/src/main/cpp/external/yahfa/include/trampoline.h +++ b/core/src/main/cpp/external/yahfa/include/trampoline.h @@ -8,7 +8,7 @@ extern "C" { #endif extern int SDKVersion; -extern int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; +extern size_t OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; extern unsigned int hookCap; // capacity for trampolines extern unsigned int hookCount; // current count of used trampolines diff --git a/core/src/main/cpp/external/yahfa/src/HookMain.cpp b/core/src/main/cpp/external/yahfa/src/HookMain.cpp index e7d0372d..65aeec29 100644 --- a/core/src/main/cpp/external/yahfa/src/HookMain.cpp +++ b/core/src/main/cpp/external/yahfa/src/HookMain.cpp @@ -8,10 +8,10 @@ #include "HookMain.h" int SDKVersion; -static int OFFSET_entry_point_from_interpreter_in_ArtMethod; -int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; -static int OFFSET_ArtMehod_in_Object; -static int OFFSET_access_flags_in_ArtMethod; +static size_t OFFSET_entry_point_from_interpreter_in_ArtMethod; +size_t OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; +static size_t OFFSET_ArtMehod_in_Object; +static size_t OFFSET_access_flags_in_ArtMethod; static size_t ArtMethodSize; static uint32_t kAccCompileDontBother = 0x01000000; static uint32_t kAccPublic = 0x0001; // class, field, method, ic diff --git a/core/src/main/cpp/main/src/context.cpp b/core/src/main/cpp/main/src/context.cpp index ffd5eed1..92b6155f 100644 --- a/core/src/main/cpp/main/src/context.cpp +++ b/core/src/main/cpp/main/src/context.cpp @@ -33,6 +33,8 @@ #include "service.h" namespace lspd { + extern int *allowUnload; + constexpr int FIRST_ISOLATED_UID = 99000; constexpr int LAST_ISOLATED_UID = 99999; constexpr int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000; @@ -167,6 +169,7 @@ namespace lspd { Context::OnNativeForkSystemServerPre(JNIEnv *env) { Service::instance()->InitService(env); skip_ = false; + setAllowUnload(false); } void @@ -180,6 +183,7 @@ namespace lspd { Init(env); FindAndCall(env, "forkSystemServerPost", "(Landroid/os/IBinder;)V", binder); } + setAllowUnload(false); } void Context::OnNativeForkAndSpecializePre(JNIEnv *env, @@ -208,6 +212,7 @@ namespace lspd { skip_ = true; LOGI("skip injecting into %s because it's isolated", process_name.get()); } + setAllowUnload(skip_); } void @@ -224,10 +229,18 @@ namespace lspd { app_data_dir_, nice_name_, binder); LOGD("injected xposed into %s", process_name.get()); + setAllowUnload(false); } else { auto context = Context::ReleaseInstance(); auto service = Service::ReleaseInstance(); LOGD("skipped %s", process_name.get()); + setAllowUnload(true); + } + } + + void Context::setAllowUnload(bool unload) { + if (allowUnload) { + *allowUnload = unload ? 1 : 0; } } } diff --git a/core/src/main/cpp/main/src/context.h b/core/src/main/cpp/main/src/context.h index fa06516d..5ab9b744 100644 --- a/core/src/main/cpp/main/src/context.h +++ b/core/src/main/cpp/main/src/context.h @@ -80,6 +80,7 @@ namespace lspd { static jclass FindClassFromLoader(JNIEnv *env, jobject class_loader, std::string_view class_name); + static void setAllowUnload(bool unload); friend std::unique_ptr std::make_unique(); }; diff --git a/core/src/main/cpp/main/src/main.cpp b/core/src/main/cpp/main/src/main.cpp index 2a0039f0..15365d77 100644 --- a/core/src/main/cpp/main/src/main.cpp +++ b/core/src/main/cpp/main/src/main.cpp @@ -29,6 +29,8 @@ #include "symbol_cache.h" namespace lspd { + int *allowUnload = nullptr; + namespace { std::string magiskPath; @@ -39,10 +41,6 @@ namespace lspd { InitSymbolCache(); } - int shouldSkipUid(int) { - return 0; - } - void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *, jintArray *, jint *, jobjectArray *, jint *, @@ -103,7 +101,6 @@ namespace lspd { .version = RIRU_MODULE_VERSION, .versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME), .onModuleLoaded = lspd::onModuleLoaded, - .shouldSkipUid = lspd::shouldSkipUid, .forkAndSpecializePre = lspd::nativeForkAndSpecializePre, .forkAndSpecializePost = lspd::nativeForkAndSpecializePost, .forkSystemServerPre = lspd::nativeForkSystemServerPre, @@ -118,6 +115,7 @@ __attribute__((noinline)) RIRU_EXPORT RiruVersionedModuleInfo *init(Riru *riru) LOGD("Using riru %d", riru->riruApiVersion); LOGD("module path: %s", riru->magiskModulePath); lspd::magiskPath = riru->magiskModulePath; + lspd::allowUnload = riru->allowUnload; return &lspd::module; }