dex文件结构

0x00013f80 |                                     64 65 78 0A             <--- 
0x00013f90 | 30 33 35 00 EE 46 38 DD 46 FF 89 0D BE CA CD BD 
0x00013fa0 | 63 CB 13 87 01 1C DC 87 53 DB 34 35 D8 2C 2C 00 
0x00013fb0 | 70 00 00 00 78 56 34 12 00 00 00 00 00 00 00 00 
0x00013fc0 | 08 2C 2C 00 5F 5C 00 00 70 00 00 00 E9 08 00 00      Header
0x00013fd0 | EC 71 01 00 16 11 00 00 90 95 01 00 6E 1F 00 00 
0x00013fe0 | 98 62 02 00 26 55 00 00 08 5E 03 00 56 08 00 00 
0x00013ff0 | 38 07 06 00 E0 1A 25 00 F8 11 07 00 AE 80 1C 00 -----------><---
0x00014000 | B0 80 1C 00 B4 80 1C 00 B7 80 1C 00 BE 80 1C 00 
0x00014010 | C4 80 1C 00 CB 80 1C 00 D9 80 1C 00 F0 80 1C 00 
...                                                              StringIds
0x0002b140 | CE 3D 23 00 DD 3D 23 00 EA 3D 23 00 FA 3D 23 00 
0x0002b150 | 02 3E 23 00 05 3E 23 00 09 3E 23 00 1E 3E 23 00 
0x0002b160 | 34 3E 23 00 38 3E 23 00 48 3E 23 00 4B 3E 23 00 
0x0002b170 | 4E 3E 23 00 53 3E 23 00 2C 06 00 00 F1 06 00 00 -------><-------
0x0002b180 | EE 08 00 00 DD 0B 00 00 96 0D 00 00 5C 0F 00 00 
0x0002b190 | E3 10 00 00 E4 10 00 00 E5 10 00 00 E6 10 00 00 
0x0002b1a0 | E7 10 00 00 E8 10 00 00 E9 10 00 00 EA 10 00 00      TypeIds
...
0x0002d500 | 89 29 00 00 8A 29 00 00 8B 29 00 00 8C 29 00 00 
0x0002d510 | 8D 29 00 00 8E 29 00 00 8F 29 00 00 2C 06 00 00 -----------><---
0x0002d520 | 00 00 00 00 00 00 00 00 3A 06 00 00 00 00 00 00 
0x0002d530 | B8 2B 1C 00 3E 06 00 00 00 00 00 00 C0 2B 1C 00 
0x0002d540 | 4D 06 00 00 00 00 00 00 C8 2B 1C 00 4E 06 00 00 
0x0002d550 | 00 00 00 00 D0 2B 1C 00 50 06 00 00 00 00 00 00     ProtoIds
0x0002d560 | D8 2B 1C 00 57 06 00 00 00 00 00 00 E0 2B 1C 00 
...
0x0003a200 | 74 10 00 00 E4 08 00 00 88 2F 1C 00 70 10 00 00 
0x0003a210 | E5 08 00 00 E8 2B 1C 00 70 10 00 00 E5 08 00 00 
0x0003a220 | 44 39 1C 00 06 00 04 00 C5 35 00 00 06 00 60 01 ---><-----------
0x0003a230 | 3E 38 00 00 07 00 04 00 C9 35 00 00 07 00 60 01 
0x0003a240 | 3E 38 00 00 09 00 04 00 14 05 00 00 09 00 04 00 
...                                                              FieldIds
0x00049d70 | CC 35 00 00 5A 08 56 08 DC 4C 00 00 5A 08 60 01
0x00049d80 | EA 56 00 00 5B 08 5B 08 B9 24 00 00 5B 08 5B 08 
0x00049d90 | B8 57 00 00 06 00 17 0B B4 04 00 00 06 00 20 0B ---><-----------
0x00049da0 | B4 04 00 00 06 00 17 03 A9 3B 00 00 06 00 FC 01 
0x00049db0 | 9C 50 00 00 06 00 79 04 9D 50 00 00 07 00 17 0B 
0x00049dc0 | B4 04 00 00 07 00 20 0B B4 04 00 00 07 00 EC 03    MethodIds
...
0x000746a0 | 4C 30 00 00 D9 08 9C 02 4C 30 00 00 DA 08 9C 02 
0x000746b0 | 4C 30 00 00 DC 08 9C 02 4C 30 00 00 DD 08 9C 02 
0x000746c0 | 4C 30 00 00 42 01 00 00 01 00 00 00 FF FF FF FF ---><-----------
0x000746d0 | 00 00 00 00 B1 1F 00 00 34 DA 1A 00 1F 0A 2A 00 
0x000746e0 | 00 00 00 00 E7 00 00 00 01 06 00 00 42 01 00 00 
0x000746f0 | 00 00 00 00 8D 23 00 00 00 00 00 00 00 00 00 00 
0x00074700 | 00 00 00 00 73 01 00 00 01 00 00 00 42 01 00 00 
0x00074710 | 9C 23 1C 00 56 25 00 00 7C DA 1A 00 6A 0A 2A 00 
0x00074720 | 08 E4 29 00 20 01 00 00 01 00 00 00 73 01 00 00 
0x00074730 | 00 00 00 00 A6 0B 00 00 00 00 00 00 04 0B 2A 00    ClassDefs
0x00074740 | 12 E4 29 00 06 00 00 00 11 00 00 00 20 01 00 00 
...
0x00085130 | 00 00 00 00 82 28 00 00 CC 22 1C 00 51 2A 2C 00 
0x00085140 | 05 0A 2A 00 5A 08 00 00 01 00 00 00 42 01 00 00 
0x00085150 | AC 2B 1C 00 4D 0A 00 00 24 23 1C 00 AD 2A 2C 00 
0x00085160 | 09 0A 2A 00 5B 08 00 00 11 00 00 00 42 01 00 00 
0x00085170 | 00 00 00 00 AA 26 00 00 84 23 1C 00 7B 2B 2C 00 
0x00085180 | 00 00 00 00 01 00 00 00 87 28 29 00 01 00 00 00 ---><-----------
0x00085190 | 95 28 29 00 02 00 00 00 A0 28 29 00 AB 28 29 00 
0x000851a0 | 01 00 00 00 B7 28 29 00 01 00 00 00 C8 28 29 00 
0x000851b0 | 01 00 00 00 D3 28 29 00 01 00 00 00 E7 28 29 00 
0x000851c0 | 01 00 00 00 F1 28 29 00 01 00 00 00 FE 28 29 00 
0x000851d0 | 01 00 00 00 09 29 29 00 01 00 00 00 14 29 29 00       data
...
0x002d6c30 | 58 3E 23 00 04 20 00 00 55 0A 00 00 87 28 29 00 
0x002d6c40 | 05 20 00 00 7C 02 00 00 08 E4 29 00 00 20 00 00 
0x002d6c50 | 15 08 00 00 1F 0A 2A 00 00 10 00 00 01 00 00 00 
0x002d6c60 | 08 2C 2C 00 64 65 78 0A 30 33 35 00 11 E1 2D 3F ---><-----------
0x002d6c70 | 23 F7 28 15 B0 A3 2C A4 34 0F 06 39 E4 5C D1 13 
0x002d6c80 | 4E 66 79 6A 90 1E 04 00 70 00 00 00 78 56 34 12 
0x002d6c90 | 00 00 00 00 00 00 00 00 C0 1D 04 00 DD 0C 00 00      Header
0x002d6ca0 | 70 00 00 00 BF 01 00 00 E4 33 00 00 3B 02 00 00
...

 

