Search in sources :

Example 1 with FallbackModeVisitor

use of jadx.core.dex.visitors.FallbackModeVisitor in project jadx by skylot.

the class Jadx method getPassesList.

public static List<IDexTreeVisitor> getPassesList(IJadxArgs args, File outDir) {
    List<IDexTreeVisitor> passes = new ArrayList<IDexTreeVisitor>();
    if (args.isFallbackMode()) {
        passes.add(new FallbackModeVisitor());
    } else {
        passes.add(new BlockSplitter());
        passes.add(new BlockProcessor());
        passes.add(new BlockExceptionHandler());
        passes.add(new BlockFinallyExtract());
        passes.add(new BlockFinish());
        passes.add(new SSATransform());
        passes.add(new DebugInfoVisitor());
        passes.add(new TypeInference());
        if (args.isRawCFGOutput()) {
            passes.add(DotGraphVisitor.dumpRaw(outDir));
        }
        passes.add(new ConstInlineVisitor());
        passes.add(new FinishTypeInference());
        passes.add(new EliminatePhiNodes());
        passes.add(new ModVisitor());
        passes.add(new CodeShrinker());
        passes.add(new ReSugarCode());
        if (args.isCFGOutput()) {
            passes.add(DotGraphVisitor.dump(outDir));
        }
        passes.add(new RegionMakerVisitor());
        passes.add(new IfRegionVisitor());
        passes.add(new ReturnVisitor());
        passes.add(new CodeShrinker());
        passes.add(new SimplifyVisitor());
        passes.add(new CheckRegions());
        if (args.isCFGOutput()) {
            passes.add(DotGraphVisitor.dumpRegions(outDir));
        }
        passes.add(new MethodInlineVisitor());
        passes.add(new ExtractFieldInit());
        passes.add(new ClassModifier());
        passes.add(new EnumVisitor());
        passes.add(new PrepareForCodeGen());
        passes.add(new LoopRegionVisitor());
        passes.add(new ProcessVariables());
        passes.add(new DependencyCollector());
        passes.add(new RenameVisitor());
    }
    return passes;
}
Also used : RegionMakerVisitor(jadx.core.dex.visitors.regions.RegionMakerVisitor) BlockExceptionHandler(jadx.core.dex.visitors.blocksmaker.BlockExceptionHandler) IfRegionVisitor(jadx.core.dex.visitors.regions.IfRegionVisitor) ClassModifier(jadx.core.dex.visitors.ClassModifier) CodeShrinker(jadx.core.dex.visitors.CodeShrinker) ArrayList(java.util.ArrayList) IDexTreeVisitor(jadx.core.dex.visitors.IDexTreeVisitor) ProcessVariables(jadx.core.dex.visitors.regions.ProcessVariables) TypeInference(jadx.core.dex.visitors.typeinference.TypeInference) FinishTypeInference(jadx.core.dex.visitors.typeinference.FinishTypeInference) ReSugarCode(jadx.core.dex.visitors.ReSugarCode) BlockFinallyExtract(jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract) RenameVisitor(jadx.core.dex.visitors.RenameVisitor) CheckRegions(jadx.core.dex.visitors.regions.CheckRegions) DependencyCollector(jadx.core.dex.visitors.DependencyCollector) SSATransform(jadx.core.dex.visitors.ssa.SSATransform) PrepareForCodeGen(jadx.core.dex.visitors.PrepareForCodeGen) DebugInfoVisitor(jadx.core.dex.visitors.DebugInfoVisitor) ExtractFieldInit(jadx.core.dex.visitors.ExtractFieldInit) EnumVisitor(jadx.core.dex.visitors.EnumVisitor) FallbackModeVisitor(jadx.core.dex.visitors.FallbackModeVisitor) ModVisitor(jadx.core.dex.visitors.ModVisitor) SimplifyVisitor(jadx.core.dex.visitors.SimplifyVisitor) MethodInlineVisitor(jadx.core.dex.visitors.MethodInlineVisitor) EliminatePhiNodes(jadx.core.dex.visitors.ssa.EliminatePhiNodes) LoopRegionVisitor(jadx.core.dex.visitors.regions.LoopRegionVisitor) BlockProcessor(jadx.core.dex.visitors.blocksmaker.BlockProcessor) FinishTypeInference(jadx.core.dex.visitors.typeinference.FinishTypeInference) ConstInlineVisitor(jadx.core.dex.visitors.ConstInlineVisitor) BlockFinish(jadx.core.dex.visitors.blocksmaker.BlockFinish) ReturnVisitor(jadx.core.dex.visitors.regions.ReturnVisitor) BlockSplitter(jadx.core.dex.visitors.blocksmaker.BlockSplitter)

