]> git.saurik.com Git - winterboard.git/commitdiff
Get WinterBoard compiled on clang (ick) for ARM64.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 8 Jan 2014 08:08:14 +0000 (00:08 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 8 Jan 2014 08:10:32 +0000 (00:10 -0800)
.gitmodules [new file with mode: 0644]
Library.mm
Settings.mm
WBMarkup.mm
iphone-api [new submodule]
make.sh [deleted file]
makefile

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..3856332
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "iphone-api"]
+       path = iphone-api
+       url = git://git.saurik.com/iphone-api.git
index eb3c7f17c31a6c082f3b7b1e5c717eb5a58bdf21..f786378ce927891baa0c08eac0b945a513c8d788 100644 (file)
@@ -331,7 +331,7 @@ static NSString *$getTheme$(NSArray *files, NSArray *themes = Themes_) {
         for (NSString *file in files) {
             path = [NSString stringWithFormat:@"%@/%@", theme, file];
             if ([Manager_ fileExistsAtPath:path]) {
-                if ([[Manager_ pathContentOfSymbolicLinkAtPath:path] isEqualToString:@"/"])
+                if ([[Manager_ destinationOfSymbolicLinkAtPath:path error:NULL] isEqualToString:@"/"])
                     path = nil;
                 goto set;
             }
@@ -1974,7 +1974,7 @@ MSHook(UIImage *, _UIImageWithName, NSString *name) {
 // }}}
 // %hook _UIImageWithNameInDomain() {{{
 MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
-    NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
+    NSString *key([NSString stringWithFormat:@"D:%zu%@%@", size_t([domain length]), domain, name]);
     UIImage *image([PathImages_ objectForKey:key]);
     if (image != nil)
         return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
@@ -2000,11 +2000,10 @@ MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits t
 // }}}
 
 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
-#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
 
 static bool GetFileNameForThisAction$(bool value, unsigned long a0, char *a1, unsigned long a2, bool &a3) {
     if (Debug_)
-        NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u, %u) = %u", a0, value ? a1 : NULL, a2, a3, value);
+        NSLog(@"WB:Debug:GetFileNameForThisAction(%lu, %s, %lu, %u) = %u", a0, value ? a1 : NULL, a2, a3, value);
 
     if (value) {
         NSString *path = [NSString stringWithUTF8String:a1];
@@ -2099,6 +2098,9 @@ static void msset(Type_ &function, MSImageRef image, const char *name) {
     function = reinterpret_cast<Type_>(MSFindSymbol(image, name));
 }
 
+#define WBHookSymbol(image, function) \
+    msset(function, image, "_" #function)
+
 template <typename Type_>
 static void nlset(Type_ &function, struct nlist *nl, size_t index) {
     struct nlist &name(nl[index]);
@@ -2294,10 +2296,8 @@ MSInitialize {
                 if (name == nil)
                     continue;
 
-                NSString *theme(nil);
-
                 #define testForTheme(format...) \
-                    if (theme == nil) { \
+                    { \
                         NSString *path = [NSString stringWithFormat:format]; \
                         if ([Manager_ fileExistsAtPath:path]) { \
                             [Themes_ addObject:path]; \
@@ -2400,7 +2400,7 @@ MSInitialize {
     }
     // }}}
     // UIKit {{{
-    if ([NSBundle bundleWithIdentifier:@"com.apple.UIKit"] != nil) {
+    if (MSImageRef image = MSGetImageByName("/System/Library/Frameworks/UIKit.framework/UIKit")) {
         class_addMethod($NSString, @selector(drawAtPoint:withStyle:), (IMP) &NSString$drawAtPoint$withStyle$, "v20@0:4{CGPoint=ff}8@16");
         class_addMethod($NSString, @selector(drawInRect:withStyle:), (IMP) &NSString$drawInRect$withStyle$, "v28@0:4{CGRect={CGSize=ff}{CGSize=ff}}8@24");
         class_addMethod($NSString, @selector(sizeWithStyle:forWidth:), (IMP) &NSString$sizeWithStyle$forWidth$, "{CGSize=ff}16@0:4@8f12");
@@ -2409,20 +2409,11 @@ MSInitialize {
             WBRename(UIImageTableArtwork, initWithName:inBundle:, initWithName$inBundle$);
             WBRename(UIImageTableArtwork, imageNamed:device:, imageNamed$device$);
         } else {
-            struct nlist nl[6];
-            memset(nl, 0, sizeof(nl));
-            nl[0].n_un.n_name = (char *) "__UIApplicationImageWithName";
-            nl[1].n_un.n_name = (char *) "__UIImageWithNameInDomain";
-            nl[2].n_un.n_name = (char *) "__UIKitBundle";
-            nl[3].n_un.n_name = (char *) "__UIPackedImageTableGetIdentifierForName";
-            nl[4].n_un.n_name = (char *) "__UISharedImageNameGetIdentifier";
-            nlist(UIKit, nl);
-
-            nlset(_UIApplicationImageWithName, nl, 0);
-            nlset(_UIImageWithNameInDomain, nl, 1);
-            nlset(_UIKitBundle, nl, 2);
-            nlset(_UIPackedImageTableGetIdentifierForName, nl, 3);
-            nlset(_UISharedImageNameGetIdentifier, nl, 4);
+            WBHookSymbol(image, _UIApplicationImageWithName);
+            WBHookSymbol(image, _UIImageWithNameInDomain);
+            WBHookSymbol(image, _UIKitBundle);
+            WBHookSymbol(image, _UIPackedImageTableGetIdentifierForName);
+            WBHookSymbol(image, _UISharedImageNameGetIdentifier);
 
             MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
             MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
index 588fbc52cce263f9abd0708ceae4481107db62be..c8ea4d23bfc044044541fd1a2394d949a483cf95 100644 (file)
@@ -51,7 +51,7 @@ static BOOL (*IsIconHiddenDisplayId)(NSString *);
 static BOOL (*HideIconViaDisplayId)(NSString *);
 static BOOL (*UnHideIconViaDisplayId)(NSString *);
 
-static const NSString *WinterBoardDisplayID = @"com.saurik.WinterBoard";
+static NSString *WinterBoardDisplayID = @"com.saurik.WinterBoard";
 
 extern NSString *PSTableCellKey;
 extern "C" UIImage *_UIImageWithName(NSString *);
index 73066d4a7854a12cbac18859ec3e57b417ee6575..77d7c376238dcdc843947a747f4bcf649be53a68 100644 (file)
@@ -1,14 +1,15 @@
 #include "WBMarkup.h"
 
+#include <substrate.h>
+
 @class WKView;
 
-extern "C" {
-    void WebThreadLock();
-    CGContextRef WKGetCurrentGraphicsContext();
-    void WKViewLockFocus(WKView *);
-    void WKViewUnlockFocus(WKView *);
-    void WKViewDisplayRect(WKView *, CGRect);
-}
+extern "C" void WebThreadLock();
+extern "C" CGContextRef WKGetCurrentGraphicsContext();
+
+static void (*WKViewLockFocus$)(WKView *);
+static void (*WKViewUnlockFocus$)(WKView *);
+static void (*WKViewDisplayRect$)(WKView *, CGRect);
 
 @interface DOMElement : NSObject
 - (void) setInnerHTML:(NSString *)value;
@@ -64,6 +65,13 @@ static WBMarkup *SharedMarkup_;
 
 @implementation WBMarkup
 
++ (void) initialize {
+    MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
+    MSHookSymbol(WKViewLockFocus$, "WKViewLockFocus", WebCore);
+    MSHookSymbol(WKViewUnlockFocus$, "WKViewUnlockFocus", WebCore);
+    MSHookSymbol(WKViewDisplayRect$, "WKViewDisplayRect", WebCore);
+}
+
 + (BOOL) isSharedMarkupCreated {
     return SharedMarkup_ != nil;
 }
@@ -117,9 +125,9 @@ static WBMarkup *SharedMarkup_;
             [view_ _drawRect:draw context:context_ lockFocus:YES];
         else {
             WKView *view([view_ _viewRef]);
-            WKViewLockFocus(view); {
-                WKViewDisplayRect(view, draw);
-            } WKViewUnlockFocus(view);
+            WKViewLockFocus$(view); {
+                WKViewDisplayRect$(view, draw);
+            } WKViewUnlockFocus$(view);
         }
     } CGContextRestoreGState(context_);
 }
diff --git a/iphone-api b/iphone-api
new file mode 160000 (submodule)
index 0000000..afdc61a
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit afdc61a9b9b010741b2a2dc1ac28e91cf754f6aa
diff --git a/make.sh b/make.sh
deleted file mode 100755 (executable)
index 3ba4fcb..0000000
--- a/make.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-set -e
-export PKG_ARCH=${PKG_ARCH-iphoneos-arm}
-PATH=/apl/n42/pre/bin:$PATH /apl/tel/exec.sh com.saurik.winterboard make "$@"
-export CODESIGN_ALLOCATE=$(which arm-apple-darwin9-codesign_allocate)
-make package
index 683ffca1bfc437df9afbf212d0dac247ca07fbc9..58c85a79a9b3832c98c2de23f8914a4a3e3bb508 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,10 +1,6 @@
-ifndef PKG_TARG
-target :=
-else
-target := $(PKG_TARG)-
-endif
+cycc = cycc -i2.0 -o$@ -- -Iiphone-api
 
-substrate := -I../mobilesubstrate -L../mobilesubstrate -lsubstrate
+substrate := -I../substrate -L../substrate -lsubstrate
 
 all: WinterBoard WinterBoard.dylib WinterBoardSettings Optimize
 
@@ -12,20 +8,16 @@ clean:
        rm -f WinterBoard WinterBoard.dylib
 
 WinterBoardSettings: Settings.mm makefile
-       $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework UIKit -framework CoreFoundation -framework Foundation -lobjc -framework CoreGraphics -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks
-       ldid -S $@
+       $(cycc) -dynamiclib -g0 -O2 $(filter %.mm,$^) -framework UIKit -framework CoreFoundation -framework Foundation -lobjc -framework CoreGraphics -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks
 
-WinterBoard.dylib: Library.mm WBMarkup.mm WBMarkup.h makefile ../mobilesubstrate/substrate.h
-       $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework ImageIO -framework GraphicsServices -framework Celestial $(substrate) -framework UIKit -framework WebCore -framework WebKit -F$(PKG_ROOT)/System/Library/PrivateFrameworks
-       ldid -S $@
+WinterBoard.dylib: Library.mm WBMarkup.mm WBMarkup.h makefile ../substrate/substrate.h
+       $(cycc) -dynamiclib -g0 -O2 $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework ImageIO -framework GraphicsServices -framework Celestial $(substrate) -framework UIKit -framework WebCore -framework WebKit -F$(PKG_ROOT)/System/Library/PrivateFrameworks
 
 WinterBoard: Application.mm makefile
-       $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -framework CoreGraphics -I/apl/sdk -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks $(substrate)
-       ldid -S $@
+       $(cycc) -g0 -O2 -Werror $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -framework CoreGraphics -I/apl/sdk -framework Preferences -F$(PKG_ROOT)/System/Library/PrivateFrameworks $(substrate)
 
 Optimize: Optimize.cpp makefile
-       $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.cpp,$^)
-       ldid -S $@
+       $(cycc) -g0 -O2 -Werror $(filter %.cpp,$^)
 
 package: all
        rm -rf winterboard