iOS9.3.2计算函数地址的方法要加一个偏移
Opened this issue · 0 comments
liaogang commented
uint32_t dylib_count = _dyld_image_count();
uint64_t slide = 0;
for (int i = 0; i < dylib_count; i ++) {
const char * name = _dyld_get_image_name(i);
if ([[NSString stringWithUTF8String:name] isEqualToString:path]) {
slide = _dyld_get_image_vmaddr_slide(i);
}
}
//经过实际测试,我要减掉这个常数才会得到正确的函数地址,我只试了一个app,别的不敢说
uint64_t offset = 0xFFFFC000;
typedef __int64 (*MyFunc)(id a1, __int64 a2, __int64 a3, __int64 a4);
myfunc = (MyFunc)(slide + 0x1027B70BC - offset) ;