diff --git a/edxp-core/src/main/cpp/external/yahfa/include/HookMain.h b/edxp-core/src/main/cpp/external/yahfa/include/HookMain.h index c22c4407..178449fe 100644 --- a/edxp-core/src/main/cpp/external/yahfa/include/HookMain.h +++ b/edxp-core/src/main/cpp/external/yahfa/include/HookMain.h @@ -30,7 +30,5 @@ void *getArtMethod(JNIEnv *env, jobject jmethod); // TODO: move to common utils instead of in YAHFA's code void *getEntryPoint(void* method); -void *getOriginalEntryPointFromHookedEntryPoint(void* method); - #endif // HOOK_MAIN_H \ No newline at end of file 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 a6f9e307..2d2c5f0c 100644 --- a/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp +++ b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.cpp @@ -17,7 +17,7 @@ static uint32_t OFFSET_access_flags_in_ArtMethod; static uint32_t kAccCompileDontBother = 0x01000000; static jfieldID fieldArtMethod = nullptr; -static std::unordered_map replaced_entrypoint; +//static std::unordered_map replaced_entrypoint; static inline uint32_t read32(void *addr) { return *((uint32_t *) addr); @@ -136,7 +136,7 @@ static int replaceMethod(void *fromMethod, void *toMethod, int isBackup) { } void* fromEntrypoint = (char *) fromMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; - replaced_entrypoint[fromEntrypoint] = newEntrypoint; + //replaced_entrypoint[fromEntrypoint] = newEntrypoint; LOGI("replace entry point from %p to %p", readAddr(fromEntrypoint), @@ -248,7 +248,3 @@ extern "C" jboolean Java_lab_galaxy_yahfa_HookMain_backupAndHookNative(JNIEnv *e return JNI_FALSE; } } - -void *getOriginalEntryPointFromHookedEntryPoint(void* method) { - return replaced_entrypoint[method]; -} \ No newline at end of file diff --git a/edxp-core/src/main/cpp/external/yahfa/src/trampoline.c b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.c index da3523b6..580591c1 100644 --- a/edxp-core/src/main/cpp/external/yahfa/src/trampoline.c +++ b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.c @@ -131,7 +131,10 @@ void *genTrampoline(void *toMethod, void *entrypoint) { size_t size = entrypoint == NULL ? sizeof(trampoline) : sizeof(trampolineForBackup); // TODO: make use of thread_local to avoid frequent memory allocate - void *targetAddr = doInitHookCap(size); + char *targetAddr = doInitHookCap(size + 8); + // 8 bytes for AOT header. + memset(targetAddr, 0, 8); + targetAddr += 8; if (targetAddr == NULL) return NULL; diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/oat_quick_method_header.h b/edxp-core/src/main/cpp/main/include/art/runtime/oat_quick_method_header.h deleted file mode 100644 index fe87cc3e..00000000 --- a/edxp-core/src/main/cpp/main/include/art/runtime/oat_quick_method_header.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// Created by εŒθ‰ι…Έι…― on 12/18/20. -// - -#ifndef EDXPOSED_OAT_QUICK_METHOD_HEADER_H -#define EDXPOSED_OAT_QUICK_METHOD_HEADER_H - -#include -#include -#include -namespace art { - // https://github.com/ElderDrivers/EdXposed/issues/740 - class OatQuickMethodHeader : public edxp::HookedObject { - private: - CREATE_HOOK_STUB_ENTRIES(uint32_t, GetCodeSize, void *thiz) { - LOGD("OatQuickMethodHeader::GetCodeSize: %p", thiz); - void* oep = getOriginalEntryPointFromHookedEntryPoint(thiz); - if (oep) { - LOGD("OatQuickMethodHeader: Original entry point: %p", oep); - return GetCodeSizeBackup(oep); - } else { - LOGD("OatQuickMethodHeader: Original entry point not found"); - return GetCodeSizeBackup(thiz); - } - } - - public: - static void Setup(void *handle, HookFunType hook_func) { - if (edxp::GetAndroidApiLevel() >= __ANDROID_API_R__) { - HOOK_FUNC(GetCodeSize, "_ZNK3art20OatQuickMethodHeader11GetCodeSizeEv"); - } - } - }; - -} - - -#endif //EDXPOSED_OAT_QUICK_METHOD_HEADER_H diff --git a/edxp-core/src/main/cpp/main/src/native_hook.cpp b/edxp-core/src/main/cpp/main/src/native_hook.cpp index d05ae242..f73e3144 100644 --- a/edxp-core/src/main/cpp/main/src/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/native_hook.cpp @@ -17,7 +17,6 @@ #include "art/runtime/gc/heap.h" #include "art/runtime/hidden_api.h" #include "art/runtime/oat_file_manager.h" -#include "art/runtime/oat_quick_method_header.h" #include "art/runtime/jit/jit_code_cache.h" std::vector linker_get_solist(); // Dobby but not in .h @@ -80,7 +79,6 @@ namespace edxp { art::mirror::Class::Setup(art_handle, hook_func); art::JNIEnvExt::Setup(art_handle, hook_func); art::oat_file_manager::DisableOnlyUseSystemOatFiles(art_handle, hook_func); - art::OatQuickMethodHeader::Setup(art_handle, hook_func); art::jit::HookJitCacheCode(art_handle, hook_func); art_hooks_installed = true;