From 9ad75c3a3d704ace3d8f6b906bfaa5e27c479a97 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 29 Feb 2012 05:42:00 +0000 Subject: [PATCH] Finish porting Cydget WebCycript to iOS 5.0. --- LockScreen.mm | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/LockScreen.mm b/LockScreen.mm index a4b0e98..a684dce 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -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(&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(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) -- 2.45.2