Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS MobileSubstrate CFNotificationCenterPostNotification-不工作_Ios_Jailbreak_Iphone Privateapi - Fatal编程技术网

iOS MobileSubstrate CFNotificationCenterPostNotification-不工作

iOS MobileSubstrate CFNotificationCenterPostNotification-不工作,ios,jailbreak,iphone-privateapi,Ios,Jailbreak,Iphone Privateapi,我有一个SpringBoard钩子,可以监听分布式通知。在SpringBoard中接收到的各种其他应用程序,我已经钩住了post通知 如果我将userInfo传递为null,SpringBoard将接收来自所有应用程序的通知。如果我将CFDictionaryRef作为userInfo传递,SpringBoard只接收来自SpringBoard和SystemApps的通知。但是,用户应用程序无法发送通知。(或者更确切地说,不是由Springboard接收) CFDictionaryRef是无辜的,

我有一个SpringBoard钩子,可以监听分布式通知。在SpringBoard中接收到的各种其他应用程序,我已经钩住了post通知

如果我将userInfo传递为null,SpringBoard将接收来自所有应用程序的通知。如果我将CFDictionaryRef作为userInfo传递,SpringBoard只接收来自SpringBoard和SystemApps的通知。但是,用户应用程序无法发送通知。(或者更确切地说,不是由Springboard接收)

CFDictionaryRef是无辜的,不是罪魁祸首,因为当发送方和接收方都是系统应用程序时,我能够传递它

是否存在用户应用程序无法向系统应用程序发送userInfo对象的限制

编辑: 附加代码。我使用iOSOpenDev编译它。依赖NSLog进行调试。 场景1:如果触摸SpringBoard,您将看到两个用于发送通知和接收通知的日志。 场景2:调用任何系统应用程序,如时钟等,您都会看到这两个日志。 场景3:应用商店中的任何应用,如SketchBookX等,只打印一个日志以发送通知。没有收到

我已经尝试了所有类型的CFNotificationCenterPostNotification,但都没有效果

#import <UIKit/UIKit.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFNotificationCenter.h>
#include "GraphicsServices/GSEvent.h"

#define GS_EVENT_TYPE_OFFSET 2
#define HOME_DOWN 1000
#define HOME_UP 1001
#define VOL_DOWN_KEY_DOWN 1008
#define VOL_DOWN_KEY_UP 1009

extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);


void LogEvent(CFNotificationCenterRef center,
          void *observer,
          CFStringRef name,
          const void *object,
          CFDictionaryRef userInfo)
{

NSString *str = [[NSString alloc]initWithFormat:@"%@,%@,%d,%d,%d,%d,%d\r\n",
     (NSString*)CFDictionaryGetValue(userInfo,@"strWindow"),
     (NSString*)CFDictionaryGetValue(userInfo,@"strView"),
     [(NSNumber*)CFDictionaryGetValue(userInfo,@"phase") intValue],
     [(NSNumber*)CFDictionaryGetValue(userInfo,@"xInView") intValue],
     [(NSNumber*)CFDictionaryGetValue(userInfo,@"yInView") intValue],
     [(NSNumber*)CFDictionaryGetValue(userInfo,@"xInWindow") intValue],
     [(NSNumber*)CFDictionaryGetValue(userInfo,@"yInWindow") intValue]];

    NSLog(@"Area51 Notification Received: %@",str);
}

