Search in sources :

Example 1 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class ANewArray method lookup.

@Override
public void lookup() {
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    myClass = group.findClass(type.getInternalName());
}
Also used : ClassGroup(net.runelite.asm.ClassGroup)

Example 2 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class MappingExecutorUtil method map.

public static ParallelExecutorMapping map(Method m1, Method m2) {
    ClassGroup group1 = m1.getClassFile().getGroup();
    ClassGroup group2 = m2.getClassFile().getGroup();
    Execution e = new Execution(group1);
    e.step = true;
    Frame frame = new Frame(e, m1);
    frame.initialize();
    e.frames.add(frame);
    Execution e2 = new Execution(group2);
    e2.step = true;
    Frame frame2 = new Frame(e2, m2);
    frame2.initialize();
    e2.frames.add(frame2);
    frame.other = frame2;
    frame2.other = frame;
    ParallellMappingExecutor parallel = new ParallellMappingExecutor(e, e2);
    ParallelExecutorMapping mappings = new ParallelExecutorMapping(m1.getClassFile().getGroup(), m2.getClassFile().getGroup());
    mappings.m1 = m1;
    mappings.m2 = m2;
    parallel.mappings = mappings;
    int same = 0;
    while (parallel.step()) {
        // get what each frame is paused/exited on
        InstructionContext p1 = parallel.getP1(), p2 = parallel.getP2();
        assert p1.getInstruction() instanceof MappableInstruction;
        assert p2.getInstruction() instanceof MappableInstruction;
        MappableInstruction mi1 = (MappableInstruction) p1.getInstruction(), mi2 = (MappableInstruction) p2.getInstruction();
        boolean isSame = mi1.isSame(p1, p2);
        assert isSame == mi2.isSame(p2, p1) : "isSame fail " + p1.getInstruction() + " <> " + p2.getInstruction();
        if (!isSame) {
            mappings.crashed = true;
            p1.getFrame().stop();
            p2.getFrame().stop();
            continue;
        }
        ++same;
        mi1.map(mappings, p1, p2);
    }
    mappings.same = same;
    return mappings;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Frame(net.runelite.asm.execution.Frame) MappableInstruction(net.runelite.asm.attributes.code.instruction.types.MappableInstruction) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) ParallellMappingExecutor(net.runelite.asm.execution.ParallellMappingExecutor)

Example 3 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class MappingExecutorUtil method isInlineable.

public static boolean isInlineable(Instruction i) {
    if (!(i instanceof InvokeStatic))
        return false;
    ClassGroup group = i.getInstructions().getCode().getMethod().getClassFile().getGroup();
    InvokeStatic is = (InvokeStatic) i;
    net.runelite.asm.pool.Method m = is.getMethod();
    return group.findClass(m.getClazz().getName()) != null;
}
Also used : ClassGroup(net.runelite.asm.ClassGroup) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Example 4 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class JarUtil method loadJar.

public static ClassGroup loadJar(File jarfile) throws IOException {
    ClassGroup group = new ClassGroup();
    try (JarFile jar = new JarFile(jarfile)) {
        for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements(); ) {
            JarEntry entry = it.nextElement();
            if (!entry.getName().endsWith(".class")) {
                continue;
            }
            InputStream is = jar.getInputStream(entry);
            ClassReader reader = new ClassReader(is);
            ClassFileVisitor cv = new ClassFileVisitor();
            reader.accept(cv, ClassReader.SKIP_FRAMES);
            group.addClass(cv.getClassFile());
        }
    }
    group.initialize();
    return group;
}
Also used : ClassFileVisitor(net.runelite.asm.visitors.ClassFileVisitor) ClassGroup(net.runelite.asm.ClassGroup) InputStream(java.io.InputStream) ClassReader(org.objectweb.asm.ClassReader) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry)

Example 5 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class ExecutionTest method test.

@Test
public void test() throws Exception {
    ClassGroup group1 = JarUtil.loadJar(new File(properties.getVanillaClient()));
    Execution e = new Execution(group1);
    e.populateInitialMethods();
    e.run();
}
Also used : ClassGroup(net.runelite.asm.ClassGroup) File(java.io.File) Test(org.junit.Test)

Aggregations

ClassGroup (net.runelite.asm.ClassGroup)66 Test (org.junit.Test)41 Code (net.runelite.asm.attributes.Code)29 ClassFile (net.runelite.asm.ClassFile)28 Instruction (net.runelite.asm.attributes.code.Instruction)28 Instructions (net.runelite.asm.attributes.code.Instructions)28 LDC (net.runelite.asm.attributes.code.instructions.LDC)28 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)26 IStore (net.runelite.asm.attributes.code.instructions.IStore)23 Deobfuscator (net.runelite.deob.Deobfuscator)22 ILoad (net.runelite.asm.attributes.code.instructions.ILoad)21 Execution (net.runelite.asm.execution.Execution)21 IMul (net.runelite.asm.attributes.code.instructions.IMul)18 Method (net.runelite.asm.Method)12 IAdd (net.runelite.asm.attributes.code.instructions.IAdd)11 Pop (net.runelite.asm.attributes.code.instructions.Pop)11 File (java.io.File)9 Label (net.runelite.asm.attributes.code.Label)9 Type (net.runelite.asm.Type)8 Signature (net.runelite.asm.signature.Signature)8