typenamevalue
uint8_t[8] magic_ "dex.035"
uint32_t checksum_

0xdd3846ee

uint8_t[20] signature_
46 FF 89 0D BE CA CD BD 
63 CB 13 87 01 1C DC 87
53 DB 34 35
uint32_t file_size_
0x002c2cd8
uint32_t header_size_
0x00000070
uint32_t endian_tag_

0x12345678

uint32_t link_size_
0x00000000
uint32_t link_off_
0x00000000
uint32_t map_off_
0x002c2c08
uint32_t string_ids_size_
0x00005c5f
uint32_t string_ids_off_
0x00000070
uint32_t type_ids_size_
0x000008e9
uint32_t type_ids_off_
0x000171ec
uint32_t proto_ids_size_
0x00001116
uint32_t proto_ids_off_
0x00019590
uint32_t field_ids_size_
0x00001f6e
uint32_t field_ids_off_
0x00026298 
uint32_t method_ids_size_

0x00005526

uint32_t method_ids_off_

0x00035e08

uint32_t class_defs_size_

0x00000856

uint32_t class_defs_off_

0x00060738

uint32_t data_size_

0x00251ae0

uint32_t data_off_

0x000711f8

StringId[]:
// offset in bytes from the base address
uint32_t string_data_off_;

 

