From ac5389e21f70ddd6e300ba61d64abd55e7eaaa01 Mon Sep 17 00:00:00 2001 From: kotori0 Date: Sun, 20 Dec 2020 23:24:37 +0800 Subject: [PATCH] Fix possible crash --- edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp | 2 +- .../src/main/cpp/main/include/art/runtime/art_method.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp index 3b1c1561..2349004c 100644 --- a/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp +++ b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp @@ -130,7 +130,7 @@ static int replaceMethod(void *fromMethod, void *toMethod, int isBackup) { void *originEntrypoint = readAddr((char *) toMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod); // entry point hardcoded newEntrypoint = genTrampoline(toMethod, originEntrypoint); - replaced_entrypoint[fromMethod] = newEntrypoint; + replaced_entrypoint[toMethod] = originEntrypoint; } else { // entry point from ArtMethod struct diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/art_method.h b/edxp-core/src/main/cpp/main/include/art/runtime/art_method.h index 49e5a146..5a29e298 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/art_method.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/art_method.h @@ -38,8 +38,8 @@ namespace art { CREATE_HOOK_STUB_ENTRIES(void *, GetOatQuickMethodHeader, void *thiz, uintptr_t pc) { // This is a partial copy from AOSP. We only touch them if they are hooked. if (UNLIKELY(edxp::isHooked(thiz))) { - uintptr_t original_ep = reinterpret_cast(getOriginalEntryPointFromTargetMethod( - thiz)); + uintptr_t original_ep = reinterpret_cast( + getOriginalEntryPointFromTargetMethod(thiz)); if (original_ep) { char *code_length_loc = reinterpret_cast(original_ep) + oat_header_code_length_offset; @@ -53,7 +53,8 @@ namespace art { LOGD("art_method::GetOatQuickMethodHeader: PC not found in current method."); return nullptr; } else { - LOGD("art_method::GetOatQuickMethodHeader: isHooked but not backup, fallback to system"); + LOGD("art_method::GetOatQuickMethodHeader: ArtMethod=%p (%s), isHooked=true, pc=0x%x, isHooked but not backup, fallback to system", + thiz, PrettyMethod(thiz).c_str(), pc); } } return GetOatQuickMethodHeaderBackup(thiz, pc);