]> git.saurik.com Git - cydget.git/commitdiff
OMG this finally works.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Oct 2010 10:50:50 +0000 (10:50 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 26 Oct 2010 10:50:50 +0000 (10:50 +0000)
LockScreen.mm
PhotoExample.cydget/index.html
PhotoExample.cydget/lcd.cy [new file with mode: 0644]
control

index b675fb3870fbdc492e4de8346e71ba1f6045406e..30286f040ae620359edbf0a17bed1efa9f3d80dc 100644 (file)
@@ -940,8 +940,10 @@ static bool cycript_;
 
 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
     _trace();
-    if (mime != "text/cycript")
+    if (mime != "text/cycript") {
+        cycript_ = false;
         return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
+    }
     _trace();
 
     static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
@@ -962,6 +964,8 @@ static void Log(const WebCore::String &string) {
 }
 
 static void Cycriptify(apr_pool_t *pool, const uint16_t *&data, size_t &size) {
+    cycript_ = false;
+
     _trace();
     if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
         if (void (*CYParseUChar)(apr_pool_t *, const uint16_t **, size_t *) = reinterpret_cast<void (*)(apr_pool_t *, const uint16_t **, size_t *)>(dlsym(handle, "CydgetPoolParse")))
@@ -974,7 +978,6 @@ static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
     if (!cycript_)
         return;
-    cycript_ = false;
 
     const uint16_t *data(source.characters());
     size_t length(source.length()), size(length);
@@ -1036,6 +1039,28 @@ MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5Stat
     return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
 }
 
+// iOS 3.x
+MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
+    if (cycript_) {
+        JSC::SourceCode *source(*_this);
+        const uint16_t *data(source->data());
+        size_t size(source->length());
+
+        apr_pool_t *pool;
+        apr_pool_create(&pool, NULL);
+
+        Cycriptify(pool, data, size);
+        source->~SourceCode();
+        // XXX: I actually don't have the original URL here: pants
+        new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
+
+        apr_pool_destroy(pool);
+
+    }
+
+    return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
+}
+
 // iOS 4.x cdata
 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
     _trace();
@@ -1338,6 +1363,13 @@ static void dlset(Type_ &function, const char *name) {
     [NSURLProtocol registerClass:[CydgetURLProtocol class]];
     [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
 
+    if (!iOS4) {
+        void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, 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));
+    }
+
     struct nlist nl[9];
     memset(nl, 0, sizeof(nl));
 
@@ -1358,15 +1390,20 @@ static void dlset(Type_ &function, const char *name) {
 
     bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &);
     nlset(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, nl, 0);
-    MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
+    if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
+        MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
 
     void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int);
     nlset(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, nl, 1);
-    MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
-
-    const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *);
-    nlset(_ZN7WebCore12CachedScript6scriptEv, nl, 2);
-    MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
+    if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
+        MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
+
+    if (iOS4) {
+        const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *);
+        nlset(_ZN7WebCore12CachedScript6scriptEv, nl, 2);
+        if (_ZN7WebCore12CachedScript6scriptEv != NULL)
+            MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
+    }
 
     /*const WebCore::String &(*_ZNK7WebCore20StringSourceProvider6sourceEv)(void *);
     nlset(_ZNK7WebCore20StringSourceProvider6sourceEv, nl, 3);
@@ -1377,10 +1414,12 @@ static void dlset(Type_ &function, const char *name) {
     if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
         MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
 
-    State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, void *, State);
-    nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, nl, 5);
-    if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
-        MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
+    if (iOS4) {
+        State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, void *, State);
+        nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, nl, 5);
+        if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
+            MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
+    }
 
     nlset(_ZN7WebCore6String6appendEPKtj, nl, 6);
     nlset(_ZN7WebCore6String8truncateEj, nl, 7);
index 3cedb186b5a0ca5c06217d87f8f9564ed5e2989a..d16c35319decfa9163f76a29143812f26b65ddcb 100644 (file)
         vertical-align:middle;
     }
 </style></head><body>
-    <div id="content"><script type="text/cycript">
-        document.write('<div id="lcd">');
-
-        var locale = CFLocaleCopyCurrent();
-        var now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
-        var formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
-        CFRelease(locale);
-
-        CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UINoAMPMTimeFormat));
-        var time = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
-        document.write('<h1>');
-        document.write(time);
-        document.write('</h1>');
-        CFRelease(time);
-
-        CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UIWeekdayNoYearDateFormat));
-        var date = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
-        document.write('<h2>');
-        document.write(date);
-        document.write('</h2>');
-        CFRelease(date);
-
-        CFRelease(formatter);
-        CFRelease(now);
-
-        document.write('</div>');
-
+    <div id="content">
+        <script type="text/cycript" src="lcd.cy"></script>
+    <script type="text/cycript">
+        document.write([NSString stringWithString:'A'].toString());
+    </script>
+    <script type="text/cycript">
+        document.write([NSString stringWithString:'B'].toString());
+    </script>
+    <script type="text/cycript">
+        document.write([NSString stringWithString:'C'].toString());
+    </script>
+        <script type="text/cycript" src="lcd.cy"></script>
+        P       
+    <script type="text/cycript">
+        document.write([NSString stringWithString:'D'].toString());
+    </script>
+    <script type="text/cycript">
+        document.write([NSString stringWithString:'E'].toString());
+    </script>
+    <script type="text/cycript">
         dlopen("/System/Library/PrivateFrameworks/PhotoLibrary.framework/PhotoLibrary", RTLD_GLOBAL);
 
         var old = [PLCameraAlbum respondsToSelector:@selector(sharedInstance)];
                     break;
             }
 
-        document.write('<img src="' + jpeg + '"/>');
+        document.write('<img src="' + jpeg.toString() + '"/>');
     </script></div>
 </body></html>
diff --git a/PhotoExample.cydget/lcd.cy b/PhotoExample.cydget/lcd.cy
new file mode 100644 (file)
index 0000000..1d69a17
--- /dev/null
@@ -0,0 +1,25 @@
+document.write('<div id="lcd">');
+
+var locale = CFLocaleCopyCurrent();
+var now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent());
+var formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
+CFRelease(locale);
+
+CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UINoAMPMTimeFormat));
+var time = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
+document.write('<h1>');
+document.write(time);
+document.write('</h1>');
+CFRelease(time);
+
+CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UIWeekdayNoYearDateFormat));
+var date = CFDateFormatterCreateStringWithDate(NULL, formatter, now);
+document.write('<h2>');
+document.write(date);
+document.write('</h2>');
+CFRelease(date);
+
+CFRelease(formatter);
+CFRelease(now);
+
+document.write('</div>');
diff --git a/control b/control
index c71c1599f509a52755d380bb7cd88b46cc889ba3..40de1b0586c08b515e0aae31b96aac8656e83791 100644 (file)
--- a/control
+++ b/control
@@ -3,10 +3,10 @@ Priority: optional
 Section: Development
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.3354-1
+Version: 0.9.3359-1
 Description: framework for managing lock screen plugins
 Name: Cydget
-Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1)
+Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), firmware (<< 5.0), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1)
 Replaces: cydialer (<< 0.9.17)
 Conflicts: gsc.wildcat
 Author: Jay Freeman (saurik) <saurik@saurik.com>