Example 2 with FallbackModeVisitor

use of jadx.core.dex.visitors.FallbackModeVisitor in project jadx by skylot.

the class MethodGen method addFallbackMethodCode.

public void addFallbackMethodCode(CodeWriter code) {
    if (mth.getInstructions() == null) {
        JadxErrorAttr errorAttr = mth.get(AType.JADX_ERROR);
        if (errorAttr == null || errorAttr.getCause() == null || !errorAttr.getCause().getClass().equals(DecodeException.class)) {
            // load original instructions
            try {
                mth.load();
                DepthTraversal.visit(new FallbackModeVisitor(), mth);
            } catch (DecodeException e) {
                LOG.error("Error reload instructions in fallback mode:", e);
                code.startLine("// Can't load method instructions: " + e.getMessage());
                return;
            }
        }
    }
    InsnNode[] insnArr = mth.getInstructions();
    if (insnArr == null) {
        code.startLine("// Can't load method instructions.");
        return;
    }
    if (mth.getThisArg() != null) {
        code.startLine(nameGen.useArg(mth.getThisArg())).add(" = this;");
    }
    addFallbackInsns(code, mth, insnArr, true);
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) FallbackModeVisitor(jadx.core.dex.visitors.FallbackModeVisitor) DecodeException(jadx.core.utils.exceptions.DecodeException) JadxErrorAttr(jadx.core.dex.attributes.nodes.JadxErrorAttr)

Aggregations

FallbackModeVisitor (jadx.core.dex.visitors.FallbackModeVisitor)2 JadxErrorAttr (jadx.core.dex.attributes.nodes.JadxErrorAttr)1 InsnNode (jadx.core.dex.nodes.InsnNode)1 ClassModifier (jadx.core.dex.visitors.ClassModifier)1 CodeShrinker (jadx.core.dex.visitors.CodeShrinker)1 ConstInlineVisitor (jadx.core.dex.visitors.ConstInlineVisitor)1 DebugInfoVisitor (jadx.core.dex.visitors.DebugInfoVisitor)1 DependencyCollector (jadx.core.dex.visitors.DependencyCollector)1 EnumVisitor (jadx.core.dex.visitors.EnumVisitor)1 ExtractFieldInit (jadx.core.dex.visitors.ExtractFieldInit)1 IDexTreeVisitor (jadx.core.dex.visitors.IDexTreeVisitor)1 MethodInlineVisitor (jadx.core.dex.visitors.MethodInlineVisitor)1 ModVisitor (jadx.core.dex.visitors.ModVisitor)1 PrepareForCodeGen (jadx.core.dex.visitors.PrepareForCodeGen)1 ReSugarCode (jadx.core.dex.visitors.ReSugarCode)1 RenameVisitor (jadx.core.dex.visitors.RenameVisitor)1 SimplifyVisitor (jadx.core.dex.visitors.SimplifyVisitor)1 BlockExceptionHandler (jadx.core.dex.visitors.blocksmaker.BlockExceptionHandler)1 BlockFinallyExtract (jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract)1 BlockFinish (jadx.core.dex.visitors.blocksmaker.BlockFinish)1