From a75dc45a6d1eff28070384cfa902536f06916ecd Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 6 Nov 2009 11:12:24 +0000 Subject: [PATCH] This was a bad idea: I'm not going to do this again. --- LockScreen.mm | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ control | 2 +- makefile | 4 +++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/LockScreen.mm b/LockScreen.mm index 9ac2c02..368d13d 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -37,6 +37,8 @@ #include +#define WTF_USE_JSC 1 + #import #import #import @@ -69,6 +71,11 @@ extern NSString * const kCAFilterNearest; #include #include +#include "wtf/Platform.h" +#include "CString.h" +#include "ScriptElement.h" +#include "ScriptSourceCode.h" + @interface WebView (UICaboodle) - (void) setScriptDebugDelegate:(id)delegate; - (void) _setFormDelegate:(id)delegate; @@ -82,6 +89,14 @@ 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__\ @@ -539,6 +554,7 @@ _trace(); subrect.size.height -= extra; [scroller_ setScrollerIndicatorSubrect:subrect]; +#undef NSSize NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height)); [document_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize]; @@ -693,8 +709,56 @@ _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); +} + @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)); +} + + (id) rootViewController { return [[[self alloc] init] autorelease]; } diff --git a/control b/control index bc5a6f2..a8b276b 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Priority: optional Section: Development Maintainer: Jay Freeman (saurik) Architecture: iphoneos-arm -Version: 0.9.3066-1 +Version: 0.9.3076-1 Description: framework for managing lock screen plugins Name: Cydget Depends: mobilesubstrate (>= 0.9.2587-1) diff --git a/makefile b/makefile index 637b624..5c0564e 100644 --- a/makefile +++ b/makefile @@ -2,11 +2,13 @@ name := CydgetLoader flags := -framework UIKit -framework AddressBook base := $(shell cd ~; pwd)/menes/tweaks include $(base)/tweak.mk +webcore := WebCore-514 +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 GraphicsServices -framework TelephonyUI + $(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} ldid -S $@ extra: -- 2.45.2