Search in sources :

Example 6 with ClassFile

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());
        }
    }
}
Also used : Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.Method)

Example 7 with ClassFile

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;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ArrayList(java.util.ArrayList) Method(net.runelite.asm.Method)

Example 8 with ClassFile

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();
        }
    }
}
Also used : ClassFile(net.runelite.asm.ClassFile) FileOutputStream(java.io.FileOutputStream) JarOutputStream(java.util.jar.JarOutputStream) Manifest(java.util.jar.Manifest) JarEntry(java.util.jar.JarEntry)

Example 9 with ClassFile

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")));
}
Also used : ClassFile(net.runelite.asm.ClassFile) InputStream(java.io.InputStream) ClassGroup(net.runelite.asm.ClassGroup) Method(net.runelite.asm.Method) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) Test(org.junit.Test)

Example 10 with ClassFile

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);
}
Also used : ClassFile(net.runelite.asm.ClassFile) InputStream(java.io.InputStream) ClassGroup(net.runelite.asm.ClassGroup) Deobfuscator(net.runelite.deob.Deobfuscator) Test(org.junit.Test)

Aggregations

ClassFile (net.runelite.asm.ClassFile)103 Method (net.runelite.asm.Method)62 Field (net.runelite.asm.Field)39 ClassGroup (net.runelite.asm.ClassGroup)32 Code (net.runelite.asm.attributes.Code)21 Instruction (net.runelite.asm.attributes.code.Instruction)18 Test (org.junit.Test)18 Signature (net.runelite.asm.signature.Signature)17 Type (net.runelite.asm.Type)16 Instructions (net.runelite.asm.attributes.code.Instructions)16 ArrayList (java.util.ArrayList)14 List (java.util.List)13 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 IOException (java.io.IOException)9 InputStream (java.io.InputStream)9 Annotation (net.runelite.asm.attributes.annotation.Annotation)9 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)9 HashMap (java.util.HashMap)8 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)7