From 918265f972193d6dfb4da6c6ea8e33187a1dfeda Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 23 Oct 2010 02:40:19 +0000 Subject: [PATCH] I actually can't believe I got this to work... like, seriously. --- LockScreen.mm | 85 ++++++++++++++++++++++++++++++--------------------- control | 3 +- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index 42e7125..0fba3da 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -74,7 +74,6 @@ extern NSString * const kCAFilterNearest; #include "JSGlobalData.h" #include "SourceCode.h" -#include "SourceCode4.h" #include #include @@ -121,7 +120,7 @@ while (false) static Class $CydgetController(objc_getClass("CydgetController")); static Class $UIFormAssistant(objc_getClass("UIFormAssistant")); -static Class $SBStatusBarController(objc_getClass("SBStatusBarController")); +//static Class $SBStatusBarController(objc_getClass("SBStatusBarController")); static Class $UIWebBrowserView; static bool Wildcat_, iOS4; @@ -963,6 +962,9 @@ extern "C" void *_ZN3WTF10fastMallocEm __attribute__((__weak_import__)); extern "C" void WTFReportAssertionFailure(const char *, int, const char *, const char *) __attribute__((__weak_import__)); extern "C" void *_ZN3WTF8fastFreeEPv __attribute__((__weak_import__)); +static void (*_ZN7WebCore6String6appendEPKtj)(WebCore::String *, const UChar *, unsigned); +static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned); + bool CYWeakHell() { return &_ZN3JSC7UString3Rep14nullBaseStringE == NULL || @@ -976,43 +978,22 @@ bool CYWeakHell() { false; } -MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, void **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) { +MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) { if (!GetParser0()) return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message); else { SetParser(false, true); - 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(); - } + JSC::SourceCode *source(*_this); + const uint16_t *data(source->data()); + size_t 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); - //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); - } + source->~SourceCode(); + new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1); apr_pool_destroy(pool); @@ -1037,6 +1018,28 @@ MSHook(void, _ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, void *_this, } } +MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) { + if (!GetParser0()) + __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line); + else { + const uint16_t *data(source.characters()); + size_t size(source.length()); + + apr_pool_t *pool; + apr_pool_create(&pool, NULL); + + Cycriptify(pool, data, size); + + WebCore::String &script(const_cast(source)); + _ZN7WebCore6String8truncateEj(&script, 0); + _ZN7WebCore6String6appendEPKtj(&script, data, size); + + apr_pool_destroy(pool); + + __ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi(_this, source, url, line); + } +} + struct State { unsigned state; }; @@ -1339,21 +1342,26 @@ static void dlset(Type_ &function, const char *name) { [NSURLProtocol registerClass:[CydgetURLProtocol class]]; [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]]; - 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)); + if (!iOS4) { + void (*_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)(JSC::SourceCode **, 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)); + } void (*_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE)(void *, int, const UChar *, unsigned, int *, int *, JSC::UString *); dlset(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, "_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE"); if (_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE != NULL) MSHookFunction(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE, MSHake(_ZN3KJS6Parser5parseEiPKNS_5UCharEjPiS4_PNS_7UStringE)); - struct nlist nl[4]; + struct nlist nl[7]; memset(nl, 0, sizeof(nl)); nl[0].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE"; nl[1].n_un.n_name = (char *) "__ZN7WebCore13HTMLTokenizer14notifyFinishedEPNS_14CachedResourceE"; nl[2].n_un.n_name = (char *) "__ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE"; + nl[3].n_un.n_name = (char *) "__ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi"; + nl[4].n_un.n_name = (char *) "__ZN7WebCore6String6appendEPKtj"; + nl[5].n_un.n_name = (char *) "__ZN7WebCore6String8truncateEj"; nlist("/System/Library/PrivateFrameworks/WebCore.framework/WebCore", nl); State (*_ZN7WebCore13HTMLTokenizer13scriptHandlerENS0_5StateE)(State); @@ -1367,6 +1375,15 @@ static void dlset(Type_ &function, const char *name) { bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &); nlset(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, nl, 2); MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)); + + if (iOS4) { + void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int); + nlset(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, nl, 3); + MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)); + } + + nlset(_ZN7WebCore6String6appendEPKtj, nl, 4); + nlset(_ZN7WebCore6String8truncateEj, nl, 5); } + (id) rootViewController { diff --git a/control b/control index 3c5300c..c71c159 100644 --- a/control +++ b/control @@ -3,11 +3,12 @@ Priority: optional Section: Development Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3212-1 +Version: 0.9.3354-1 Description: framework for managing lock screen plugins Name: Cydget Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1) Replaces: cydialer (<< 0.9.17) +Conflicts: gsc.wildcat Author: Jay Freeman (saurik) Depiction: http://cydia.saurik.com/info/cydget/ Tag: purpose::library, role::developer -- 2.45.2