fishhook
fishhook copied to clipboard
Hook should call the original method before
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?
I'm agree with you