1

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
Community
  • 1
  • 1
TorukMakto
  • 2,066
  • 2
  • 24
  • 38

1 Answers1

3
CFNotificationCenterAddObserver(
            CFNotificationCenterGetDistributedNotifyCenter(),
            NULL,
            LogEvent,
            (CFStringRef)@"RecordTouch",
            NULL,
            CFNotificationSuspensionBehaviorDeliverImmediately
);
Yotam Omer
  • 15,310
  • 11
  • 62
  • 65
creker
  • 9,400
  • 1
  • 30
  • 47
  • Now I get the linker error although I have included CoreFoundation Framework. Is it because of 6.1? #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || TARGET_OS_WIN32 CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); #endif – TorukMakto Aug 06 '13 at 04:15
  • 1
    Try `extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);` – creker Aug 06 '13 at 09:31