diff options
-rw-r--r-- | CyteKit/WebViewController.mm | 13 | ||||
-rw-r--r-- | MobileCydia.mm | 18 | ||||
-rw-r--r-- | makefile | 1 |
3 files changed, 27 insertions, 5 deletions
diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 643c2b8..5846a66 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -38,6 +38,8 @@ extern NSString * const kCAFilterNearest; #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; @@ -138,6 +140,14 @@ float CYScrollViewDecelerationRateNormal; + (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"); @@ -994,7 +1004,8 @@ float CYScrollViewDecelerationRateNormal; 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 { diff --git a/MobileCydia.mm b/MobileCydia.mm index c1fbddc..bdc5b7a 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -267,6 +267,15 @@ static bool AprilFools_; 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)); @@ -725,7 +734,7 @@ static NSString *SerialNumber_ = nil; 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_; @@ -4059,7 +4068,7 @@ static _H<NSMutableSet> Diversions_; } - (NSString *) device { - return [[UIDevice currentDevice] uniqueIdentifier]; + return UniqueIdentifier(); } - (NSString *) firmware { @@ -10657,6 +10666,9 @@ int main(int argc, char *argv[]) { 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; @@ -10688,7 +10700,7 @@ int main(int argc, char *argv[]) { 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"]; @@ -62,7 +62,6 @@ libs += -framework CoreGraphics libs += -framework Foundation libs += -framework GraphicsServices libs += -framework IOKit -libs += -framework JavaScriptCore libs += -framework QuartzCore libs += -framework SpringBoardServices libs += -framework SystemConfiguration |