From 6a2e53134f5c990f14fa4f379039c5d9ea7ff79b Mon Sep 17 00:00:00 2001 From: LoveSy Date: Wed, 8 Sep 2021 23:45:28 +0800 Subject: [PATCH] [core] Fix `failed to open [anon:linker_alloc]` (#1082) Fix LSPosed/LSPatch#17 --- core/src/main/cpp/main/src/elf_util.cpp | 2 +- core/src/main/cpp/main/src/symbol_cache.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/cpp/main/src/elf_util.cpp b/core/src/main/cpp/main/src/elf_util.cpp index f9e4169f..2c712a20 100644 --- a/core/src/main/cpp/main/src/elf_util.cpp +++ b/core/src/main/cpp/main/src/elf_util.cpp @@ -228,7 +228,7 @@ bool ElfImg::findModuleBase() { while (fgets(buff, sizeof(buff), maps)) { - if ((strstr(buff, "r-xp") || strstr(buff, "r--p")) && strstr(buff, elf.data())) { + if ((buff[0] == '/' && (strstr(buff, "r-xp") || strstr(buff, "r--p"))) && strstr(buff, elf.data())) { found = 1; LOGD("found: %s", buff); std::string_view b = buff; diff --git a/core/src/main/cpp/main/src/symbol_cache.cpp b/core/src/main/cpp/main/src/symbol_cache.cpp index 8517163b..e2b402fd 100644 --- a/core/src/main/cpp/main/src/symbol_cache.cpp +++ b/core/src/main/cpp/main/src/symbol_cache.cpp @@ -67,7 +67,7 @@ namespace lspd { void InitSymbolCache() { LOGD("InitSymbolCache"); sym_initialized = FindLibArt(); - sym_do_dlopen = SandHook::ElfImg("linker").getSymbAddress( + sym_do_dlopen = SandHook::ElfImg("/linker").getSymbAddress( "__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv"); if (!sym_initialized) [[unlikely]] { sym_initialized = false;