android dex分析,Android DEX 文件打开分析

函数为

DexFile_openDexFileNative

ClassLinker::OpenDexFilesFromOat

1、 FindOpenedOatDexFile 查找缓存中是否存在,checksum为空或者相同

2、 CreateOatFileForDexLocation

一、生成oat文件 执行execv 调用 dex2oat 生成Oat 会启动进程生成较慢

std::string dex2oat(Runtime::Current()->GetCompilerExecutable()); 文件路径待研究

execv执行成功就返回成功,不管是不是成功

二、OatFile::Open打开,如果失败返回null OatFile* OatFile::Open

调用 ElfFile::Open 判断非ELF文件返回NULL

3、CreateOatFileForDexLocation 生成失败 调用 DexFile::Open 不生成优化

// Failed, bail.

if (open_oat_file.get() == nullptr) {

std::string error_msg;

// dex2oat was disabled or crashed. Add the dex file in the list of dex_files to make progress.

DexFile::Open(dex_location, dex_location, &error_msg, dex_files);

error_msgs->push_back(error_msg);

return false;

}

经过以上分析 内存打开Dex文件的时候 hook execv 然后失败,防止转换oat成功可以提高首次启动速度,且能

正常运行,但是每次的速度是变慢的,DEX加固的时候有的手机会出现卡死的情况(有buggly时才会出现),暂时

不知道原因,待以后研究明白在说明,如果有人知道原因也麻烦告知。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值