]> git.saurik.com Git - cydget.git/commitdiff
Finish porting Cydget WebCycript to iOS 5.0.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 29 Feb 2012 05:42:00 +0000 (05:42 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 29 Feb 2012 05:42:00 +0000 (05:42 +0000)
LockScreen.mm

index a4b0e98cee01957d26fbc92fff9b43b7983c9d89..a684dcedc2fe8bf628d37f95c47516f5241079ab 100644 (file)
@@ -438,6 +438,9 @@ static bool StringGet(const WebCore::String &string, const UChar *&data, size_t
         terminated = true;
     } else return false;
 
+    if (data == NULL)
+        return false;
+
     if (_ZNK7WebCore6String6lengthEv != NULL)
         length = (*_ZNK7WebCore6String6lengthEv)(&string);
     else if (terminated)
@@ -510,6 +513,7 @@ static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
     if (!cycript_)
         return;
+    cycript_ = false;
 
     const UChar *data;
     size_t length;
@@ -575,7 +579,7 @@ MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_t
     return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
 }
 
-// iOS 4.x @src=
+// iOS 4.x+5.0 @src=
 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
     const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
     string = const_cast<WebCore::String *>(&script);
@@ -601,6 +605,25 @@ MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12T
     return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
 }
 
+// iOS 5.0 @src=
+MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
+    string = NULL;
+    return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
+}
+
+void (*_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
+
+// iOS 5.0 @src=
+MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, void *source) {
+    if (string != NULL) {
+        _ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
+        Cycriptify(*string, reinterpret_cast<int *>(source) + 3);
+        string = NULL;
+    }
+
+    return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, source);
+}
+
 /* Cydget:// Protocol {{{ */
 @interface CydgetURLProtocol : NSURLProtocol {
 }
@@ -967,6 +990,18 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW
     if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
         MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
 
+    void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
+    msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
+    if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
+        MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
+
+    msset(_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, WebCore);
+
+    void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, void *);
+    msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
+    if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
+        MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
+
     if (_ZN7WebCore6String6appendEPKtj == NULL)
         msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
     if (_ZN7WebCore6String6appendEPKtj == NULL)