-
-
[求助]想用substrate hook memcpy 打印下信息为啥总是报错
-
发表于: 2021-1-21 07:31 2037
-
直接上代码,各位大神可以帮忙看看么,感觉也没写啥代码呀。 Hook time 函数都没问题。
MSConfig(MSFilterLibrary, "libc.so");
void (* old_memcpy)(void *dst0, const void *src0, size_t length);
void new_memcpy(void *dst0, const void *src0, size_t length)
{
// LOGD("Hook memcpy des : 0x%08X ,src : 0x%08X ,lenth : 0x%08X ", dst0,src0,length);
LOGD("hook memcpy success");
old_memcpy(dst0,src0,length); //注释掉该行可以正常运行
}
//Substrate entry point
MSInitialize{
LOGD("Substrate initialized.");
MSImageRef image;
image = MSGetImageByName("/system/lib/libc.so"); // ����·��
if (image != NULL)
{
LOGD("libc image: 0x%08X", (void*)image);
void * libcmemcoy = MSFindSymbol(image, "memcpy");
if(libcmemcoy == NULL)
{
LOGD("error find libc memcpy function.");
}
else
{
MSHookFunction(libcmemcoy,(void*)&new_memcpy,(void **)&old_memcpy); //注释掉该行可以正常运行
LOGD("hook libc memcpy success.");
}
}
else{
LOGD("can not find libc.");
}
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!