X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/95a5777bab9f18d4307f69495671a1f595ceca86..1d3b613ff73deb265588b0bf4a393ce1e6a98963:/UIImages.mm diff --git a/UIImages.mm b/UIImages.mm index 85ded74..f83b772 100644 --- a/UIImages.mm +++ b/UIImages.mm @@ -10,25 +10,46 @@ extern "C" { extern "C" NSData *UIImagePNGRepresentation(UIImage *image); +template +static void nlset(Type_ &function, struct nlist *nl, size_t index) { + struct nlist &name(nl[index]); + uintptr_t value(name.n_value); + if ((name.n_desc & N_ARM_THUMB_DEF) != 0) + value |= 0x00000001; + function = reinterpret_cast(value); +} + int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - struct nlist nl[3]; + struct nlist nl[4]; + memset(nl, 0, sizeof(nl)); nl[0].n_un.n_name = (char *) "___mappedImages"; nl[1].n_un.n_name = (char *) "__UISharedImageInitialize"; + nl[2].n_un.n_name = (char *) "_LoadMappedImageRef"; nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl); - NSMutableDictionary **images = (id *) nl[0].n_value; - void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value; + + NSMutableDictionary **images; + nlset(images, nl, 0); + + void (*__UISharedImageInitialize)(bool); + nlset(__UISharedImageInitialize, nl, 1); + + CGImageRef (*_LoadMappedImageRef)(CFStringRef); + nlset(_LoadMappedImageRef, nl, 2); __UISharedImageInitialize(false); - [UIKeyboard preheatArtwork]; NSArray *keys = [*images allKeys]; for (int i(0), e([keys count]); i != e; ++i) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *key = [keys objectAtIndex:i]; - CGImageRef ref = (CGImageRef) [*images objectForKey:key]; + CGImageRef ref; + if (_LoadMappedImageRef == NULL) + ref = reinterpret_cast([*images objectForKey:key]); + else + ref = _LoadMappedImageRef(reinterpret_cast(key)); UIImage *image = [UIImage imageWithCGImage:ref]; NSData *data = UIImagePNGRepresentation(image); [data writeToFile:[NSString stringWithFormat:@"%@", key] atomically:YES];