diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h b/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h index 335ba750..2a2dbf2d 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/class_linker.h @@ -120,8 +120,10 @@ namespace art { HOOK_FUNC(FixupStaticTrampolines, "_ZN3art11ClassLinker22FixupStaticTrampolinesENS_6ObjPtrINS_6mirror5ClassEEE"); + // Sandhook will hook ShouldUseInterpreterEntrypoint, so we just skip + // edxp::Context::GetInstance()->GetVariant() will not work here, so we use smh dirty hack if (api_level >= __ANDROID_API_R__ && - edxp::Context::GetInstance()->GetVariant() != edxp::Variant::SANDHOOK) { + access(edxp::kLibSandHookNativePath.c_str(), F_OK) == -1) { LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv"); HOOK_FUNC(ShouldUseInterpreterEntrypoint, "_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv"); diff --git a/edxp-core/src/main/cpp/main/include/config.h b/edxp-core/src/main/cpp/main/include/config.h index 772cfb48..33b70734 100644 --- a/edxp-core/src/main/cpp/main/include/config.h +++ b/edxp-core/src/main/cpp/main/include/config.h @@ -37,12 +37,15 @@ inline constexpr bool is64 = Is64(); static const auto kLibArtName = "libart.so"s; static const auto kLibFwName = "libandroidfw.so"s; static const auto kLibSandHookName = "libsandhook.edxp.so"s; + static const auto kLibDlName = "libdl.so"s; + static const auto kLibSandHookNativeName = "libsandhook-native.so"s; static const auto kLibBasePath = LP_SELECT("/system/lib/"s, "/system/lib64/"s); static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName; + static const auto kLibSandHookNativePath = kLibBasePath + kLibSandHookNativeName; static const auto kLibFwPath = kLibBasePath + kLibFwName; inline constexpr const char *const BoolToString(bool b) { diff --git a/edxp-core/template_override/customize.sh b/edxp-core/template_override/customize.sh index da7a9200..95f06f3e 100644 --- a/edxp-core/template_override/customize.sh +++ b/edxp-core/template_override/customize.sh @@ -246,6 +246,7 @@ else ui_print "- Extracting arm libraries" extract "$ZIPFILE" 'system/lib/libriru_edxp.so' "$MODPATH" if [[ "${VARIANTS}" == "SandHook" ]]; then + extract "$ZIPFILE" 'system/lib/libsandhook-native.so' "$MODPATH" extract "$ZIPFILE" 'system/lib/libsandhook.edxp.so' "$MODPATH" fi @@ -253,6 +254,7 @@ else ui_print "- Extracting arm64 libraries" extract "$ZIPFILE" 'system/lib64/libriru_edxp.so' "$MODPATH" if [[ "${VARIANTS}" == "SandHook" ]]; then + extract "$ZIPFILE" 'system/lib64/libsandhook-native.so' "$MODPATH" extract "$ZIPFILE" 'system/lib64/libsandhook.edxp.so' "$MODPATH" fi fi diff --git a/edxp-sandhook/template_override/system/lib/libsandhook-native.so b/edxp-sandhook/template_override/system/lib/libsandhook-native.so new file mode 100644 index 00000000..34a2ce0f Binary files /dev/null and b/edxp-sandhook/template_override/system/lib/libsandhook-native.so differ diff --git a/edxp-sandhook/template_override/system/lib64/libsandhook-native.so b/edxp-sandhook/template_override/system/lib64/libsandhook-native.so new file mode 100644 index 00000000..1d64ee53 Binary files /dev/null and b/edxp-sandhook/template_override/system/lib64/libsandhook-native.so differ