iOS上的系统级点击模拟

时间:2012-07-15 16:59:11

标签: iphone objective-c ios ipad jailbreak

我想通过MobileSubstrate插件在iOS上实现系统级点击模拟。我们的想法是能够在iOS 5.1.1中在系统级别上模拟触摸(首次单触,然后是多点触控)。

我已成功实现this article来模拟特定视图的触摸,我现在希望能够在系统范围内模拟它们。

我知道我应该使用私有MobileServices框架这样做,我在GSEvent上documented myself(我也看过Veency& MouseSupport源代码)。

我试图连接一个视图来拦截UIEvents并查看底层结构:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    GSEventRef eventRef = (GSEventRef)[event performSelector:@selector( _gsEvent)];
    GSEventRecord record = *_GSEventGetGSEventRecord(eventRef);
    < breakpoint here to look at record >
}

,结果与上面详述的旧(iOS 3)结构非常相似。

然后我尝试自己启动这些事件(在独立应用上,暂时不是MS调整):

+(void)simulateTouchDown:(CGPoint)point{

    point.x = roundf(point.x);
    point.y = roundf(point.y);

    GSEventRecord record;
    memset(&record, 0, sizeof(record));

    record.type = kGSEventHand;
    record.windowLocation = point;
    record.timestamp = GSCurrentEventTimestamp();

    GSSendSystemEvent(&record);

}

现在,它根本不起作用(也不会崩溃)。

大多数代码(MouseSupport,Veency)看起来像这样

// Create & populate a GSEvent
struct {
    struct GSEventRecord record;
    struct {
        struct GSEventRecordInfo info;
        struct GSPathInfo path;
    } data;
} event;

memset(&event, 0, sizeof(event));

event.record.type = kGSEventHand;
event.record.windowLocation = point;
event.record.timestamp = GSCurrentEventTimestamp();
event.record.infoSize = sizeof(event.data);

event.data.info.handInfo.type = kGSHandInfoTypeTouchDown;    
event.data.info.handInfo._0x44 = 0x1;
event.data.info.handInfo._0x48 = 0x1;

event.data.info.pathPositions = 1;  

event.data.path.pathIndex = 0x01;
event.data.path.pathIdentity = 0x02;
event.data.path.pathProximity = 0x00;
event.data.path.pathLocation = event.record.windowLocation;


GSSendSystemEvent(&event.record);

仅限:

  • GSEventRecordInfo未知(我找不到它的定位)
  • 我没有看到整个事件只传递记录的重点

请在iOS 5上通过此操作的人指导我。

1 个答案:

答案 0 :(得分:0)

GSEventRecordInfo可能是从iOS 3.2开始引入的(这是您链接到的Graphics Services标头所在的位置)。 class-dump在iOS 5.1.1上实际在你的设备上的框架并查看它是否在那里定义了?