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

The following examples show how to use org.jf.dexlib2.writer.io.FileDataStore. These examples are extracted from open source projects. 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 Project: atlas   Source File: SmaliDiffUtils.java    License: 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 Project: ZjDroid   Source File: DexPool.java    License: 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 Project: atlas   Source File: SmaliUtils.java    License: 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 Project: zjdroid   Source File: DexPool.java    License: 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 Project: HeyGirl   Source File: DexPool.java    License: 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 Project: ZjDroid   Source File: DexPool.java    License: 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 Project: JAADAS   Source File: DexPrinter.java    License: 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();
}