zoukankan      html  css  js  c++  java
  • 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源码文件 dalviklibdexDexFile.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 };
  • 相关阅读:
    C++扬帆远航——4(百钱百鸡)
    C++扬帆远航——3(打印图形)
    C++扬帆远航——2
    web开发之Servlet 三
    web开发之Servlet 二
    web开发之Servlet 一
    迟来的2017年计划
    JSP 学习二
    JSP 学习一
    window7 32位安装Oracle11g
  • 原文地址:https://www.cnblogs.com/heixiang/p/10965084.html
Copyright © 2011-2022 走看看