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 - (NSString *) selectedStylesheetSet;
124 - (void) setSelectedStylesheetSet:(NSString *)value;
125 - (DOMStyleSheetList *) styleSheets;
128 @interface NSURL (Apple)
129 - (BOOL) isSpringboardHandledURL;
132 @interface UIWebView (Apple)
133 - (UIWebDocumentView *) _documentView;
134 - (void) setDataDetectorTypes:(NSInteger)types;
135 - (void) _setDrawInWebThread:(BOOL)draw;
136 - (UIScrollView *) _scrollView;
137 - (UIScroller *) _scroller;
138 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
139 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
142 @protocol CydgetWebViewDelegate <UIWebViewDelegate>
143 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
146 MSClassHook(UIApplication)
148 MSInstanceMessageHook1(void, UIApplication, openURL, NSURL *, url) {
149 [self applicationOpenURL:url];
152 @implementation NSURL (Cydget)
154 - (NSNumber *) cydget$isSpringboardHandledURL {
155 return [NSNumber numberWithBool:[self isSpringboardHandledURL]];
162 MSInstanceMessageHook0(BOOL, NSURL, isSpringboardHandledURL) {
163 if (![NSThread isMainThread])
166 return [[self cydget$yieldToSelector:@selector(cydget$isSpringboardHandledURL)] boolValue];
169 @implementation UIWebView (WebCycript)
171 - (void) updateStyles {
172 DOMDocument *document([[[[self _documentView] webView] mainFrame] DOMDocument]);
173 [document setSelectedStylesheetSet:[document selectedStylesheetSet]];
178 extern "C" void WebCycriptSetupView(WebView *webview) {
179 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
180 if (void (*CYSetupContext)(JSGlobalContextRef) = reinterpret_cast<void (*)(JSGlobalContextRef)>(dlsym(handle, "CydgetSetupContext"))) {
181 WebFrame *frame([webview mainFrame]);
182 JSGlobalContextRef context([frame globalContext]);
184 CYSetupContext(context);
185 } @catch (NSException *e) {
186 NSLog(@"*** CydgetSetupContext => %@", e);
220 union ScriptSourceCode {
222 JSC::SourceCode source_;
226 JSC::SourceCode source_;
230 class CFStringStruct {
240 CFStringStruct(const CFStringStruct &value) :
241 value_((CFStringRef) CFRetain(value.value_))
249 operator CFStringRef() const {
253 operator NSString *() const {
254 return (NSString *) value_;
258 // String Helpers {{{
259 static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *);
260 static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *);
261 static CFStringStruct (*_ZNK3WTF6String14createCFStringEv)(const WebCore::String *);
262 static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *);
264 static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) {
268 } else if (_ZNK7WebCore6String10charactersEv != NULL) {
269 data = (*_ZNK7WebCore6String10charactersEv)(&string);
271 } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) {
272 data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string);
274 } else if (_ZNK3WTF6String14createCFStringEv != NULL) {
275 CFStringStruct cf((*_ZNK3WTF6String14createCFStringEv)(&string));
276 data = (const UChar *) [cf cStringUsingEncoding:NSUTF16StringEncoding];
277 length = CFStringGetLength(cf);
284 if (_ZNK7WebCore6String6lengthEv != NULL)
285 length = (*_ZNK7WebCore6String6lengthEv)(&string);
287 for (length = 0; data[length] != 0; ++length);
293 static bool StringEquals(const WebCore::String &string, const char *value) {
296 if (!StringGet(string, data, size))
299 size_t length(strlen(value));
303 for (size_t index(0); index != length; ++index)
304 if (data[index] != value[index])
311 static bool cycript_;
313 MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) {
314 if (!StringEquals(mime, "text/cycript")) {
316 return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime);
319 static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL));
327 // Script Compiler {{{
328 static void Log(const WebCore::String &string) {
332 if (!StringGet(string, data, length))
335 UChar terminated[length + 1];
336 terminated[length] = 0;
337 memcpy(terminated, data, length * 2);
338 NSLog(@"wtf %p:%zu:%S:", &string, length, terminated);
342 static bool Cycriptify(const uint16_t *&data, size_t &size) {
345 if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL))
346 if (void (*CydgetMemoryParse)(const uint16_t **, size_t *) = reinterpret_cast<void (*)(const uint16_t **, size_t *)>(dlsym(handle, "CydgetMemoryParse"))) @try {
347 CydgetMemoryParse(&data, &size);
349 } @catch (NSException *e) {
350 NSLog(@"*** CydgetMemoryParse => %@", e);
355 static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned);
356 static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned);
358 static void Cycriptify(const WebCore::String &source, int *psize = NULL) {
365 if (!StringGet(source, data, length))
369 if (!Cycriptify(data, size))
372 WebCore::String &script(const_cast<WebCore::String &>(source));
373 _ZN7WebCore6String8truncateEj(&script, 0);
374 _ZN7WebCore6String6appendEPKtj(&script, data, size);
385 static WebCore::String *string;
388 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, void *_this, const WebCore::String &string, State state, const WebCore::String &url, int line) {
390 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line);
394 MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) {
396 JSC::SourceCode *source(_this[iOS32 ? 6 : 0]);
397 const uint16_t *data(source->data());
398 size_t size(source->length());
400 if (Cycriptify(data, size)) {
401 source->~SourceCode();
402 // XXX: I actually don't have the original URL here: pants
403 new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1);
408 return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message);
412 MSHook(const WebCore::String &, _ZNK7WebCore4Node11textContentEb, void *_this, bool convert) {
413 const WebCore::String &code(__ZNK7WebCore4Node11textContentEb(_this, convert));
414 string = const_cast<WebCore::String *>(&code);
420 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) {
422 return __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line);
426 MSHook(const WebCore::String &, _ZN7WebCore12CachedScript6scriptEv, void *_this) {
427 const WebCore::String &script(__ZN7WebCore12CachedScript6scriptEv(_this));
428 string = const_cast<WebCore::String *>(&script);
433 MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, void *_this, JSC::ScriptSourceCode &script, State state) {
434 if (string != NULL) {
435 JSC::SourceCode *source(iOS4 ? &script.New.source_ : &script.Old.source_);
436 Cycriptify(*string, &source->end_);
440 return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE(_this, script, state);
444 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
446 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE(_this, source, url, position);
450 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
452 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE(_this, position, legacy);
455 void (*$_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE)(void *_this, int legacy);
458 MSHook(void, _ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, void *_this, JSC::ScriptSourceCode &script) {
459 if (string != NULL) {
460 JSC::SourceCode *source(&script.New.source_);
461 $_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE(_this, 0);
462 Cycriptify(*string, &source->end_);
466 return __ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE(_this, script);
470 MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, void *_this, const WebCore::String &source, const WebCore::KURL &url, void *position) {
472 return __ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE(_this, source, url, position);
476 MSHook(void, _ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, void *_this, void *position, int legacy) {
478 return __ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE(_this, position, legacy);
481 /* Cydget:// Protocol {{{ */
482 @interface CydgetURLProtocol : NSURLProtocol {
487 @implementation CydgetURLProtocol
489 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
490 NSURL *url([request URL]);
493 NSString *scheme([[url scheme] lowercaseString]);
494 if (scheme == nil || ![scheme isEqualToString:@"cydget"])
499 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
503 - (void) _returnPNGWithImage:(UIImage *)icon forRequest:(NSURLRequest *)request {
504 id<NSURLProtocolClient> client([self client]);
506 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
508 NSData *data(UIImagePNGRepresentation(icon));
510 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:@"image/png" expectedContentLength:-1 textEncodingName:nil] autorelease]);
511 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
512 [client URLProtocol:self didLoadData:data];
513 [client URLProtocolDidFinishLoading:self];
517 - (void) startLoading {
518 id<NSURLProtocolClient> client([self client]);
519 NSURLRequest *request([self request]);
521 NSURL *url([request URL]);
522 NSString *href([url absoluteString]);
524 NSString *path([href substringFromIndex:9]);
525 NSRange slash([path rangeOfString:@"/"]);
528 if (slash.location == NSNotFound) {
532 command = [path substringToIndex:slash.location];
533 path = [path substringFromIndex:(slash.location + 1)];
536 if ([command isEqualToString:@"_UIImageWithName"]) {
539 path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
540 UIImage *icon(_UIImageWithName(path));
541 [self _returnPNGWithImage:icon forRequest:request];
543 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
547 - (void) stopLoading {
552 /* Cydget-CGI:// Protocol {{{ */
553 @interface CydgetCGIURLProtocol : NSURLProtocol {
555 CFHTTPMessageRef http_;
556 NSFileHandle *handle_;
561 @implementation CydgetCGIURLProtocol
563 + (BOOL) canInitWithRequest:(NSURLRequest *)request {
564 NSURL *url([request URL]);
567 NSString *scheme([[url scheme] lowercaseString]);
568 if (scheme == nil || ![scheme isEqualToString:@"cydget-cgi"])
573 + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
577 - (id) initWithRequest:(NSURLRequest *)request cachedResponse:(NSCachedURLResponse *)response client:(id<NSURLProtocolClient>)client {
578 if ((self = [super initWithRequest:request cachedResponse:response client:client]) != nil) {
583 - (void) startLoading {
584 id<NSURLProtocolClient> client([self client]);
585 NSURLRequest *request([self request]);
586 NSURL *url([request URL]);
588 NSString *path([url path]);
590 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
594 NSFileManager *manager([NSFileManager defaultManager]);
595 if (![manager fileExistsAtPath:path]) {
596 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
601 _assert(pipe(fds) != -1);
606 _assert(close(fds[0]) != -1);
607 _assert(close(fds[1]) != -1);
608 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]];
613 const char *script([path UTF8String]);
615 setenv("GATEWAY_INTERFACE", "CGI/1.1", true);
616 setenv("SCRIPT_FILENAME", script, true);
617 NSString *query([url query]);
619 setenv("QUERY_STRING", [query UTF8String], true);
621 _assert(dup2(fds[1], 1) != -1);
622 _assert(close(fds[0]) != -1);
623 _assert(close(fds[1]) != -1);
625 execl(script, script, NULL);
630 _assert(close(fds[1]) != -1);
632 _assert(http_ == NULL);
633 http_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE);
634 CFHTTPMessageAppendBytes(http_, (const uint8_t *) "HTTP/1.1 200 OK\r\n", 17);
636 _assert(handle_ == nil);
637 handle_ = [[NSFileHandle alloc] initWithFileDescriptor:fds[0] closeOnDealloc:YES];
639 [[NSNotificationCenter defaultCenter]
641 selector:@selector(onRead:)
642 name:@"NSFileHandleReadCompletionNotification"
646 [handle_ readInBackgroundAndNotify];
649 - (void) onRead:(NSNotification *)notification {
650 NSFileHandle *handle([notification object]);
652 NSData *data([[notification userInfo] objectForKey:NSFileHandleNotificationDataItem]);
654 if (size_t length = [data length]) {
655 CFHTTPMessageAppendBytes(http_, reinterpret_cast<const UInt8 *>([data bytes]), length);
656 [handle readInBackgroundAndNotify];
658 id<NSURLProtocolClient> client([self client]);
660 CFStringRef mime(CFHTTPMessageCopyHeaderFieldValue(http_, CFSTR("Content-type")));
662 [client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadServerResponse userInfo:nil]];
664 NSURLRequest *request([self request]);
666 NSURLResponse *response([[[NSURLResponse alloc] initWithURL:[request URL] MIMEType:(NSString *)mime expectedContentLength:-1 textEncodingName:nil] autorelease]);
669 [client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
671 CFDataRef body(CFHTTPMessageCopyBody(http_));
672 [client URLProtocol:self didLoadData:(NSData *)body];
675 [client URLProtocolDidFinishLoading:self];
683 //[client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorNetworkConnectionLost userInfo:nil]];
685 - (void) stopLoading_ {
686 [[NSNotificationCenter defaultCenter] removeObserver:self];
688 if (handle_ != nil) {
696 _syscall(waitpid(pid_, &status, 0));
701 - (void) stopLoading {
703 performSelectorOnMainThread:@selector(stopLoading_)
713 class MediaQueryEvaluator;
714 class CSSParserValueList;
718 struct MediaQueryExp {
725 typedef std::map<std::string, BOOL (*)()> StyleMap_;
726 static StyleMap_ styles_;
728 extern "C" void WebCycriptRegisterStyle(const char *name, BOOL (*code)()) {
729 styles_.insert(std::make_pair(name, code));
732 MSHook(bool, _ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore::MediaQueryEvaluator *_this, WebCore::String &query) {
734 for (StyleMap_::const_iterator style(styles_.begin()); style != styles_.end(); ++style)
735 if (StringEquals(query, style->first.c_str()))
736 return style->second();
737 return __ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE(_this, query);
740 MSHook(void *, _ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore::MediaQueryExp *_this, WebCore::String &query, WebCore::CSSParserValueList *values) {
742 void *value(__ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE(_this, query, values));
744 for (StyleMap_::const_iterator style(styles_.begin()); style != styles_.end(); ++style)
745 if (StringEquals(query, style->first.c_str()))
746 _this->valid_ = true;
750 template <typename Type_>
751 static void dlset(Type_ &function, const char *name) {
752 function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
755 #define msset(function, handle) \
756 MSHookSymbol(function, "_" #function, handle)
759 iOS4 = kCFCoreFoundationVersionNumber >= 550.32;
760 iOS32 = !iOS4 && kCFCoreFoundationVersionNumber >= 478.61;
763 size_t size(sizeof(maxproc));
764 if (sysctlbyname("kern.maxproc", &maxproc, &size, NULL, 0) == -1)
765 NSLog(@"sysctlbyname(\"kern.maxproc\", ?)");
766 else if (maxproc < 72) {
768 if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1)
769 NSLog(@"sysctlbyname(\"kern.maxproc\", #)");
772 [NSURLProtocol registerClass:[CydgetURLProtocol class]];
773 [WebView registerURLSchemeAsLocal:@"cydget"];
775 [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]];
776 [WebView registerURLSchemeAsLocal:@"cydget-cgi"];
778 MSImageRef JavaScriptCore(NULL);
779 if (JavaScriptCore == NULL)
780 JavaScriptCore = MSGetImageByName("/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore");
781 if (JavaScriptCore == NULL)
782 JavaScriptCore = MSGetImageByName("/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore");
784 MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
787 void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, JSC::JSGlobalData *, int *, JSC::UString *);
788 dlset(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, "_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE");
789 if (_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE != NULL)
790 MSHookFunction(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE));
793 bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &) = NULL;
794 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
795 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE", WebCore);
796 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE == NULL)
797 MSHookSymbol(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKN3WTF6StringE", WebCore);
798 if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL)
799 MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE));
801 void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int) = NULL;
802 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi == NULL)
803 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi", WebCore);
804 if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL)
805 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi));
808 const WebCore::String &(*_ZNK7WebCore4Node11textContentEb)(void *, bool) = NULL;
809 if (_ZNK7WebCore4Node11textContentEb == NULL)
810 MSHookSymbol(_ZNK7WebCore4Node11textContentEb, "__ZNK7WebCore4Node11textContentEb", WebCore);
811 if (_ZNK7WebCore4Node11textContentEb != NULL)
812 MSHookFunction(_ZNK7WebCore4Node11textContentEb, MSHake(_ZNK7WebCore4Node11textContentEb));
815 const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *) = NULL;
816 if (_ZN7WebCore12CachedScript6scriptEv == NULL)
817 MSHookSymbol(_ZN7WebCore12CachedScript6scriptEv, "__ZN7WebCore12CachedScript6scriptEv", WebCore);
818 if (_ZN7WebCore12CachedScript6scriptEv != NULL)
819 MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv));
821 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)(void *, const WebCore::String &, State, const WebCore::String &, int) = NULL;
822 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i == NULL)
823 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i", WebCore);
824 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL)
825 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i));
827 State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, JSC::ScriptSourceCode &, State) = NULL;
828 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE == NULL)
829 MSHookSymbol(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, "__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE", WebCore);
830 if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL)
831 MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE));
833 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
834 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, WebCore);
835 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE != NULL)
836 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionINS1_14OneBasedNumberEEE));
838 void (*_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE)(void *, const WebCore::String &, const WebCore::KURL &, void *);
839 msset(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, WebCore);
840 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE == NULL)
841 MSHookSymbol(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, "__ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_3URLERKNS1_12TextPositionE", WebCore);
842 if (_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE != NULL)
843 MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKN3WTF6StringERKNS_4KURLERKNS1_12TextPositionE));
845 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE)(void *, void *, int);
846 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, WebCore);
847 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE != NULL)
848 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionINS1_14OneBasedNumberEEENS0_17LegacyTypeSupportE));
850 void (*_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE)(void *, void *, int);
851 msset(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, WebCore);
852 if (_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE != NULL)
853 MSHookFunction(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE, MSHake(_ZN7WebCore13ScriptElement13prepareScriptERKN3WTF12TextPositionENS0_17LegacyTypeSupportE));
855 MSHookSymbol($_ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE, "__ZNK7WebCore13ScriptElement21isScriptTypeSupportedENS0_17LegacyTypeSupportE", WebCore);
857 void (*_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE)(void *, JSC::ScriptSourceCode &);
858 msset(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, WebCore);
859 if (_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE != NULL)
860 MSHookFunction(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore13ScriptElement13executeScriptERKNS_16ScriptSourceCodeE));
862 if (_ZN7WebCore6String6appendEPKtj == NULL)
863 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN7WebCore6String6appendEPKtj", WebCore);
864 if (_ZN7WebCore6String6appendEPKtj == NULL)
865 msset(_ZN7WebCore6String6appendEPKtj, JavaScriptCore);
866 if (_ZN7WebCore6String6appendEPKtj == NULL)
867 MSHookSymbol(_ZN7WebCore6String6appendEPKtj, "__ZN3WTF6String6appendEPKtj", JavaScriptCore);
869 if (_ZN7WebCore6String8truncateEj == NULL)
870 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN7WebCore6String8truncateEj", WebCore);
871 if (_ZN7WebCore6String8truncateEj == NULL)
872 msset(_ZN7WebCore6String8truncateEj, JavaScriptCore);
873 if (_ZN7WebCore6String8truncateEj == NULL)
874 MSHookSymbol(_ZN7WebCore6String8truncateEj, "__ZN3WTF6String8truncateEj", JavaScriptCore);
876 msset(_ZNK7WebCore6String10charactersEv, WebCore);
878 msset(_ZN7WebCore6String29charactersWithNullTerminationEv, JavaScriptCore);
879 if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL)
880 MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore);
882 msset(_ZNK3WTF6String14createCFStringEv, JavaScriptCore);
884 msset(_ZNK7WebCore6String6lengthEv, WebCore);
886 bool (*_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE)(WebCore::MediaQueryEvaluator *, WebCore::String &);
887 msset(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, WebCore);
888 if (_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE != NULL)
889 MSHookFunction(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE, MSHake(_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE));
891 void *(*_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE)(WebCore::MediaQueryExp *, WebCore::String &, WebCore::CSSParserValueList *);
892 msset(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, WebCore);
893 if (_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE != NULL)
894 MSHookFunction(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE, MSHake(_ZN7WebCore13MediaQueryExpC2ERKN3WTF12AtomicStringEPNS_18CSSParserValueListE));
898 MSMetaClassHook(WebView)
900 MSClassMessageHook0(void, WebView, enableWebThread) {
901 if (kCFCoreFoundationVersionNumber >= 478.61)
904 NSLog(@"-[WebView enableWebThread]");