From 782560ad96c5ec491188993bae618174b2712899 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 13 Sep 2020 23:23:34 +0800 Subject: [PATCH] Don't use sandhook on x86 devices --- edxp-core/src/main/cpp/main/include/config.h | 2 ++ edxp-core/src/main/cpp/main/src/native_hook.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/edxp-core/src/main/cpp/main/include/config.h b/edxp-core/src/main/cpp/main/include/config.h index b52d0754a..91dba559f 100644 --- a/edxp-core/src/main/cpp/main/include/config.h +++ b/edxp-core/src/main/cpp/main/include/config.h @@ -32,6 +32,7 @@ namespace edxp { static constexpr auto kLibFwName = "libandroidfw.so"; static constexpr auto kLibWhaleName = "libwhale.edxp.so"; static constexpr auto kLibSandHookName = "libsandhook.edxp.so"; + static constexpr auto kLibDlName = "libdl.so"; static constexpr auto kLibSandHookNativeName = "libsandhook-native.so"; static const auto kLibBasePath = std::string( @@ -41,6 +42,7 @@ namespace edxp { LP_SELECT("/apex/com.android.runtime/bin/linker", "/apex/com.android.runtime/bin/linker64")); + static const auto kLibDlPath = kLibBasePath + kLibDlName; static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; static const auto kLibWhalePath = kLibBasePath + kLibWhaleName; static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName; diff --git a/edxp-core/src/main/cpp/main/src/native_hook.cpp b/edxp-core/src/main/cpp/main/src/native_hook.cpp index b80eece5b..79e9bad07 100644 --- a/edxp-core/src/main/cpp/main/src/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/native_hook.cpp @@ -70,7 +70,13 @@ namespace edxp { hook_func = reinterpret_cast(hook_func_symbol); if (api_level >= __ANDROID_API_Q__) { +#if defined(__i386__) || defined(__x86_64__) + ScopedDlHandle dl_handle(kLibDlPath.c_str()); + void *handle = dl_handle.Get(); + HOOK_FUNC(mydlopen, "__loader_dlopen"); +#else InstallLinkerHooks(kLinkerPath.c_str()); +#endif } else { ScopedDlHandle art_handle(kLibArtLegacyPath.c_str()); InstallArtHooks(art_handle.Get());