Search in sources :

Example 1 with org.jf.baksmali.baksmaliOptions

use of org.jf.baksmali.baksmaliOptions in project Apktool by iBotPeaches.

the class SmaliDecoder method decode.

private void decode() throws AndrolibException {
    try {
        baksmaliOptions options = new baksmaliOptions();
        // options
        options.deodex = false;
        options.outputDirectory = mOutDir.toString();
        options.noParameterRegisters = false;
        options.useLocalsDirective = true;
        options.useSequentialLabels = true;
        options.outputDebugInfo = mBakDeb;
        options.addCodeOffsets = false;
        options.jobs = -1;
        options.noAccessorComments = false;
        options.registerInfo = 0;
        options.ignoreErrors = false;
        options.inlineResolver = null;
        options.checkPackagePrivateAccess = false;
        // set jobs automatically
        options.jobs = Runtime.getRuntime().availableProcessors();
        if (options.jobs > 6) {
            options.jobs = 6;
        }
        // create the dex
        DexBackedDexFile dexFile = DexFileFactory.loadDexFile(mApkFile, mDexFile, mApi, false);
        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, options);
    } catch (IOException ex) {
        throw new AndrolibException(ex);
    }
}
Also used : org.jf.baksmali.baksmaliOptions(org.jf.baksmali.baksmaliOptions) DexBackedDexFile(org.jf.dexlib2.dexbacked.DexBackedDexFile) AndrolibException(brut.androlib.AndrolibException) DexBackedOdexFile(org.jf.dexlib2.dexbacked.DexBackedOdexFile) IOException(java.io.IOException)

Example 2 with org.jf.baksmali.baksmaliOptions

use of org.jf.baksmali.baksmaliOptions in project dex2jar by pxb1988.

the class SmaliTest method baksmali.

private static String baksmali(DexBackedClassDef def) throws IOException {
    baksmaliOptions opts = new baksmaliOptions();
    opts.outputDebugInfo = false;
    opts.syntheticAccessorResolver = new SyntheticAccessorResolver(Collections.EMPTY_LIST);
    ClassDefinition classDefinition = new ClassDefinition(opts, def);
    StringWriter bufWriter = new StringWriter();
    IndentingWriter writer = new IndentingWriter(bufWriter);
    classDefinition.writeTo((IndentingWriter) writer);
    writer.flush();
    return bufWriter.toString();
}
Also used : org.jf.baksmali.baksmaliOptions(org.jf.baksmali.baksmaliOptions) IndentingWriter(org.jf.util.IndentingWriter) ClassDefinition(org.jf.baksmali.Adaptors.ClassDefinition) SyntheticAccessorResolver(org.jf.dexlib2.util.SyntheticAccessorResolver)

Example 3 with org.jf.baksmali.baksmaliOptions

use of org.jf.baksmali.baksmaliOptions in project atlas by alibaba.

the class SmaliDiffUtils method getBuildOption.

public static BaksmaliOptions getBuildOption(Iterable<? extends ClassDef> collection, int apiLevel) {
    BaksmaliOptions options = new BaksmaliOptions();
    options.deodex = false;
    options.parameterRegisters = false;
    options.localsDirective = true;
    options.sequentialLabels = true;
    options.debugInfo = true;
    options.codeOffsets = false;
    options.accessorComments = false;
    // 128
    options.registerInfo = 0;
    options.inlineResolver = null;
    options.apiLevel = apiLevel;
    if (!options.accessorComments) {
        options.syntheticAccessorResolver = new SyntheticAccessorResolver(Opcodes.getDefault(), collection);
    }
    return options;
}
Also used : BaksmaliOptions(org.jf.baksmali.BaksmaliOptions) SyntheticAccessorResolver(org.jf.dexlib2.util.SyntheticAccessorResolver)

Example 4 with org.jf.baksmali.baksmaliOptions

use of org.jf.baksmali.baksmaliOptions in project atlas by alibaba.

the class SmaliUtils method createBaksmaliOptions.

/**
 * 生成解析成smali代码的选项
 * @return
 */
private static BaksmaliOptions createBaksmaliOptions() {
    BaksmaliOptions options = new BaksmaliOptions();
    options.deodex = false;
    options.parameterRegisters = false;
    options.localsDirective = true;
    options.sequentialLabels = true;
    options.debugInfo = true;
    options.codeOffsets = false;
    options.accessorComments = false;
    // 128
    options.registerInfo = 0;
    options.inlineResolver = null;
    options.apiLevel = DEFAULT_API_LEVEL;
    return options;
}
Also used : BaksmaliOptions(org.jf.baksmali.BaksmaliOptions)

Example 5 with org.jf.baksmali.baksmaliOptions

use of org.jf.baksmali.baksmaliOptions in project atlas by alibaba.

the class SmaliCodeUtils method createBaksmaliOptions.

/**
 * 生成解析成smali代码的选项
 *
 * @return
 */
private static BaksmaliOptions createBaksmaliOptions(ClassDef classDef) {
    BaksmaliOptions options = new BaksmaliOptions();
    options.deodex = false;
    options.parameterRegisters = false;
    options.localsDirective = true;
    options.sequentialLabels = true;
    options.debugInfo = false;
    options.codeOffsets = false;
    options.accessorComments = false;
    // 128
    options.registerInfo = 0;
    options.inlineResolver = null;
    options.apiLevel = DEFAULT_API_LEVEL;
    List<ClassDef> classDefs = Lists.newArrayList();
    classDefs.add(classDef);
    options.syntheticAccessorResolver = new SyntheticAccessorResolver(Opcodes.getDefault(), classDefs);
    return options;
}
Also used : ClassDef(org.jf.dexlib2.iface.ClassDef) BaksmaliOptions(org.jf.baksmali.BaksmaliOptions) SyntheticAccessorResolver(org.jf.dexlib2.util.SyntheticAccessorResolver)

Aggregations

BaksmaliOptions (org.jf.baksmali.BaksmaliOptions)4 SyntheticAccessorResolver (org.jf.dexlib2.util.SyntheticAccessorResolver)3 org.jf.baksmali.baksmaliOptions (org.jf.baksmali.baksmaliOptions)2 ClassDef (org.jf.dexlib2.iface.ClassDef)2 AndrolibException (brut.androlib.AndrolibException)1 IOException (java.io.IOException)1 ClassDefinition (org.jf.baksmali.Adaptors.ClassDefinition)1 DexBackedDexFile (org.jf.dexlib2.dexbacked.DexBackedDexFile)1 DexBackedOdexFile (org.jf.dexlib2.dexbacked.DexBackedOdexFile)1 DexFile (org.jf.dexlib2.iface.DexFile)1 ClassFileNameHandler (org.jf.util.ClassFileNameHandler)1 IndentingWriter (org.jf.util.IndentingWriter)1