5 dex文件
Dex文件中數據結構
| 類型 | 含義 |
| u1 | 等同于uint8_t,表示1字節無符號數 |
| u2 | 等同于uint16_t,表示2字節的無符號數 |
| u4 | 等同于uint32_t,表示4字節的無符號數 |
| u8 | 等同于uint64_t,表示8字節的無符號數 |
| sleb128 | 有符號LEB128,可變長度1~5字節 |
| uleb128 | 無符號LEB128,可變長度1~5字節 |
| uleb128p1 | 無符號LEB128值加1,可變長度1~5字節 |
?
sleb128,uleb128,uleb128p1是DEX文件中特有的數據類型
每個LEB128由1~5個字節組成,所有字節組合在一起表示一個32位的數據,
每個字節只有7位為有效位,如果第一個字節的最高位為1,則LEB128使用第二個字節,以此類推。如果讀取5個字節后下一個字節的最高位仍為1則該dex文件無效,Dalvik虛擬機在驗證dex時會返回失敗
?
Dex文件整體結構
Dex由多個結構體組合而成,一個dex有7部份。
DexHeader結構體占用0x70個字節
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 };轉載于:https://www.cnblogs.com/heixiang/p/10965084.html
總結
- 上一篇: ADO winform注册
- 下一篇: GeoHash -------寻找附近人