From 4143d0cd03755bea7db945da42b0d8a9a3eec0db Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 13 Oct 2011 09:08:14 +0000 Subject: [PATCH] Reactivate _UIImageAtPath() hook. --- Library.mm | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Library.mm b/Library.mm index b36ec0f..4626f53 100644 --- a/Library.mm +++ b/Library.mm @@ -563,24 +563,23 @@ MSHook(CGImageRef, _UIImageRefAtPath, NSString *name, bool cache, UIImageOrienta return __UIImageRefAtPath(themed, cache, orientation, scale); } -/*MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) { - if (bundle == nil) - return __UIImageAtPath(name, nil); - else { - NSString *key = [NSString stringWithFormat:@"B:%@/%@", [bundle bundleIdentifier], name]; - UIImage *image = [PathImages_ objectForKey:key]; - if (image != nil) - return reinterpret_cast(image) == [NSNull null] ? nil : image; - if (Debug_) - NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle); - if (NSString *path = $pathForFile$inBundle$(name, bundle, false)) - image = CachedImageAtPath(path); - if (image == nil) - image = __UIImageAtPath(name, bundle); - [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast(image)) forKey:key]; - return image; - } -}*/ +MSHook(UIImage *, _UIImageAtPath, NSString *name, NSBundle *bundle) { + if (Debug_) + NSLog(@"WB:Debug: _UIImageAtPath(\"%@\", %@)", name, bundle); + + NSString *file([name rangeOfString:@"."].location != NSNotFound ? name : [name stringByAppendingString:@".png"]); + + NSString *key = [NSString stringWithFormat:@"B:%@/%@", bundle == nil ? @"" : [bundle bundleIdentifier], name]; + UIImage *image = [PathImages_ objectForKey:key]; + if (image != nil) + return reinterpret_cast(image) == [NSNull null] ? nil : image; + if (NSString *path = $pathForFile$inBundle$(file, bundle, false)) + image = CachedImageAtPath(path); + if (image == nil) + image = __UIImageAtPath(name, bundle); + [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast(image)) forKey:key]; + return image; +} MSHook(UIImage *, _UIApplicationImageWithName, NSString *name) { NSBundle *bundle = [NSBundle mainBundle]; @@ -1623,6 +1622,7 @@ extern "C" void WBInitialize() { nlset(_UISharedImageNameGetIdentifier, nl, 6); MSHookFunction(_UIApplicationImageWithName, &$_UIApplicationImageWithName, &__UIApplicationImageWithName); + MSHookFunction(_UIImageAtPath, &$_UIImageAtPath, &__UIImageAtPath); MSHookFunction(_UIImageRefAtPath, &$_UIImageRefAtPath, &__UIImageRefAtPath); MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName); MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain); -- 2.45.2