From 8b4b47fef07b397f2171773d00e35cbc27e20d8a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 12 Jul 2010 12:53:40 +0000 Subject: [PATCH] Almost entirely fixed iOS4. --- LockScreen.mm | 61 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index fc710b3..42e7125 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -72,7 +72,9 @@ extern NSString * const kCAFilterNearest; #include #include "JSGlobalData.h" + #include "SourceCode.h" +#include "SourceCode4.h" #include #include @@ -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(_this[0])); + JSC::SourceCode4 *source4(reinterpret_cast(_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(reinterpret_cast(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(reinterpret_cast(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)); -- 2.45.2