How to test notify_post in cycript?

I read the 2nd edition of the book, and get stuck in ‘change Incoming Calls value’, as the author mention, it could be tested in cycript, i did all the test except the line code line:


it always shows:

cy= notify_post("")
ReferenceError: Can't find variable: notify_post

How to reference ‘notify_post’, I search the official document, and i could not find anything useful, please help.

To call C functions in Cycript, you should locate the symbol using dlsym

Thanks very much, the problem is solved, here’s the procedure, hope it helps to others.

ssh root@
cycript -p SpringBoard
cy# dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/"]


cy# [dict setValue:[NSNumber numberWithInt:1] forKey:@"DefaultRouteForCallPreference"]
cy# [dict writeToFile:@"/var/mobile/Library/Preferences/" atomically:YES]


cy# np = @encode(unsigned int(*)(char const*))(dlsym(RTLD_DEFAULT, "notify_post"))

cy# (*np)("")

After run these commands in cycript, the setting changes to “headerset”.

1 个赞

Thank‘s for your share.