【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | DexFile 构造函数及相关调用函数 | Android 源码中查找 native 函数 )
文章目錄
- 一、DexFile 構造函數
- 二、DexFile.openInMemoryDexFile 函數
- 三、Android 源碼中查找 native 函數
一、DexFile 構造函數
上一篇博客 【Android 逆向】ART 脫殼 ( InMemoryDexClassLoader 脫殼 | BaseDexClassLoader 構造函數 | DexPathList 構造函數及后續調用 ) 分析到 , 在 DexPathList 中的 makeInMemoryDexElements 方法中 , 調用了 DexFile(ByteBuffer buf) 構造函數 , 創建 DexFile ;
在 DexFile 構造函數中 , 調用了 openInMemoryDexFile 函數 ;
DexFile 構造函數源碼 :
/*** 加載DEX文件。此類僅供內部使用,不應使用* 通過申請。* * @已棄用的此類不應由應用程序直接使用。會痛的* 在大多數情況下,會導致字節碼的錯誤執行* 最壞的情況。應用程序應該使用一個標準類加載器,例如* 改為{@link dalvik.system.PathClassLoader}<b> 此API將被刪除* 在未來的Android版本中</b>。*/ @Deprecated public final class DexFile {DexFile(ByteBuffer buf) throws IOException {// ★ 核心跳轉mCookie = openInMemoryDexFile(buf);mInternalCookie = mCookie;mFileName = null;} }二、DexFile.openInMemoryDexFile 函數
在 DexFile.openInMemoryDexFile 函數中 , 調用了 222 個 native 方法 ,
/*** 加載DEX文件。此類僅供內部使用,不應使用* 通過申請。* * @已棄用的此類不應由應用程序直接使用。會痛的* 在大多數情況下,會導致字節碼的錯誤執行* 最壞的情況。應用程序應該使用一個標準類加載器,例如* 改為{@link dalvik.system.PathClassLoader}<b> 此API將被刪除* 在未來的Android版本中</b>。*/ @Deprecated public final class DexFile {private static Object openInMemoryDexFile(ByteBuffer buf) throws IOException {if (buf.isDirect()) {// ★ 核心跳轉return createCookieWithDirectBuffer(buf, buf.position(), buf.limit());} else {// ★ 核心跳轉return createCookieWithArray(buf.array(), buf.position(), buf.limit());}}private static native Object createCookieWithDirectBuffer(ByteBuffer buf, int start, int end);private static native Object createCookieWithArray(byte[] buf, int start, int end); }源碼路徑 : /libcore/dalvik/src/main/java/dalvik/system/DexFile.java#openInMemoryDexFile
三、Android 源碼中查找 native 函數
進入 Android 源碼查看網站 http://aospxref.com/android-8.0.0_r36/ ,
在 Project(s) 中 , 選擇 " select all " , 選中所有模塊 , 在 " Full Search " 中 搜索 createCookieWithDirectBuffer 函數 , 這是 native 函數 ,
搜索出該 native 函數在 /art/runtime/native/dalvik_system_DexFile.cc 中定義 ;
總結
以上是生活随笔為你收集整理的【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | DexFile 构造函数及相关调用函数 | Android 源码中查找 native 函数 )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Android 逆向】ART 脱壳 (
- 下一篇: 【Android 逆向】ART 脱壳 (