fishhook

2018-06-13  本文已影响0人  MAXZhangZZ
int (*p_strlen)(char *s);
int mystrlen(char *s){
//    NSLog(@"1111");
    return 999;
}
- (IBAction)fishHook:(id)sender {
    NSLog(@"测试fishhook");
    char *hookString = "good good study";
    NSLog(@"%lu",strlen(hookString));
    struct rebinding rebd;
    rebd.name = "strlen";
    rebd.replaced = (void*)&p_strlen;
    rebd.replacement = mystrlen;
    
    struct rebinding rebs[]= {rebd};
    
    rebind_symbols(rebs, 1);
    NSLog(@"%lu",strlen(hookString));
}

结果如下

2018-06-13 17:20:39.217093+0800 test[53965:923791] 测试fishhook
2018-06-13 17:20:39.217884+0800 test[53965:923791] 15
2018-06-13 17:20:42.360519+0800 test[53965:923791] 999
上一篇 下一篇

猜你喜欢

热点阅读