Skip to content

Instantly share code, notes, and snippets.

@lukele
Last active September 22, 2021 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukele/379f9e79c359c5dd4cd34d54b85ab55a to your computer and use it in GitHub Desktop.
Save lukele/379f9e79c359c5dd4cd34d54b85ab55a to your computer and use it in GitHub Desktop.
Mail Mime Type Mappings

Shows the first 2 NSString objects

(lldb) memory read -c 64 sMimeTypeMappings
0x7ff95b9a1bb0: 78 29 d7 5a f8 7f 00 00 c8 07 00 00 00 00 00 00  x).Z............
0x7ff95b9a1bc0: 29 b4 fa 35 f9 7f 00 00 04 00 00 00 00 00 00 00  )..5............
0x7ff95b9a1bd0: 78 29 d7 5a f8 7f 00 00 c8 07 00 00 00 00 00 00  x).Z............
0x7ff95b9a1be0: 2e b4 fa 35 f9 7f 00 00 08 00 00 00 00 00 00 00  ...5............

Shows the first 4 struct entries

(lldb) memory read -c 64 &sMimeTypeMappings
0x7ff95b99aad0: b0 1b 9a 5b f9 7f 00 00 01 00 00 00 00 00 00 00  ...[............
0x7ff95b99aae0: 30 1d 9a 5b f9 7f 00 00 02 00 00 00 00 00 00 00  0..[............
0x7ff95b99aaf0: 90 1d 9a 5b f9 7f 00 00 03 00 00 00 00 00 00 00  ...[............
0x7ff95b99ab00: d0 1d 9a 5b f9 7f 00 00 04 00 00 00 00 00 00 00  ...[............
- (NSDictionary *)mimeTypeMappingsOfType:(NSString *)type {
    MimeTypeMapping *mapping = [type isEqualToString:@"subtype"] ? (MimeTypeMapping *)0x7ff95b99ab50 : (MimeTypeMapping *)0x7ff95b99aad0;
    NSMutableDictionary *mappings = [NSMutableDictionary new];
    while((uint64_t)*(uint64_t *)mapping != 0) {
        MimeTypeMapping mimeType = *mapping;
        NSLog(@"[%lu] type: %@", mimeType.typeCode, mimeType.type);
        [mappings setObject:[NSNumber numberWithUnsignedInteger:mimeType.typeCode] forKey:mimeType.type];
        mapping = (MimeTypeMapping *)((uint64_t)mapping + sizeof(MimeTypeMapping));
    }
    
    return (NSDictionary *)mappings;
}
Type Mappings: {
	text: 1 -› 0x01,
	image: 2 -› 0x02,
	audio: 3 -› 0x03,
	video: 4 -› 0x04,
	application: 5 -› 0x05,
	multipart: 6 -› 0x06,
	message: 7 -› 0x07,
}
Subtype Mappings: {
	calendar: 1 -› 0x01,
	directory: 2 -› 0x02,
	earthlink-xml: 3 -› 0x03,
	enriched: 4 -› 0x04,
	richtext: 5 -› 0x05,
	html: 6 -› 0x06,
	plain: 7 -› 0x07,
	rtf: 8 -› 0x08,
	gif: 30 -› 0x1e,
	jpeg: 31 -› 0x1f,
	png: 32 -› 0x20,
	tiff: 33 -› 0x21,
	basic: 50 -› 0x32,
	mpeg: 70 -› 0x46,
	applefile: 90 -› 0x5a,
	mac-binhex40: 91 -› 0x5b,
	ms-tnef: 92 -› 0x5c,
	octet-stream: 94 -› 0x5e,
	pdf: 95 -› 0x5f,
	pkcs7-mime: 96 -› 0x60,
	x-pkcs7-mime: 96 -› 0x60,
	pkcs7-signature: 97 -› 0x61,
	x-pkcs7-signature: 97 -› 0x61,
	postscript: 98 -› 0x62,
	smil: 99 -› 0x63,
	zip: 101 -› 0x65,
	vnd.iwork.pages.archive: 102 -› 0x66,
	vnd.iwork.numbers.archive: 103 -› 0x67,
	vnd.iwork.keynote.archive: 104 -› 0x68,
	alternative: 120 -› 0x78,
	appledouble: 121 -› 0x79,
	digest: 122 -› 0x7a,
	x-folder: 123 -› 0x7b,
	mixed: 124 -› 0x7c,
	related: 125 -› 0x7d,
	report: 126 -› 0x7e,
	signed: 127 -› 0x7f,
	delivery-status: 140 -› 0x8c,
	external-body: 141 -› 0x8d,
	partial: 142 -› 0x8e,
	rfc822: 143 -› 0x8f,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment