【问题标题】:CFNotificationCenterAddObserver No matching function for call errorCFNotificationCenterAddObserver 调用错误没有匹配函数
【发布时间】:2013-08-05 15:01:23
【问题描述】:

我正在编写越狱调整。我正在连接所有应用程序,包括基于应用程序商店的应用程序。我需要编写一个文件来捕获一些数据。基于这个answer,最好的方法是让所有应用程序向SpringBoard发送通知,让SpringBoard将文件写入/var/mobile/application。但我无法编译 CFNotificationCenterAddObserver。它给出了错误“NO Matching function for call to ....”。下面是代码sn-p。哦,是的,我已经包含了“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

【问题讨论】:

    标签: iphone ios jailbreak iphone-privateapi


    【解决方案1】:
    CFNotificationCenterAddObserver(
                CFNotificationCenterGetDistributedNotifyCenter(),
                NULL,
                LogEvent,
                (CFStringRef)@"RecordTouch",
                NULL,
                CFNotificationSuspensionBehaviorDeliverImmediately
    );
    

    【讨论】:

    • 现在我得到了链接器错误,尽管我已经包含了 CoreFoundation 框架。是因为6.1吗? #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || TARGET_OS_WIN32 CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); #endif
    • 试试extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
    猜你喜欢
    • 2013-05-05
    • 2012-12-28
    • 2016-01-18
    • 2015-03-31
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    相关资源
    最近更新 更多