[core] Fix native hook (#784)

Close #783
This commit is contained in:
LoveSy 2021-06-27 19:34:34 +08:00 committed by GitHub
parent 5e5158dab1
commit 21f9aedce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -11,6 +11,7 @@ Checks: >
clang-analyzer-*, clang-analyzer-*,
llvm-include-order, llvm-include-order,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-readability-implicit-bool-conversion,
CheckOptions: CheckOptions:
- key: readability-identifier-naming.ClassCase - key: readability-identifier-naming.ClassCase
@ -55,9 +56,5 @@ CheckOptions:
value: lower_case value: lower_case
- key: readability-identifier-naming.IgnoreMainLikeFunctions - key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1 value: 1
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 1
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 1
- key: readability-braces-around-statements.ShortStatementLines - key: readability-braces-around-statements.ShortStatementLines
value: 1 value: 1

View File

@ -41,7 +41,7 @@ namespace lspd {
void *sym_set_table_override = nullptr; void *sym_set_table_override = nullptr;
std::unique_ptr<const SandHook::ElfImg> art_img = nullptr; std::unique_ptr<const SandHook::ElfImg> art_img = nullptr;
bool findLibArt() { bool FindLibArt() {
art_img = std::make_unique<SandHook::ElfImg>(kLibArtName); art_img = std::make_unique<SandHook::ElfImg>(kLibArtName);
if (!art_img->isValid()) return false; if (!art_img->isValid()) return false;
auto api_level = GetAndroidApiLevel(); auto api_level = GetAndroidApiLevel();
@ -67,10 +67,13 @@ namespace lspd {
void InitSymbolCache() { void InitSymbolCache() {
if (UNLIKELY(sym_initialized)) return; if (UNLIKELY(sym_initialized)) return;
LOGD("InitSymbolCache"); LOGD("InitSymbolCache");
sym_initialized = findLibArt(); sym_initialized =
FindLibArt() && (sym_do_dlopen = SandHook::ElfImg("linker").getSymbAddress<void *>(
"__dl__Z9do_dlopenPKciPK17android_dlextinfoPKv"));
if (UNLIKELY(!sym_initialized)) { if (UNLIKELY(!sym_initialized)) {
sym_initialized = false;
art_img.reset(); art_img.reset();
LOGE("Init symbol cache failed"); LOGE("Init symbol cache failed");
} }
} }
} } // namespace lspd