Search in sources :

Example 1 with RootNode

use of jadx.core.dex.nodes.RootNode in project jadx by skylot.

the class JadxClasspathTest method initClsp.

@Before
public void initClsp() throws IOException, DecodeException {
    clsp = new ClspGraph();
    clsp.load();
    dex = mock(DexNode.class);
    RootNode rootNode = mock(RootNode.class);
    when(rootNode.getClsp()).thenReturn(clsp);
    when(dex.root()).thenReturn(rootNode);
}
Also used : RootNode(jadx.core.dex.nodes.RootNode) DexNode(jadx.core.dex.nodes.DexNode) ClspGraph(jadx.core.clsp.ClspGraph) Before(org.junit.Before)

Example 2 with RootNode

use of jadx.core.dex.nodes.RootNode in project jadx by skylot.

the class IntegrationTest method getClassNodeFromFile.

public ClassNode getClassNodeFromFile(File file, String clsName) {
    JadxDecompiler d = new JadxDecompiler(args);
    try {
        d.loadFile(file);
    } catch (JadxException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    RootNode root = JadxInternalAccess.getRoot(d);
    root.getConstValues().getResourcesNames().putAll(resMap);
    ClassNode cls = root.searchClassByName(clsName);
    assertThat("Class not found: " + clsName, cls, notNullValue());
    assertThat(clsName, is(cls.getClassInfo().getFullName()));
    if (unloadCls) {
        decompile(d, cls);
    } else {
        decompileWithoutUnload(d, cls);
    }
    System.out.println("-----------------------------------------------------------");
    System.out.println(cls.getCode());
    System.out.println("-----------------------------------------------------------");
    checkCode(cls);
    compile(cls);
    runAutoCheck(clsName);
    return cls;
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) RootNode(jadx.core.dex.nodes.RootNode) ClassNode(jadx.core.dex.nodes.ClassNode) JadxDecompiler(jadx.api.JadxDecompiler)

Example 3 with RootNode

use of jadx.core.dex.nodes.RootNode in project jadx by skylot.

the class TypeMergeTest method initClsp.

@Before
public void initClsp() throws IOException, DecodeException {
    ClspGraph clsp = new ClspGraph();
    clsp.load();
    dex = mock(DexNode.class);
    RootNode rootNode = mock(RootNode.class);
    when(rootNode.getClsp()).thenReturn(clsp);
    when(dex.root()).thenReturn(rootNode);
}
Also used : RootNode(jadx.core.dex.nodes.RootNode) DexNode(jadx.core.dex.nodes.DexNode) ClspGraph(jadx.core.clsp.ClspGraph) Before(org.junit.Before)

Example 4 with RootNode

use of jadx.core.dex.nodes.RootNode in project jadx by skylot.

the class ConvertToClsSet method main.

public static void main(String[] args) throws IOException, DecodeException {
    if (args.length < 2) {
        usage();
        System.exit(1);
    }
    File output = new File(args[0]);
    List<InputFile> inputFiles = new ArrayList<InputFile>(args.length - 1);
    for (int i = 1; i < args.length; i++) {
        File f = new File(args[i]);
        if (f.isDirectory()) {
            addFilesFromDirectory(f, inputFiles);
        } else {
            InputFile.addFilesFrom(f, inputFiles);
        }
    }
    for (InputFile inputFile : inputFiles) {
        LOG.info("Loaded: {}", inputFile.getFile());
    }
    RootNode root = new RootNode(new JadxArgs());
    root.load(inputFiles);
    ClsSet set = new ClsSet();
    set.load(root);
    set.save(output);
    LOG.info("Output: {}", output);
    LOG.info("done");
}
Also used : RootNode(jadx.core.dex.nodes.RootNode) ArrayList(java.util.ArrayList) JadxArgs(jadx.api.JadxArgs) InputFile(jadx.core.utils.files.InputFile) File(java.io.File) InputFile(jadx.core.utils.files.InputFile)

Example 5 with RootNode

use of jadx.core.dex.nodes.RootNode in project jadx by skylot.

the class JadxDecompiler method parse.

void parse() throws DecodeException {
    reset();
    init();
    root = new RootNode(args);
    LOG.info("loading ...");
    root.load(inputFiles);
    root.initClassPath();
    root.loadResources(getResources());
    root.initAppResClass();
    initVisitors();
}
Also used : RootNode(jadx.core.dex.nodes.RootNode)

Aggregations

RootNode (jadx.core.dex.nodes.RootNode)5 ClspGraph (jadx.core.clsp.ClspGraph)2 DexNode (jadx.core.dex.nodes.DexNode)2 Before (org.junit.Before)2 JadxArgs (jadx.api.JadxArgs)1 JadxDecompiler (jadx.api.JadxDecompiler)1 ClassNode (jadx.core.dex.nodes.ClassNode)1 JadxException (jadx.core.utils.exceptions.JadxException)1 InputFile (jadx.core.utils.files.InputFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1