问题
I was working with a program which was intercepting the calling from jailbreak iphone. I used a dylib to intercept the system call event , but how did i call back my main program and handle this event?
回答1:
You can use CFNotificationCenter for sending Darwin notifications from your dylib to the app. It is limiting in that no user data can be passed around but you can at least notify the app of the event. More on that at https://developer.apple.com/library/IOs/#documentation/CoreFoundation/Reference/CFNotificationCenterRef/Reference/reference.html
Example of registering and posting:
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),NULL, &NotificationReceivedCallback,(CFStringRef)MyNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter() , CFSTR(MyNotificationString), NULL, NULL, YES);
来源:https://stackoverflow.com/questions/9123202/dylib-how-to-call-back-the-main-program