xHook
xHook copied to clipboard
在二进制文件中使用libxhook对__android_log_print进行hook,hook不成功
static int my_android_log_print(int prio, const char* tag, const char* fmt, ...) { va_list ap; char buf[1024]; int r; int n = 100;
va_start(ap, fmt);
r = __android_log_print(ANDROID_LOG_INFO, "ProjectName", "I am : %d/n", n);
va_end(ap);
} static void test_invoke_hook(){ int res = xhook_register("^/system/.*\.so$", "__android_log_print", my_android_log_print, NULL); if(res != 0){ printf("register failed\n"); return; } else { printf("register success\n"); }
while(1){
int res_r = xhook_refresh(0);
if(res_r != 0){
printf("refresh failed\n");
} else {
printf("refresh success\n");
}
sleep(3);
}
}
出现register success refresh success, 可是logcat里面没有I am的信息