1 /* Cydget - open-source AwayView plugin multiplexer
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cydget is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cydget is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cydget. If not, see <http://www.gnu.org/licenses/>.
22 #include <CydiaSubstrate/CydiaSubstrate.h>
23 #include <UIKit/UIKit.h>
25 #include <sys/sysctl.h>
28 #include <WebKit/WebFrame.h>
29 #include <WebKit/WebView.h>
33 #include "yieldToSelector.h"
35 _disused static unsigned trace_;
37 #define _trace() do { \
38 NSLog(@"_trace(%u)@%s:%u[%s](%p)\n", \
39 trace_++, __FILE__, __LINE__, __FUNCTION__, pthread_self() \
43 #define _assert(test) do \
45 NSLog(@"_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
50 #define _syscall(expr) \
51 do if ((long) (expr) != -1) \
53 else switch (errno) { \
60 extern "C" UIImage *_UIImageWithName(NSString *name);
62 typedef uint16_t UChar;
64 @interface UIApplication (Apple)
65 - (void) applicationOpenURL:(NSURL *)url;
68 @interface UIScroller : UIView
69 - (CGSize) contentSize;
70 - (void) setOffset:(CGPoint)offset;
73 @interface UIWebDocumentView : UIView
74 - (WebView *) webView;
77 @interface UIView (Apple)
78 - (UIScroller *) _scroller;
81 static bool iOS32, iOS4;
83 @interface NSString (UIKit)
84 - (NSString *) stringByAddingPercentEscapes;
87 @implementation UIWebDocumentView (WebCycript)
89 - (void) _setScrollerOffset:(CGPoint)offset {
90 UIScroller *scroller([self _scroller]);
92 CGSize size([scroller contentSize]);
93 CGSize bounds([scroller bounds].size);
96 max.x = size.width - bounds.width;
97 max.y = size.height - bounds.height;
105 offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x;
106 offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y;
108 [scroller setOffset:offset];
113 @interface DOMCSSStyleSheet : NSObject
114 - (int) addRule:(NSString *)rule style:(NSString *)style index:(unsigned)index;
115 - (void) deleteRule:(unsigned)index;
118 @interface DOMStyleSheetList : NSObject
119 - (DOMCSSStyleSheet *) item:(unsigned)index;
122 @interface DOMDocument : NSObject
123 - (DOMStyleSheetList *) styleSheets;
126 @interface NSURL (Apple)
127 - (BOOL) isSpringboardHandledURL;
130 @interface UIWebView (Apple)
131 - (UIWebDocumentView *) _documentView;
132 - (void) setDataDetectorTypes:(NSInteger)types;
133 - (void) _setDrawInWebThread:(BOOL)draw;
134 - (UIScrollView *) _scrollView;
135 - (UIScroller *) _scroller;
136 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
137 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
140 @protocol CydgetWebViewDelegate <UIWebViewDelegate>
141 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
144 MSClassHook(UIApplication)
146 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
147 [self applicationOpenURL:url];
150 @implementation NSURL (Cydget)
152 - (NSNumber *) cydget$isSpringboardHandledURL {
153 return [NSNumber numberWithBool:[self isSpringboardHandledURL]];
160 MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) {
161 if (![NSThread isMainThread])
164 return [[self cydget$yieldToSelector:@selector(cydget$isSpringboardHandledURL)] boolValue];
167 @implementation UIWebView (WebCycript)
169 - (void) updateStyles {
170 DOMCSSStyleSheet *sheet([[[[[[self _documentView] webView] mainFrame] DOMDocument] styleSheets] item:0]);
171 [sheet addRule:@"cydget" style:@"color: black" index:0];
172 [sheet deleteRule:0];
177 extern "C" void WebCycriptSetupView(WebView *webview) {
178 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
179 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
180 WebFrame *frame([webview mainFrame]);
181 JSGlobalContextRef context([frame globalContext]);
183 CYSetupContext(context);
184 } @catch (NSException *e) {
185 NSLog(@"*** CydgetSetupContext => %@", e);
219 union ScriptSourceCode {
221 JSC::SourceCode source_;
225 JSC::SourceCode source_;
229 class CFStringStruct {
239 CFStringStruct(const CFStringStruct &value) :
240 value_((CFStringRef) CFRetain(value.value_))
248 operator CFStringRef() const {
252 operator NSString *() const {
253 return (NSString *) value_;
257 // String Helpers {{{
258 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
259 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
260 static CFStringStruct (*_ZNK3WTF6String14createCFStringEv)(const WebCore::String *);
261 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
263 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
267 } else if (_ZNK7WebCore6String10charactersEv != NULL) {
268 data = (*_ZNK7WebCore6String10charactersEv)(&string);
270 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
271 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
273 } else if (_ZNK3WTF6String14createCFStringEv != NULL) {
274 CFStringStruct cf((*_ZNK3WTF6String14createCFStringEv)(&string));
275 data = (const UChar *) [cf cStringUsingEncoding:NSUTF16StringEncoding];
276 length = CFStringGetLength(cf);
283 if (_ZNK7WebCore6String6lengthEv != NULL)
284 length = (*_ZNK7WebCore6String6lengthEv)(&string);
286 for (length = 0; data[length] != 0; ++length);
292 static bool StringEquals(const WebCore::String &string, const char *value) {
295 if (!StringGet(string, data, size))
298 size_t length(strlen(value));
302 for (size_t index(0); index != length; ++index)
303 if (data[index] != value[index])
310 static bool cycript_;
312 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
313 if (!StringEquals(mime, "text/cycript")) {
315 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
318 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
326 // Script Compiler {{{
327 static void Log(const WebCore::String &string) {
331 if (!StringGet(string, data, length))
334 UChar terminated[length + 1];
335 terminated[length] = 0;
336 memcpy(terminated, data, length * 2);
337 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
341 static bool Cycriptify(const uint16_t *&data, size_t &size) {
344 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
345 if (void (*CydgetMemoryParse)(const uint16_t **, size_t *) = reinterpret_cast<void (*)(const uint16_t **, size_t *)>(dlsym(handle, "CydgetMemoryParse"))) @try {
346 CydgetMemoryParse(&data, &size);
348 } @catch (NSException *e) {
349 NSLog(@"*** CydgetMemoryParse => %@", e);
354 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
355 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
357 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
364 if (!StringGet(source, data, length))
368 if (!Cycriptify(data, size))
371 WebCore::String &script(const_cast<WebCore::String &>(source));
372 _ZN7WebCore6String8truncateEj(&script, 0);
373 _ZN7WebCore6String6appendEPKtj(&script, data, size);
384 static WebCore::String *string;
387 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
389 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
393 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
395 JSC::SourceCode *source(_this[iOS32 ? 6 : 0]);
396 const uint16_t *data(source->data());
397 size_t size(source->length());
399 if (Cycriptify(data, size)) {
400 source->~SourceCode();
401 // XXX: I actually don't have the original URL here: pants
402 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
407 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
411 MSHook(const WebCore::String &, _ZNK7WebCore4Node11textContentEb, void *_this, bool convert) {
412 const WebCore::String &code(__ZNK7WebCore4Node11textContentEb(_this, convert));
413 string = const_cast<WebCore::String *>(&code);
419 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
421 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
425 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
426 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
427 string = const_cast<WebCore::String *>(&script);
432 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, JSC::ScriptSourceCode &script, State state) {
433 if (string != NULL) {
434 JSC::SourceCode *source(iOS4 ? &script.New.source_ : &script.Old.source_);
435 Cycriptify(*string, &source->end_);
439 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, script, state);
443 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
445 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
449 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
451 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
454 void (*$_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
457 MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, JSC::ScriptSourceCode &script) {
458 if (string != NULL) {
459 JSC::SourceCode *source(&script.New.source_);
460 $_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
461 Cycriptify(*string, &source->end_);
465 return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, script);
469 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
471 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE(_this, source, url, position);
475 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
477 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE(_this, position, legacy);
480 /* Cydget:// Protocol {{{ */
481 @interface CydgetURLProtocol : NSURLProtocol {
486 @implementation CydgetURLProtocol
488 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
489 NSURL *url([request URL]);
492 NSString *scheme([[url scheme] lowercaseString]);
493 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
498 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
502 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
503 id<NSURLProtocolClient> client([self client]);
505 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
507 NSData *data(UIImagePNGRepresentation(icon));
509 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
510 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
511 [client URLProtocol:self didLoadData:data];
512 [client URLProtocolDidFinishLoading:self];
516 - (void) startLoading {
517 id<NSURLProtocolClient> client([self client]);
518 NSURLRequest *request([self request]);
520 NSURL *url([request URL]);
521 NSString *href([url absoluteString]);
523 NSString *path([href substringFromIndex:9]);
524 NSRange slash([path rangeOfString:@"/"]);
527 if (slash.location == NSNotFound) {
531 command = [path substringToIndex:slash.location];
532 path = [path substringFromIndex:(slash.location + 1)];
535 if ([command isEqualToString:@"_UIImageWithName"]) {
538 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
539 UIImage *icon(_UIImageWithName(path));
540 [self _returnPNGWithImage:icon forRequest:request];
542 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
546 - (void) stopLoading {
551 /* Cydget-CGI:// Protocol {{{ */
552 @interface CydgetCGIURLProtocol : NSURLProtocol {
554 CFHTTPMessageRef http_;
555 NSFileHandle *handle_;
560 @implementation CydgetCGIURLProtocol
562 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
563 NSURL *url([request URL]);
566 NSString *scheme([[url scheme] lowercaseString]);
567 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
572 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
576 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
577 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
582 - (void) startLoading {
583 id<NSURLProtocolClient> client([self client]);
584 NSURLRequest *request([self request]);
585 NSURL *url([request URL]);
587 NSString *path([url path]);
589 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
593 NSFileManager *manager([NSFileManager defaultManager]);
594 if (![manager fileExistsAtPath:path]) {
595 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
600 _assert(pipe(fds) != -1);
605 _assert(close(fds[0]) != -1);
606 _assert(close(fds[1]) != -1);
607 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
612 const char *script([path UTF8String]);
614 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
615 setenv("SCRIPT_FILENAME", script, true);
616 NSString *query([url query]);
618 setenv("QUERY_STRING", [query UTF8String], true);
620 _assert(dup2(fds[1], 1) != -1);
621 _assert(close(fds[0]) != -1);
622 _assert(close(fds[1]) != -1);
624 execl(script, script, NULL);
629 _assert(close(fds[1]) != -1);
631 _assert(http_ == NULL);
632 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
633 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
635 _assert(handle_ == nil);
636 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
638 [[NSNotificationCenter defaultCenter]
640 selector:@selector(onRead:)
641 name:@"NSFileHandleReadCompletionNotification"
645 [handle_ readInBackgroundAndNotify];
648 - (void) onRead:(NSNotification *)notification {
649 NSFileHandle *handle([notification object]);
651 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
653 if (size_t length = [data length]) {
654 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
655 [handle readInBackgroundAndNotify];
657 id<NSURLProtocolClient> client([self client]);
659 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
661 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
663 NSURLRequest *request([self request]);
665 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
668 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
670 CFDataRef body(CFHTTPMessageCopyBody(http_));
671 [client URLProtocol:self didLoadData:(NSData *)body];
674 [client URLProtocolDidFinishLoading:self];
682 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
684 - (void) stopLoading_ {
685 [[NSNotificationCenter defaultCenter] removeObserver:self];
687 if (handle_ != nil) {
695 _syscall(waitpid(pid_, &status, 0));
700 - (void) stopLoading {
702 performSelectorOnMainThread:@selector(stopLoading_)
712 class MediaQueryEvaluator;
713 class CSSParserValueList;
717 struct MediaQueryExp {
724 typedef std::map<std::string, BOOL (*)()> StyleMap_;
725 static StyleMap_ styles_;
727 extern "C" void WebCycriptRegisterStyle(const char *name, BOOL (*code)()) {
728 styles_.insert(std::make_pair(name, code));
731 MSHook(bool, _ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore::MediaQueryEvaluator *_this, WebCore::String &query) {
733 for (StyleMap_::const_iterator style(styles_.begin()); style != styles_.end(); ++style)
734 if (StringEquals(query, style->first.c_str()))
735 return style->second();
736 return __ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE(_this, query);
739 MSHook(void *, _ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore::MediaQueryExp *_this, WebCore::String &query, WebCore::CSSParserValueList *values) {
741 void *value(__ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE(_this, query, values));
743 for (StyleMap_::const_iterator style(styles_.begin()); style != styles_.end(); ++style)
744 if (StringEquals(query, style->first.c_str()))
745 _this->valid_ = true;
749 template <typename Type_>
750 static void dlset(Type_ &function, const char *name) {
751 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
754 #define msset(function, handle) \
755 MSHookSymbol(function, "_" #function, handle)
758 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
759 iOS32 = !iOS4 && kCFCoreFoundationVersionNumber >= 478.61;
762 size_t size(sizeof(maxproc));
763 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
764 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
765 else if (maxproc < 72) {
767 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
768 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
771 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
772 [WebView registerURLSchemeAsLocal:@"cydget"];
774 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
775 [WebView registerURLSchemeAsLocal:@"cydget-cgi"];
777 MSImageRef JavaScriptCore(NULL);
778 if (JavaScriptCore == NULL)
779 JavaScriptCore = MSGetImageByName("/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore");
780 if (JavaScriptCore == NULL)
781 JavaScriptCore = MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore");
783 MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
786 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
787 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
788 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
789 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
792 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &) = NULL;
793 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
794 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE", WebCore);
795 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
796 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKN3WTF6StringE", WebCore);
797 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
798 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
800 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int) = NULL;
801 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi == NULL)
802 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi", WebCore);
803 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
804 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
807 const WebCore::String &(*_ZNK7WebCore4Node11textContentEb)(void *, bool) = NULL;
808 if (_ZNK7WebCore4Node11textContentEb == NULL)
809 MSHookSymbol(_ZNK7WebCore4Node11textContentEb, "__ZNK7WebCore4Node11textContentEb", WebCore);
810 if (_ZNK7WebCore4Node11textContentEb != NULL)
811 MSHookFunction(_ZNK7WebCore4Node11textContentEb, MSHake(_ZNK7WebCore4Node11textContentEb));
814 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *) = NULL;
815 if (_ZN7WebCore12CachedScript6scriptEv == NULL)
816 MSHookSymbol(_ZN7WebCore12CachedScript6scriptEv, "__ZN7WebCore12CachedScript6scriptEv", WebCore);
817 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
818 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
820 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int) = NULL;
821 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i == NULL)
822 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i", WebCore);
823 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
824 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
826 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, JSC::ScriptSourceCode &, State) = NULL;
827 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE == NULL)
828 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE", WebCore);
829 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
830 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
832 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
833 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, WebCore);
834 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
835 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
837 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
838 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, WebCore);
839 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE == NULL)
840 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, "__ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_3URLERKNS1_12TextPositionE", WebCore);
841 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE != NULL)
842 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE));
844 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
845 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
846 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
847 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
849 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE)(void *, void *, int);
850 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, WebCore);
851 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE != NULL)
852 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE));
854 MSHookSymbol($_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, "__ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE", WebCore);
856 void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, JSC::ScriptSourceCode &);
857 msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
858 if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
859 MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
861 if (_ZN7WebCore6String6appendEPKtj == NULL)
862 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN7WebCore6String6appendEPKtj", WebCore);
863 if (_ZN7WebCore6String6appendEPKtj == NULL)
864 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
865 if (_ZN7WebCore6String6appendEPKtj == NULL)
866 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN3WTF6String6appendEPKtj", JavaScriptCore);
868 if (_ZN7WebCore6String8truncateEj == NULL)
869 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN7WebCore6String8truncateEj", WebCore);
870 if (_ZN7WebCore6String8truncateEj == NULL)
871 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
872 if (_ZN7WebCore6String8truncateEj == NULL)
873 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN3WTF6String8truncateEj", JavaScriptCore);
875 msset(_ZNK7WebCore6String10charactersEv, WebCore);
877 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
878 if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL)
879 MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore);
881 msset(_ZNK3WTF6String14createCFStringEv, JavaScriptCore);
883 msset(_ZNK7WebCore6String6lengthEv, WebCore);
885 bool (*_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE)(WebCore::MediaQueryEvaluator *, WebCore::String &);
886 msset(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore);
887 if (_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE != NULL)
888 MSHookFunction(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, MSHake(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE));
890 void *(*_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE)(WebCore::MediaQueryExp *, WebCore::String &, WebCore::CSSParserValueList *);
891 msset(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore);
892 if (_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE != NULL)
893 MSHookFunction(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, MSHake(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE));
897 MSMetaClassHook(WebView)
899 MSClassMessageHook0(void, WebView, enableWebThread) {
900 if (kCFCoreFoundationVersionNumber >= 478.61)
903 NSLog(@"-[WebView enableWebThread]");