#import <mach-o/dyld.h>
#import <mach-o/nlist.h>
#import "_ViewController.h"
@implementation _ViewController
extern UIImage *_UIImageWithName(NSString *);
- (NSMutableDictionary*) UIKitImages
{
NSMutableDictionary *mappedImages = nil;
for(uint32_t i = 0; i < _dyld_image_count(); i++) {
if (strstr(_dyld_get_image_name(i), "UIKit.framework")) {
struct nlist symlist[] = {{"___mappedImages", 0, 0, 0, 0}, NULL};
if (nlist(_dyld_get_image_name(i), symlist) == 0 && symlist[0].n_value != 0) {
mappedImages = (NSMutableDictionary*)*(int*)symlist[0].n_value;
}
break;
}
}
return mappedImages;
}
- (IBAction) extractArtwork:(id)sender
{NSLog(@"extracting...");
for (NSString *imageName in [[self UIKitImages] allKeys]) {
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *imagePath = [documentsPath stringByAppendingPathComponent:imageName];
[UIImagePNGRepresentation(_UIImageWithName(imageName)) writeToFile:imagePath atomically:YES];
}
}
- (void)viewDidLoad {
[self extractArtwork:nil];
[super viewDidLoad];
}
@end