MSClassHook(UIImage)
MSMetaClassHook(UIImage)
+MSClassHook(UIImageTableArtwork)
MSClassHook(UINavigationBar)
+MSClassHook(UISharedArtwork)
MSClassHook(UIToolbar)
MSClassHook(UIStatusBarTimeItemView)
MSClassHook(UIWebDocumentView)
}
// }}}
// $pathForFile$inBundle$() {{{
-static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) {
+static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui, bool use) {
NSString *identifier = [bundle bundleIdentifier];
NSMutableArray *names = [NSMutableArray arrayWithCapacity:8];
[names addObject:[NSString stringWithFormat:@"Fallback/%@", file]];
- if (NSString *path = $getTheme$($useScale$(names, ui)))
+ if (NSString *path = $getTheme$($useScale$(names, use)))
return path;
return nil;
if ([file hasPrefix:prefix]) {
NSUInteger length([prefix length]);
if (length != [file length])
- if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false))
+ if (NSString *path = $pathForFile$inBundle$([file substringFromIndex:(length + 1)], bundle, false, false))
return path;
}
}
NSBundle *bundle = [NSBundle mainBundle];
if (Debug_)
NSLog(@"WB:Debug: _UIApplicationImageWithName(\"%@\", %@)", name, bundle);
- if (NSString *path = $pathForFile$inBundle$(name, bundle, false))
+ if (NSString *path = $pathForFile$inBundle$(name, bundle, false, false))
return CachedImageAtPath(path);
return __UIApplicationImageWithName(name);
}
NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
if (Debug_)
NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
- if (NSString *path = $pathForFile$inBundle$(file, self, false))
+ if (NSString *path = $pathForFile$inBundle$(file, self, false, false))
return path;
return MSOldCall(resource, type);
}
[view setBackgroundColor:[UIColor clearColor]];
[self insertSubview:view aboveSubview:_backgroundView];
+
+ if ($objc_setAssociatedObject != NULL)
+ $objc_setAssociatedObject(self, @selector(wb$widgetView), view, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
}
+MSHook(void, SBAwayView$_addSubview$positioned$relativeTo$, SBAwayView *self, SEL sel, UIView *view, int positioned, UIView *relative) {
+ UIView *&_backgroundView(MSHookIvar<UIView *>(self, "_backgroundView"));
+ UIView *&_chargingView(MSHookIvar<UIView *>(self, "_chargingView"));
+ if (&_chargingView != NULL)
+ if (positioned == -2 && (relative == _backgroundView && _chargingView == nil || relative == _chargingView))
+ if ($objc_getAssociatedObject != NULL)
+ if (UIView *widget = $objc_getAssociatedObject(self, @selector(wb$widgetView)))
+ relative = widget;
+ return _SBAwayView$_addSubview$positioned$relativeTo$(self, sel, view, positioned, relative);
+}
+
/*extern "C" CGColorRef CGGStateGetSystemColor(void *);
extern "C" CGColorRef CGGStateGetFillColor(void *);
extern "C" CGColorRef CGGStateGetStrokeColor(void *);
return value;
} else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
language, file
- ], self, false)) {
+ ], self, false, false)) {
if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
[Strings_ setObject:[strings autorelease] forKey:name];
goto strings;
}
// }}}
+MSInstanceMessage2(UISharedArtwork *, UISharedArtwork, initWithName,inBundle, NSString *, name, NSBundle *, bundle) {
+ if ((self = MSOldCall(name, bundle)) != nil) {
+ $objc_setAssociatedObject(self, @selector(wb$bundle), bundle, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ } return self;
+}
+
+MSInstanceMessage1(UIImage *, UIImageTableArtwork, imageNamed, NSString *, name) {
+ NSBundle *bundle($objc_getAssociatedObject(self, @selector(wb$bundle)));
+ if (Debug_)
+ NSLog(@"WB:Debug:[UIImageTableArtwork[%@] imageNamed:\"%@\"]", bundle, name);
+ if (bundle == nil)
+ return MSOldCall(name);
+ UIImage *image = [UIImages_ objectForKey:name];
+ if (image != nil)
+ return reinterpret_cast<id>(image) == [NSNull null] ? MSOldCall(name) : image;
+ if (NSString *path = $pathForFile$inBundle$(name, bundle, true, true))
+ image = $getImage$(path);
+ [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:name];
+ if (image != nil)
+ return image;
+
+ image = MSOldCall(name);
+
+ if (UIDebug_) {
+ NSString *path([@"/tmp/UIImages/" stringByAppendingString:name]);
+ if (![Manager_ fileExistsAtPath:path])
+ [UIImagePNGRepresentation(image) writeToFile:path atomically:YES];
+ }
+
+ return image;
+}
+
// %hook _UIImageWithName() {{{
MSHook(UIImage *, _UIImageWithName, NSString *name) {
if (Debug_)
UIImage *image([UIImages_ objectForKey:key]);
if (image != nil)
return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithName(name) : image;
- if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true))
+ if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true, true))
image = $getImage$(path);
[UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
if (image != nil)
#define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
-bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
-
-MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
- if (Debug_)
- NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
- bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
+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", a0, value ? a1 : NULL, a2, value);
+ NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u, %u) = %u", a0, value ? a1 : NULL, a2, a3, value);
if (value) {
NSString *path = [NSString stringWithUTF8String:a1];
return value;
}
+MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a3) {
+ bool value(__Z24GetFileNameForThisActionmPcRb(a0, a1, a3));
+ return GetFileNameForThisAction$(value, a0, a1, 0, a3);
+}
+
+MSHook(bool, _Z24GetFileNameForThisActionmPcmRb, unsigned long a0, char *a1, unsigned long a2, bool &a3) {
+ bool value(__Z24GetFileNameForThisActionmPcmRb(a0, a1, a2, a3));
+ return GetFileNameForThisAction$(value, a0, a1, a2, a3);
+}
+
static void ChangeWallpaper(
CFNotificationCenterRef center,
void *observer,
}
+MSHook(NSArray *, CPBitmapCreateImagesFromPath, NSString *path, NSDictionary **names, void *arg2, void *arg3) {
+ NSArray *images(_CPBitmapCreateImagesFromPath(path, names, arg2, arg3));
+ if (images != NULL && *names != nil && CFGetTypeID((CFTypeRef) *names) == CFDictionaryGetTypeID()) {
+ if (NSBundle *bundle = [NSBundle wb$bundleWithFile:path]) {
+ NSMutableArray *copy([images mutableCopy]);
+ [images release];
+ images = copy;
+
+ NSString *file([path stringByResolvingSymlinksInPath]);
+ NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]);
+ if ([file hasPrefix:prefix]) {
+ NSUInteger length([prefix length]);
+ if (length != [file length]) {
+ NSEnumerator *enumerator([*names keyEnumerator]);
+ while (NSString *name = [enumerator nextObject]) {
+ NSString *png([name stringByAppendingString:@".png"]);
+ if (NSString *themed = $pathForFile$inBundle$(png, bundle, false, true)) {
+ NSUInteger index([[*names objectForKey:name] intValue]);
+ UIImage *image($getImage$(themed));
+ CGImageRef cg([image CGImage]);
+ [copy replaceObjectAtIndex:index withObject:(id)cg];
+ }
+ }
+ }
+ }
+ }
+ } return images;
+}
+
+MSHook(void, BKSDisplayServicesSetSystemAppExitedImagePath, NSString *path) {
+ if (NSString *themed = $getTheme$($useScale$([NSArray arrayWithObject:@"SystemAppExited.png"])))
+ path = themed;
+ _BKSDisplayServicesSetSystemAppExitedImagePath(path);
+}
+
#define WBRename(name, sel, imp) \
MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp, &_ ## name ## $ ## imp)
//WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
+ if (kCFCoreFoundationVersionNumber >= 700)
+ WBRename(SBAwayView, _addSubview:positioned:relativeTo:, _addSubview$positioned$relativeTo$);
+
WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
//WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
//WBRename(SBStatusBarController, setStatusBarMode:orientation:duration:animation:, setStatusBarMode$orientation$duration$animation$);
[Info_ setObject:[info objectForKey:key] forKey:key];
// }}}
+ // AppSupport {{{
+ if (MSImageRef image = MSGetImageByName("/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport")) {
+ NSArray *(*CPBitmapCreateImagesFromPath)(NSString *, NSDictionary **, void *, void *);
+ msset(CPBitmapCreateImagesFromPath, image, "_CPBitmapCreateImagesFromPath");
+ MSHookFunction(CPBitmapCreateImagesFromPath, MSHake(CPBitmapCreateImagesFromPath));
+ }
+ // }}}
// AudioToolbox {{{
if (MSImageRef image = MSGetImageByName(AudioToolbox)) {
+ bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long, char *, bool &);
msset(_Z24GetFileNameForThisActionmPcRb, image, "__Z24GetFileNameForThisActionmPcRb");
MSHookFunction(_Z24GetFileNameForThisActionmPcRb, &$_Z24GetFileNameForThisActionmPcRb, &__Z24GetFileNameForThisActionmPcRb);
+
+ bool (*_Z24GetFileNameForThisActionmPcmRb)(unsigned long, char *, unsigned long, bool &);
+ msset(_Z24GetFileNameForThisActionmPcmRb, image, "__Z24GetFileNameForThisActionmPcmRb");
+ MSHookFunction(_Z24GetFileNameForThisActionmPcmRb, &$_Z24GetFileNameForThisActionmPcmRb, &__Z24GetFileNameForThisActionmPcmRb);
+ }
+ // }}}
+ // BackBoardServices {{{
+ if (MSImageRef image = MSGetImageByName("/System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices")) {
+ void (*BKSDisplayServicesSetSystemAppExitedImagePath)(NSString *path);
+ msset(BKSDisplayServicesSetSystemAppExitedImagePath, image, "_BKSDisplayServicesSetSystemAppExitedImagePath");
+ MSHookFunction(BKSDisplayServicesSetSystemAppExitedImagePath, MSHake(BKSDisplayServicesSetSystemAppExitedImagePath));
}
// }}}
// GraphicsServices {{{
}
// }}}
// ImageIO {{{
- if (MSImageRef image = MSGetImageByName("/System/Library/Frameworks/ImageIO.framework/ImageIO")) {
+ MSImageRef imageio = MSGetImageByName("/System/Library/Frameworks/ImageIO.framework/ImageIO");
+ if (imageio == NULL)
+ imageio = MSGetImageByName("/System/Library/PrivateFrameworks/ImageIO.framework/ImageIO");
+ if (MSImageRef image = imageio) {
void *(*CGImageReadCreateWithFile)(NSString *, int);
msset(CGImageReadCreateWithFile, image, "_CGImageReadCreateWithFile");
MSHookFunction(CGImageReadCreateWithFile, MSHake(CGImageReadCreateWithFile));
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");
- 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);
-
- MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
- MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
- MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
+ if (kCFCoreFoundationVersionNumber > 700) { // XXX: iOS 6.x
+ WBRename(UISharedArtwork, initWithName:inBundle:, initWithName$inBundle$);
+ WBRename(UIImageTableArtwork, imageNamed:, imageNamed$);
+ } 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);
+
+ MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName);
+ MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
+ MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
+ }
}
// }}}