org.jf.dexlib2.dexbacked.DexBackedOdexFile Java Examples

The following examples show how to use org.jf.dexlib2.dexbacked.DexBackedOdexFile. 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: ApkSmaliDecoder.java    From apk-dependency-graph with Apache License 2.0 6 votes vote down vote up
private BaksmaliOptions getSmaliOptions(final DexBackedDexFile dexFile) {
    final BaksmaliOptions options = new BaksmaliOptions();

    options.deodex = false;
    options.implicitReferences = false;
    options.parameterRegisters = true;
    options.localsDirective = true;
    options.sequentialLabels = true;
    options.debugInfo = false;
    options.codeOffsets = false;
    options.accessorComments = false;
    options.registerInfo = 0;

    if (dexFile instanceof DexBackedOdexFile) {
        options.inlineResolver =
                InlineMethodResolver.createInlineMethodResolver(
                    ((DexBackedOdexFile)dexFile).getOdexVersion());
    } else {
        options.inlineResolver = null;
    }

    return options;
}
 
Example #2
Source File: SmaliDecoder.java    From ratel with Apache License 2.0 5 votes vote down vote up
private void decode() throws AndrolibException {
    try {
        final BaksmaliOptions options = new BaksmaliOptions();

        // options
        options.deodex = false;
        options.implicitReferences = false;
        options.parameterRegisters = true;
        options.localsDirective = true;
        options.sequentialLabels = true;
        options.debugInfo = mBakDeb;
        options.codeOffsets = false;
        options.accessorComments = false;
        options.registerInfo = 0;
        options.inlineResolver = null;

        // set jobs automatically
        int jobs = Runtime.getRuntime().availableProcessors();
        if (jobs > 6) {
            jobs = 6;
        }

        // create the dex
        DexBackedDexFile dexFile = DexFileFactory.loadDexEntry(mApkFile, mDexFile, true, Opcodes.forApi(mApi));

        if (dexFile.isOdexFile()) {
            throw new AndrolibException("Warning: You are disassembling an odex file without deodexing it.");
        }

        if (dexFile instanceof DexBackedOdexFile) {
            options.inlineResolver =
                    InlineMethodResolver.createInlineMethodResolver(((DexBackedOdexFile)dexFile).getOdexVersion());
        }

        Baksmali.disassembleDexFile(dexFile, mOutDir, jobs, options);
    } catch (IOException ex) {
        throw new AndrolibException(ex);
    }
}
 
Example #3
Source File: ExecuteInlineInstruction.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void deOdex(DexFile parentFile) {
	if (!(parentFile instanceof DexBackedOdexFile))
		throw new RuntimeException("ODEX instruction in non-ODEX file");
	DexBackedOdexFile odexFile = (DexBackedOdexFile) parentFile;
	InlineMethodResolver inlineMethodResolver = InlineMethodResolver.createInlineMethodResolver(
			odexFile.getOdexVersion());
	targetMethod = inlineMethodResolver.resolveExecuteInline(
			new AnalyzedInstruction(instruction, -1, -1));
}
 
Example #4
Source File: ApkToolPlus.java    From ApkToolPlus with Apache License 2.0 4 votes vote down vote up
/**
 * .dex转换为smali
 *
 * @param dexFile       dex/apk文件
 * @param outDir        smali文件输出目录
 * @return  是否转换成功
 */
public static boolean dex2smali(File dexFile, File outDir){

    if (dexFile == null || !dexFile.exists()){
        LogUtils.w( "dex2smali dexFile is null or not exists : " + dexFile.getPath());
        return false;
    }

    // dex文件的处理
    BaksmaliOptions options = new BaksmaliOptions();

    // options
    options.deodex = false;
    options.implicitReferences = false;
    options.parameterRegisters = true;
    options.localsDirective = true;
    options.sequentialLabels = true;
    options.debugInfo = true;
    options.codeOffsets = false;
    options.accessorComments = false;
    options.registerInfo = 0;
    options.inlineResolver = null;

    // set jobs automatically
    int jobs = Runtime.getRuntime().availableProcessors();
    if (jobs > 6) {
        jobs = 6;
    }

    try {
        //brut/androlib/ApkDecoder.mApi default value is 15
        // create the dex
        DexBackedDexFile dexBackedDexFile = DexFileFactory.loadDexFile(dexFile, Opcodes.forApi(15));

        if (dexBackedDexFile.isOdexFile()) {
            LogUtils.w("Warning: You are disassembling an odex file without deodexing it.");
        }

        if (dexBackedDexFile instanceof DexBackedOdexFile) {
            options.inlineResolver =
                    InlineMethodResolver.createInlineMethodResolver(((DexBackedOdexFile)dexBackedDexFile).getOdexVersion());
        }

        Baksmali.disassembleDexFile(dexBackedDexFile, outDir, jobs, options);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}