DexRepair批量自动修复dex

这篇文章介绍了一个名为DexRepair的工具,它根据bin文件自动修复Dex,适用于Fart的不同版本。主要功能包括选择需要修复的dex路径并执行修复操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DexRepair根据bin文件批量自动修复dex

https://github.com/luoyesiqiu/DexRepair

理论适用于 Fart 各个版本

适配mikrom1.0.1

增加的关键代码

public static void main(String[] args) {
    FileChooser.choose();
    System.exit(0);
}
    
public static void repair(String binPath,String dexPath){
        if(new File(dexPath).exists() && new File(binPath).exists()) {
            byte[] data = IoUtils.readFile(binPath);
            List<CodeItem> items = DexUtils.convertToCodeItems(data);
            DexUtils.patch(dexPath, items,true);
        }
        else{
            System.err.println("Dex file or bin file not exists!");
        }
}

选择需要修复的dex路径

public class FileChooser {

    public static void choose() {
        File folder = new File("bin,dex文件路径");

        if (folder.isDirectory()) {
            File[] files = folder.listFiles();

            for (File file : files) {
                String fileName = file.getName();
                if(fileName.endsWith(".bin")){
                    String[] strings = fileName.split("_");
                    String dexName,binPath,dexPath;
                    switch (strings.length){
                        case 3:
                            dexName = strings[0]+"_dexfile.dex";
                            binPath = folder.getAbsolutePath()+"\\"+fileName;
                            dexPath = folder.getAbsolutePath()+"\\"+dexName;
                            System.out.println(binPath+"<=>"+dexPath);
                            DexRepair.repair(binPath, dexPath);
                            break;
                        case 4:
                            dexName = strings[0]+"_"+strings[1]+"_dexfile.dex";
                            binPath = folder.getAbsolutePath()+"\\"+fileName;
                            dexPath = folder.getAbsolutePath()+"\\"+dexName;
                            System.out.println(binPath+"<=>"+dexPath);
                            DexRepair.repair(binPath, dexPath);
                            break;
                        default:
                            break;
                    }
                }
            }
        } else {
            System.out.println("指定的路径不是一个文件夹");
        }
    }

}

代码待完善

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值