static NSBundle *(*_UIKitBundle)();
static bool (*_UIPackedImageTableGetIdentifierForName)(NSString *, int *);
static int (*_UISharedImageNameGetIdentifier)(NSString *);
+CGColorRef (*UIKBGetNamedColor)(CFStringRef colorName);
static NSMutableDictionary *UIImages_;
static NSMutableDictionary *PathImages_;
return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
}
+MSHook(CGColorRef, UIKBGetNamedColor, CFStringRef colorName)
+{
+ static CFMutableDictionaryRef keyboardColors;
+ if (!keyboardColors) {
+ keyboardColors = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ NSString *path = [[NSBundle bundleWithPath:@"/System/Library/Frameworks/UIKit.framework"] pathForResource:@"UIKBColors" ofType:@"plist"];
+ NSDictionary *colorSettings = [NSDictionary dictionaryWithContentsOfFile:path];
+ if (colorSettings) {
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ for (NSString *settingName in [colorSettings allKeys]) {
+ NSArray *c = [colorSettings objectForKey:settingName];
+ CGFloat components[4];
+ switch ([c count]) {
+ case 1:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = components[0];
+ components[2] = components[0];
+ components[3] = 1.0f;
+ break;
+ case 2:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = components[0];
+ components[2] = components[0];
+ components[0] = [[c objectAtIndex:1] floatValue];
+ break;
+ case 3:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = [[c objectAtIndex:1] floatValue];
+ components[2] = [[c objectAtIndex:2] floatValue];
+ components[3] = 1.0f;
+ break;
+ case 4:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = [[c objectAtIndex:1] floatValue];
+ components[2] = [[c objectAtIndex:2] floatValue];
+ components[3] = [[c objectAtIndex:3] floatValue];
+ break;
+ default:
+ continue;
+ }
+ CGColorRef color = CGColorCreate(colorSpace, components);
+ CFDictionarySetValue(keyboardColors, settingName, color);
+ CFRelease(color);
+ }
+ CGColorSpaceRelease(colorSpace);
+ }
+ }
+ return (CGColorRef)CFDictionaryGetValue(keyboardColors, colorName) ?: _UIKBGetNamedColor(colorName);
+}
+
MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
if (Debug_)
NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath);
MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
+
+ dlset(UIKBGetNamedColor, "UIKBGetNamedColor");
+ if (UIKBGetNamedColor != NULL && identifier) {
+ MSHookFunction(UIKBGetNamedColor, &$UIKBGetNamedColor, &_UIKBGetNamedColor);
+ }
// }}}
}