From dff68faf8145d2920b06c3e4b995c7d82b2c08a7 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 27 Nov 2014 04:48:24 -0800 Subject: [PATCH] Use WTF::String::createCFString as slow GetString. --- LockScreen.mm | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/LockScreen.mm b/LockScreen.mm index 52f278f..ec12dff 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -588,20 +588,49 @@ union ScriptSourceCode { } New; }; } +class CFStringStruct { + private: + CFStringRef value_; + + public: + CFStringStruct() : + value_(NULL) + { + } + + ~CFStringStruct() { + } + + operator CFStringRef() const { + return value_; + } + + operator NSString *() const { + return (NSString *) value_; + } +}; + // String Helpers {{{ static const UChar *(*_ZNK7WebCore6String10charactersEv)(const WebCore::String *); static const UChar *(*_ZN7WebCore6String29charactersWithNullTerminationEv)(const WebCore::String *); +static CFStringStruct (*_ZNK3WTF6String14createCFStringEv)(const WebCore::String *); static unsigned (*_ZNK7WebCore6String6lengthEv)(const WebCore::String *); static bool StringGet(const WebCore::String &string, const UChar *&data, size_t &length) { bool terminated; - if (_ZNK7WebCore6String10charactersEv != NULL) { + if (false) { + } else if (_ZNK7WebCore6String10charactersEv != NULL) { data = (*_ZNK7WebCore6String10charactersEv)(&string); terminated = false; } else if (_ZN7WebCore6String29charactersWithNullTerminationEv != NULL) { data = (*_ZN7WebCore6String29charactersWithNullTerminationEv)(&string); terminated = true; + } else if (_ZNK3WTF6String14createCFStringEv != NULL) { + CFStringStruct cf((*_ZNK3WTF6String14createCFStringEv)(&string)); + data = (const UChar *) [cf cStringUsingEncoding:NSUTF16StringEncoding]; + length = CFStringGetLength(cf); + [cf autorelease]; } else return false; if (data == NULL) @@ -1234,6 +1263,8 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW if (_ZN7WebCore6String29charactersWithNullTerminationEv == NULL) MSHookSymbol(_ZN7WebCore6String29charactersWithNullTerminationEv, "__ZN3WTF6String29charactersWithNullTerminationEv", JavaScriptCore); + msset(_ZNK3WTF6String14createCFStringEv, JavaScriptCore); + msset(_ZNK7WebCore6String6lengthEv, WebCore); bool (*_ZNK7WebCore19MediaQueryEvaluator4evalEPKNS_13MediaQueryExpE)(WebCore::MediaQueryEvaluator *, WebCore::String &); -- 2.45.2