Allocate 8 bytes more memory for AOT header
This commit is contained in:
parent
c23e3ff33d
commit
122a59df2b
|
|
@ -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
|
||||
|
|
@ -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<void*, void*> replaced_entrypoint;
|
||||
//static std::unordered_map<void*, void*> 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];
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <base/object.h>
|
||||
#include <config_manager.h>
|
||||
#include <HookMain.h>
|
||||
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
|
||||
|
|
@ -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<soinfo_t> 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue