Merge libsandhook.so into core so to reduce binary size
This commit is contained in:
parent
c508cb382f
commit
cca7ae0067
|
|
@ -152,7 +152,6 @@ afterEvaluate {
|
||||||
|
|
||||||
def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}", type: Delete) {
|
def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}", type: Delete) {
|
||||||
dependsOn "assemble${variantCapped}"
|
dependsOn "assemble${variantCapped}"
|
||||||
dependsOn tasks.getByPath(":sandhook-hooklib:copySandHook${variantCapped}LibraryToMagiskTemplate")
|
|
||||||
dependsOn tasks.getByPath(":key-selector:copyKeySelector${variantCapped}LibraryToMagiskTemplate")
|
dependsOn tasks.getByPath(":key-selector:copyKeySelector${variantCapped}LibraryToMagiskTemplate")
|
||||||
doFirst {
|
doFirst {
|
||||||
copy {
|
copy {
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,7 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_subdirectory(Dobby)
|
add_subdirectory(Dobby)
|
||||||
target_include_directories(dobby PUBLIC Dobby/include)
|
target_include_directories(dobby PUBLIC Dobby/include)
|
||||||
target_include_directories(dobby PUBLIC Dobby/builtin-plugin/BionicLinkerRestriction)
|
target_include_directories(dobby PUBLIC Dobby/builtin-plugin/BionicLinkerRestriction)
|
||||||
|
|
||||||
|
add_subdirectory(SandHook)
|
||||||
|
target_include_directories(sandhook.lspd PUBLIC SandHook)
|
||||||
|
|
@ -5,6 +5,7 @@ ENABLE_LANGUAGE(ASM)
|
||||||
|
|
||||||
add_definitions(-std=c++11)
|
add_definitions(-std=c++11)
|
||||||
|
|
||||||
|
if (${CMAKE_ANDROID_ARCH_ABI} STREQUAL armeabi-v7a OR ${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a)
|
||||||
set(${PROJECT_NAME}_SOURCES
|
set(${PROJECT_NAME}_SOURCES
|
||||||
sandhook.cpp
|
sandhook.cpp
|
||||||
trampoline/trampoline.cpp
|
trampoline/trampoline.cpp
|
||||||
|
|
@ -25,9 +26,11 @@ set(${PROJECT_NAME}_SOURCES
|
||||||
inst/insts_arm64.cpp
|
inst/insts_arm64.cpp
|
||||||
nativehook/native_hook.cpp
|
nativehook/native_hook.cpp
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
set(${PROJECT_NAME}_SOURCES dummy.cpp)
|
||||||
|
endif()
|
||||||
add_library(${PROJECT_NAME}
|
add_library(${PROJECT_NAME}
|
||||||
SHARED
|
STATIC
|
||||||
${${PROJECT_NAME}_SOURCES})
|
${${PROJECT_NAME}_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} log)
|
target_link_libraries(${PROJECT_NAME} log)
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
//
|
||||||
|
// Created by Kotori0 on 2021/1/30.
|
||||||
|
//
|
||||||
|
#include "sandhook.h"
|
||||||
|
#include "includes/log.h"
|
||||||
|
|
||||||
|
bool JNI_Load_Ex(JNIEnv* env, jclass classSandHook, jclass classNeverCall) {
|
||||||
|
LOGE("Sandhook: Unsupported platform.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -547,8 +547,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||||
return JNI_VERSION_1_6;
|
return JNI_VERSION_1_6;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
bool JNI_Load_Ex(JNIEnv* env, jclass classSandHook, jclass classNeverCall) {
|
||||||
JNIEXPORT bool JNI_Load_Ex(JNIEnv* env, jclass classSandHook, jclass classNeverCall) {
|
|
||||||
int jniMethodSize = sizeof(JNINativeMethod);
|
int jniMethodSize = sizeof(JNINativeMethod);
|
||||||
|
|
||||||
if (env == nullptr || classSandHook == nullptr || classNeverCall == nullptr)
|
if (env == nullptr || classSandHook == nullptr || classNeverCall == nullptr)
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Created by Kotori0 on 2021/1/29.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EDXPOSED_SANDHOOK_H
|
||||||
|
#define EDXPOSED_SANDHOOK_H
|
||||||
|
#include <jni.h>
|
||||||
|
bool JNI_Load_Ex(JNIEnv* env, jclass classSandHook, jclass classNeverCall);
|
||||||
|
#endif //EDXPOSED_SANDHOOK_H
|
||||||
|
|
@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 3.4.1)
|
||||||
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -fvisibility=hidden")
|
||||||
|
|
||||||
aux_source_directory(src SRC_LIST)
|
add_library(yahfa STATIC src/HookMain.cpp src/trampoline.c)
|
||||||
add_library(yahfa STATIC ${SRC_LIST})
|
|
||||||
|
|
||||||
find_library(log-lib log)
|
find_library(log-lib log)
|
||||||
target_link_libraries(yahfa ${log-lib})
|
target_link_libraries(yahfa ${log-lib})
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ jboolean Java_lab_galaxy_yahfa_HookMain_backupAndHookNative(JNIEnv *env, jclass
|
||||||
|
|
||||||
void setNonCompilable(void *method);
|
void setNonCompilable(void *method);
|
||||||
|
|
||||||
void *getArtMethod(JNIEnv *env, jobject jmethod);
|
void *getArtMethodYahfa(JNIEnv *env, jobject jmethod);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#ifndef YAHFA_TAMPOLINE_H
|
#ifndef YAHFA_TAMPOLINE_H
|
||||||
#define YAHFA_TAMPOLINE_H
|
#define YAHFA_TAMPOLINE_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
extern int SDKVersion;
|
extern int SDKVersion;
|
||||||
extern int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
|
extern int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
|
||||||
|
|
||||||
|
|
@ -18,5 +20,7 @@ void setupTrampoline();
|
||||||
void *genTrampoline(void *hookMethod);
|
void *genTrampoline(void *hookMethod);
|
||||||
|
|
||||||
#define DEFAULT_CAP 1 //size of each trampoline area would be no more than 4k Bytes(one page)
|
#define DEFAULT_CAP 1 //size of each trampoline area would be no more than 4k Bytes(one page)
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif //YAHFA_TAMPOLINE_H
|
#endif //YAHFA_TAMPOLINE_H
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "trampoline.h"
|
#include "trampoline.h"
|
||||||
|
|
@ -21,7 +20,7 @@ static uint32_t kAccProtected = 0x0004; // field, method, ic
|
||||||
static uint32_t kAccStatic = 0x0008; // field, method, ic
|
static uint32_t kAccStatic = 0x0008; // field, method, ic
|
||||||
|
|
||||||
|
|
||||||
static jfieldID fieldArtMethod = NULL;
|
static jfieldID fieldArtMethod = nullptr;
|
||||||
|
|
||||||
static inline uint32_t read32(void *addr) {
|
static inline uint32_t read32(void *addr) {
|
||||||
return *((uint32_t *) addr);
|
return *((uint32_t *) addr);
|
||||||
|
|
@ -39,14 +38,14 @@ static inline void writeAddr(void *addr, void *value) {
|
||||||
*((void **) addr) = value;
|
*((void **) addr) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion) {
|
extern "C" void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion) {
|
||||||
SDKVersion = sdkVersion;
|
SDKVersion = sdkVersion;
|
||||||
jclass classExecutable;
|
jclass classExecutable;
|
||||||
LOGI("init to SDK %d", sdkVersion);
|
LOGI("init to SDK %d", sdkVersion);
|
||||||
switch (sdkVersion) {
|
switch (sdkVersion) {
|
||||||
case __ANDROID_API_R__:
|
case __ANDROID_API_R__:
|
||||||
classExecutable = (*env)->FindClass(env, "java/lang/reflect/Executable");
|
classExecutable = env->FindClass("java/lang/reflect/Executable");
|
||||||
fieldArtMethod = (*env)->GetFieldID(env, classExecutable, "artMethod", "J");
|
fieldArtMethod = env->GetFieldID(classExecutable, "artMethod", "J");
|
||||||
case __ANDROID_API_Q__:
|
case __ANDROID_API_Q__:
|
||||||
case __ANDROID_API_P__:
|
case __ANDROID_API_P__:
|
||||||
kAccCompileDontBother = 0x02000000;
|
kAccCompileDontBother = 0x02000000;
|
||||||
|
|
@ -188,63 +187,61 @@ static int doBackupAndHook(JNIEnv *env, void *targetMethod, void *hookMethod, vo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *getArtMethod(JNIEnv *env, jobject jmethod) {
|
void *getArtMethodYahfa(JNIEnv *env, jobject jmethod) {
|
||||||
void *artMethod = NULL;
|
void *artMethod = nullptr;
|
||||||
|
|
||||||
if (jmethod == NULL) {
|
if (jmethod == nullptr) {
|
||||||
return artMethod;
|
return artMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDKVersion == __ANDROID_API_R__) {
|
if (SDKVersion == __ANDROID_API_R__) {
|
||||||
artMethod = (void *) (*env)->GetLongField(env, jmethod, fieldArtMethod);
|
artMethod = (void *) env->GetLongField(jmethod, fieldArtMethod);
|
||||||
} else {
|
} else {
|
||||||
artMethod = (void *) (*env)->FromReflectedMethod(env, jmethod);
|
artMethod = (void *) env->FromReflectedMethod(jmethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("ArtMethod: %p", artMethod);
|
LOGI("ArtMethod: %p", artMethod);
|
||||||
return artMethod;
|
return artMethod;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject Java_lab_galaxy_yahfa_HookMain_findMethodNative(JNIEnv *env, jclass clazz,
|
extern "C" jobject Java_lab_galaxy_yahfa_HookMain_findMethodNative(JNIEnv *env, jclass clazz,
|
||||||
jclass targetClass, jstring methodName,
|
jclass targetClass, jstring methodName,
|
||||||
jstring methodSig) {
|
jstring methodSig) {
|
||||||
const char *c_methodName = (*env)->GetStringUTFChars(env, methodName, NULL);
|
const char *c_methodName = env->GetStringUTFChars(methodName, nullptr);
|
||||||
const char *c_methodSig = (*env)->GetStringUTFChars(env, methodSig, NULL);
|
const char *c_methodSig = env->GetStringUTFChars(methodSig, nullptr);
|
||||||
jobject ret = NULL;
|
jobject ret = nullptr;
|
||||||
|
|
||||||
|
|
||||||
//Try both GetMethodID and GetStaticMethodID -- Whatever works :)
|
//Try both GetMethodID and GetStaticMethodID -- Whatever works :)
|
||||||
jmethodID method = (*env)->GetMethodID(env, targetClass, c_methodName, c_methodSig);
|
jmethodID method = env->GetMethodID(targetClass, c_methodName, c_methodSig);
|
||||||
if (!(*env)->ExceptionCheck(env)) {
|
if (!env->ExceptionCheck()) {
|
||||||
ret = (*env)->ToReflectedMethod(env, targetClass, method, JNI_FALSE);
|
ret = env->ToReflectedMethod(targetClass, method, JNI_FALSE);
|
||||||
} else {
|
} else {
|
||||||
(*env)->ExceptionClear(env);
|
env->ExceptionClear();
|
||||||
method = (*env)->GetStaticMethodID(env, targetClass, c_methodName, c_methodSig);
|
method = env->GetStaticMethodID(targetClass, c_methodName, c_methodSig);
|
||||||
if (!(*env)->ExceptionCheck(env)) {
|
if (!env->ExceptionCheck()) {
|
||||||
ret = (*env)->ToReflectedMethod(env, targetClass, method, JNI_TRUE);
|
ret = env->ToReflectedMethod(targetClass, method, JNI_TRUE);
|
||||||
} else {
|
} else {
|
||||||
(*env)->ExceptionClear(env);
|
env->ExceptionClear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*env)->ReleaseStringUTFChars(env, methodName, c_methodName);
|
env->ReleaseStringUTFChars(methodName, c_methodName);
|
||||||
(*env)->ReleaseStringUTFChars(env, methodSig, c_methodSig);
|
env->ReleaseStringUTFChars(methodSig, c_methodSig);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean Java_lab_galaxy_yahfa_HookMain_backupAndHookNative(JNIEnv *env, jclass clazz,
|
extern "C" jboolean Java_lab_galaxy_yahfa_HookMain_backupAndHookNative(JNIEnv *env, jclass clazz,
|
||||||
jobject target, jobject hook,
|
jobject target, jobject hook,
|
||||||
jobject backup) {
|
jobject backup) {
|
||||||
|
|
||||||
if (!doBackupAndHook(env,
|
if (!doBackupAndHook(env,
|
||||||
getArtMethod(env, target),
|
getArtMethodYahfa(env, target),
|
||||||
getArtMethod(env, hook),
|
getArtMethodYahfa(env, hook),
|
||||||
getArtMethod(env, backup)
|
getArtMethodYahfa(env, backup)
|
||||||
)) {
|
)) {
|
||||||
(*env)->NewGlobalRef(env,
|
env->NewGlobalRef(hook); // keep a global ref so that the hook method would not be GCed
|
||||||
hook); // keep a global ref so that the hook method would not be GCed
|
if (backup) env->NewGlobalRef(backup);
|
||||||
if (backup) (*env)->NewGlobalRef(env, backup);
|
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
} else {
|
} else {
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
|
|
@ -9,4 +9,4 @@ add_library(riru_lspd SHARED ${SRC_LIST} ${SRC_JNI_LIST})
|
||||||
|
|
||||||
find_package(riru REQUIRED CONFIG)
|
find_package(riru REQUIRED CONFIG)
|
||||||
find_library(log-lib log)
|
find_library(log-lib log)
|
||||||
target_link_libraries(riru_lspd yahfa riru::riru xhook android dobby ${log-lib})
|
target_link_libraries(riru_lspd yahfa riru::riru xhook android dobby sandhook.lspd ${log-lib})
|
||||||
|
|
@ -63,13 +63,6 @@ namespace lspd {
|
||||||
return misc_path_ / "cache" / suffix;
|
return misc_path_ / "cache" / suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static auto GetLibSandHookName() {
|
|
||||||
if constexpr(lspd::is64)
|
|
||||||
return GetFrameworkPath("lib64/libsandhook.lspd.so");
|
|
||||||
else
|
|
||||||
return GetFrameworkPath("lib/libsandhook.lspd.so");
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto GetConfigPath(const std::string &suffix = {}) const {
|
inline auto GetConfigPath(const std::string &suffix = {}) const {
|
||||||
return base_config_path_ / "conf" / suffix;
|
return base_config_path_ / "conf" / suffix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <nativehelper/scoped_local_ref.h>
|
#include <nativehelper/scoped_local_ref.h>
|
||||||
#include <jni/pending_hooks.h>
|
#include <jni/pending_hooks.h>
|
||||||
|
#include <sandhook.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
|
@ -126,25 +127,19 @@ namespace lspd {
|
||||||
RegisterPendingHooks(env);
|
RegisterPendingHooks(env);
|
||||||
|
|
||||||
variant_ = Variant(ConfigManager::GetInstance()->GetVariant());
|
variant_ = Variant(ConfigManager::GetInstance()->GetVariant());
|
||||||
// LOGI("EdxpVariant: %d", variant_);
|
LOGI("LSP Variant: %d", variant_);
|
||||||
|
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
|
||||||
if (variant_ == SANDHOOK) {
|
if (variant_ == SANDHOOK) {
|
||||||
//for SandHook variant
|
//for SandHook variant
|
||||||
ScopedDlHandle sandhook_handle(ConfigManager::GetLibSandHookName().c_str());
|
|
||||||
if (!sandhook_handle.IsValid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
typedef bool *(*TYPE_JNI_LOAD)(JNIEnv *, jclass, jclass);
|
|
||||||
auto jni_load = sandhook_handle.DlSym<TYPE_JNI_LOAD>("JNI_Load_Ex");
|
|
||||||
ScopedLocalRef sandhook_class(env, FindClassFromLoader(env, kSandHookClassName));
|
ScopedLocalRef sandhook_class(env, FindClassFromLoader(env, kSandHookClassName));
|
||||||
ScopedLocalRef nevercall_class(env,
|
ScopedLocalRef nevercall_class(env,
|
||||||
FindClassFromLoader(env, kSandHookNeverCallClassName));
|
FindClassFromLoader(env, kSandHookNeverCallClassName));
|
||||||
if (sandhook_class == nullptr || nevercall_class == nullptr) { // fail-fast
|
if (sandhook_class == nullptr || nevercall_class == nullptr) { // fail-fast
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!jni_load(env, sandhook_class.get(), nevercall_class.get())) {
|
if (!JNI_Load_Ex(env, sandhook_class.get(), nevercall_class.get())) {
|
||||||
LOGE("SandHook: HookEntry class error. %d", getpid());
|
LOGE("SandHook: HookEntry class error. %d", getpid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace lspd {
|
||||||
static std::unordered_set<void *> deopted_methods;
|
static std::unordered_set<void *> deopted_methods;
|
||||||
|
|
||||||
static void ClassLinker_setEntryPointsToInterpreter(JNI_START, jobject method) {
|
static void ClassLinker_setEntryPointsToInterpreter(JNI_START, jobject method) {
|
||||||
void *reflected_method = getArtMethod(env, method);
|
void *reflected_method = getArtMethodYahfa(env, method);
|
||||||
if (deopted_methods.count(reflected_method)) {
|
if (deopted_methods.count(reflected_method)) {
|
||||||
LOGD("method %p has been deopted before, skip...", reflected_method);
|
LOGD("method %p has been deopted before, skip...", reflected_method);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,6 @@ namespace lspd {
|
||||||
return env->NewStringUTF(ConfigManager::GetInstance()->GetInstallerPackageName().c_str());
|
return env->NewStringUTF(ConfigManager::GetInstance()->GetInstallerPackageName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static jstring ConfigManager_getLibSandHookName(JNI_START) {
|
|
||||||
return env->NewStringUTF(ConfigManager::GetLibSandHookName().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
static jstring ConfigManager_getDataPathPrefix(JNI_START) {
|
static jstring ConfigManager_getDataPathPrefix(JNI_START) {
|
||||||
return env->NewStringUTF(ConfigManager::GetInstance()->GetDataPathPrefix().c_str());
|
return env->NewStringUTF(ConfigManager::GetInstance()->GetDataPathPrefix().c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +67,6 @@ namespace lspd {
|
||||||
NATIVE_METHOD(ConfigManager, isResourcesHookEnabled, "()Z"),
|
NATIVE_METHOD(ConfigManager, isResourcesHookEnabled, "()Z"),
|
||||||
NATIVE_METHOD(ConfigManager, isNoModuleLogEnabled, "()Z"),
|
NATIVE_METHOD(ConfigManager, isNoModuleLogEnabled, "()Z"),
|
||||||
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
|
NATIVE_METHOD(ConfigManager, getInstallerPackageName, "()Ljava/lang/String;"),
|
||||||
NATIVE_METHOD(ConfigManager, getLibSandHookName, "()Ljava/lang/String;"),
|
|
||||||
NATIVE_METHOD(ConfigManager, getDataPathPrefix, "()Ljava/lang/String;"),
|
NATIVE_METHOD(ConfigManager, getDataPathPrefix, "()Ljava/lang/String;"),
|
||||||
NATIVE_METHOD(ConfigManager, getPrefsPath,
|
NATIVE_METHOD(ConfigManager, getPrefsPath,
|
||||||
"(Ljava/lang/String;)Ljava/lang/String;"),
|
"(Ljava/lang/String;)Ljava/lang/String;"),
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace lspd {
|
||||||
|
|
||||||
static void PendingHooks_recordPendingMethodNative(JNI_START, jobject method_ref, jclass class_ref) {
|
static void PendingHooks_recordPendingMethodNative(JNI_START, jobject method_ref, jclass class_ref) {
|
||||||
auto *class_ptr = art::Thread::Current().DecodeJObject(class_ref);
|
auto *class_ptr = art::Thread::Current().DecodeJObject(class_ref);
|
||||||
auto *method = getArtMethod(env, method_ref);
|
auto *method = getArtMethodYahfa(env, method_ref);
|
||||||
art::mirror::Class mirror_class(class_ptr);
|
art::mirror::Class mirror_class(class_ptr);
|
||||||
if (auto def = mirror_class.GetClassDef(); LIKELY(def)) {
|
if (auto def = mirror_class.GetClassDef(); LIKELY(def)) {
|
||||||
LOGD("record pending: %p (%s) with %p", class_ptr, mirror_class.GetDescriptor().c_str(), method);
|
LOGD("record pending: %p (%s) with %p", class_ptr, mirror_class.GetDescriptor().c_str(), method);
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ namespace lspd {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Yahfa_recordHooked(JNI_START, jobject member) {
|
static void Yahfa_recordHooked(JNI_START, jobject member) {
|
||||||
lspd::recordHooked(getArtMethod(env, member));
|
lspd::recordHooked(getArtMethodYahfa(env, member));
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean Yahfa_isHooked(JNI_START, jobject member) {
|
static jboolean Yahfa_isHooked(JNI_START, jobject member) {
|
||||||
return lspd::isHooked(getArtMethod(env, member));
|
return lspd::isHooked(getArtMethodYahfa(env, member));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod gMethods[] = {
|
static JNINativeMethod gMethods[] = {
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ public class ConfigManager {
|
||||||
|
|
||||||
public static native String getInstallerPackageName();
|
public static native String getInstallerPackageName();
|
||||||
|
|
||||||
public static native String getLibSandHookName();
|
|
||||||
|
|
||||||
public static native String getPrefsPath(String suffix);
|
public static native String getPrefsPath(String suffix);
|
||||||
|
|
||||||
public static native String getCachePath(String suffix);
|
public static native String getCachePath(String suffix);
|
||||||
|
|
|
||||||
|
|
@ -120,13 +120,7 @@ public final class SandHookXposedBridge {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
if (Process.is64Bit()) {
|
SandHookConfig.libSandHookPath = "";
|
||||||
// SandHookConfig.libSandHookPath = "/system/lib64/libsandhook.lspd.so";
|
|
||||||
SandHookConfig.libSandHookPath = "/system/lib64/" + ConfigManager.getLibSandHookName();
|
|
||||||
} else {
|
|
||||||
// SandHookConfig.libSandHookPath = "/system/lib/libsandhook.lspd.so";
|
|
||||||
SandHookConfig.libSandHookPath = "/system/lib/" + ConfigManager.getLibSandHookName();
|
|
||||||
}
|
|
||||||
SandHookConfig.libLoader = new SandHookConfig.LibLoader() {
|
SandHookConfig.libLoader = new SandHookConfig.LibLoader() {
|
||||||
@Override
|
@Override
|
||||||
public void loadLib() {
|
public void loadLib() {
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,6 @@ VERSION=$(grep_prop version "${TMPDIR}/module.prop")
|
||||||
RIRU_MIN_API_VERSION=$(grep_prop api "${TMPDIR}/module.prop")
|
RIRU_MIN_API_VERSION=$(grep_prop api "${TMPDIR}/module.prop")
|
||||||
|
|
||||||
LIB_RIRU_EDXP="libriru_${RIRU_EDXP}.so"
|
LIB_RIRU_EDXP="libriru_${RIRU_EDXP}.so"
|
||||||
LIB_SANDHOOK_EDXP="lib$(getRandomNameExist 13 "lib" ".so" "
|
|
||||||
/system/lib
|
|
||||||
/system/lib64
|
|
||||||
").so"
|
|
||||||
|
|
||||||
### lang start ###
|
### lang start ###
|
||||||
# Default en_US
|
# Default en_US
|
||||||
|
|
@ -187,12 +183,10 @@ if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
|
||||||
else
|
else
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
|
||||||
extract "$ZIPFILE" 'system/lib/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'system/lib/libriru_lspd.so' "${MODPATH}"
|
||||||
extract "$ZIPFILE" 'system/lib/libsandhook.lspd.so' "${MODPATH}"
|
|
||||||
|
|
||||||
if [ "$IS64BIT" = true ]; then
|
if [ "$IS64BIT" = true ]; then
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
|
||||||
extract "$ZIPFILE" 'system/lib64/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'system/lib64/libriru_lspd.so' "${MODPATH}"
|
||||||
extract "$ZIPFILE" 'system/lib64/libsandhook.lspd.so' "${MODPATH}"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -246,9 +240,9 @@ set_perm /data/misc/$MISC_PATH root root 0771 "u:object_r:magisk_file:s0" || abo
|
||||||
echo "[[ -f /data/adb/lspd/keep_data ]] || rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
echo "[[ -f /data/adb/lspd/keep_data ]] || rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||||
echo "[[ -f /data/adb/lspd/new_install ]] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
echo "[[ -f /data/adb/lspd/new_install ]] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||||
|
|
||||||
if [ $VARIANT == 17 ]; then
|
if [ $VARIANT == 17 ]; then # YAHFA
|
||||||
echo "1" > /data/misc/$MISC_PATH/variant
|
echo "1" > /data/misc/$MISC_PATH/variant
|
||||||
elif [ $VARIANT == 18 ]; then
|
elif [ $VARIANT == 18 ]; then # SandHook
|
||||||
echo "2" > /data/misc/$MISC_PATH/variant
|
echo "2" > /data/misc/$MISC_PATH/variant
|
||||||
else
|
else
|
||||||
abortC "${LANG_UTIL_ERR_VARIANT_UNSUPPORT} ${VARIANT}"
|
abortC "${LANG_UTIL_ERR_VARIANT_UNSUPPORT} ${VARIANT}"
|
||||||
|
|
@ -261,10 +255,8 @@ mv "${MODPATH}/system/framework" "/data/misc/$MISC_PATH/framework"
|
||||||
|
|
||||||
|
|
||||||
mkdir -p "/data/misc/$MISC_PATH/framework/lib"
|
mkdir -p "/data/misc/$MISC_PATH/framework/lib"
|
||||||
mv "${MODPATH}/system/lib/libsandhook.lspd.so" "/data/misc/$MISC_PATH/framework/lib/libsandhook.lspd.so"
|
|
||||||
if [ "$IS64BIT" = true ]; then
|
if [ "$IS64BIT" = true ]; then
|
||||||
mkdir -p "/data/misc/$MISC_PATH/framework/lib64"
|
mkdir -p "/data/misc/$MISC_PATH/framework/lib64"
|
||||||
mv "${MODPATH}/system/lib64/libsandhook.lspd.so" "/data/misc/$MISC_PATH/framework/lib64/libsandhook.lspd.so"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_perm_recursive /data/misc/$MISC_PATH/framework root root 0755 0644 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
|
set_perm_recursive /data/misc/$MISC_PATH/framework root root 0755 0644 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
|
||||||
|
|
|
||||||
|
|
@ -9,23 +9,9 @@ android {
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
//arguments "-DCMAKE_BUILD_TYPE=Release"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ndk {
|
|
||||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
|
||||||
}
|
|
||||||
consumerProguardFiles 'proguard-rules.pro'
|
consumerProguardFiles 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
path "src/main/cpp/CMakeLists.txt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
|
|
@ -38,28 +24,4 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
api project(':sandhook-annotation')
|
api project(':sandhook-annotation')
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
android.libraryVariants.all { variant ->
|
|
||||||
def variantNameCapped = variant.name.capitalize()
|
|
||||||
def variantNameLowered = variant.name.toLowerCase()
|
|
||||||
|
|
||||||
task("copySandHook${variantNameCapped}LibraryToMagiskTemplate") {
|
|
||||||
def libPathRelease = "${buildDir}/intermediates/cmake/${variantNameLowered}/obj"
|
|
||||||
doLast {
|
|
||||||
copy {
|
|
||||||
include "libsandhook.lspd.so"
|
|
||||||
from "${libPathRelease}/armeabi-v7a"
|
|
||||||
into "${zipPathMagiskReleasePath}/system/lib"
|
|
||||||
}
|
|
||||||
copy {
|
|
||||||
include "libsandhook.lspd.so"
|
|
||||||
from "${libPathRelease}/arm64-v8a"
|
|
||||||
into "${zipPathMagiskReleasePath}/system/lib64"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue