Quantcast
Channel: 睿论坛 - 最新话题
Viewing all articles
Browse latest Browse all 5731

如何 hook C++ 类中的某个方法

$
0
0

@sailor wrote:

如题,尝试hook dyld中ImageLoader这个类的一个方法 const char* getRealPath(),仿照hook C的套路,使用MSHookFunction,直接上代码:

MSHookFunction((constchar**)MSFindSymbol(MSGetImageByName("/usr/lib/dyld"),"_getRealPath") ,(const char**)repl_getRealPath,(const char***)&orig_getRealPath);

hook失败,然后使用 nm dyld 找到符号表 __ZNK11ImageLoader11getRealPathEv,再次尝试,

MSHookFunction((constchar**)MSFindSymbol(MSGetImageByName("/usr/lib/dyld"),"__ZNK11ImageLoader11getRealPathEv") ,(const char**)repl_getRealPath,(const char***)&orig_getRealPath);

还是失败,查看findSymbol的返回值,
void * pathSymbol=MSFindSymbol(MSGetImageByName("/usr/lib/dyld"), “__ZNK11ImageLoader11getRealPathEv”);

两次都是null,所以想请教下各位大大,是不是我的方法有误,怎么才能正确找到这个函数的地址?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5731

Trending Articles