Increase hook cap to prevent frequent memory allocating

This commit is contained in:
kotori0 2020-12-11 15:02:14 +08:00
parent de1dd6cdcf
commit b13c9ba98d
3 changed files with 6 additions and 9 deletions

View File

@ -9,13 +9,11 @@
#include "HookMain.h" #include "HookMain.h"
int SDKVersion; int SDKVersion;
static int OFFSET_entry_point_from_interpreter_in_ArtMethod; static uint32_t OFFSET_entry_point_from_interpreter_in_ArtMethod;
static int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; static uint32_t OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
static int OFFSET_ArtMehod_in_Object; static uint32_t OFFSET_ArtMehod_in_Object;
static int OFFSET_access_flags_in_ArtMethod; static uint32_t OFFSET_access_flags_in_ArtMethod;
static uint32_t kAccNative = 0x0100;
static uint32_t kAccCompileDontBother = 0x01000000; static uint32_t kAccCompileDontBother = 0x01000000;
static uint32_t kAccFastInterpreterToInterpreterInvoke = 0x40000000;
static jfieldID fieldArtMethod = NULL; static jfieldID fieldArtMethod = NULL;
@ -32,7 +30,6 @@ static inline void *readAddr(void *addr) {
} }
void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion) { void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion) {
int i;
SDKVersion = sdkVersion; SDKVersion = sdkVersion;
jclass classExecutable; jclass classExecutable;
LOGI("init to SDK %d", sdkVersion); LOGI("init to SDK %d", sdkVersion);

View File

@ -16,6 +16,6 @@ int doInitHookCap(unsigned int cap);
void setupTrampoline(uint8_t offset); void setupTrampoline(uint8_t offset);
void *genTrampoline(void *toMethod, void *entrypoint); void *genTrampoline(void *toMethod, void *entrypoint);
#define DEFAULT_CAP 1 //size of each trampoline area would be no more than 4k Bytes(one page) #define DEFAULT_CAP 4 //size of each trampoline area would be no more than 4k Bytes(one page)
#endif //YAHFA_TAMPOLINE_H #endif //YAHFA_TAMPOLINE_H

View File

@ -9,7 +9,7 @@ namespace art {
CREATE_HOOK_STUB_ENTRIES(const void*, GetSavedEntryPointOfPreCompiledMethod, void *thiz, CREATE_HOOK_STUB_ENTRIES(const void*, GetSavedEntryPointOfPreCompiledMethod, void *thiz,
void *art_method) { void *art_method) {
if (UNLIKELY(edxp::isHooked(art_method))) { if (UNLIKELY(edxp::isHooked(art_method))) {
LOGD("Found hooked method, return entrypoint as jit entrypoint"); LOGD("Found hooked method %p, return entrypoint as jit entrypoint", art_method);
return getEntryPoint(art_method); return getEntryPoint(art_method);
} }
return GetSavedEntryPointOfPreCompiledMethodBackup(thiz, art_method); return GetSavedEntryPointOfPreCompiledMethodBackup(thiz, art_method);