Search in sources :

Example 61 with Method

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

the class BufferFinder method find.

public void find() {
    for (ClassFile cf : group.getClasses()) {
        for (Method m : cf.getMethods()) {
            Code code = m.getCode();
            if (findModPow(code)) {
                buffer = cf;
                // packetBuffer extends this
                packetBuffer = group.getClasses().stream().filter(cl -> cl.getParent() == cf).findAny().get();
                logger.info("Identified buffer {}, packetBuffer {}", buffer, packetBuffer);
            }
        }
    }
}
Also used : ClassFile(net.runelite.asm.ClassFile) Logger(org.slf4j.Logger) Method(net.runelite.asm.Method) Instructions(net.runelite.asm.attributes.code.Instructions) LoggerFactory(org.slf4j.LoggerFactory) Code(net.runelite.asm.attributes.Code) Instruction(net.runelite.asm.attributes.code.Instruction) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) ClassGroup(net.runelite.asm.ClassGroup) ClassFile(net.runelite.asm.ClassFile) Method(net.runelite.asm.Method) Code(net.runelite.asm.attributes.Code)

Example 62 with Method

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

the class RuneliteBufferTransformer method injectPacketFinish.

private void injectPacketFinish(ClassGroup group) {
    PacketFlushFinder pff = new PacketFlushFinder(group);
    pff.find();
    for (InstructionContext queueForWriteCtx : pff.getQueueForWrite()) {
        Instruction before = // socket
        queueForWriteCtx.getPops().get(3).getPushed().getInstruction();
        GetStatic getBuffer;
        try {
            getBuffer = (GetStatic) // buffer
            queueForWriteCtx.getPops().get(2).getPushed().getPops().get(// getstatic
            0).getPushed().getInstruction();
        } catch (ClassCastException ex) {
            continue;
        }
        Instructions instructions = before.getInstructions();
        int idx = instructions.getInstructions().indexOf(before);
        assert idx != -1;
        instructions.addInstruction(idx++, getBuffer.clone());
        net.runelite.asm.pool.Method method = new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class(getBuffer.getField().getType().getInternalName()), RUNELITE_FINISH_PACKET, new Signature("()V"));
        instructions.addInstruction(idx++, new InvokeVirtual(instructions, method));
    }
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) PacketFlushFinder(net.runelite.deob.deobfuscators.transformers.buffer.PacketFlushFinder) Instructions(net.runelite.asm.attributes.code.Instructions) Method(net.runelite.asm.Method) Instruction(net.runelite.asm.attributes.code.Instruction) GetStatic(net.runelite.asm.attributes.code.instructions.GetStatic) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature)

Example 63 with Method

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

the class BufferMethodInjector method inject.

public void inject() throws IOException {
    Field buffer = bp.getBuffer();
    Field offset = bp.getOffset();
    assert buffer.getClassFile() == offset.getClassFile();
    InputStream in = getClass().getResourceAsStream("RuneliteBuffer.class");
    assert in != null : "no RuneliteBuffer";
    ClassFile runeliteBuffer = loadClass(in);
    ClassFile bufferClass = buffer.getClassFile();
    for (Field f : runeliteBuffer.getFields()) {
        if (!f.getName().startsWith("runelite")) {
            continue;
        }
        inject(bufferClass, f);
    }
    for (Method m : runeliteBuffer.getMethods()) {
        if (!m.getName().startsWith("runelite")) {
            continue;
        }
        inject(bufferClass, m);
    }
}
Also used : Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) InputStream(java.io.InputStream) Method(net.runelite.asm.Method)

Example 64 with Method

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

the class ConstantParameter method getCMPFor.

private ConstantMethodParameter getCMPFor(List<Method> methods, int paramIndex, int lvtIndex) {
    ConstantMethodParameter cmp = new ConstantMethodParameter();
    cmp.methods = methods;
    cmp.paramIndex = paramIndex;
    cmp.lvtIndex = lvtIndex;
    ConstantMethodParameter exists = parameters.get(cmp);
    if (exists != null) {
        // due to invokespecial on virtual methods.
        return exists;
    }
    parameters.put(cmp, cmp);
    for (Method m : methods) {
        mparams.put(m, cmp);
    }
    return cmp;
}
Also used : Method(net.runelite.asm.Method)

Example 65 with Method

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

the class ConstantParameter method annotateObfuscatedSignature.

private void annotateObfuscatedSignature(ConstantMethodParameter parameter) {
    for (Method m : parameter.methods) {
        Object value = parameter.values.get(0);
        Annotations annotations = m.getAnnotations();
        Annotation obfuscatedSignature = annotations.find(DeobAnnotations.OBFUSCATED_SIGNATURE);
        if (obfuscatedSignature != null && obfuscatedSignature.getElements().size() == 2) {
            // already annotated
            continue;
        }
        if (obfuscatedSignature == null) {
            obfuscatedSignature = annotations.addAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, "signature", m.getDescriptor().toString());
        }
        // Add garbage value
        Element element = new Element(obfuscatedSignature);
        element.setName("garbageValue");
        element.setValue(value.toString());
        obfuscatedSignature.addElement(element);
    }
}
Also used : Annotations(net.runelite.asm.attributes.Annotations) DeobAnnotations(net.runelite.deob.DeobAnnotations) Element(net.runelite.asm.attributes.annotation.Element) Method(net.runelite.asm.Method) Annotation(net.runelite.asm.attributes.annotation.Annotation)

Aggregations

Method (net.runelite.asm.Method)90 ClassFile (net.runelite.asm.ClassFile)64 Field (net.runelite.asm.Field)34 Instruction (net.runelite.asm.attributes.code.Instruction)29 Code (net.runelite.asm.attributes.Code)28 Instructions (net.runelite.asm.attributes.code.Instructions)28 Signature (net.runelite.asm.signature.Signature)28 ClassGroup (net.runelite.asm.ClassGroup)20 ArrayList (java.util.ArrayList)18 Type (net.runelite.asm.Type)18 List (java.util.List)13 Test (org.junit.Test)13 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 LDC (net.runelite.asm.attributes.code.instructions.LDC)10 DeobAnnotations (net.runelite.deob.DeobAnnotations)9 Annotation (net.runelite.asm.attributes.annotation.Annotation)8 InstructionType (net.runelite.asm.attributes.code.InstructionType)8 Label (net.runelite.asm.attributes.code.Label)8