文章目录

  • 前言
  • 一、根据 File 加载 DexFile
  • 二、DexPathList.loadDexFile 函数分析

前言


上一篇博客 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | DexPathList 构造函数分析 | makeDexElements 函数分析 ) 中 , 介绍了在 DexPathList 构造函数中调用了 makeDexElements 方法 , 在 makeDexElements 方法中执行了加载 dex 文件的操作 , 将加载后的 dex 文件封装在了 Element 实例对象中 , 并生成了 Element[] 数组 , 每个 dex 文件都对应 Element[] 数组 中的一个元素 ;

本篇博客中重点介绍 dex 文件加载的细节 ;

一、根据 File 加载 DexFile


在 DexPathList 中的 makeDexElements 方法中 , 调用了 loadDexFile 方法 , 根据 Dex 文件的 File 对象 , 创建了 DexFile 对象 ;

在 文件名称 以 .dex 后缀时 与 .apk / .jar / .zip 后缀进行不同的处理 ;

/*package*/ final class DexPathList {private static Element[] makeDexElements(ArrayList<File> files, File optimizedDirectory,ArrayList<IOException> suppressedExceptions) {ArrayList<Element> elements = new ArrayList<Element>();for (File file : files) {File zip = null;DexFile dex = null;String name = file.getName();if (name.endsWith(DEX_SUFFIX)) {// Raw dex file (not inside a zip/jar).try {dex = loadDexFile(file, optimizedDirectory);} catch (IOException ex) {}} else if (name.endsWith(APK_SUFFIX) || name.endsWith(JAR_SUFFIX)|| name.endsWith(ZIP_SUFFIX)) {zip = file;try {dex = loadDexFile(file, optimizedDirectory);} catch (IOException suppressed) {}}}}
}

源码路径 : /libcore/dalvik/src/main/java/dalvik/system/DexPathList.java

二、DexPathList.loadDexFile 函数分析


在 DexPathList. loadDexFile 方法中 , 主要是调用了 DexFile.loadDex 方法 生成 DexFile 实例对象 ;

执行 DexFile.loadDex , 先调用了 optimizedPathFor 方法 , 根据 dex 文件路径 和 优化目录 生成一个相关的 优化 dex 文件路径 ;

/*package*/ final class DexPathList {/*** Constructs a {@code DexFile} instance, as appropriate depending* on whether {@code optimizedDirectory} is {@code null}.*/private static DexFile loadDexFile(File file, File optimizedDirectory)throws IOException {if (optimizedDirectory == null) {return new DexFile(file);} else {String optimizedPath = optimizedPathFor(file, optimizedDirectory);return DexFile.loadDex(file.getPath(), optimizedPath, 0);}}
}

源码路径 : /libcore/dalvik/src/main/java/dalvik/system/DexPathList.java

【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | DexPathList 中根据 File 加载 DexFile | loadDexFile 分析 )相关推荐

  1. 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | DexFile loadDexFile 函数 | 构造函数 | openDexFile 函数 )

    文章目录 前言 一.DexFile.loadDexFile 函数分析 二.DexFile 构造函数分析 三.DexFile.openDexFile 函数分析 前言 上一篇博客 [Android 逆向] ...

  2. 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | DexClassLoader 构造函数 | 参考 Dalvik 的 DexClassLoader 类加载流程 )

    文章目录 一.DexClassLoader 源码分析 二.参考 Dalvik 下的 DexClassLoader 类加载流程 一.DexClassLoader 源码分析 ART 虚拟机下的 DexCl ...

  3. 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | RawDexFile.cpp 分析 | dvmRawDexFileOpen函数读取 DEX 文件 )

    文章目录 前言 一.RawDexFile.cpp 中 dvmRawDexFileOpen() 方法分析 前言 上一篇博客 [Android 逆向]整体加固脱壳 ( DexClassLoader 加载 ...

  4. 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | 查找 DexFile 对应的C代码 | dalvik_system_DexFile.cpp 分析 )

    文章目录 前言 一.查找 DexFile 对应的 C++ 代码 1.根据 Native 文件命名惯例查找 C++ 代码 2.根据方法名查找 二.dalvik_system_DexFile.cpp 源码 ...

  5. 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | DexPathList 构造函数分析 | makeDexElements 函数分析 )

    文章目录 前言 一.DexPathList 构造函数分析 二.DexPathList.makeDexElements 函数分析 三.Element 类分析 前言 上一篇博客 [Android 逆向]整 ...

  6. 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | oat_file_assistant.cc 中涉及的 oat 文件生成流程 )

    文章目录 前言 一.dalvik_system_DexFile.cc#DexFile_openDexFileNative 函数分析 二.oat_file_manager.cc#OpenDexFiles ...

  7. 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | exec_utils.cc 中执行 Dex 编译为 Oat 文件的 Exec 和 ExecAndReturnC函数 )

    文章目录 前言 一.exec_utils.cc#Exec 函数分析 二.exec_utils.cc#ExecAndReturnCode 函数分析 前言 在上一篇博客 [Android 逆向]ART 脱 ...

  8. 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | 类加载器构造函数分析 | DexPathList 引入 )

    文章目录 一.DexClassLoader 类加载器构造函数分析 二.DexPathList 引入 一.DexClassLoader 类加载器构造函数分析 DexClassLoader 是加载 dex ...

  9. 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 )

    文章目录 一.ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 1.file_magic.cc#OpenAndReadMagic 函数 2.dex_file.cc#DexFile:: ...

最新文章

  1. Delphi 2009 泛型容器单元(Generics.Collections)[1]: TListT
  2. 什么是线程安全,你真的了解吗?
  3. requestmapping配置页面后_@RequestMapping接口及页面乱码问题
  4. Python实现将图片转字符画
  5. SpingBoot-Thymeleaf-bootstrapTable-分页之H5
  6. sql2008安装时提示参数不能为空_Java Validation API,实现参数的合法性校验
  7. HDMI显示器驱动设计与验证
  8. Maven和Java多版本模块
  9. python 内存_一行Python解决内存问题
  10. 后端码农谈前端(HTML篇)第三课:常见属性
  11. Debian、Ubuntu源码编译制作安装包(二)
  12. jndi mysql数据库_JNDI连接数据库
  13. Togu Audio Line推出最新版本的TAL-BassLine-101插件 支持M1芯片
  14. 解码隆基模式:光伏企业的百亿成长之路
  15. 网络管理员考试试题分类精解电子书
  16. Linux CentOS 6不能使用yum安装命令
  17. Java:15位或18位居民身份证号码简单校验(正则表达式)
  18. c语言教学方法措施,C语言教学对策
  19. 【Ubuntu】安装企业微信(Wine)
  20. python 管理 交换机_用python 脚本控制telnet登录交换机

热门文章

  1. php中的__autoload()函数
  2. FineUI(开源版)v4.2.2发布(8年125个版本,官网示例突破300个)!
  3. XenDesktop7-基于SCVMM2012SP1的部署
  4. 实验楼项目课学习笔记-jQuery翻转拼图游戏
  5. jQuery 入门教程(1): 概述
  6. 说说在MVC开发中,遇到的错误及解决方法(本文章是我在实际开发中总结出来的,希望对您有帮助)...
  7. 日子过得真快,转眼就工作了4个月了
  8. Intellij IDEA常用配置详解
  9. 系统性能优化的常见八大误区
  10. nginx配置详解与优化