How does SimulateTouch click on my app when injecting into Springboard #127485
Unanswered
lengfeng222
asked this question in
Code Security
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
#import "TouchSimulator.h"
#import <UIKit/UIApplication.h>
#import <dlfcn.h>
static void postEvent(IOHIDEventRef event);
static void execute();
static IOHIDEventRef parent = NULL;
void simulateTouch(int type, float x, float y) {
if (parent == NULL) {
parent = IOHIDEventCreateDigitizerEvent(kCFAllocatorDefault,
mach_absolute_time(),
kIOHIDDigitizerTransducerTypeHand,
0,
0,
kIOHIDDigitizerEventTouch,
0,
0.0,
0.0,
0.0,
0.0,
0.0,
0,
true,
0
);
IOHIDEventSetIntegerValue(parent, kIOHIDEventFieldDigitizerIsDisplayIntegrated, 1);
}
}
static UIWindow* getKeyWindow() {
for (UIWindow *window in [UIApplication sharedApplication].windows) {
if (window.isKeyWindow) {
return window;
}
}
return NULL;
}
static void postEvent(IOHIDEventRef event) {
static IOHIDEventSystemClientRef ioSystemClient = nil;
UIWindow* keyWindow = getKeyWindow();
NSLog(@"���� ��%@",keyWindow);
if (ioSystemClient == NULL) {
ioSystemClient = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
}
if (event != NULL && keyWindow != NULL) {
uint32_t contextID = keyWindow._contextId;
void handle = dlopen("/System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices", RTLD_NOW);
if (handle) {
typedef void ( BKSHIDEventSetDigitizerInfoType)(IOHIDEventRef,uint32_t,uint8_t,uint8_t,CFStringRef,CFTimeInterval,float);
}
static void execute() {
IOHIDEventSetIntegerValue(parent, kIOHIDEventFieldDigitizerTiltX, kIOHIDDigitizerTransducerTypeHand);
IOHIDEventSetIntegerValue(parent, kIOHIDEventFieldDigitizerTiltY, 1);
IOHIDEventSetIntegerValue(parent, kIOHIDEventFieldDigitizerAltitude, 1);
postEvent(parent);
CFRelease(parent);
parent = NULL;
}
Beta Was this translation helpful? Give feedback.
All reactions