From 89afbf46356b3c000d58b03df27be0bbd6a55721 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 26 Oct 2010 10:50:50 +0000 Subject: [PATCH] OMG this finally works. --- LockScreen.mm | 63 +++++++++++++++++++++++++++------- PhotoExample.cydget/index.html | 49 ++++++++++++-------------- PhotoExample.cydget/lcd.cy | 25 ++++++++++++++ control | 4 +-- 4 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 PhotoExample.cydget/lcd.cy diff --git a/LockScreen.mm b/LockScreen.mm index b675fb3..30286f0 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -940,8 +940,10 @@ static bool cycript_; MSHook(bool, _ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, const WebCore::String &mime) { _trace(); - if (mime != "text/cycript") + if (mime != "text/cycript") { + cycript_ = false; return __ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE(mime); + } _trace(); static void *handle(dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL)); @@ -962,6 +964,8 @@ static void Log(const WebCore::String &string) { } static void Cycriptify(apr_pool_t *pool, const uint16_t *&data, size_t &size) { + cycript_ = false; + _trace(); if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL)) if (void (*CYParseUChar)(apr_pool_t *, const uint16_t **, size_t *) = reinterpret_cast(dlsym(handle, "CydgetPoolParse"))) @@ -974,7 +978,6 @@ static void (*_ZN7WebCore6String8truncateEj)(WebCore::String *, unsigned); static void Cycriptify(const WebCore::String &source, int *psize = NULL) { if (!cycript_) return; - cycript_ = false; const uint16_t *data(source.characters()); size_t length(source.length()), size(length); @@ -1036,6 +1039,28 @@ MSHook(State, _ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5Stat return __ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i(_this, string, state, url, line); } +// iOS 3.x +MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::SourceCode **_this, JSC::JSGlobalData *global, int *line, JSC::UString *message) { + if (cycript_) { + JSC::SourceCode *source(*_this); + const uint16_t *data(source->data()); + size_t size(source->length()); + + apr_pool_t *pool; + apr_pool_create(&pool, NULL); + + Cycriptify(pool, data, size); + source->~SourceCode(); + // XXX: I actually don't have the original URL here: pants + new (source) JSC::SourceCode(JSC::UStringSourceProvider::create(JSC::UString(data, size), "cycript://"), 1); + + apr_pool_destroy(pool); + + } + + return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, global, line, message); +} + // iOS 4.x cdata MSHook(void, _ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, void *_this, const WebCore::String &source, const WebCore::KURL &url, int line) { _trace(); @@ -1338,6 +1363,13 @@ static void dlset(Type_ &function, const char *name) { [NSURLProtocol registerClass:[CydgetURLProtocol class]]; [NSURLProtocol registerClass:[CydgetCGIURLProtocol class]]; + 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)); + } + struct nlist nl[9]; memset(nl, 0, sizeof(nl)); @@ -1358,15 +1390,20 @@ static void dlset(Type_ &function, const char *name) { bool (*_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)(const WebCore::String &); nlset(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, nl, 0); - MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)); + if (_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE != NULL) + MSHookFunction(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE, MSHake(_ZN7WebCore16MIMETypeRegistry29isSupportedJavaScriptMIMETypeERKNS_6StringE)); void (*_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)(void *, const WebCore::String &, const WebCore::KURL &, int); nlset(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, nl, 1); - MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)); - - const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *); - nlset(_ZN7WebCore12CachedScript6scriptEv, nl, 2); - MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv)); + if (_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi != NULL) + MSHookFunction(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi, MSHake(_ZN7WebCore16ScriptSourceCodeC2ERKNS_6StringERKNS_4KURLEi)); + + if (iOS4) { + const WebCore::String &(*_ZN7WebCore12CachedScript6scriptEv)(void *); + nlset(_ZN7WebCore12CachedScript6scriptEv, nl, 2); + if (_ZN7WebCore12CachedScript6scriptEv != NULL) + MSHookFunction(_ZN7WebCore12CachedScript6scriptEv, MSHake(_ZN7WebCore12CachedScript6scriptEv)); + } /*const WebCore::String &(*_ZNK7WebCore20StringSourceProvider6sourceEv)(void *); nlset(_ZNK7WebCore20StringSourceProvider6sourceEv, nl, 3); @@ -1377,10 +1414,12 @@ static void dlset(Type_ &function, const char *name) { if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i != NULL) MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_6StringENS0_5StateES3_i)); - State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, void *, State); - nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, nl, 5); - if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL) - MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)); + if (iOS4) { + State (*_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)(void *, void *, State); + nlset(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, nl, 5); + if (_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE != NULL) + MSHookFunction(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE, MSHake(_ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE)); + } nlset(_ZN7WebCore6String6appendEPKtj, nl, 6); nlset(_ZN7WebCore6String8truncateEj, nl, 7); diff --git a/PhotoExample.cydget/index.html b/PhotoExample.cydget/index.html index 3cedb18..d16c353 100644 --- a/PhotoExample.cydget/index.html +++ b/PhotoExample.cydget/index.html @@ -80,33 +80,26 @@ vertical-align:middle; } -
+ + + + + P + + +
diff --git a/PhotoExample.cydget/lcd.cy b/PhotoExample.cydget/lcd.cy new file mode 100644 index 0000000..1d69a17 --- /dev/null +++ b/PhotoExample.cydget/lcd.cy @@ -0,0 +1,25 @@ +document.write('
'); + +var locale = CFLocaleCopyCurrent(); +var now = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()); +var formatter = CFDateFormatterCreate(NULL, locale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle); +CFRelease(locale); + +CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UINoAMPMTimeFormat)); +var time = CFDateFormatterCreateStringWithDate(NULL, formatter, now); +document.write('

'); +document.write(time); +document.write('

'); +CFRelease(time); + +CFDateFormatterSetFormat(formatter, UIDateFormatStringForFormatType(UIWeekdayNoYearDateFormat)); +var date = CFDateFormatterCreateStringWithDate(NULL, formatter, now); +document.write('

'); +document.write(date); +document.write('

'); +CFRelease(date); + +CFRelease(formatter); +CFRelease(now); + +document.write('
'); diff --git a/control b/control index c71c159..40de1b0 100644 --- a/control +++ b/control @@ -3,10 +3,10 @@ Priority: optional Section: Development Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3354-1 +Version: 0.9.3359-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) +Depends: mobilesubstrate (>= 0.9.2587-1), firmware (>= 2.2), firmware (<< 5.0), preferenceloader, apr-lib, pcre, cycript (>= 0.9.292-1) Replaces: cydialer (<< 0.9.17) Conflicts: gsc.wildcat Author: Jay Freeman (saurik) -- 2.45.2