]> git.saurik.com Git - cydget.git/commitdiff
This seriously sort of worked.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 6 Nov 2009 12:16:49 +0000 (12:16 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 6 Nov 2009 12:16:49 +0000 (12:16 +0000)
CydgetCentral.plist
Index.html [new file with mode: 0644]
Index.js [new file with mode: 0644]
LockScreen.mm
makefile

index c96cf0f430b90d6844a31aa96b18fa7d4b518bac..dfbce565c7c6793e4c0ea1ee3be84ea51c618046 100644 (file)
@@ -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 (file)
index 0000000..bfca301
--- /dev/null
@@ -0,0 +1,7 @@
+<html><head>
+<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
+</head><body bgcolor="red">
+<script type="text/javascript" src="Index.js"></script>
+<h1>testing the stuffs</h1>
+<h1>testing the stuffs</h1>
+</body></html>
diff --git a/Index.js b/Index.js
new file mode 100644 (file)
index 0000000..4d07295
--- /dev/null
+++ b/Index.js
@@ -0,0 +1,3 @@
+with (Cycript.runtime) {
+    document.write('<h1>[' + malloc + ']</h1>');
+}
index 368d13dc57549a8c6e1e120aca73a6408928781e..5207b154d091761f643a6eb29c02f81c5e7c721b 100644 (file)
@@ -37,8 +37,6 @@
 
 #include <substrate.h>
 
-#define WTF_USE_JSC 1
-
 #import <GraphicsServices/GraphicsServices.h>
 #import <UIKit/UIKit.h>
 #import <AddressBook/AddressBook.h>
@@ -71,10 +69,8 @@ extern NSString * const kCAFilterNearest;
 #include <WebCore/WebCoreThread.h>
 #include <WebKit/WebPreferences-WebPrivate.h>
 
-#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 <typename Type_>
-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<Type_>(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<void (*)(JSGlobalContextRef)>(dlsym(handle, "CYSetupContext"));
 }
 
 + (id) rootViewController {
index 5c0564e6e3802205f29990bf5f221600fe30203a..73efca93f3a216bc1f7eac7612377cc0c8103056 100644 (file)
--- 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