]> git.saurik.com Git - cydget.git/commitdiff
Almost entirely fixed iOS4.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 12 Jul 2010 12:53:40 +0000 (12:53 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 12 Jul 2010 12:53:40 +0000 (12:53 +0000)
LockScreen.mm

index fc710b331f4239ea0838ba6349efaab3a4f78301..42e7125be49198d9b585c76f263b5a6542908ab6 100644 (file)
@@ -72,7 +72,9 @@ extern NSString * const kCAFilterNearest;
 #include <WebKit/WebPreferences-WebPrivate.h>
 
 #include "JSGlobalData.h"
+
 #include "SourceCode.h"
+#include "SourceCode4.h"
 
 #include <apr-1/apr_pools.h>
 #include <pcre.h>
@@ -122,7 +124,7 @@ static Class $UIFormAssistant(objc_getClass("UIFormAssistant"));
 static Class $SBStatusBarController(objc_getClass("SBStatusBarController"));
 
 static Class $UIWebBrowserView;
-static bool Wildcat_;
+static bool Wildcat_, iOS4;
 
 @interface NSString (UIKit)
 - (NSString *) stringByAddingPercentEscapes;
@@ -130,16 +132,6 @@ static bool Wildcat_;
 
 @implementation UIWebDocumentView (WebCycript)
 
-- (void) _initialize {
-    $UIWebBrowserView = objc_getClass("UIWebBrowserView");
-    if ($UIWebBrowserView == nil) {
-        Wildcat_ = false;
-        $UIWebBrowserView = objc_getClass("UIWebDocumentView");
-    } else {
-        Wildcat_ = true;
-    }
-}
-
 - (void) _setScrollerOffset:(CGPoint)offset {
     UIScroller *scroller([self _scroller]);
 
@@ -573,7 +565,7 @@ class Pcre {
 
         WebThreadLock();
 
-        document_ = [[UIWebDocumentView alloc] initWithFrame:rect];
+        document_ = [[$UIWebBrowserView alloc] initWithFrame:rect];
         WebView *webview([document_ webView]);
 
         [document_ setBackgroundColor:[UIColor blackColor]];
@@ -984,22 +976,43 @@ bool CYWeakHell() {
     false;
 }
 
-MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
+MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, void **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
     if (!GetParser0())
         return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
     else {
         SetParser(false, true);
 
-        JSC::SourceCode *source(*_this);
-        const uint16_t *data(source->data());
-        size_t size(source->length());
+        const uint16_t *data;
+        size_t size;
+
+        JSC::SourceCode *source(reinterpret_cast<JSC::SourceCode *>(_this[0]));
+        JSC::SourceCode4 *source4(reinterpret_cast<JSC::SourceCode4 *>(_this[13]));
+
+        if (iOS4) {
+            data = source4->data();
+            size = source4->length();
+        } else {
+            data = source->data();
+            size = source->length();
+        }
 
         apr_pool_t *pool;
         apr_pool_create(&pool, NULL);
 
+        //NSLog(@"!:%u:%@", size, [[[NSString alloc] initWithBytes:const_cast<char *>(reinterpret_cast<const char *>(data)) length:size encoding:NSUnicodeStringEncoding] autorelease]);
         Cycriptify(pool, data, size);
-        source->~SourceCode();
-        new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
+        //NSLog(@"%:%u:%@", size, [[[NSString alloc] initWithBytes:const_cast<char *>(reinterpret_cast<const char *>(data)) length:size encoding:NSUnicodeStringEncoding] autorelease]);
+
+        if (iOS4) {
+            NSLog(@":*");
+            source4->~SourceCode4();
+            NSLog(@":@");
+            new (source4) JSC::SourceCode4(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
+            NSLog(@":#");
+        } else {
+            source->~SourceCode();
+            new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
+        }
 
         apr_pool_destroy(pool);
 
@@ -1301,6 +1314,16 @@ static void dlset(Type_ &function, const char *name) {
 @implementation WebCycriptLockScreenController
 
 + (void) initialize {
+    iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
+
+    $UIWebBrowserView = objc_getClass("UIWebBrowserView");
+    if ($UIWebBrowserView == nil) {
+        Wildcat_ = false;
+        $UIWebBrowserView = objc_getClass("UIWebDocumentView");
+    } else {
+        Wildcat_ = true;
+    }
+
     int maxproc;
     size_t size(sizeof(maxproc));
     if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
@@ -1316,7 +1339,7 @@ static void dlset(Type_ &function, const char *name) {
     [NSURLProtocol registerClass:[CydgetURLProtocol class]];
     [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
 
-    void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
+    void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(void **, JSC::JSGlobalData *, int *, JSC::UString *);
     dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
     if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
         MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));