string_ids
0x001c80ae
0x001c80b0
0x001c80b4
0x001c80b7
0x001c80be
0x001c80c4
...
0x00233e1e
0x00233e34
0x00233e38
0x00233e48
0x00233e4b
0x00233e4e
0x00233e53
TypeId[]:

// index into string_ids
uint32_t descriptor_idx_;

type_ids
0x0000062c
0x000006f1
0x000008ee
0x00000bdd
0x00000d96
0x00000f5c
0x000010e3
0x000010e4
...
0x00002989
0x0000298a
0x0000298b
0x0000298c
0x0000298d
0x0000298e
0x0000298f

ProtoId[]:
// index into string_ids array for shorty descriptor
uint32_t shorty_idx_;
// index into type_ids array for return type
uint16_t return_type_idx_;
// padding = 0
uint16_t pad_;
// file offset to type_list for parameter types
uint32_t parameters_off_;

proto_ids
{
0x0000062c,
0x0000,
0x0000,
0x00000000
},{
0x0000063a,
0x0000,
0x0000,
0x001c2bb8
},{
0x0000063e,
0x0000,
0x0000,
0x001c2bc0
}, {
...
},{
    0x00001070,
    0x08e5,
    0x0000,
    0x001c2be8
},{
0x00001070,
0x08e5,
0x0000,
0x001c3944
}

FieldId[]:
// index into type_ids_ array for defining class
uint16_t class_idx_;
// index into type_ids_ array for field type
uint16_t type_idx_;
// index into string_ids_ array for field name
uint32_t name_idx_;

field_ids
{
0x0006,
0x0004,
0x000035c5
},
{
0x0007,
0x0004,
0x000035c9
},
{
0x0007,
0x0160,
0x0000383e
},{
...
},{
    0x085b,
    0x085b,
    0x000024b9
},{
    0x085b,
    0x085b,
    0x000057b8
}

MethodId[]:
// index into type_ids_ array for defining class
uint16_t class_idx_;
// index into proto_ids_ array for method prototype
uint16_t proto_idx_;
// index into string_ids_ array for method name
uint32_t name_idx_; 

method_ids
{
0x0006,
0x0b17,
0x000004b4
},{
0x0006,
0x0b20,
0x000004b4
},{
0x0006,
0x0317,
0x00003ba9
},
{ 0x0006,
0x01fc,
0x0000509c
},{
0x0006,
0x0479,
0x0000509d
},{
0x0007,
0x0b17,
0x000004b4
},{
...
},{
0x08dc,
0x029c,
0x0000304c
},{
0x08dd,
0x029c,
0x0000304c
}
ClassDef[]:
// index into type_ids_ array for this class
uint16_t class_idx_; 
// padding = 0
uint16_t pad1_; 
uint32_t access_flags_;
// index into type_ids_ array for superclass
uint16_t superclass_idx_;
// padding = 0
uint16_t pad2_;
// file offset to TypeList
uint32_t interfaces_off_;
// index into string_ids_ for source file name
uint32_t source_file_idx_;
// file offset to annotations_directory_item
uint32_t annotations_off_;
// file offset to class_data_item
uint32_t class_data_off_;
// file offset to EncodedArray
uint32_t static_values_off_;
class_defs
{
0x0142,
0x0000,
0x00000001,
0xffff,
0xffff,
0x00000000,
0x00001fb1,
0x001ada34,
0x002a0a1f,
0x00000000
},{
0x00e7,
0x0000,
0x00000601,
0x0142,
0x0000,
0x00000000,
0x0000238d,
0x00000000,
0x00000000,
0x00000000
},{
0x0173,
0x0000,
0x00000001,
0x0142,
0x0000,
0x001c239c,
0x00002556,
0x001ada7c,
0x002a0a6a,
0x0029e408
},{
....
},{
0x085a,
0x0000,
0x00000001,
0x0142,
0x0000,
0x001c2bac,
0x00000a4d,
0x001c2324,
0x002c2aad,
0x002a0a09
},{
0x085b,
0x0000,
0x00000001,
0x0142,
0x0000,
0x00000000,
0x000026aa,
0x001c2384,
0x002c2b7b,
0x00000000
}
uint32_t[] data
0x00000001,
0x00292887,
0x00000001,
0x00292895
0x00000002
0x002928a0
0x002928ab
...
0x00000815,
0x002a0a1f,
0x00001000,
0x00000001,
0x002c2c08
posted @ 2017-05-14 00:18  YYPapa  阅读(415)  评论(0编辑  收藏  举报