#include <substrate.h>
-#define WTF_USE_JSC 1
-
#import <GraphicsServices/GraphicsServices.h>
#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#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;
_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__\
- (NSDictionary *) currentConfiguration;
@end
+static void (*CYSetupContext)(JSGlobalContextRef);
+
static Class $CydgetController(objc_getClass("CydgetController"));
@interface NSString (UIKit)
UIScroller *scroller_;
UIWebDocumentView *document_;
+ bool cycript_;
float width_;
CGSize size_;
bool editing_;
//#include "UICaboodle/UCInternal.h"
- (void) dealloc {
-_trace();
WebThreadLock();
WebView *webview([document_ webView]);
[scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
NSDictionary *configuration([$CydgetController currentConfiguration]);
+ cycript_ = [[configuration objectForKey:@"Cycript"] boolValue];
NSString *homepage([configuration objectForKey:@"Homepage"]);
[self loadURL:[NSURL URLWithString:homepage]];
} return self;
}
- (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 {
}
- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
- _trace();
/*if ([frame parentFrame] == nil)
[self autorelease];*/
@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 {
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