1

我正在写一个越狱调整。我正在连接所有应用程序,包括基于应用程序商店的应用程序。我需要编写一个文件来捕获一些数据。基于这个答案,最好的方法是让所有应用程序向 SpringBoard 发送通知并让 SpringBoard 将文件写入 /var/mobile/application。但我无法编译 CFNotificationCenterAddObserver。它给出了错误“NO Matching function for call to ....”。下面是代码片段。哦,是的,我已经包含了“CoreFoundation.h”和“CFNotificationCenter.h”(没那么愚蠢:-)

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

有谁知道如何解决这个错误。我看到了一些 github 示例 %ctor 但无法消化...

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
4

1 回答 1

3
CFNotificationCenterAddObserver(
            CFNotificationCenterGetDistributedNotifyCenter(),
            NULL,
            LogEvent,
            (CFStringRef)@"RecordTouch",
            NULL,
            CFNotificationSuspensionBehaviorDeliverImmediately
);
于 2013-08-05T17:45:41.457 回答