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:

notify_post("com.apple.Accessibility.plist”)

it always shows:

cy= notify_post("com.apple.Accessibility.plist")
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@192.168.1.101
cycript -p SpringBoard
cy# dict = [NSMutableDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.Accessibility.plist"]

@{"TripleClickChoice":@[],"VoiceOverTouchEnabled":false,"AssistiveTouchScannerEnabled":false,"AccessibilityEnabled":false,"ApplicationAccessibilityEnabled":false,"AssistiveTouchEnabled":false,"AssistiveTouchHardwareEnabled":false,"DefaultRouteForCallPreference":2,"HearingAidCompliance":false}

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

1

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

&0x3a7623e5
cy# (*np)("com.apple.accessibility.defaultrouteforcall")
0
cy# 

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

1 个赞

Thank‘s for your share.