[core] Support Riru 25 (#367)
This commit is contained in:
parent
3071023864
commit
55248342fc
|
|
@ -42,9 +42,9 @@ val moduleId = "riru_lsposed"
|
||||||
val authors = "LSPosed Developers"
|
val authors = "LSPosed Developers"
|
||||||
|
|
||||||
val riruModuleId = "lsposed"
|
val riruModuleId = "lsposed"
|
||||||
val moduleMinRiruApiVersion = 24
|
val moduleMinRiruApiVersion = 25
|
||||||
val moduleMinRiruVersionName = "v24.1.0"
|
val moduleMinRiruVersionName = "25.0.0"
|
||||||
val moduleMaxRiruApiVersion = 24
|
val moduleMaxRiruApiVersion = 25
|
||||||
|
|
||||||
val defaultManagerPackageName: String by rootProject.extra
|
val defaultManagerPackageName: String by rootProject.extra
|
||||||
val apiCode: Int 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
|
val verName: String by rootProject.extra
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("dev.rikka.ndk:riru:24.0.0")
|
implementation("dev.rikka.ndk:riru:${moduleMinRiruVersionName}")
|
||||||
implementation(files("libs/dobby_prefab.aar"))
|
implementation(files("libs/dobby_prefab.aar"))
|
||||||
implementation("com.android.tools.build:apksig:4.1.2")
|
implementation("com.android.tools.build:apksig:4.1.2")
|
||||||
compileOnly(project(":hiddenapi-stubs"))
|
compileOnly(project(":hiddenapi-stubs"))
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
extern int SDKVersion;
|
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 hookCap; // capacity for trampolines
|
||||||
extern unsigned int hookCount; // current count of used trampolines
|
extern unsigned int hookCount; // current count of used trampolines
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@
|
||||||
#include "HookMain.h"
|
#include "HookMain.h"
|
||||||
|
|
||||||
int SDKVersion;
|
int SDKVersion;
|
||||||
static int OFFSET_entry_point_from_interpreter_in_ArtMethod;
|
static size_t OFFSET_entry_point_from_interpreter_in_ArtMethod;
|
||||||
int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
|
size_t OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
|
||||||
static int OFFSET_ArtMehod_in_Object;
|
static size_t OFFSET_ArtMehod_in_Object;
|
||||||
static int OFFSET_access_flags_in_ArtMethod;
|
static size_t OFFSET_access_flags_in_ArtMethod;
|
||||||
static size_t ArtMethodSize;
|
static size_t ArtMethodSize;
|
||||||
static uint32_t kAccCompileDontBother = 0x01000000;
|
static uint32_t kAccCompileDontBother = 0x01000000;
|
||||||
static uint32_t kAccPublic = 0x0001; // class, field, method, ic
|
static uint32_t kAccPublic = 0x0001; // class, field, method, ic
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
|
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
|
extern int *allowUnload;
|
||||||
|
|
||||||
constexpr int FIRST_ISOLATED_UID = 99000;
|
constexpr int FIRST_ISOLATED_UID = 99000;
|
||||||
constexpr int LAST_ISOLATED_UID = 99999;
|
constexpr int LAST_ISOLATED_UID = 99999;
|
||||||
constexpr int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000;
|
constexpr int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000;
|
||||||
|
|
@ -167,6 +169,7 @@ namespace lspd {
|
||||||
Context::OnNativeForkSystemServerPre(JNIEnv *env) {
|
Context::OnNativeForkSystemServerPre(JNIEnv *env) {
|
||||||
Service::instance()->InitService(env);
|
Service::instance()->InitService(env);
|
||||||
skip_ = false;
|
skip_ = false;
|
||||||
|
setAllowUnload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -180,6 +183,7 @@ namespace lspd {
|
||||||
Init(env);
|
Init(env);
|
||||||
FindAndCall(env, "forkSystemServerPost", "(Landroid/os/IBinder;)V", binder);
|
FindAndCall(env, "forkSystemServerPost", "(Landroid/os/IBinder;)V", binder);
|
||||||
}
|
}
|
||||||
|
setAllowUnload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::OnNativeForkAndSpecializePre(JNIEnv *env,
|
void Context::OnNativeForkAndSpecializePre(JNIEnv *env,
|
||||||
|
|
@ -208,6 +212,7 @@ namespace lspd {
|
||||||
skip_ = true;
|
skip_ = true;
|
||||||
LOGI("skip injecting into %s because it's isolated", process_name.get());
|
LOGI("skip injecting into %s because it's isolated", process_name.get());
|
||||||
}
|
}
|
||||||
|
setAllowUnload(skip_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -224,10 +229,18 @@ namespace lspd {
|
||||||
app_data_dir_, nice_name_,
|
app_data_dir_, nice_name_,
|
||||||
binder);
|
binder);
|
||||||
LOGD("injected xposed into %s", process_name.get());
|
LOGD("injected xposed into %s", process_name.get());
|
||||||
|
setAllowUnload(false);
|
||||||
} else {
|
} else {
|
||||||
auto context = Context::ReleaseInstance();
|
auto context = Context::ReleaseInstance();
|
||||||
auto service = Service::ReleaseInstance();
|
auto service = Service::ReleaseInstance();
|
||||||
LOGD("skipped %s", process_name.get());
|
LOGD("skipped %s", process_name.get());
|
||||||
|
setAllowUnload(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context::setAllowUnload(bool unload) {
|
||||||
|
if (allowUnload) {
|
||||||
|
*allowUnload = unload ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ namespace lspd {
|
||||||
|
|
||||||
static jclass FindClassFromLoader(JNIEnv *env, jobject class_loader,
|
static jclass FindClassFromLoader(JNIEnv *env, jobject class_loader,
|
||||||
std::string_view class_name);
|
std::string_view class_name);
|
||||||
|
static void setAllowUnload(bool unload);
|
||||||
|
|
||||||
friend std::unique_ptr<Context> std::make_unique<Context>();
|
friend std::unique_ptr<Context> std::make_unique<Context>();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include "symbol_cache.h"
|
#include "symbol_cache.h"
|
||||||
|
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
|
int *allowUnload = nullptr;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string magiskPath;
|
std::string magiskPath;
|
||||||
|
|
||||||
|
|
@ -39,10 +41,6 @@ namespace lspd {
|
||||||
InitSymbolCache();
|
InitSymbolCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
int shouldSkipUid(int) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
|
void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
|
||||||
jintArray *, jint *,
|
jintArray *, jint *,
|
||||||
jobjectArray *, jint *,
|
jobjectArray *, jint *,
|
||||||
|
|
@ -103,7 +101,6 @@ namespace lspd {
|
||||||
.version = RIRU_MODULE_VERSION,
|
.version = RIRU_MODULE_VERSION,
|
||||||
.versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME),
|
.versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME),
|
||||||
.onModuleLoaded = lspd::onModuleLoaded,
|
.onModuleLoaded = lspd::onModuleLoaded,
|
||||||
.shouldSkipUid = lspd::shouldSkipUid,
|
|
||||||
.forkAndSpecializePre = lspd::nativeForkAndSpecializePre,
|
.forkAndSpecializePre = lspd::nativeForkAndSpecializePre,
|
||||||
.forkAndSpecializePost = lspd::nativeForkAndSpecializePost,
|
.forkAndSpecializePost = lspd::nativeForkAndSpecializePost,
|
||||||
.forkSystemServerPre = lspd::nativeForkSystemServerPre,
|
.forkSystemServerPre = lspd::nativeForkSystemServerPre,
|
||||||
|
|
@ -118,6 +115,7 @@ __attribute__((noinline)) RIRU_EXPORT RiruVersionedModuleInfo *init(Riru *riru)
|
||||||
LOGD("Using riru %d", riru->riruApiVersion);
|
LOGD("Using riru %d", riru->riruApiVersion);
|
||||||
LOGD("module path: %s", riru->magiskModulePath);
|
LOGD("module path: %s", riru->magiskModulePath);
|
||||||
lspd::magiskPath = riru->magiskModulePath;
|
lspd::magiskPath = riru->magiskModulePath;
|
||||||
|
lspd::allowUnload = riru->allowUnload;
|
||||||
return &lspd::module;
|
return &lspd::module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue