From 878715700a04f6bc9111e937dd46efd6b015ab67 Mon Sep 17 00:00:00 2001 From: Wang Han Date: Sun, 13 Jul 2025 15:59:38 +0800 Subject: [PATCH] Hook ReinitializeMethodsCode on A16+ https://github.com/LSPosed/LSPlant/issues/157 --- .../src/main/jni/art/runtime/instrumentation.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lsplant/src/main/jni/art/runtime/instrumentation.cxx b/lsplant/src/main/jni/art/runtime/instrumentation.cxx index 62d00512d..281c68e8c 100644 --- a/lsplant/src/main/jni/art/runtime/instrumentation.cxx +++ b/lsplant/src/main/jni/art/runtime/instrumentation.cxx @@ -45,6 +45,18 @@ export class Instrumentation { backup(thiz, MaybeUseBackupMethod(art_method, quick_code), quick_code); }; + inline static auto ReinitializeMethodsCode_ = + "_ZN3art15instrumentation15Instrumentation23ReinitializeMethodsCodeEPNS_9ArtMethodE"_sym.hook->*[] + + (Instrumentation *thiz, ArtMethod *art_method) static -> void { + if (IsDeoptimized(art_method)) { + LOGV("skip update entrypoint on deoptimized method %s", + art_method->PrettyMethod(true).c_str()); + return; + } + backup(thiz, MaybeUseBackupMethod(art_method, nullptr)); + }; + public: static bool Init(JNIEnv *env, const HookHandler &handler) { if (!IsJavaDebuggable(env)) [[likely]] { @@ -52,7 +64,7 @@ export class Instrumentation { } int sdk_int = GetAndroidApiLevel(); if (sdk_int >= __ANDROID_API_P__) [[likely]] { - if (!handler(InitializeMethodsCode_, UpdateMethodsCodeToInterpreterEntryPoint_)) { + if (!handler(ReinitializeMethodsCode_, InitializeMethodsCode_, UpdateMethodsCodeToInterpreterEntryPoint_)) { return false; } }