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;
}
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);
}
}
}
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;
}
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();
}
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);
}
Aggregations