X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/fabdff02fc6f3a1e0228a7f2462b3dbce3f5f194..c4bc3f112e49c3841c5e2bdf9a346a0b4719e9d5:/Library.mm diff --git a/Library.mm b/Library.mm index 5580171..bc8084b 100644 --- a/Library.mm +++ b/Library.mm @@ -433,7 +433,12 @@ static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") { NSString *path = [self path]; NSString *folder = [path lastPathComponent]; NSString *dname = [self displayName]; - NSString *didentifier = [self displayIdentifier]; + + NSString *didentifier; + if ([self respondsToSelector:@selector(displayIdentifier)]) + didentifier = [self displayIdentifier]; + else + didentifier = nil; if (Debug_) NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier); @@ -450,7 +455,7 @@ static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") { if (NSString *name = Name) \ [names addObject:[NSString stringWithFormat:@"Icons%@/%@.png", suffix, name]]; - if (![didentifier isEqualToString:identifier]) + if (didentifier != nil && ![didentifier isEqualToString:identifier]) testForIcon(didentifier); testForIcon(identifier); @@ -2231,33 +2236,48 @@ static void ChangeWallpaper( } -MSHook(NSArray *, CPBitmapCreateImagesFromPath, NSString *path, NSDictionary **names, void *arg2, void *arg3) { +MSHook(NSArray *, CPBitmapCreateImagesFromPath, NSString *path, CFTypeRef *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, true)) { - NSUInteger index([[*names objectForKey:name] intValue]); - UIImage *image($getImage$(themed)); - CGImageRef cg([image CGImage]); - [copy replaceObjectAtIndex:index withObject:(id)cg]; - } - } - } - } + if (images == nil) + return nil; + if (*names == nil) + return images; + + NSBundle *bundle([NSBundle wb$bundleWithFile:path]); + if (bundle == nil) + return images; + + NSString *file([path stringByResolvingSymlinksInPath]); + NSString *prefix([[bundle bundlePath] stringByResolvingSymlinksInPath]); + // XXX: why do I care about this? + if (![file hasPrefix:prefix]) + return images; + + NSMutableArray *copy([images mutableCopy]); + [images release]; + images = copy; + + NSDictionary *indexes; + NSEnumerator *enumerator; + + if (CFGetTypeID((CFTypeRef) *names) == CFDictionaryGetTypeID()) { + indexes = (NSDictionary *) *names; + enumerator = [indexes keyEnumerator]; + } else { + indexes = nil; + enumerator = [(NSArray *) *names objectEnumerator]; + } + + for (NSUInteger index(0); NSString *name = [enumerator nextObject]; ++index) + if (NSString *themed = $pathForFile$inBundle$([name stringByAppendingString:@".png"], bundle, true)) { + if (indexes != nil) + index = [[indexes objectForKey:name] intValue]; + UIImage *image($getImage$(themed)); + CGImageRef cg([image CGImage]); + [copy replaceObjectAtIndex:index withObject:(id)cg]; } - } return images; + + return images; } MSHook(void, BKSDisplayServicesSetSystemAppExitedImagePath, NSString *path) { @@ -2415,7 +2435,7 @@ static void SBInitialize() { no = true; if (strstr(path, "/icon") != NULL) - MSHookProcess(-1, ""); + *reinterpret_cast(NULL) = NULL; if (fd == -1 && errno == EFAULT) NSLog(@"open(%p, %#x, %#o) = %d\n", path, oflag, mode, fd); @@ -2443,7 +2463,9 @@ MSInitialize { // Load Settings.plist {{{ if (NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) { - if (NSNumber *value = [settings objectForKey:@"SummerBoard"]) + if (kCFCoreFoundationVersionNumber >= 1000) + SummerBoard_ = false; + else if (NSNumber *value = [settings objectForKey:@"SummerBoard"]) SummerBoard_ = [value boolValue]; else SummerBoard_ = true; @@ -2499,7 +2521,7 @@ MSInitialize { // AppSupport {{{ if (MSImageRef image = MSGetImageByName("/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport")) { - NSArray *(*CPBitmapCreateImagesFromPath)(NSString *, NSDictionary **, void *, void *); + NSArray *(*CPBitmapCreateImagesFromPath)(NSString *, CFTypeRef *, void *, void *); msset(CPBitmapCreateImagesFromPath, image, "_CPBitmapCreateImagesFromPath"); MSHookFunction(CPBitmapCreateImagesFromPath, MSHake(CPBitmapCreateImagesFromPath)); }