Question

I am writing a jail break tweak. I am hooking to all apps including app store based apps. I need to write a file to capture some data. Based on this answer, best way is for all apps to send notification to SpringBoard and let SpringBoard write file to /var/mobile/application. But I am not able to compile CFNotificationCenterAddObserver. It gives error "NO Matching function for call to ....". Below is the code snippet. Oh yes, I have included "CoreFoundation.h" and "CFNotificationCenter.h" (Not that dumb :-)

Idea for code below is to listen to notification from SpringBoard and post notification from all other apps.

Does any one know how to get through this error. I saw some github sample %ctor but couldn't digest it...

void LogEvent(CFNotificationCenterRef center,
              void *observer,
              CFStringRef name,
              const void *object,
              CFDictionaryRef userInfo)
{
    NSLog(@"RecordEvent");
}
%hook UIApplication
-(void)applicationDidFinishLaunching:(UIApplication*) application
{
    if(  [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"]  )
    {

        CFNotificationCenterAddObserver(
            CFNotificationCenterGetDistributedNotifyCenter(),
            NULL,
            &LogEvent,
            @"RecordTouch",
            NULL,
            CFNotificationSuspensionBehaviorDeliverImmediately);
    }

    %orig;
}
%end
Était-ce utile?

La solution

CFNotificationCenterAddObserver(
            CFNotificationCenterGetDistributedNotifyCenter(),
            NULL,
            LogEvent,
            (CFStringRef)@"RecordTouch",
            NULL,
            CFNotificationSuspensionBehaviorDeliverImmediately
);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top