diff --git a/core/src/main/cpp/main/src/native_hook.cpp b/core/src/main/cpp/main/src/native_hook.cpp index b21fbc81..631b0202 100644 --- a/core/src/main/cpp/main/src/native_hook.cpp +++ b/core/src/main/cpp/main/src/native_hook.cpp @@ -41,8 +41,6 @@ #include "art/runtime/thread_list.h" #include "art/runtime/gc/scoped_gc_critical_section.h" -std::vector linker_get_solist(); // Dobby but not in .h - namespace lspd { static volatile bool installed = false; @@ -68,17 +66,16 @@ namespace lspd { if (api_level >= __ANDROID_API_Q__) { // From Riru v22 we can't get ART handle by hooking dlopen, so we get libart.so from soinfo. // Ref: https://android.googlesource.com/platform/bionic/+/master/linker/linker_soinfo.h - auto solist = linker_get_solist(); - bool found = false; - for (auto & it : solist) { - const char* real_path = linker_soinfo_get_realpath(it); - if (real_path != nullptr && std::string(real_path).find(kLibArtName) != std::string::npos) { - found = true; - InstallArtHooks(it); - break; + linker_iterate_soinfo([](auto soinfo) { + const char *real_path = linker_soinfo_get_realpath(soinfo); + if (real_path != nullptr && + strstr(real_path, kLibArtName.c_str()) != nullptr){ + InstallArtHooks(soinfo); + return 1; } - } - if(!found) { + return 0; + }); + if (!art_hooks_installed) { LOGE("Android 10+ detected and libart.so can't be found in memory."); return; }