diff --git a/core/src/main/cpp/external/SandHook/includes/arch.h b/core/src/main/cpp/external/SandHook/includes/arch.h index d3843971..cbc52ccc 100644 --- a/core/src/main/cpp/external/SandHook/includes/arch.h +++ b/core/src/main/cpp/external/SandHook/includes/arch.h @@ -44,5 +44,6 @@ static void clearCacheArm32(char* begin, char *end) #define ANDROID_P 28 #define ANDROID_Q 29 #define ANDROID_R 30 +#define ANDROID_S 31 #endif //SANDHOOK_ARCH_H \ No newline at end of file diff --git a/core/src/main/cpp/external/yahfa/src/HookMain.cpp b/core/src/main/cpp/external/yahfa/src/HookMain.cpp index b567f214..e87d1e94 100644 --- a/core/src/main/cpp/external/yahfa/src/HookMain.cpp +++ b/core/src/main/cpp/external/yahfa/src/HookMain.cpp @@ -43,6 +43,16 @@ extern "C" void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, j jclass classExecutable; LOGI("init to SDK %d", sdkVersion); switch (sdkVersion) { + case __ANDROID_API_S__: + classExecutable = env->FindClass("java/lang/reflect/Executable"); + fieldArtMethod = env->GetFieldID(classExecutable, "artMethod", "J"); + kAccCompileDontBother = 0x02000000; + OFFSET_ArtMehod_in_Object = 0; + OFFSET_access_flags_in_ArtMethod = 4; + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod = + roundUpToPtrSize(4 * 3 + 2 * 2) + pointer_size; + ArtMethodSize = roundUpToPtrSize(4 * 3 + 2 * 2) + pointer_size * 2; + break; case __ANDROID_API_R__: classExecutable = env->FindClass("java/lang/reflect/Executable"); fieldArtMethod = env->GetFieldID(classExecutable, "artMethod", "J"); @@ -194,7 +204,7 @@ void *getArtMethodYahfa(JNIEnv *env, jobject jmethod) { return artMethod; } - if (SDKVersion == __ANDROID_API_R__) { + if (SDKVersion >= __ANDROID_API_R__) { artMethod = (void *) env->GetLongField(jmethod, fieldArtMethod); } else { artMethod = (void *) env->FromReflectedMethod(jmethod); diff --git a/core/src/main/cpp/main/include/art/runtime/class_linker.h b/core/src/main/cpp/main/include/art/runtime/class_linker.h index 15565fff..662116c8 100644 --- a/core/src/main/cpp/main/include/art/runtime/class_linker.h +++ b/core/src/main/cpp/main/include/art/runtime/class_linker.h @@ -130,6 +130,7 @@ namespace art { LOGE("No valid offset for art::Runtime::class_linker_ found. Using Android R."); [[fallthrough]]; case __ANDROID_API_R__: + case __ANDROID_API_S__: if constexpr(lspd::is64) { OFFSET_classlinker = 472; } else { diff --git a/core/src/main/cpp/main/src/native_api.cpp b/core/src/main/cpp/main/src/native_api.cpp index 57d8c905..a33d2b2f 100644 --- a/core/src/main/cpp/main/src/native_api.cpp +++ b/core/src/main/cpp/main/src/native_api.cpp @@ -107,8 +107,8 @@ namespace lspd { }); void InstallNativeAPI() { - LOGD("InstallNativeAPI: %p", symbol_do_dlopen); symbol_do_dlopen = DobbySymbolResolver(nullptr, "__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv"); + LOGD("InstallNativeAPI: %p", symbol_do_dlopen); HookSymNoHandle(symbol_do_dlopen, do_dlopen); } } \ No newline at end of file diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java index d01d8d10..637e00be 100644 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java +++ b/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java @@ -53,8 +53,11 @@ public class SandHookImpl extends BaseImpl { @Override public void init() { - SandHook.init(ClassNeverCall.class, com.swift.sandhook.SandHook.class); - Yahfa.init(Build.VERSION.SDK_INT); + int sdkVersion = Build.VERSION.SDK_INT; + if (Build.VERSION.PREVIEW_SDK_INT != 0) { + sdkVersion += 1; + } + Yahfa.init(sdkVersion); getRouter().injectConfig(); SandHookXposedBridge.init(); setInitialized(); diff --git a/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java b/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java index b74500f3..8a7be367 100644 --- a/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java +++ b/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java @@ -47,7 +47,11 @@ public class YahfaImpl extends BaseImpl { @Override public void init() { - Yahfa.init(Build.VERSION.SDK_INT); + int sdkVersion = Build.VERSION.SDK_INT; + if (Build.VERSION.PREVIEW_SDK_INT != 0) { + sdkVersion += 1; + } + Yahfa.init(sdkVersion); getRouter().injectConfig(); setInitialized(); }