fishhook icon indicating copy to clipboard operation
fishhook copied to clipboard

Hook should call the original method before

Open fangshufeng opened this issue 5 years ago • 1 comments

static int (*orig_strlen)(const char *__s);
int my_strlen(const char *__s) {
    printf("===\n");
    return orig_strlen(__s);
} 

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        strlen("s"); // 1
        struct rebinding strlen_rebinding = { "strlen", my_strlen,
            (void *)&orig_strlen };
        
        rebind_symbols((struct rebinding[1]){ strlen_rebinding }, 1);
        
        char *str = "HelloWorld";
        
        strlen(str);
}

hello : I think the old method (strlen("s")) should be called before calling the rebind_symbols method to ensure that lazy bind is already the real address, right?

fangshufeng avatar Apr 01 '19 10:04 fangshufeng

I'm agree with you

sclcoder avatar Sep 29 '20 07:09 sclcoder