当前位置: 首页>>代码示例>>Java>>正文


Java DexBuilder.makeDexBuilder方法代码示例

本文整理汇总了Java中org.jf.dexlib2.writer.builder.DexBuilder.makeDexBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java DexBuilder.makeDexBuilder方法的具体用法?Java DexBuilder.makeDexBuilder怎么用?Java DexBuilder.makeDexBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jf.dexlib2.writer.builder.DexBuilder的用法示例。


在下文中一共展示了DexBuilder.makeDexBuilder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCode

import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
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 = DexBuilder.makeDexBuilder();
    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;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:SmaliDiffUtils.java

示例2: build

import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
private void build() throws AndrolibException {
    try {
        DexBuilder dexBuilder = DexBuilder.makeDexBuilder();

        for (String fileName : mSmaliDir.getDirectory().getFiles(true)) {
            buildFile(fileName, dexBuilder);
        }
        dexBuilder.writeTo(new FileDataStore( new File(mDexFile.getAbsolutePath())));
    } catch (IOException | DirectoryException ex) {
        throw new AndrolibException(ex);
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:13,代码来源:SmaliBuilder.java

示例3: assembleSmaliFile

import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
/**
 * 将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 = DexBuilder.makeDexBuilder();
        for(File smaliFile:smaliFiles){
            SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
        }
        dexBuilder.writeTo(new FileDataStore(outDexFile));
        return true;
    }else{
        return false;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:20,代码来源:SmaliUtils.java

示例4: DexPrinter

import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
public DexPrinter() {
	dexFile = DexBuilder.makeDexBuilder(19);
	//dexAnnotation = new DexAnnotation(dexFile);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:5,代码来源:DexPrinter.java

示例5: compileSmali

import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
public static ClassDef compileSmali(String smaliText, int apiLevel, boolean experimental)
        throws RecognitionException, IOException {
    CommonTokenStream tokens;
    LexerErrorInterface lexer;
    DexBuilder dexBuilder = DexBuilder.makeDexBuilder(apiLevel);

    Reader reader = new StringReader(smaliText);

    lexer = new smaliFlexLexer(reader);
    tokens = new CommonTokenStream((TokenSource)lexer);

    smaliParser parser = new smaliParser(tokens);
    parser.setVerboseErrors(true);
    parser.setAllowOdex(false);
    parser.setApiLevel(apiLevel, experimental);

    smaliParser.smali_file_return result = parser.smali_file();

    if(parser.getNumberOfSyntaxErrors() > 0 || lexer.getNumberOfSyntaxErrors() > 0) {
        throw new RuntimeException("Error occured while compiling text");
    }

    CommonTree t = result.getTree();

    CommonTreeNodeStream treeStream = new CommonTreeNodeStream(t);
    treeStream.setTokenStream(tokens);

    smaliTreeWalker dexGen = new smaliTreeWalker(treeStream);
    dexGen.setApiLevel(apiLevel, experimental);
    dexGen.setVerboseErrors(true);
    dexGen.setDexBuilder(dexBuilder);
    dexGen.smali_file();

    if (dexGen.getNumberOfSyntaxErrors() > 0) {
        throw new RuntimeException("Error occured while compiling text");
    }

    MemoryDataStore dataStore = new MemoryDataStore();

    dexBuilder.writeTo(dataStore);

    DexBackedDexFile dexFile = new DexBackedDexFile(
            new Opcodes(apiLevel, experimental), dataStore.getData());

    return Iterables.getFirst(dexFile.getClasses(), null);
}
 
开发者ID:Sukelluskello,项目名称:VectorAttackScanner,代码行数:47,代码来源:SmaliTestUtils.java


注:本文中的org.jf.dexlib2.writer.builder.DexBuilder.makeDexBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。