5 dex文件
Dex文件中數(shù)據(jù)結(jié)構(gòu)
| 類型 | 含義 |
| u1 | 等同于uint8_t,表示1字節(jié)無(wú)符號(hào)數(shù) |
| u2 | 等同于uint16_t,表示2字節(jié)的無(wú)符號(hào)數(shù) |
| u4 | 等同于uint32_t,表示4字節(jié)的無(wú)符號(hào)數(shù) |
| u8 | 等同于uint64_t,表示8字節(jié)的無(wú)符號(hào)數(shù) |
| sleb128 | 有符號(hào)LEB128,可變長(zhǎng)度1~5字節(jié) |
| uleb128 | 無(wú)符號(hào)LEB128,可變長(zhǎng)度1~5字節(jié) |
| uleb128p1 | 無(wú)符號(hào)LEB128值加1,可變長(zhǎng)度1~5字節(jié) |
?
sleb128,uleb128,uleb128p1是DEX文件中特有的數(shù)據(jù)類型
每個(gè)LEB128由1~5個(gè)字節(jié)組成,所有字節(jié)組合在一起表示一個(gè)32位的數(shù)據(jù),
每個(gè)字節(jié)只有7位為有效位,如果第一個(gè)字節(jié)的最高位為1,則LEB128使用第二個(gè)字節(jié),以此類推。如果讀取5個(gè)字節(jié)后下一個(gè)字節(jié)的最高位仍為1則該dex文件無(wú)效,Dalvik虛擬機(jī)在驗(yàn)證dex時(shí)會(huì)返回失敗
?
Dex文件整體結(jié)構(gòu)
Dex由多個(gè)結(jié)構(gòu)體組合而成,一個(gè)dex有7部份。
DexHeader結(jié)構(gòu)體占用0x70個(gè)字節(jié)
DexFile源碼文件 dalvik\libdex\DexFile.h
3 /* 4 * Structure representing a DEX file. 5 * 6 * Code should regard DexFile as opaque, using the API calls provided here 7 * to access specific structures. 8 */ 9 struct DexFile { 10 /* directly-mapped "opt" header */ 11 const DexOptHeader* pOptHeader; 12 13 /* pointers to directly-mapped structs and arrays in base DEX */ 14 const DexHeader* pHeader; 15 const DexStringId* pStringIds; 16 const DexTypeId* pTypeIds; 17 const DexFieldId* pFieldIds; 18 const DexMethodId* pMethodIds; 19 const DexProtoId* pProtoIds; 20 const DexClassDef* pClassDefs; 21 const DexLink* pLinkData; 22 23 /* 24 * These are mapped out of the "auxillary" section, and may not be 25 * included in the file. 26 */ 27 const DexClassLookup* pClassLookup; 28 const void* pRegisterMapPool; // RegisterMapClassPool 29 30 /* points to start of DEX file data */ 31 const u1* baseAddr; 32 33 /* track memory overhead for auxillary structures */ 34 int overhead; 35 36 /* additional app-specific data structures associated with the DEX */ 37 //void* auxData; 38 };轉(zhuǎn)載于:https://www.cnblogs.com/heixiang/p/10965084.html
總結(jié)
- 上一篇: ADO winform注册
- 下一篇: GeoHash -------寻找附近人