Search in sources :

Example 6 with ClassNode

use of org.mapleir.asm.ClassNode in project maple-ir by LLVM-but-worse.

the class SimpleApplicationContext method isLibraryInheritedMethod.

private boolean isLibraryInheritedMethod(MethodNode m) {
    if (Modifier.isStatic(m.node.access) || m.getName().equals("<init>")) {
        return false;
    }
    ClassTree tree = app.getClassTree();
    // TODO: could probably optimise with dfs instead of getAll
    Collection<ClassNode> parents = tree.getAllParents(m.owner);
    for (ClassNode cn : parents) {
        if (app.isLibraryClass(cn.getName())) {
            for (MethodNode cnM : cn.getMethods()) {
                if (!Modifier.isStatic(cnM.node.access) && cnM.getName().equals(m.getName()) && cnM.getDesc().equals(m.getDesc())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ClassNode(org.mapleir.asm.ClassNode) MethodNode(org.mapleir.asm.MethodNode) ClassTree(org.mapleir.app.service.ClassTree)

Example 7 with ClassNode

use of org.mapleir.asm.ClassNode in project maple-ir by LLVM-but-worse.

the class SingleJarDownloader method download.

@Override
public void download() throws IOException {
    URL url = null;
    JarURLConnection connection = (JarURLConnection) (url = new URL(jarInfo.formattedURL())).openConnection();
    JarFile jarFile = connection.getJarFile();
    Enumeration<JarEntry> entries = jarFile.entries();
    contents = new LocateableJarContents<>(url);
    Map<String, ClassNode> map = new HashMap<>();
    while (entries.hasMoreElements()) {
        JarEntry entry = entries.nextElement();
        byte[] bytes = read(jarFile.getInputStream(entry));
        if (entry.getName().endsWith(".class")) {
            C cn = factory.create(bytes, entry.getName());
            if (!map.containsKey(cn.getName())) {
                contents.getClassContents().add(cn);
            } else {
                throw new IllegalStateException("duplicate: " + cn.getName());
            }
        // if(cn.name.equals("org/xmlpull/v1/XmlPullParser")) {
        // System.out.println("SingleJarDownloader.download() " +entry.getName() + " " + bytes.length);
        // }
        } else {
            JarResource resource = new JarResource(entry.getName(), bytes);
            contents.getResourceContents().add(resource);
        }
    }
}
Also used : ClassNode(org.mapleir.asm.ClassNode) HashMap(java.util.HashMap) JarURLConnection(java.net.JarURLConnection) JarResource(org.topdank.byteengineer.commons.data.JarResource) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) URL(java.net.URL)

Example 8 with ClassNode

use of org.mapleir.asm.ClassNode in project maple-ir by LLVM-but-worse.

the class JarClassLoader method findClass.

@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
    name = name.replace(".", "/");
    // try the loaded cache
    if (cache.containsKey(name))
        return cache.get(name);
    // try the node cache
    ClassNode node = fastNodeCache.get(name);
    if (node != null)
        return defineNode(node);
    // Logger.getDefaultLogger().debug(this.getClass().getSimpleName() + " from: " + creator(true));
    Class<?> c = myParent.loadClass(name);
    cache(c, name);
    return c;
}
Also used : ClassNode(org.mapleir.asm.ClassNode)

Example 9 with ClassNode

use of org.mapleir.asm.ClassNode in project maple-ir by LLVM-but-worse.

the class CompleteJarDumper method dump.

/**
 * Dumps the jars contents.
 *
 * @param file File to dump it to.
 */
@Override
public void dump(File file) throws IOException {
    if (file.exists())
        file.delete();
    file.createNewFile();
    JarOutputStream jos = new JarOutputStream(new FileOutputStream(file));
    int classesDumped = 0;
    int resourcesDumped = 0;
    for (ClassNode cn : contents.getClassContents()) {
        classesDumped += dumpClass(jos, cn.getName(), cn);
    }
    for (JarResource res : contents.getResourceContents()) {
        resourcesDumped += dumpResource(jos, res.getName(), res.getData());
    }
    if (!Debug.debugging)
        System.out.println("Dumped " + classesDumped + " classes and " + resourcesDumped + " resources to " + file.getAbsolutePath());
    jos.close();
}
Also used : ClassNode(org.mapleir.asm.ClassNode) JarResource(org.topdank.byteengineer.commons.data.JarResource) FileOutputStream(java.io.FileOutputStream) JarOutputStream(java.util.jar.JarOutputStream)

Example 10 with ClassNode

use of org.mapleir.asm.ClassNode in project maple-ir by LLVM-but-worse.

the class FieldRSADecryptionPass method lookupField0.

private String lookupField0(AnalysisContext cxt, String oldKey, String owner, String name, String desc, boolean isStatic) {
    ClassNode cn = cxt.getApplication().findClassNode(owner);
    if (cn == null) {
        String newKey = key(owner, name, desc);
        fieldLookupCache.put(oldKey, newKey);
        return newKey;
    }
    for (FieldNode fn : cn.getFields()) {
        if (fn.getName().equals(name) && fn.getDesc().equals(desc) && (Modifier.isStatic(fn.node.access) == isStatic)) {
            String newKey = key(cn.getName(), fn.getName(), fn.getDesc());
            fieldLookupCache.put(oldKey, newKey);
            return newKey;
        }
    }
    return lookupField0(cxt, oldKey, cn.node.superName, name, desc, isStatic);
}
Also used : ClassNode(org.mapleir.asm.ClassNode) FieldNode(org.mapleir.asm.FieldNode)

Aggregations

ClassNode (org.mapleir.asm.ClassNode)45 MethodNode (org.mapleir.asm.MethodNode)24 ControlFlowGraph (org.mapleir.ir.cfg.ControlFlowGraph)16 AnalysisContext (org.mapleir.context.AnalysisContext)13 ApplicationClassSource (org.mapleir.app.service.ApplicationClassSource)11 JarInfo (org.topdank.byteengineer.commons.data.JarInfo)11 SingleJarDownloader (org.topdank.byteio.in.SingleJarDownloader)11 IRCache (org.mapleir.context.IRCache)8 ControlFlowGraphBuilder (org.mapleir.ir.cfg.builder.ControlFlowGraphBuilder)8 SimpleApplicationContext (org.mapleir.app.client.SimpleApplicationContext)7 LibraryClassSource (org.mapleir.app.service.LibraryClassSource)7 BasicAnalysisContext (org.mapleir.context.BasicAnalysisContext)7 IPass (org.mapleir.deob.IPass)7 PassGroup (org.mapleir.deob.PassGroup)7 LiveDataFlowAnalysisImpl (org.mapleir.deob.dataflow.LiveDataFlowAnalysisImpl)7 ControlFlowGraphDumper (org.mapleir.ir.codegen.ControlFlowGraphDumper)7 BasicBlock (org.mapleir.ir.cfg.BasicBlock)6 JarOutputStream (java.util.jar.JarOutputStream)5 Expr (org.mapleir.ir.code.Expr)5 Stmt (org.mapleir.ir.code.Stmt)5