From: Jay Freeman (saurik) Date: Wed, 8 Jan 2014 08:08:14 +0000 (-0800) Subject: Get WinterBoard compiled on clang (ick) for ARM64. X-Git-Tag: v0.9.3912~37 X-Git-Url: https://git.saurik.com/winterboard.git/commitdiff_plain/fdac1738630980ed08c04fb39ac081730d709b32 Get WinterBoard compiled on clang (ick) for ARM64. --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3856332 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "iphone-api"] + path = iphone-api + url = git://git.saurik.com/iphone-api.git diff --git a/Library.mm b/Library.mm index eb3c7f1..f786378 100644 --- a/Library.mm +++ b/Library.mm @@ -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(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(MSFindSymbol(image, name)); } +#define WBHookSymbol(image, function) \ + msset(function, image, "_" #function) + template 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); diff --git a/Settings.mm b/Settings.mm index 588fbc5..c8ea4d2 100644 --- a/Settings.mm +++ b/Settings.mm @@ -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 *); diff --git a/WBMarkup.mm b/WBMarkup.mm index 73066d4..77d7c37 100644 --- a/WBMarkup.mm +++ b/WBMarkup.mm @@ -1,14 +1,15 @@ #include "WBMarkup.h" +#include + @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 index 0000000..afdc61a --- /dev/null +++ b/iphone-api @@ -0,0 +1 @@ +Subproject commit afdc61a9b9b010741b2a2dc1ac28e91cf754f6aa diff --git a/make.sh b/make.sh deleted file mode 100755 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 diff --git a/makefile b/makefile index 683ffca..58c85a7 100644 --- 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