[core] Support Riru 25 (#367)

This commit is contained in:
LoveSy 2021-03-17 08:08:30 +08:00 committed by GitHub
parent 3071023864
commit 55248342fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 14 deletions

View File

@ -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"))

View File

@ -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

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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<Context> std::make_unique<Context>();
};

View File

@ -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;
}