现在,我发现iOS应用程序中的钩子很难,并且发现有一个名为“fishhook”的工具,由facebook创建。我在我的个人项目中导入该工具,但它不起作用。我错了吗?以下是源代码:
#import <dlfcn.h>
#import <Foundation/Foundation.h>
#import "fishhook.h"
static void (*orig_testABC)(void);
void testABC()
{
NSLog(@"This is main log...");
}
void my_testABC()
{
NSLog(@"This is other log, not main log...");
}
void save_original_symbols()
{
// void *handle = dlopen("/Users/bianyiji/Library/Developer/Xcode/DerivedData/HookTest-ghlgmahvsgfbqeekbrouzdyoxgdw/Build/Intermediates/HookTest.build/Debug/HookTest.build/Objects-normal/x86_64/main.o", RTLD_LAZY);
// printf("%s\n", handle);
orig_testABC = dlsym(RTLD_DEFAULT, "testABC");
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
// save_original_symbols();
int rebind_int = rebind_symbols((struct rebinding[1]){"testABC", my_testABC}, 1);
printf("%d\n", rebind_int);
}
testABC();
return 0;
}
虽然我调用了函数“testABC()”,但之前我使用“rebind_symbols”,为什么我无法得到预期的结果......