| DexHeader | 备注 |
|---|---|
| ubyte magic[8] | dex文件的标识,一般为dex\n035\0 |
| uint checksum | adler32 检验用来确保DEX文件内容有没有损毁 |
| ubyte signature[20] | SHA-1 哈希值 20个字节 |
| uint fileSize | 文件总大小 |
| uint headerSize | dex header 的大小,一般为70字节 |
| uint endian Tag | 判断大小端 ,小端“0x12345678”,大端“0x78563412” |
| uint linkSize | LinkSection 的大小,如果为0,表示该DEX文件不是静态链接 |
| uint linkOff | LinkSection 的偏移地址 |
| uint mapOff | MapItem的偏移地址 |
| uint stringIdSize | DexStringId(字符串列表)的个数 |
| uint stringIdOff | DexStringId(字符串列表)的偏移地址 |
| uint typeIdsSize | DexTypeId(类型列表)的个数 |
| uint typeIdsOff | DexTypeId(类型列表)的偏移地址 |
| uint protoIdsSize | DexProtoId(声明列表)的个数 |
| uint protoIdsOff | DexprotoId(声明列表)的偏移地址 |
| uint fieldIdsSize | DexFileID(字段列表)的个数 |
| uint fieldIdsOff | DexFileID(字段列表)的偏移地址 |
| uint methodIdsSize | DexMethodId(方法列表)的个数 |
| uint methodIdsOff | DexMethodId(方法列表)的偏移地址 |
| uint classDefsSize | DexClassDef(类列表)的个数 |
| uint classDefsOff | DexClassDef(类列表)的偏移地址 |
| uint dataSize | 数据段的大小 |
| DexStringId | 备注 | 备注 | 备注 |
|---|---|---|---|
| uint stringDataOff | stringDataItem 的偏移地址 | / | / |
| / | stringDataItem | uleb128 utf16Size | 字符串大小 |
| / | stringDataItem | ubyte data | 字符串 |
| DexTypeId | 备注 | 备注 | 备注 |
|---|---|---|---|
| typeIdItem | 存放dex中所有的类型 | / | / |
| / | uint dexcriptor_idx | DexStringId中的index |
| DexProtoId | 备注 | 备注 | 备注 |
|---|---|---|---|
| ptotoIdItem | 描述方法的圆形,即方法返回类型+方法参数 | ||
| / | uint shortIdx | 方法声明字符串指向DexStringId中的index,方法声明 = 返回类型 + 参数列表 | / |
| / | uint returnTypeIdx | 方法返回类型 指向DexTypeId 的 index | / |
| / | uint parametersOff | DexTypeList结构体的偏移地址 | / |
| / | DexTypeList | 存放方法的参数列表 | / |
| / | uint size | DexTypeItem 的个数 | / |
| / | DexTypeItem* list | DexTypeItem 的数组 | / |
| / | ushort typeIdx | 指向 DexTypeId 列表的 index | / |
| DexFieldId | 备注 | 备注 | 备注 |
|---|---|---|---|
| fieldIdItem | 字段所属的类、字段的类型以及字段名 | / | / |
| / | ushort classIdx | 字段所属类的类型,指向DexTypeId列表的index | / |
| / | ushort typeIdx | 字段的类型,指向DexTypeId 列表的index | / |
| / | uint nameIdx | 字段名,指向DexStringId 列表的index | / |
| DexMethodId | 备注 | 备注 | 备注 |
|---|---|---|---|
| methodIdItem | dex中所有的方法 | / | / |
| / | ushort classIdx | 类的类型,指向DexTypeId的列表的index | / |
| / | ushort protoIdx | 声明的类型,指向DexProtoId 列表的index | / |
| / | uint nameIdx | 方法名,指向 DexStringId的列表index | / |
| DexClassDef | 备注 | 备注 | 备注 |
|---|---|---|---|
| classDefItem | dex中类的定义 | / | / |
| / | uint classIdx | 类的类型,指向DexTypeId的列表的index | / |
| / | uint accessFlags | 访问标识,如 public | / |
| / | uint superclassIdx | 父类类型,指向DexTypeId列表的index | / |
| / | uint interfacesOff | 接口,指向DexTypeList 的偏移,如果没有则为0 | / |
| / | uint sourceFieldIdx | 源文件名,指向DexStringId 列表的index | / |
| / | uint annotationsOff | 注解,指向 DexAnnotationsDirectoryItem 接口,或者为0 | / |
| / | uint classDataOff | 指向DexClassData 结构的偏移,类的数据部分 | / |
| / | classDataItem | 类使用到的各种数据 | / |
| / | uleb128 staticFieldsSize | 静态字段个数 | / |
| / | uleb128 instanceFieldSize | 实例字段个数 | / |
| / | uleb128 directMethodsSize | 直接方法个数 | / |
| / | uleb128 virtualMethodsSize | 虚方法个数 | / |
| / | encodedField staticFieds | 静态字段 | / |
| / | encodedField | 类中的字段 | / |
| / | uleb128 fieldIdxDiff | DexDieldId 列表的index | / |
| / | uleb128 accessFlags | 访问标识,如pubic | / |
| / | encodedField instanceFields | 实例字段 | |
| / | encodedMethod directMethods | 直接方法 | / |
| / | encodedMethod | 类中的方法 | / |
| / | uleb128 methodIdexDiff | DexMethodId列表的index | / |
| / | uleb128 accessFlags | 访问标识,如public | / |
| / | uleb128 codeOff | codeItem 的偏移地址 | / |
| / | codeItem | 方法的逻辑代码 | / |
| / | ushort registerSize | 代码使用到的寄存器个数 | / |
| / | ushort insSize | 方法传入参数的个数 | / |
| / | ushort outSize | 代码调用其他方法时需要的参数个数 | / |
| / | ushort triesSize | try_item 结构的个数 | / |
| / | uint debugInfoOff | 指向本段代码的的 debug 信息存放位置,是一个 debug_info_item 结构偏移地址 | / |
| / | ushort insns | 代码指令 | / |
| / | ushort padding | 值 为 0 ,用于对齐字节 | / |
| / | tryItem tries | 异常相关 | / |
| / | encodedCatchHandlerList | 异常相关 | / |
| / | encodeMethod virtualMethods | 虚方法 | / |
| / | uint staticValuesOff | 指向 DexEncodeArray 结构的偏移,记录了类中的静态数据,没有则为0 | / |
| DexClassDef | 备注 | 备注 | 备注 |
|---|---|---|---|
| uint size | mapItem 的个数 | / | / |
| maptiem list | mapItem 数组 | / | / |
| / | ushort rtype | 一个枚举常量 | / |
| / | / | kDexTypeHeaderItem = 0x0000 | / |
| / | / | kDexTypeStringIdItem = 0x0001 | / |
| / | / | kDexTypeTypeIdItem = 0x0002 | / |
| / | / | kDexTypeProtoIdItem = 0x0003 | / |
| / | / | kDexTypeFieldIdItem = 0x0004 | / |
| / | / | kDexTypeMethodIdItem = 0x0005 | / |
| / | / | kDexTypeClassDefItem = 0x0006 | / |
| / | / | kDexTypeMapList = 0x1000 | / |
| / | / | kDexTypeTypeList = 0x1001 | / |
| / | / | kDexTypeAnnotationSetReList = 0x1002 | / |
| / | / | kDexTypeannotationSetItem = 0x1003 | / |
| / | / | kDexTypeClassDataItem = 0x2000 | / |
| / | / | kDexTypeCodeItem = 0x2001 | / |
| / | / | kDexTypeStringDataItem = 0x2002 | / |
| / | / | kDexTypeDebugInfoItem = 0x2003 | / |
| / | / | kDextypeAnnotationItem = 0x2004 | / |
| / | / | kDexTypeEncodeArrayItem = 0x2005 | / |
| / | / | kDexTypeAnnotationsDirectoryItem = 0x2006 | / |
| / | ushort unused | 未使用,用于对齐 | / |
| / | uint size | 指定类型的个数 | / |
| / | uint offset | 指定类型数据的文件偏移 | / |