use of net.runelite.asm.ClassFile in project runelite by runelite.
the class AnnotationCopier method copy.
public void copy() {
for (ClassFile cf1 : group1.getClasses()) {
ClassFile cf2 = group2.findClass(cf1.getName());
assert cf2 != null;
copy(cf1.getAnnotations(), cf2.getAnnotations());
for (Field f : cf1.getFields()) {
Field f2 = cf2.findField(f.getName(), f.getType());
assert f2 != null || f.getAnnotations() == null;
if (f2 == null)
continue;
copy(f.getAnnotations(), f2.getAnnotations());
}
for (Method m : cf1.getMethods()) {
Method m2 = cf2.findMethod(m.getName(), m.getDescriptor());
assert m2 != null || m.getAnnotations() == null;
if (m2 == null)
continue;
copy(m.getAnnotations(), m2.getAnnotations());
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class HandlerFinder method findHandlers.
public PacketHandlers findHandlers() {
// Some of the packet handlers are if (type == 1 || type == 2) func()
// and func() checks the type... so search all functions for packet handlers
List<PacketHandler> handlers = new ArrayList<>();
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
if (method.getCode() == null) {
continue;
}
List<PacketHandler> h = findHandlers(method, packetType);
handlers.addAll(h);
}
}
PacketHandlers packetHandlers = new PacketHandlers(group, packetType, handlers);
removeDuplicates(packetHandlers);
prepareFrame(execution, packetHandlers);
return packetHandlers;
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class JarUtil method saveJar.
public static void saveJar(ClassGroup group, File jarfile) throws IOException {
try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile), new Manifest())) {
for (ClassFile cf : group.getClasses()) {
JarEntry entry = new JarEntry(cf.getName() + ".class");
jout.putNextEntry(entry);
byte[] data = writeClass(group, cf);
jout.write(data);
jout.closeEntry();
}
}
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class ParallelMappingExecutorTest method testTableswitch.
@Test
public void testTableswitch() throws IOException {
InputStream in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
Assert.assertNotNull(in);
ClassGroup group = new ClassGroup();
ClassFile cf = ClassUtil.loadClass(in);
group.addClass(cf);
in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
Assert.assertNotNull(in);
ClassGroup group2 = new ClassGroup();
ClassFile cf2 = ClassUtil.loadClass(in);
group2.addClass(cf2);
Method m1 = cf.findMethod("method");
Method m2 = cf2.findMethod("method");
ParallelExecutorMapping map = MappingExecutorUtil.map(m1, m2);
Assert.assertEquals(cf2.findField("field2"), map.get(cf.findField("field2")));
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class SimpleModArithTest method test.
@Test
public void test() throws IOException {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/deobfuscators/arithmetic/TestClass.class");
Assert.assertNotNull(in);
ClassGroup group = new ClassGroup();
ClassFile cf = ClassUtil.loadClass(in);
group.addClass(cf);
ModArith d1 = new ModArith();
d1.run(group);
d1.runOnce();
Deobfuscator d2 = new MultiplicationDeobfuscator();
d2.run(group);
this.checkConstants(cf);
}
Aggregations