1 #import <Foundation/Foundation.h>
2 #import <CoreGraphics/CoreGraphics.h>
4 #import <UIKit/UIKeyboard.h>
5 #import <UIKit/UIImage.h>
8 #include <mach-o/nlist.h>
11 extern "C" NSData *UIImagePNGRepresentation(UIImage *image);
13 int main(int argc, char *argv[]) {
14 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
17 memset(nl, 0, sizeof(nl));
18 nl[0].n_un.n_name = (char *) "___mappedImages";
19 nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
20 nl[2].n_un.n_name = (char *) "_LoadMappedImageRef";
21 nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl);
22 NSMutableDictionary **images = (id *) nl[0].n_value;
23 void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value;
24 CGImageRef (*_LoadMappedImageRef)(CFStringRef) = (CGImageRef (*)(CFStringRef)) nl[2].n_value;
26 __UISharedImageInitialize(false);
28 NSArray *keys = [*images allKeys];
29 for (int i(0), e([keys count]); i != e; ++i) {
30 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
31 NSString *key = [keys objectAtIndex:i];
33 if (_LoadMappedImageRef == NULL)
34 ref = reinterpret_cast<CGImageRef>([*images objectForKey:key]);
36 ref = _LoadMappedImageRef(reinterpret_cast<CFStringRef>(key));
37 UIImage *image = [UIImage imageWithCGImage:ref];
38 NSData *data = UIImagePNGRepresentation(image);
39 [data writeToFile:[NSString stringWithFormat:@"%@", key] atomically:YES];