Quantcast
Channel: 睿论坛 - 最新帖子
Viewing all articles
Browse latest Browse all 37470

如何在dlopen动态加载dylib且未执行constructor函数前hook这个dylib?

$
0
0
void add_callback(const struct mach_header *mh, intptr_t vmaddr_slide)
{
    Dl_info info;
    dladdr(mh, &info);
    NSLog(@"dylib : %s",info.dli_fname);
    %init;
    MSHookFunction(((void*)MSFindSymbol(NULL,"_func")),(void*)repl_func,(void**)&orig_func);
}

static __attribute__((constructor)) void InitTweak()
{
    _dyld_register_func_for_add_image(add_callback);
}

我这样做发现都没有hook到,_dyld_register_func_for_add_image函数是成功的,能打印出要加载的dylib名称,理论上这时候已经处于dylib加载完毕且还未执行constructor的时候,但是后面的MSHookFunction就是没hook上,换用fishhook也不行,它只能hook原生函数。。


Viewing all articles
Browse latest Browse all 37470

Trending Articles