I'm using dlsym
to load private APIs (required on iOS 9.3) :
handle = dlopen(CORETELPATH, RTLD_LAZY);
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
When I kill the app (swipe from bottom on multitask mode) and restart app, it crashes on the second line.
The handle
is equal to NULL
and I didn't succeed in loading the lib twice.
I tried to get the error with dlerror()
, but it returns also NULL
.
Does anybody got this issue ? How to resolve it ?
Edit :
Here is the full code ; with the if (handle != NULL)
the app doesn't crashes, but private frameworks won't load also
#define CORETELPATH "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"
handle = dlopen(CORETELPATH, RTLD_LAZY);
NSLog(@"DL Error : %s", dlerror());
if (handle != NULL) {
_CTServerConnectionCreate = dlsym(handle, "_CTServerConnectionCreate");
CTResultConnection = _CTServerConnectionCreate(NULL, simMonitorCallback, NULL);
_CTServerConnectionAddToRunLoop = dlsym(handle, "_CTServerConnectionAddToRunLoop");
_CTServerConnectionAddToRunLoop(CTResultConnection, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
_CTServerConnectionRegisterForNotification = dlsym(handle, "_CTServerConnectionRegisterForNotification");
_CTServerConnectionUnregisterForNotification = dlsym(handle, "_CTServerConnectionUnregisterForNotification");
_CTServerConnectionRegisterForNotification(CTResultConnection, kCTSIMSupportSIMStatusChangeNotification);
_CTServerConnectionGetSIMStatus = dlsym(handle, "_CTServerConnectionGetSIMStatus");
_CTServerConnectionCopyMobileEquipmentInfo = dlsym(handle, "_CTServerConnectionCopyMobileEquipmentInfo");
}
It seems that changing Private API path to public fix the issue ; and the call to private APIs still works :
#define CORETELPATH "/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony"