#define lprintf(args...) fprintf(stderr, args)
+JSValueRef (*$JSObjectCallAsFunction)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *);
+
// XXX: centralize these special class things to some file or mechanism?
static Class $MFMailComposeViewController;
+ (void) _initialize {
[WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+ void *js(NULL);
+ if (js == NULL)
+ js = dlopen("/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore", RTLD_GLOBAL | RTLD_LAZY);
+ if (js == NULL)
+ js = dlopen("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore", RTLD_GLOBAL | RTLD_LAZY);
+ if (js != NULL)
+ $JSObjectCallAsFunction = reinterpret_cast<JSValueRef (*)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *)>(dlsym(js, "JSObjectCallAsFunction"));
+
dlopen("/System/Library/Frameworks/MessageUI.framework/MessageUI", RTLD_GLOBAL | RTLD_LAZY);
$MFMailComposeViewController = objc_getClass("MFMailComposeViewController");
JSGlobalContextRef context([frame globalContext]);
JSObjectRef object([function JSObject]);
- JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
+ if ($JSObjectCallAsFunction != NULL)
+ ($JSObjectCallAsFunction)(context, object, NULL, 0, NULL, NULL);
}
- (void) reloadButtonClicked {
static void (*$SBSSetInterceptsMenuButtonForever)(bool);
+static CFStringRef (*$MGCopyAnswer)(CFStringRef);
+
+static NSString *UniqueIdentifier(UIDevice *device = nil) {
+ if (kCFCoreFoundationVersionNumber < 800) // iOS 7.x
+ return [device ?: [UIDevice currentDevice] uniqueIdentifier];
+ else
+ return [(id)$MGCopyAnswer(CFSTR("UniqueDeviceID")) autorelease];
+}
+
static bool IsReachable(const char *name) {
SCNetworkReachabilityFlags flags; {
SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, name));
static NSString *ChipID_ = nil;
static NSString *BBSNum_ = nil;
static _H<NSString> Token_;
-static NSString *UniqueID_ = nil;
+static _H<NSString> UniqueID_;
static _H<NSString> UserAgent_;
static _H<NSString> Product_;
static _H<NSString> Safari_;
}
- (NSString *) device {
- return [[UIDevice currentDevice] uniqueIdentifier];
+ return UniqueIdentifier();
}
- (NSString *) firmware {
dealloc_ = dealloc->method_imp;
dealloc->method_imp = (IMP) &Dealloc_;*/
+ void *gestalt(dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY));
+ $MGCopyAnswer = reinterpret_cast<CFStringRef (*)(CFStringRef)>(dlsym(gestalt, "MGCopyAnswer"));
+
/* System Information {{{ */
size_t size;
ChipID_ = [CYHex((NSData *) CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString];
BBSNum_ = CYHex((NSData *) CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false);
- UniqueID_ = [device uniqueIdentifier];
+ UniqueID_ = UniqueIdentifier(device);
if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:@"/Applications/MobileSafari.app/Info.plist"]) {
Product_ = [info objectForKey:@"SafariProductVersion"];
libs += -framework Foundation
libs += -framework GraphicsServices
libs += -framework IOKit
-libs += -framework JavaScriptCore
libs += -framework QuartzCore
libs += -framework SpringBoardServices
libs += -framework SystemConfiguration