org.jf.dexlib2.writer.io.FileDataStore Java Examples

The following examples show how to use org.jf.dexlib2.writer.io.FileDataStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmaliDiffUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static Set<String> buildCode(File smaliDir, File dexFile, DexDiffInfo info) throws IOException,
        RecognitionException {
    Set<String> classes = new HashSet<String>();
    Set<DexBackedClassDef> classDefs = new HashSet<DexBackedClassDef>();
    classDefs.addAll(info.getModifiedClasses());
    classDefs.addAll(info.getAddedClasses());
    final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
    final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
    DexBuilder dexBuilder = new DexBuilder(Opcodes.getDefault());
    File smaliFile;
    String className;
    for (DexBackedClassDef classDef : classDefs) {
        ApkPatch.currentClassType = classDef.getType();
        className = TypeGenUtil.newType(classDef.getType());
        AfBakSmali.disassembleClass(classDef, outFileNameHandler, getBuildOption(classDefs, 19), false, false);
        smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
        classes.add(className.substring(1, className.length() - 1).replace('/', '.'));
        SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
    }

    dexBuilder.writeTo(new FileDataStore(dexFile));

    return classes;
}
 
Example #2
Source File: DexPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
    DexPool dexPool = makeDexPool();
    for (ClassDef classDef: input.getClasses()) {
        ((ClassPool)dexPool.classSection).intern(classDef);
    }
    dexPool.writeTo(new FileDataStore(new File(path)));
}
 
Example #3
Source File: SmaliUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * 将smali文件夹转换为dex文件
 * @param smaliFolder
 * @param outDexFile
 * @return
 */
public static boolean assembleSmaliFile(File smaliFolder,File outDexFile) throws IOException, RecognitionException {
    Collection<File> smaliFiles =  FileUtils.listFiles(smaliFolder, new String[]{"smali"}, true);
    if(null!= smaliFiles && smaliFiles.size() > 0){
        DexBuilder dexBuilder = new DexBuilder(Opcodes.getDefault());
        for(File smaliFile:smaliFiles){
            SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
        }
        dexBuilder.writeTo(new FileDataStore(outDexFile));
        return true;
    }else{
        return false;
    }
}
 
Example #4
Source File: DexPool.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
    DexPool dexPool = makeDexPool();
    for (ClassDef classDef: input.getClasses()) {
        ((ClassPool)dexPool.classSection).intern(classDef);
    }
    dexPool.writeTo(new FileDataStore(new File(path)));
}
 
Example #5
Source File: DexPool.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
    DexPool dexPool = makeDexPool();
    for (ClassDef classDef: input.getClasses()) {
        ((ClassPool)dexPool.classSection).intern(classDef);
    }
    dexPool.writeTo(new FileDataStore(new File(path)));
}
 
Example #6
Source File: DexPool.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(@Nonnull String path, @Nonnull org.jf.dexlib2.iface.DexFile input) throws IOException {
    DexPool dexPool = makeDexPool();
    for (ClassDef classDef: input.getClasses()) {
        ((ClassPool)dexPool.classSection).intern(classDef);
    }
    dexPool.writeTo(new FileDataStore(new File(path)));
}
 
Example #7
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
private void writeTo(String fileName) throws IOException {
	FileDataStore fds = new FileDataStore(new File(fileName));
	dexFile.writeTo(fds);
	fds.close();
}