use of jdk.internal.org.objectweb.asm.tree.ClassNode in project OSJR by zeruth.
the class JarInjector method run.
public void run() {
classnodes = new CanvasInjector(classnodes).run();
try {
injectedJar = new File("./export/gamepack_injected.jar");
JarOutputStream jos = new JarOutputStream(new FileOutputStream(injectedJar));
for (ClassNode cn : classnodes.values()) {
ClassWriter cw = new ClassWriter(1);
cn.accept(cw);
JarEntry entry = new JarEntry(cn.name + ".class");
jos.putNextEntry(entry);
jos.write(cw.toByteArray());
jos.closeEntry();
}
jos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
use of jdk.internal.org.objectweb.asm.tree.ClassNode in project OSJR by zeruth.
the class JarLoader method loadJar.
private void loadJar() {
try {
if (Settings.DOWNLOAD_GAMEPACK) {
long start = System.currentTimeMillis();
ReadableByteChannel rbc = Channels.newChannel(new URL(gamepackUrl).openStream());
FileOutputStream fos = new FileOutputStream("gamepack.jar");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
System.out.println("Gamepack download took " + (System.currentTimeMillis() - start) + "ms");
} else {
}
JarFile jar = new JarFile(new File("./export/gamepack.jar"));
Enumeration<JarEntry> en = jar.entries();
while (en.hasMoreElements()) {
JarEntry entry = en.nextElement();
if (entry.getName().endsWith(".class")) {
ClassReader cr = new ClassReader(jar.getInputStream(entry));
ClassNode cn = new ClassNode();
cr.accept(cn, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
classnodes.put(cn.name, cn);
}
}
jar.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations