2013-08-05 85 views
1

我正在编写一个jail break调整。我喜欢所有应用程序,包括基于应用程序商店的应用程序。我需要编写一个文件来捕获一些数据。基于这个answer,最好的方法是让所有应用程序向SpringBoard发送通知,并让SpringBoard将文件写入/ var/mobile/application。但我无法编译CFNotificationCenterAddObserver。它给出错误“没有匹配函数调用....”。以下是代码片段。哦,是的,我已经包含了“CoreFoundation.h”和“CFNotificationCenter.h”(不那么愚蠢:-)CFNotificationCenterAddObserver没有调用错误的匹配函数

想法下面的代码是收听来自SpringBoard通知和发布通知从所有其他应用程序。

有没有人知道如何解决这个错误。我看到一些github上样品%男星,但尽管我已经包括的CoreFoundation框架无法消化它?

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 

回答

3
CFNotificationCenterAddObserver(
      CFNotificationCenterGetDistributedNotifyCenter(), 
      NULL, 
      LogEvent, 
      (CFStringRef)@"RecordTouch", 
      NULL, 
      CFNotificationSuspensionBehaviorDeliverImmediately 
); 
+0

现在我得到的链接错误。是因为6.1吗? #if(TARGET_OS_MAC &&!(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))|| TARGET_OS_WIN32 CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); #endif – Jailbroken

+1

尝试'extern“C”CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);' – creker

+0

它工作!谢谢。 – Jailbroken

相关问题