日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

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

發布時間:2025/6/17 Android 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Android 逆向】整体加固脱壳 ( DexClassLoader 加载 dex 流程分析 | DexPathList 中根据 File 加载 DexFile | loadDexFile 分析 ) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 前言
  • 一、根據 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 分析 )的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。