]> git.saurik.com Git - winterboard.git/blob - UIImages.mm
Matched up WinterBoard to the documentation.
[winterboard.git] / UIImages.mm
1 #import <Foundation/Foundation.h>
2 #import <CoreGraphics/CoreGraphics.h>
3 #import <UIKit/UIKit.h>
4
5 extern "C" {
6 #include <mach-o/nlist.h>
7 }
8
9 int main(int argc, char *argv[]) {
10 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
11
12 struct nlist nl[3];
13 memset(nl, 0, sizeof(nl));
14 nl[0].n_un.n_name = (char *) "___mappedImages";
15 nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
16 nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl);
17 NSMutableDictionary **images = (id *) nl[0].n_value;
18 void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value;
19
20 __UISharedImageInitialize(false);
21
22 NSArray *keys = [*images allKeys];
23 for (int i(0), e([keys count]); i != e; ++i) {
24 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
25 NSString *key = [keys objectAtIndex:i];
26 CGImageRef ref = (CGImageRef) [*images objectForKey:key];
27 UIImage *image = [UIImage imageWithCGImage:ref];
28 NSData *data = UIImagePNGRepresentation(image);
29 [data writeToFile:[NSString stringWithFormat:@"%@", key] atomically:YES];
30 [pool release];
31 }
32
33 [pool release];
34 return 0;
35 }