From cb6f14a41a438b1baac8ff0ae226344a9e9ba579 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 7 Mar 2021 15:03:12 +0800 Subject: [PATCH] [core] Fix pending hook for Android S (#278) --- .../main/cpp/main/include/art/runtime/class_linker.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/main/cpp/main/include/art/runtime/class_linker.h b/core/src/main/cpp/main/include/art/runtime/class_linker.h index 662116c8..7824fecd 100644 --- a/core/src/main/cpp/main/include/art/runtime/class_linker.h +++ b/core/src/main/cpp/main/include/art/runtime/class_linker.h @@ -64,6 +64,14 @@ namespace art { MaybeDelayHook(clazz_ptr); }); + CREATE_MEM_HOOK_STUB_ENTRIES( + "_ZN3art11ClassLinker22FixupStaticTrampolinesEPNS_6ThreadENS_6ObjPtrINS_6mirror5ClassEEE", + void, FixupStaticTrampolinesWithThread, + (void * thiz, void * self, void * clazz_ptr), { + backup(thiz, self, clazz_ptr); + MaybeDelayHook(clazz_ptr); + }); + CREATE_MEM_HOOK_STUB_ENTRIES( "_ZN3art11ClassLinker20MarkClassInitializedEPNS_6ThreadENS_6HandleINS_6mirror5ClassEEE", void*, MarkClassInitialized, (void * thiz, void * self, uint32_t * clazz_ptr), { @@ -84,7 +92,8 @@ namespace art { "_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv", bool, ShouldUseInterpreterEntrypoint, (void * art_method, const void *quick_code), { - if (quick_code != nullptr && UNLIKELY(lspd::isHooked(art_method) || lspd::IsMethodPending(art_method))) { + if (quick_code != nullptr && + UNLIKELY(lspd::isHooked(art_method) || lspd::IsMethodPending(art_method))) { return false; } return backup(art_method, quick_code); @@ -157,6 +166,7 @@ namespace art { // Therefore we hook the new introduced MarkClassInitialized instead // This only happens on non-x86 devices lspd::HookSyms(handle, MarkClassInitialized); + lspd::HookSyms(handle, FixupStaticTrampolinesWithThread); } else { lspd::HookSyms(handle, FixupStaticTrampolines); }