%hook UIApplication
-(void) sendEvent:(UIEvent*)event
{

if(  [NSStringFromClass([event class]) isEqualToString:@"UITouchesEvent"] )
{

    NSSet *touches = [event allTouches];

    NSEnumerator *enumerator = [touches objectEnumerator];
    id value;

    while ((value = [enumerator nextObject])) {
        UITouch *touch = value;
        NSString *strViewClassName;
        if(!touch.view)
            strViewClassName = @" ";
        else
            strViewClassName = [NSString stringWithString:NSStringFromClass([[touch view] class])];

        CFMutableDictionaryRef dictionary = CFDictionaryCreateMutable(NULL,0,&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

        CFDictionaryAddValue(dictionary, @"phase", [NSNumber numberWithInt:[touch phase]] );
        CFDictionaryAddValue(dictionary, @"strWindow", NSStringFromClass([[touch window] class]) );
        CFDictionaryAddValue(dictionary, @"strView", strViewClassName);
        CFDictionaryAddValue(dictionary, @"xInView", [NSNumber numberWithInt:[touch locationInView:touch.view].x]) ;
        CFDictionaryAddValue(dictionary, @"yInView", [NSNumber numberWithInt:[touch locationInView:touch.view].y]) ;
        CFDictionaryAddValue(dictionary, @"xInWindow", [NSNumber numberWithInt:[touch locationInView:nil].x]) ;
        CFDictionaryAddValue(dictionary, @"yInWindow", [NSNumber numberWithInt:[touch locationInView:nil].y]) ;

        CFNotificationCenterPostNotificationWithOptions(
             CFNotificationCenterGetDistributedCenter(),
             (CFStringRef)@"RecordTouch",
             NULL,
             dictionary,
             kCFNotificationDeliverImmediately|kCFNotificationPostToAllSessions);

            NSLog(@"Area 51: Notification Send for App: %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] );

    }

}

%orig;
}

%end

%hook SpringBoard
-(void)applicationDidFinishLaunching:(UIApplication*) application
{

CFNotificationCenterAddObserver(
    CFNotificationCenterGetDistributedCenter(),
    NULL,
    LogEvent,
    NULL,
    NULL,
    CFNotificationSuspensionBehaviorDeliverImmediately);

NSLog(@"Area51: ObserverAdded");

%orig;
}

%end

__attribute__((constructor)) void area51init() {

%init;
}
#导入
#包括
#包括
#包括“GraphicsServices/GSEvent.h”
#定义GS\U事件类型\U偏移量2
#定义HOME_DOWN 1000
#定义HOME\u UP 1001
#定义音量下降键下降1008
#定义音量下降键上升1009
外部“C”cf通知中心参考cf通知中心GetDistributedCenter(无效);
无效日志事件(CFNotificationCenterRef center,
无效*观察员,
CFStringRef名称,
const void*对象,
CFDictionaryRef用户信息)
{
NSString*str=[[NSString alloc]initWithFormat:@“%@、%@、%d、%d、%d、%d\r\n”,
(NSString*)CFDictionaryGetValue(userInfo,@“strWindow”),
(NSString*)CFDictionaryGetValue(userInfo,@“strView”),
[(NSNumber*)CFDictionaryGetValue(用户信息,@“阶段”)intValue],
[(NSNumber*)CFDictionaryGetValue(userInfo,@“xInView”)intValue],
[(NSNumber*)CFDictionaryGetValue(userInfo,@“yInView”)intValue],
[(NSNumber*)CFDictionaryGetValue(userInfo,@“xInWindow”)intValue],
[(NSNumber*)CFDictionaryGetValue(userInfo,@“yInWindow”)intValue];
NSLog(@“收到的区域51通知:%@”,str);
}
%钩子应用
-(void)sendEvent:(UIEvent*)事件
{
if([NSStringFromClass([event class])IsequalString:@“UITouchesEvent”])
{
NSSet*touchs=[event alltouchs];
NSEnumerator*枚举数=[objectEnumerator];
id值;
while((值=[enumerator nextObject])){
UITouch*触摸=值;
NSString*strViewClassName;
如果(!touch.view)
strViewClassName=@”;
其他的
strViewClassName=[NSString stringWithString:NSStringFromClass([[touch view]class]);
CFMutableDictionaryRef dictionary=CFDictionaryCreateMutable(NULL、0和&kCFTypeDictionaryKeyCallBacks和&kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(字典,@“阶段”,[NSNumber numberWithInt:[触摸阶段]]);
CFDictionaryAddValue(dictionary,@“strWindow”,NSStringFromClass([[touch window]class]);
CFDictionaryAddValue(字典,@“strView”,strViewClassName);
CFDictionaryAddValue(dictionary,@“xInView”,[NSNumber numberWithInt:[touch location inview:touch.view].x]);
CFDictionaryAddValue(dictionary,@“yInView”,[NSNumber numberWithInt:[touch location inview:touch.view].y]);
CFDictionaryAddValue(dictionary,@“xInWindow”,[NSNumber Number Withint:[触摸位置查看:nil].x]);
CFDictionaryAddValue(dictionary,@“yInWindow”,[NSNumber numberWithInt:[触摸位置查看:nil].y]);
CFNotificationCenterPostNotificationWithOptions(
CFNotificationCenterGetDistributedCenter(),
(CFStringRef)@“RecordTouch”,
无效的
字典,
KCF通知立即交付(KCF通知后所有会议);
NSLog(@“区域51:为应用程序发送通知:%@,[[NSBundle mainBundle]objectForInfoDictionaryKey:@“CbundleDisplayName]”);
}
}
%奥利格;
}
%结束
%钩跳板
-(无效)应用程序IDFinishLaunching:(UIApplication*)应用程序
{
CFNotificationCenterAddObserver(
CFNotificationCenterGetDistributedCenter(),
无效的
LogEvent,
无效的
无效的
CFNotificationSusperationBehavior立即交货);
NSLog(@“Area51:ObserverAdded”);
%奥利格;
}
%结束
__属性(构造函数)无效区域51init(){
%初始化;
}

问题似乎在于,当使用达尔文通知中心作为
中心时,
用户信息
被忽略(因此为空)


另请参见。

请发布您用来发送通知的代码,以及您用来监听通知的代码。@Nate-我已经添加了这些代码。希望有帮助。我看不出有什么不对劲。我从一个简单的例子开始。首先,确保没有字典(
userInfo
)时,通知始终成功。然后,添加一个简单的字典,只有一个字符串键和一个字符串值。从那里构建复杂性。看看是什么导致它失败。您可以尝试从另一个示例(例如)开始。消除过程:(@Nate-如果没有字典,它会工作。当我发送字典时,它会停止工作。(一本非常简单的字典也不工作)。@Nate-抱歉,我没有机会尝试它。我将在周末尝试它。我一定会让你知道。。