栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

dex解密(dex文件格式)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

dex解密(dex文件格式)

在上一篇中介绍了string_ids的解析,那么接下来就要学习type_ids的解析。

1. type_ids结构

在android的aosp源码中,type_ids的结构如下:
aosp源码位置:art/libdexfile/dex/dex_file.h

TypeId

 // Raw type_id_item.
  struct TypeId {
    dex::StringIndex descriptor_idx_;  // index into string_ids

   private:
    DISALLOW_COPY_AND_ASSIGN(TypeId);
  };

StringIndex

class StringIndex {
 public:
  uint32_t index_;
  ....  
  ....
};

TypeId的结构,存储着一个无符号的4字节数据(StringIndex对应的是无符号的int类型),descriptor_idx_对应的是字符串索引列表的索引/下标

2. 010Editor解析

如图,仔细观察


3. type_ids解析

java语言解析type_ids

private static List toParseDexTypeIds(RandomAccessFile raf) {
    try {
        List typeIdList = new ArrayList<>();
        //获取类型索引列表的文件偏移量
        int type_ids_off = mDexFile.getType_ids_off();
        //获取类型索引列表的大小
        int type_ids_size = mDexFile.getType_ids_size();
        //偏移到类型索引列表的开始位置
        raf.seek(type_ids_off);
        //遍历类型索引列表,类型索引列表中存储着 字符串索引列表的 索引(下标)
        for (int i=0;i 

实体类TypeId

public class TypeId {
    private int typeDescriptorIdx; //存储着 字符串索引列表中的索引

    public int getTypeDescriptorIdx() {
        return typeDescriptorIdx;
    }

    public void setTypeDescriptorIdx(int typeDescriptorIdx) {
        this.typeDescriptorIdx = typeDescriptorIdx;
    }
}

工具类NumConversion

public class NumConversion {

    public static int byteToInt(byte[] bytes,boolean isBigEndian) {
        if (bytes.length <=0 || bytes.length > 4) return -1;
        int result = 0;
        for (int i=0;i 

asjhan for Android reverse

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/776604.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号