How to find the purple port for most applications in iOS 5 and above?

I am trying to write an application that runs in the background and introduces strokes into a springboard or other applications. I understand that I will use private APIs and structures. The application is a corporate application and does not need approval for the AppStore.

I am using the GSEvent framework proposed by KennyTM, with some minor changes for iOS 5/6. I can send touch events and other events to Springboard by sending GSSystemEvents.

I also need to send similar events to other applications, but I can not find the port for the largest application.

Is there a way to get a port for an application that works and works so that I can send my GSEvents to the application?

It would be nice if someone could point me to examples or show me how I can get the purple port of the largest application.

Thank!

+11
ios iphone-privateapi
Apr 22 '13 at 21:13
source share
1 answer

UPDATE: I have not tested this on ios7.

I am working on the same requirement before.

To get the purple port, you can use GSCopyPurpleNamedPort () with the packet identifier as an argument.

If you need to simulate a SpringBoard touch, use the GSGetPurpleSystemEventPort.

Using this code below, you can get the port and use it to inject the sensor system.

#import <dlfcn.h> // Framework Paths #define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices" -(mach_port_t)getFrontMostAppPort { bool locked; bool passcode; mach_port_t *port; void *lib = dlopen(SBSERVPATH, RTLD_LAZY); int (*SBSSpringBoardServerPort)() = dlsym(lib, "SBSSpringBoardServerPort"); void* (*SBGetScreenLockStatus)(mach_port_t* port, bool *lockStatus, bool *passcodeEnabled) = dlsym(lib, "SBGetScreenLockStatus"); port = (mach_port_t *)SBSSpringBoardServerPort(); dlclose(lib); SBGetScreenLockStatus(port, &locked, &passcode); void *(*SBFrontmostApplicationDisplayIdentifier)(mach_port_t *port, char *result) = dlsym(lib, "SBFrontmostApplicationDisplayIdentifier"); char appId[256]; memset(appId, 0, sizeof(appId)); SBFrontmostApplicationDisplayIdentifier(port, appId); NSString * frontmostApp=[NSString stringWithFormat:@"%s",appId]; if([frontmostApp length] == 0 || locked) return GSGetPurpleSystemEventPort(); else return GSCopyPurpleNamedPort(appId); } 

I tested ... this works fine on iOS 5 and 6. You may not need a lock if you do not enter it when the lock screen appears. Hope this helps.

+12
Apr 22 '13 at 22:04
source share



All Articles