本帖最后由 x10510 于 2015-7-6 12:25 编辑
按照网上实例来
第一个测试apk com.example.test:
[C] 纯文本查看 复制代码 void hook_hello(int i,int j ) {
LOGD("Hook%d\n", i+j);
}
==================
第二个hook apk
[C] 纯文本查看 复制代码 void (* old_hook_hello)(int,int);
void new_hook_hello(int x,int y){
LOGD("hook add %d %d ",x,y);
}
void hook()
{
MSImageRef image = MSGetImageByName("/data/data/com.example.test/lib//libTEST.so");
if (image != NULL)
{
void * symbole = MSFindSymbol(image,"hook_hello");
if (symbole == NULL){
LOGD("error find1");
}else{
MSHookFunction(symbole, (void*)&new_hook_hello,(void **) &old_hook_hello);
LOGD("hook ok");
}
}else{
LOGD("error find2");
}
}
}
打印出来是LOGD("error find2 "); 没取到;
=========================
我又试了下
[C] 纯文本查看 复制代码 void *handle= dlopen("/data/data/com.example.test/lib/libTEST.so", RTLD_LAZY);
void *ex_test_org = dlsym(handle, "hook_hello");
LOGD("%p",ex_test_org);//能打印出地址
MSHookFunction(ex_test_org, (void*)&new_hook_hello, (void**)&old_hook_hello);
但是到com.example.test 调用hook_hello函数没有执行new_hook_hello,求帮助
|