From: Jay Freeman (saurik) Date: Fri, 6 Nov 2009 12:16:49 +0000 (+0000) Subject: This seriously sort of worked. X-Git-Tag: v0.9.4000~57 X-Git-Url: https://git.saurik.com/cydget.git/commitdiff_plain/3d796c95ba30398901f3acef1ef186318dd509a9 This seriously sort of worked. --- diff --git a/CydgetCentral.plist b/CydgetCentral.plist index c96cf0f..dfbce56 100644 --- a/CydgetCentral.plist +++ b/CydgetCentral.plist @@ -1,4 +1,5 @@ Plugin = "WebCycriptLockScreen"; Configuration = { - Homepage = "http://www.cydget.org/central/"; + Homepage = "file:///System/Library/LockCydgets/CydgetCentral.cydget/Index.html"; + Cycript = "YES"; }; diff --git a/Index.html b/Index.html new file mode 100644 index 0000000..bfca301 --- /dev/null +++ b/Index.html @@ -0,0 +1,7 @@ + + + + +

testing the stuffs

+

testing the stuffs

+ diff --git a/Index.js b/Index.js new file mode 100644 index 0000000..4d07295 --- /dev/null +++ b/Index.js @@ -0,0 +1,3 @@ +with (Cycript.runtime) { + document.write('

[' + malloc + ']

'); +} diff --git a/LockScreen.mm b/LockScreen.mm index 368d13d..5207b15 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -37,8 +37,6 @@ #include -#define WTF_USE_JSC 1 - #import #import #import @@ -71,10 +69,8 @@ extern NSString * const kCAFilterNearest; #include #include -#include "wtf/Platform.h" -#include "CString.h" -#include "ScriptElement.h" -#include "ScriptSourceCode.h" +//#include "Parser.h" +#include "JSGlobalData.h" @interface WebView (UICaboodle) - (void) setScriptDebugDelegate:(id)delegate; @@ -89,14 +85,6 @@ extern NSString * const kCAFilterNearest; _disused static unsigned trace_; -#define _assert(test) do { \ - if (!(test)) { \ - NSLog(@"_assert(%u)@%s:%u[%s]\n", \ - trace_++, __FILE__, __LINE__, __FUNCTION__\ - ); \ - } \ -} while (false) - #define _trace() do { \ NSLog(@"_trace(%u)@%s:%u[%s]\n", \ trace_++, __FILE__, __LINE__, __FUNCTION__\ @@ -107,6 +95,8 @@ _disused static unsigned trace_; - (NSDictionary *) currentConfiguration; @end +static void (*CYSetupContext)(JSGlobalContextRef); + static Class $CydgetController(objc_getClass("CydgetController")); @interface NSString (UIKit) @@ -246,6 +236,7 @@ static Class $CydgetController(objc_getClass("CydgetController")); UIScroller *scroller_; UIWebDocumentView *document_; + bool cycript_; float width_; CGSize size_; bool editing_; @@ -264,7 +255,6 @@ static Class $CydgetController(objc_getClass("CydgetController")); //#include "UICaboodle/UCInternal.h" - (void) dealloc { -_trace(); WebThreadLock(); WebView *webview([document_ webView]); @@ -491,6 +481,7 @@ _trace(); [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; NSDictionary *configuration([$CydgetController currentConfiguration]); + cycript_ = [[configuration objectForKey:@"Cycript"] boolValue]; NSString *homepage([configuration objectForKey:@"Homepage"]); [self loadURL:[NSURL URLWithString:homepage]]; } return self; @@ -594,6 +585,12 @@ _trace(); } - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame { + if (cycript_ && CYSetupContext != NULL) { + WebView *webview([document_ webView]); + WebFrame *frame([webview mainFrame]); + JSGlobalContextRef context([frame globalContext]); + CYSetupContext(context); + } } - (bool) isLoading { @@ -670,7 +667,6 @@ _trace(); } - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame { - _trace(); /*if ([frame parentFrame] == nil) [self autorelease];*/ @@ -709,54 +705,17 @@ _trace(); @end -WebCore::String (*__ZNK7WebCore6String15stripWhiteSpaceEv)(WebCore::String *); -extern "C" WebCore::String _ZNK7WebCore6String15stripWhiteSpaceEv(WebCore::String *_this) { - return __ZNK7WebCore6String15stripWhiteSpaceEv(_this); } -WebCore::String (*__ZNK7WebCore6String5lowerEv)(WebCore::String *); -extern "C" WebCore::String _ZNK7WebCore6String5lowerEv(WebCore::String *_this) { - return __ZNK7WebCore6String5lowerEv(_this); } -WebCore::CString (*__ZNK7WebCore6String4utf8Ev)(WebCore::String *); -extern "C" WebCore::CString _ZNK7WebCore6String4utf8Ev(WebCore::String *_this) { - return __ZNK7WebCore6String4utf8Ev(_this); } -const char *(*__ZNK7WebCore7CString4dataEv)(WebCore::CString *); -extern "C" const char *_ZNK7WebCore7CString4dataEv(WebCore::CString *_this) { - return __ZNK7WebCore7CString4dataEv(_this); } - -MSHook(void, _ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE, WebCore::ScriptElementData *_this, const WebCore::ScriptSourceCode &code) { - WebCore::String type(_this->m_scriptElement->typeAttributeValue()); - type = type.stripWhiteSpace().lower(); - NSLog(@"type:%s", type.utf8().data()); - __ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE(_this, code); -} - -template -static void nlset(Type_ &function, struct nlist *nl, size_t index) { - struct nlist &name(nl[index]); - uintptr_t value(name.n_value); - _assert(value != 0); - if ((name.n_desc & N_ARM_THUMB_DEF) != 0) - value |= 0x00000001; - function = reinterpret_cast(value); -} +/*extern "C" void _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(JSC::Parser *, JSC::JSGlobalData *, int *, JSC::UString *); +MSHook(void, _ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, JSC::Parser *_this, JSC::JSGlobalData *data, int *line, JSC::UString *message) { + return __ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE(_this, data, line, message); +}*/ @implementation WebCycriptLockScreenController + (void) initialize { - struct nlist nl[6]; - memset(nl, 0, sizeof(nl)); - nl[0].n_un.n_name = (char *) "__ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE"; - nl[1].n_un.n_name = (char *) "__ZNK7WebCore6String15stripWhiteSpaceEv"; - nl[2].n_un.n_name = (char *) "__ZNK7WebCore6String5lowerEv"; - nl[3].n_un.n_name = (char *) "__ZNK7WebCore6String4utf8Ev"; - nl[4].n_un.n_name = (char *) "__ZNK7WebCore7CString4dataEv"; - nlist("/System/Library/PrivateFrameworks/WebCore.framework/WebCore", nl); - void (*_ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE)(WebCore::ScriptElementData *, const WebCore::ScriptSourceCode &); - nlset(_ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE, nl, 0); - nlset(__ZNK7WebCore6String15stripWhiteSpaceEv, nl, 1); - nlset(__ZNK7WebCore6String5lowerEv, nl, 2); - nlset(__ZNK7WebCore6String4utf8Ev, nl, 3); - nlset(__ZNK7WebCore7CString4dataEv, nl, 4); - MSHookFunction(_ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE, MSHake(_ZN7WebCore17ScriptElementData14evaluateScriptERKNS_16ScriptSourceCodeE)); + //MSHookFunction(&_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE, MSHake(_ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE)); + if (void *handle = dlopen("/usr/lib/libcycript.dylib", RTLD_LAZY | RTLD_GLOBAL)) + CYSetupContext = reinterpret_cast(dlsym(handle, "CYSetupContext")); } + (id) rootViewController { diff --git a/makefile b/makefile index 5c0564e..73efca9 100644 --- a/makefile +++ b/makefile @@ -8,11 +8,12 @@ jscore := JavaScriptCore-521 all: WebCycriptLockScreen WebCycriptLockScreen: LockScreen.mm makefile $(base)/../mobilesubstrate/substrate.h - $(target)g++ -bundle -mthumb -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -lobjc -I$(base)/../mobilesubstrate $(link) $(flags) -framework CoreGraphics -framework QuartzCore -framework SpringBoardUI -framework WebCore -framework JavaScriptCore -framework GraphicsServices -framework TelephonyUI -I$(jscore) -iquote$(webcore)/{bindings/js,dom,loader,platform{,/animation,/cf,/network{,/cf},/text},/rendering/style} -iquote$(jscore)/{jit,runtime} + $(target)g++ -F. -bundle -mthumb -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -lobjc -I$(base)/../mobilesubstrate $(link) $(flags) -framework CoreGraphics -framework QuartzCore -framework SpringBoardUI -framework WebCore -framework JavaScriptCore -framework GraphicsServices -framework TelephonyUI -I$(jscore) -iquote$(webcore)/{bindings/js,dom,loader,platform{,/animation,/cf,/network{,/cf},/text},/rendering/style} -iquote$(jscore)/{bytecode,debugger,interpreter,jit,parser,runtime} ldid -S $@ extra: mkdir -p package/System/Library/LockCydgets/CydgetCentral.cydget + cp -a Index.{html,js} package/System/Library/LockCydgets/CydgetCentral.cydget cp -a CydgetCentral.plist package/System/Library/LockCydgets/CydgetCentral.cydget/Info.plist mkdir -p package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle cp -a Info.plist package/System/Library/SpringBoardPlugins/WebCycriptLockScreen.bundle