Riru v22 support
This commit is contained in:
parent
e9c03a8f37
commit
1ea3c22e1c
|
|
@ -34,6 +34,10 @@ ext {
|
|||
|
||||
riruModuleId = "edxp"
|
||||
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
|
||||
|
||||
moduleMinRiruApiVersion = 9
|
||||
moduleMinRiruVersionName = "v22.0"
|
||||
moduleMaxRiruApiVersion = 9
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
@ -47,6 +51,9 @@ android {
|
|||
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
|
||||
cppFlags "-std=c++17 -ffixed-x18 -Qunused-arguments -frtti"
|
||||
cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti"
|
||||
arguments "-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion",
|
||||
"-DRIRU_MODULE_VERSION=$buildVersionCode",
|
||||
"-DRIRU_MODULE_VERSION_NAME:STRING=\"$buildVersionName\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +81,7 @@ android {
|
|||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version "3.10.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,22 +156,35 @@ afterEvaluate {
|
|||
versionCode: "$versionCode", authorList: "$authorList")
|
||||
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
copy {
|
||||
from "${projectDir}/tpl/riru_module.prop.tpl"
|
||||
into "$templateRootPath/riru"
|
||||
rename "riru_module.prop.tpl", "module.prop.new"
|
||||
expand(minApi: "$moduleMinRiruApiVersion",
|
||||
versionName: "$version" + " ($backend)",
|
||||
versionCode: "$versionCode", authorList: "$authorList")
|
||||
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
}
|
||||
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
|
||||
doLast {
|
||||
copy {
|
||||
from "${projectDir}/template_override"
|
||||
into zipPathMagiskRelease
|
||||
exclude 'riru.sh'
|
||||
}
|
||||
copy {
|
||||
from "${projectDir}/template_override"
|
||||
into zipPathMagiskRelease
|
||||
include 'riru.sh'
|
||||
filter { line ->
|
||||
line.replaceAll('%%%RIRU_MODULE_ID%%%', riruModuleId)
|
||||
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', moduleMinRiruApiVersion.toString())
|
||||
.replaceAll('%%%RIRU_MIN_VERSION_NAME%%%', moduleMinRiruVersionName)
|
||||
}
|
||||
filter(FixCrLfFilter.class,
|
||||
eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
// copy {
|
||||
// from "${projectDir}/template_override/util_functions.sh"
|
||||
// into "${zipPathMagiskRelease}/"
|
||||
// filter { line -> line
|
||||
// .replaceAll('%VERSION%', "$version")
|
||||
// .replaceAll('%VERSION_CODE%', "$versionCode")
|
||||
// .replaceAll('%BACKEND%', "$backendCapped") }
|
||||
// filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
// }
|
||||
copy {
|
||||
from "$libPathRelease/armeabi-v7a"
|
||||
into "$zipPathMagiskRelease/system/lib"
|
||||
|
|
|
|||
|
|
@ -2,5 +2,10 @@ cmake_minimum_required(VERSION 3.4.1)
|
|||
|
||||
link_libraries("-ffixed-x18")
|
||||
|
||||
add_definitions(-DRIRU_MODULE)
|
||||
add_definitions(-DRIRU_MODULE_API_VERSION=${RIRU_MODULE_API_VERSION})
|
||||
add_definitions(-DRIRU_MODULE_VERSION=${RIRU_MODULE_VERSION})
|
||||
add_definitions(-DRIRU_MODULE_VERSION_NAME=${RIRU_MODULE_VERSION_NAME})
|
||||
|
||||
add_subdirectory(main)
|
||||
add_subdirectory(external)
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
#include <dlfcn.h>
|
||||
#include <memory.h>
|
||||
#include <jni.h>
|
||||
|
||||
#ifdef __LP64__
|
||||
#define LIB "/system/lib64/libmemtrack.so"
|
||||
#else
|
||||
#define LIB "/system/lib/libmemtrack.so"
|
||||
#endif
|
||||
|
||||
static void *riru_handle;
|
||||
static char *riru_module_name;
|
||||
|
||||
static void *get_handle() {
|
||||
if (riru_handle == NULL)
|
||||
riru_handle = dlopen(LIB, RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
return riru_handle;
|
||||
}
|
||||
|
||||
const char *riru_get_module_name() {
|
||||
return riru_module_name;
|
||||
}
|
||||
|
||||
void riru_set_module_name(const char *name) {
|
||||
riru_module_name = strdup(name);
|
||||
}
|
||||
|
||||
int riru_get_version() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return -1;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_version");
|
||||
if (sym) return ((int (*)()) sym)();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *riru_get_func(const char *name) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return NULL;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_func");
|
||||
if (sym) return ((void *(*)(const char *, const char *)) sym)(riru_get_module_name(), name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *riru_get_native_method_func(const char *className, const char *name, const char *signature) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return NULL;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_native_method_func");
|
||||
if (sym)
|
||||
return ((void *(*)(const char *, const char *, const char *, const char *)) sym)(
|
||||
riru_get_module_name(), className, name, signature);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void riru_set_func(const char *name, void *func) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_set_func");
|
||||
if (sym)
|
||||
((void *(*)(const char *, const char *, void *)) sym)(riru_get_module_name(), name, func);
|
||||
}
|
||||
|
||||
void riru_set_native_method_func(const char *className, const char *name, const char *signature,
|
||||
void *func) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_set_native_method_func");
|
||||
if (sym)
|
||||
((void *(*)(const char *, const char *, const char *, const char *, void *)) sym)(
|
||||
riru_get_module_name(), className, name, signature, func);
|
||||
}
|
||||
|
||||
const JNINativeMethod *riru_get_original_native_methods(const char *className, const char *name,
|
||||
const char *signature) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return NULL;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_original_native_methods");
|
||||
if (sym)
|
||||
return ((JNINativeMethod *(*)(const char *, const char *, const char *)) sym)
|
||||
(className, name, signature);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int riru_is_zygote_methods_replaced() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_is_zygote_methods_replaced");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int riru_get_nativeForkAndSpecialize_calls_count() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_nativeForkAndSpecialize_calls_count");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int riru_get_nativeForkSystemServer_calls_count() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_nativeForkSystemServer_calls_count");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,93 +1,169 @@
|
|||
#ifndef RIRU_H
|
||||
#define RIRU_H
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
__attribute__((visibility("default"))) void riru_set_module_name(const char *name);
|
||||
|
||||
/**
|
||||
* Get Riru version.
|
||||
*
|
||||
* @return Riru version
|
||||
*/
|
||||
int riru_get_version();
|
||||
#include <stdint.h>
|
||||
#include <jni.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
typedef void(onModuleLoaded_v9)();
|
||||
|
||||
typedef int(shouldSkipUid_v9)(int uid);
|
||||
|
||||
typedef void(nativeForkAndSpecializePre_v9)(
|
||||
JNIEnv *env, jclass cls, jint *uid, jint *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
|
||||
jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
|
||||
jstring *instructionSet, jstring *appDataDir, jboolean *isTopApp, jobjectArray *pkgDataInfoList,
|
||||
jobjectArray *whitelistedDataInfoList, jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs);
|
||||
|
||||
typedef void(nativeForkAndSpecializePost_v9)(JNIEnv *env, jclass cls, jint res);
|
||||
|
||||
typedef void(nativeForkSystemServerPre_v9)(
|
||||
JNIEnv *env, jclass cls, uid_t *uid, gid_t *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jlong *permittedCapabilities, jlong *effectiveCapabilities);
|
||||
|
||||
typedef void(nativeForkSystemServerPost_v9)(JNIEnv *env, jclass cls, jint res);
|
||||
|
||||
typedef void(nativeSpecializeAppProcessPre_v9)(
|
||||
JNIEnv *env, jclass cls, jint *uid, jint *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
|
||||
jboolean *startChildZygote, jstring *instructionSet, jstring *appDataDir,
|
||||
jboolean *isTopApp, jobjectArray *pkgDataInfoList, jobjectArray *whitelistedDataInfoList,
|
||||
jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs);
|
||||
|
||||
typedef void(nativeSpecializeAppProcessPost_v9)(JNIEnv *env, jclass cls);
|
||||
|
||||
typedef struct {
|
||||
int supportHide;
|
||||
int version;
|
||||
const char *versionName;
|
||||
onModuleLoaded_v9 *onModuleLoaded;
|
||||
shouldSkipUid_v9 *shouldSkipUid;
|
||||
nativeForkAndSpecializePre_v9 *forkAndSpecializePre;
|
||||
nativeForkAndSpecializePost_v9 *forkAndSpecializePost;
|
||||
nativeForkSystemServerPre_v9 *forkSystemServerPre;
|
||||
nativeForkSystemServerPost_v9 *forkSystemServerPost;
|
||||
nativeSpecializeAppProcessPre_v9 *specializeAppProcessPre;
|
||||
nativeSpecializeAppProcessPost_v9 *specializeAppProcessPost;
|
||||
} RiruModuleInfoV9;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
typedef void *(RiruGetFunc_v9)(uint32_t token, const char *name);
|
||||
|
||||
typedef void (RiruSetFunc_v9)(uint32_t token, const char *name, void *func);
|
||||
|
||||
typedef void *(RiruGetJNINativeMethodFunc_v9)(uint32_t token, const char *className, const char *name, const char *signature);
|
||||
|
||||
typedef void (RiruSetJNINativeMethodFunc_v9)(uint32_t token, const char *className, const char *name, const char *signature, void *func);
|
||||
|
||||
typedef const JNINativeMethod *(RiruGetOriginalJNINativeMethodFunc_v9)(const char *className, const char *name, const char *signature);
|
||||
|
||||
typedef void *(RiruGetGlobalValue_v9)(const char *key);
|
||||
|
||||
typedef void(RiruPutGlobalValue_v9)(const char *key, void *value);
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint32_t token;
|
||||
RiruGetFunc_v9 *getFunc;
|
||||
RiruGetJNINativeMethodFunc_v9 *getJNINativeMethodFunc;
|
||||
RiruSetFunc_v9 *setFunc;
|
||||
RiruSetJNINativeMethodFunc_v9 *setJNINativeMethodFunc;
|
||||
RiruGetOriginalJNINativeMethodFunc_v9 *getOriginalJNINativeMethodFunc;
|
||||
RiruGetGlobalValue_v9 *getGlobalValue;
|
||||
RiruPutGlobalValue_v9 *putGlobalValue;
|
||||
} RiruApiV9;
|
||||
|
||||
typedef void *(RiruInit_t)(void *);
|
||||
|
||||
#ifdef RIRU_MODULE
|
||||
#define RIRU_EXPORT __attribute__((visibility("default"))) __attribute__((used))
|
||||
|
||||
/*
|
||||
* Get new_func address from last module which hook func.
|
||||
* Use this as your old_func if you want to hook func.
|
||||
* Init will be called three times.
|
||||
*
|
||||
* The first time:
|
||||
* Returns the highest version number supported by both Riru and the module.
|
||||
*
|
||||
* arg: (int *) Riru's API version
|
||||
* returns: (int *) the highest possible API version
|
||||
*
|
||||
* The second time:
|
||||
* Returns the RiruModuleX struct created by the module (X is the return of the first call).
|
||||
*
|
||||
* arg: (RiruApiVX *) RiruApi strcut, this pointer can be saved for further use
|
||||
* returns: (RiruModuleX *) RiruModule strcut
|
||||
*
|
||||
* The second time:
|
||||
* Let the module to cleanup (such as RiruModuleX struct created before).
|
||||
*
|
||||
* arg: null
|
||||
* returns: (ignored)
|
||||
*
|
||||
* @param name a unique name
|
||||
* @return new_func from last module or null
|
||||
*/
|
||||
void *riru_get_func(const char *name);
|
||||
void* init(void *arg) RIRU_EXPORT;
|
||||
|
||||
/*
|
||||
* Java native version of riru_get_func.
|
||||
*
|
||||
* @param className class name
|
||||
* @param name method name
|
||||
* @param signature method signature
|
||||
* @return new_func address from last module or original address
|
||||
*/
|
||||
void *riru_get_native_method_func(const char *className, const char *name, const char *signature);
|
||||
extern int riru_api_version;
|
||||
extern RiruApiV9 *riru_api_v9;
|
||||
|
||||
/*
|
||||
* Set new_func address for next module which wants to hook func.
|
||||
*
|
||||
* @param name a unique name
|
||||
* @param func your new_func address
|
||||
*/
|
||||
void riru_set_func(const char *name, void *func);
|
||||
inline void *riru_get_func(const char *name) {
|
||||
if (riru_api_version == 9) {
|
||||
return riru_api_v9->getFunc(riru_api_v9->token, name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Java native method version of riru_set_func.
|
||||
*
|
||||
* @param className class name
|
||||
* @param name method name
|
||||
* @param signature method signature
|
||||
* @param func your new_func address
|
||||
*/
|
||||
void riru_set_native_method_func(const char *className, const char *name, const char *signature,
|
||||
void *func);
|
||||
inline void *riru_get_native_method_func(const char *className, const char *name, const char *signature) {
|
||||
if (riru_api_version == 9) {
|
||||
return riru_api_v9->getJNINativeMethodFunc(riru_api_v9->token, className, name, signature);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get native methods from Riru's jniRegisterNativeMethods hook.
|
||||
* If both name and signature are null, all the class's methods will be returned.
|
||||
*
|
||||
* @param className className
|
||||
* @param name method name, null for the method with specific signature
|
||||
* @param signature method signature, null for the method with specific name
|
||||
* @return JNINativeMethod*
|
||||
*/
|
||||
const JNINativeMethod *riru_get_original_native_methods(const char *className, const char *name,
|
||||
const char *signature);
|
||||
inline const JNINativeMethod *riru_get_original_native_methods(const char *className, const char *name, const char *signature) {
|
||||
if (riru_api_version == 9) {
|
||||
return riru_api_v9->getOriginalJNINativeMethodFunc(className, name, signature);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if Zygote class's native method nativeForkAndSpecialize & nativeForkSystemServer is replaced by
|
||||
* Riru.
|
||||
*
|
||||
* @return methods replaced
|
||||
*/
|
||||
int riru_is_zygote_methods_replaced();
|
||||
inline void riru_set_func(const char *name, void *func) {
|
||||
if (riru_api_version == 9) {
|
||||
riru_api_v9->setFunc(riru_api_v9->token, name, func);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return calls count of Zygote class's native method nativeForkAndSpecialize replaced by Riru.
|
||||
*
|
||||
* @return nativeForkAndSpecialize calls count
|
||||
*/
|
||||
int riru_get_nativeForkAndSpecialize_calls_count();
|
||||
inline void riru_set_native_method_func(const char *className, const char *name, const char *signature,
|
||||
void *func) {
|
||||
if (riru_api_version == 9) {
|
||||
riru_api_v9->setJNINativeMethodFunc(riru_api_v9->token, className, name, signature, func);
|
||||
}
|
||||
}
|
||||
|
||||
inline void *riru_get_global_value(const char *key) {
|
||||
if (riru_api_version == 9) {
|
||||
return riru_api_v9->getGlobalValue(key);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void riru_put_global_value(const char *key, void *value) {
|
||||
if (riru_api_version == 9) {
|
||||
riru_api_v9->putGlobalValue(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return calls count of Zygote class native's method nativeForkSystemServer replaced by Riru.
|
||||
*
|
||||
* @return nativeForkAndSpecialize calls count
|
||||
*/
|
||||
int riru_get_nativeForkSystemServer_calls_count();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif //RIRU_H
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#define LOGW(...)
|
||||
#define LOGE(...)
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
||||
#else
|
||||
#define LOGD(...)
|
||||
|
|
|
|||
|
|
@ -15,34 +15,31 @@
|
|||
#include "logging.h"
|
||||
#include "config.h"
|
||||
#include "edxp_context.h"
|
||||
#include "riru.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-value"
|
||||
|
||||
#define EXPORT extern "C" __attribute__((visibility("default")))
|
||||
|
||||
namespace edxp {
|
||||
|
||||
// TODO exclude unrelated processes
|
||||
EXPORT void onModuleLoaded() {
|
||||
static void onModuleLoaded() {
|
||||
LOG(INFO) << "onModuleLoaded: welcome to EdXposed!";
|
||||
InstallInlineHooks();
|
||||
}
|
||||
|
||||
EXPORT int shouldSkipUid(int uid) {
|
||||
static int shouldSkipUid(int uid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT void nativeForkAndSpecializePre(JNIEnv *env, jclass clazz, jint *_uid, jint *gid,
|
||||
static void nativeForkAndSpecializePre(JNIEnv *env, jclass clazz, jint *_uid, jint *gid,
|
||||
jintArray *gids, jint *runtime_flags,
|
||||
jobjectArray *rlimits, jint *mount_external,
|
||||
jstring *se_info, jstring *nice_name,
|
||||
jintArray *fds_to_close, jintArray *fds_to_ignore,
|
||||
jboolean *start_child_zygote, jstring *instruction_set,
|
||||
jstring *app_data_dir,
|
||||
/* parameters added in Android Q */
|
||||
jstring *package_name, jobjectArray *packages_for_uid,
|
||||
jstring *sandbox_id) {
|
||||
jstring *app_data_dir, jboolean *is_top_app, jobjectArray *pkg_data_info_list,
|
||||
jobjectArray *whitelisted_data_info_list, jboolean *bind_mount_app_data_dirs,
|
||||
jboolean *bind_mount_app_storage_dirs) {
|
||||
Context::GetInstance()->OnNativeForkAndSpecializePre(env, clazz, *_uid, *gid, *gids,
|
||||
*runtime_flags, *rlimits,
|
||||
*mount_external, *se_info, *nice_name,
|
||||
|
|
@ -52,11 +49,11 @@ namespace edxp {
|
|||
*app_data_dir);
|
||||
}
|
||||
|
||||
EXPORT int nativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
|
||||
return Context::GetInstance()->OnNativeForkAndSpecializePost(env, clazz, res);
|
||||
static void nativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
|
||||
Context::GetInstance()->OnNativeForkAndSpecializePost(env, clazz, res);
|
||||
}
|
||||
|
||||
EXPORT void nativeForkSystemServerPre(JNIEnv *env, jclass clazz, uid_t *uid, gid_t *gid,
|
||||
static void nativeForkSystemServerPre(JNIEnv *env, jclass clazz, uid_t *uid, gid_t *gid,
|
||||
jintArray *gids, jint *runtime_flags,
|
||||
jobjectArray *rlimits, jlong *permitted_capabilities,
|
||||
jlong *effective_capabilities) {
|
||||
|
|
@ -67,17 +64,18 @@ namespace edxp {
|
|||
);
|
||||
}
|
||||
|
||||
EXPORT int nativeForkSystemServerPost(JNIEnv *env, jclass clazz, jint res) {
|
||||
return Context::GetInstance()->OnNativeForkSystemServerPost(env, clazz, res);
|
||||
static void nativeForkSystemServerPost(JNIEnv *env, jclass clazz, jint res) {
|
||||
Context::GetInstance()->OnNativeForkSystemServerPost(env, clazz, res);
|
||||
}
|
||||
|
||||
/* method added in Android Q */
|
||||
EXPORT void specializeAppProcessPre(JNIEnv *env, jclass clazz, jint *uid, jint *gid,
|
||||
static void specializeAppProcessPre(JNIEnv *env, jclass clazz, jint *uid, jint *gid,
|
||||
jintArray *gids, jint *runtime_flags, jobjectArray *rlimits,
|
||||
jint *mount_external, jstring *se_info, jstring *nice_name,
|
||||
jboolean *start_child_zygote, jstring *instruction_set,
|
||||
jstring *app_data_dir, jstring *package_name,
|
||||
jobjectArray *packages_for_uid, jstring *sandbox_id) {
|
||||
jstring *app_data_dir, jboolean *is_top_app, jobjectArray *pkg_data_info_list,
|
||||
jobjectArray *whitelisted_data_info_list, jboolean *bind_mount_app_data_dirs,
|
||||
jboolean *bind_mount_app_storage_dirs) {
|
||||
Context::GetInstance()->OnNativeForkAndSpecializePre(env, clazz, *uid, *gid, *gids,
|
||||
*runtime_flags, *rlimits,
|
||||
*mount_external, *se_info, *nice_name,
|
||||
|
|
@ -86,10 +84,62 @@ namespace edxp {
|
|||
*app_data_dir);
|
||||
}
|
||||
|
||||
EXPORT int specializeAppProcessPost(JNIEnv *env, jclass clazz) {
|
||||
return Context::GetInstance()->OnNativeForkAndSpecializePost(env, clazz, 0);
|
||||
static void specializeAppProcessPost(JNIEnv *env, jclass clazz) {
|
||||
Context::GetInstance()->OnNativeForkAndSpecializePost(env, clazz, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int riru_api_version;
|
||||
RiruApiV9 *riru_api_v9;
|
||||
|
||||
RIRU_EXPORT void *init(void *arg) {
|
||||
static int step = 0;
|
||||
step += 1;
|
||||
|
||||
static void *_module;
|
||||
|
||||
switch (step) {
|
||||
case 1: {
|
||||
auto core_max_api_version = *(int *) arg;
|
||||
riru_api_version = core_max_api_version <= RIRU_MODULE_API_VERSION ? core_max_api_version : RIRU_MODULE_API_VERSION;
|
||||
return &riru_api_version;
|
||||
}
|
||||
case 2: {
|
||||
switch (riru_api_version) {
|
||||
case 9: {
|
||||
riru_api_v9 = (RiruApiV9 *) arg;
|
||||
|
||||
auto module = (RiruModuleInfoV9 *) malloc(sizeof(RiruModuleInfoV9));
|
||||
memset(module, 0, sizeof(RiruModuleInfoV9));
|
||||
_module = module;
|
||||
|
||||
module->supportHide = false;
|
||||
|
||||
module->version = RIRU_MODULE_VERSION;
|
||||
module->versionName = RIRU_MODULE_VERSION_NAME;
|
||||
module->onModuleLoaded = edxp::onModuleLoaded;
|
||||
module->shouldSkipUid = edxp::shouldSkipUid;
|
||||
module->forkAndSpecializePre = edxp::nativeForkAndSpecializePre;
|
||||
module->forkAndSpecializePost = edxp::nativeForkAndSpecializePost;
|
||||
module->specializeAppProcessPre = edxp::specializeAppProcessPre;
|
||||
module->specializeAppProcessPost = edxp::specializeAppProcessPost;
|
||||
module->forkSystemServerPre = edxp::nativeForkSystemServerPre;
|
||||
module->forkSystemServerPost = edxp::nativeForkSystemServerPost;
|
||||
return module;
|
||||
}
|
||||
default: {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 3: {
|
||||
free(_module);
|
||||
return nullptr;
|
||||
}
|
||||
default: {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
|
@ -3,13 +3,11 @@
|
|||
|
||||
#define XHOOK_REGISTER(NAME) \
|
||||
if (xhook_register(".*", #NAME, (void*) new_##NAME, (void **) &old_##NAME) == 0) { \
|
||||
if (riru_get_version() >= 8) { \
|
||||
void *f = riru_get_func(#NAME); \
|
||||
if (f != nullptr) { \
|
||||
memcpy(&old_##NAME, &f, sizeof(void *)); \
|
||||
} \
|
||||
riru_set_func(#NAME, (void *) new_##NAME); \
|
||||
void *f = riru_get_func(#NAME); \
|
||||
if (f != nullptr) { \
|
||||
memcpy(&old_##NAME, &f, sizeof(void *)); \
|
||||
} \
|
||||
riru_set_func(#NAME, (void *) new_##NAME); \
|
||||
} else { \
|
||||
LOGE("failed to register riru hook " #NAME "."); \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ getRandomNameExist() {
|
|||
fi
|
||||
}
|
||||
|
||||
RIRU_PATH="/data/misc/riru"
|
||||
RIRU_PATH="/data/adb/riru"
|
||||
RIRU_EDXP="$(getRandomNameExist 4 "libriru_" ".so" "
|
||||
/system/lib
|
||||
/system/lib64
|
||||
|
|
@ -114,21 +114,6 @@ update_new_magisk() {
|
|||
ui_print "******************************"
|
||||
}
|
||||
|
||||
require_riru() {
|
||||
ui_print "******************************"
|
||||
ui_print "! Requirement module 'Riru - Core' is not installed"
|
||||
ui_print "! You can download from 'Magisk Manager' or https://github.com/RikkaApps/Riru/releases"
|
||||
abortC "******************************"
|
||||
}
|
||||
|
||||
require_new_riru() {
|
||||
ui_print "******************************"
|
||||
ui_print "! Old Riru ${1} (below v19) detected"
|
||||
ui_print "! The latest version of 'Riru - Core' is required"
|
||||
ui_print "! You can download from 'Magisk Manager' or https://github.com/RikkaApps/Riru/releases"
|
||||
abortC "******************************"
|
||||
}
|
||||
|
||||
require_yahfa() {
|
||||
ui_print "******************************"
|
||||
ui_print "! Architecture x86 or x86_64 detected"
|
||||
|
|
@ -193,18 +178,6 @@ check_magisk_version() {
|
|||
[[ ${MAGISK_VER_CODE} -eq 20101 ]] && update_new_magisk
|
||||
}
|
||||
|
||||
check_riru_version() {
|
||||
if [[ ! -f "${RIRU_PATH}/api_version" ]] && [[ ! -f "${RIRU_PATH}/api_version.new" ]]; then
|
||||
require_riru
|
||||
fi
|
||||
RIRU_API_VERSION=$(cat "${RIRU_PATH}/api_version.new") || RIRU_API_VERSION=$(cat "${RIRU_PATH}/api_version") || RIRU_API_VERSION=0
|
||||
[[ "${RIRU_API_VERSION}" -eq "${RIRU_API_VERSION}" ]] || RIRU_API_VERSION=0
|
||||
ui_print "- Riru API version: ${RIRU_API_VERSION}"
|
||||
if [[ "${RIRU_API_VERSION}" -lt ${RIRU_MIN_API_VERSION} ]]; then
|
||||
require_new_riru ${RIRU_API_VERSION}
|
||||
fi
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
if [[ "${MODID}" == "riru_edxposed_sandhook" ]]; then
|
||||
VARIANTS="SandHook"
|
||||
|
|
@ -238,6 +211,10 @@ check_android_version() {
|
|||
# fi
|
||||
#}
|
||||
|
||||
# extract riru.sh
|
||||
unzip -o "$ZIPFILE" riru.sh -d "$MODPATH" >&2
|
||||
. $MODPATH/riru.sh
|
||||
|
||||
ui_print "- EdXposed Version ${VERSION}"
|
||||
|
||||
#check_persist
|
||||
|
|
@ -338,6 +315,17 @@ if [[ -e "${RIRU_MODULES}/edxp" ]]; then
|
|||
rm -rf "${RIRU_MODULES}/edxp"
|
||||
fi
|
||||
|
||||
# extract Riru files
|
||||
ui_print "- Extracting Riru files"
|
||||
ui_print $RIRU_TARGET
|
||||
[ -d "$RIRU_TARGET" ] || mkdir -p "$RIRU_TARGET" || abort "! Can't create $RIRU_TARGET"
|
||||
|
||||
rm -f "$RIRU_TARGET/module.prop.new"
|
||||
unzip -o "$ZIPFILE" 'riru/module.prop.new' -d "$RIRU_TARGET" >&2
|
||||
mv "$RIRU_TARGET/riru/module.prop.new" "$RIRU_TARGET/module.prop"
|
||||
rm -rf "$RIRU_TARGET/riru/"
|
||||
set_perm "$RIRU_TARGET/module.prop" 0 0 0600 $RIRU_SECONTEXT
|
||||
|
||||
ui_print "- Copying extra files"
|
||||
|
||||
[[ -d "${RIRU_TARGET}" ]] || mkdir -p "${RIRU_TARGET}" || abort "! Can't mkdir -p ${RIRU_TARGET}"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
name=Riru - EdXposed
|
||||
version=v0.5.0.6 (YAHFA)
|
||||
versionCode=233
|
||||
author=solohsu, MlgmXyysd & rk700
|
||||
description=Another enhanced implementation of Xposed Framework. Supports Android 8.0, 8.1, 9, 10 or above. Requires Riru - Core v19 or above installed. Telegram: @EdXposed
|
||||
minApi=9
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#!/sbin/sh
|
||||
RIRU_PATH="/data/adb/riru"
|
||||
RIRU_MODULE_ID="%%%RIRU_MODULE_ID%%%"
|
||||
RIRU_MODULE_PATH="$RIRU_PATH/modules/$RIRU_MODULE_ID"
|
||||
RIRU_SECONTEXT="u:object_r:magisk_file:s0"
|
||||
|
||||
check_riru_version() {
|
||||
RIRU_MIN_API_VERSION=%%%RIRU_MIN_API_VERSION%%%
|
||||
RIRU_MIN_VERSION_NAME="%%%RIRU_MIN_VERSION_NAME%%%"
|
||||
|
||||
if [ ! -f "$RIRU_PATH/api_version" ] && [ ! -f "$RIRU_PATH/api_version.new" ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Riru is not installed"
|
||||
ui_print "! Please install Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version.new") || RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version") || RIRU_API_VERSION=0
|
||||
[ "$RIRU_API_VERSION" -eq "$RIRU_API_VERSION" ] || RIRU_API_VERSION=0
|
||||
ui_print "- Riru API version: $RIRU_API_VERSION"
|
||||
if [ "$RIRU_API_VERSION" -lt $RIRU_MIN_API_VERSION ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Riru $RIRU_MIN_VERSION_NAME or above is required"
|
||||
ui_print "! Please upgrade Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
if [ "$ARCH" != "arm" ] && [ "$ARCH" != "arm64" ] && [ "$ARCH" != "x86" ] && [ "$ARCH" != "x64" ]; then
|
||||
abort "! Unsupported platform: $ARCH"
|
||||
else
|
||||
ui_print "- Device platform: $ARCH"
|
||||
fi
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
name=Riru - EdXposed
|
||||
version=v0.5.0.6 (YAHFA)
|
||||
versionCode=233
|
||||
author=solohsu, MlgmXyysd & rk700
|
||||
description=Another enhanced implementation of Xposed Framework. Supports Android 8.0, 8.1, 9, 10 or above. Requires Riru - Core v19 or above installed. Telegram: @EdXposed
|
||||
minApi=9
|
||||
|
|
@ -14,6 +14,11 @@ fi
|
|||
|
||||
if [[ "${REMOVE}" == true ]]; then
|
||||
rm -rf /data/misc/riru/modules/edxp
|
||||
if [[ -f "/data/adb/riru/modules/edxp.prop" ]]; then
|
||||
OLD_CONFIG=$(cat "/data/adb/riru/modules/edxp.prop")
|
||||
rm -rf "/data/adb/riru/modules/${OLD_CONFIG}"
|
||||
rm "/data/adb/riru/modules/edxp.prop"
|
||||
fi
|
||||
if [[ -f "/data/misc/riru/modules/edxp.prop" ]]; then
|
||||
OLD_CONFIG=$(cat "/data/misc/riru/modules/edxp.prop")
|
||||
rm -rf "/data/misc/riru/modules/${OLD_CONFIG}"
|
||||
|
|
|
|||
|
|
@ -4,4 +4,3 @@ version=${versionName}
|
|||
versionCode=${versionCode}
|
||||
author=${authorList}
|
||||
description=Another enhanced implementation of Xposed Framework. Supports Android 8.0, 8.1, 9, 10 or above. Requires Riru - Core v19 or above installed. Telegram: @EdXposed
|
||||
api=4
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
name=Riru - EdXposed
|
||||
version=${versionName}
|
||||
versionCode=${versionCode}
|
||||
author=${authorList}
|
||||
description=Another enhanced implementation of Xposed Framework. Supports Android 8.0, 8.1, 9, 10 or above. Requires Riru - Core v19 or above installed. Telegram: @EdXposed
|
||||
minApi=${minApi}
|
||||
Loading…
Reference in New Issue