Search in sources :

Example 11 with InvokeVirtual

use of net.runelite.asm.attributes.code.instructions.InvokeVirtual in project runelite by runelite.

the class ReflectionTransformer method transformGetInt.

// invokevirtual         java/lang/reflect/Field/getInt(Ljava/lang/Object;)I
private void transformGetInt(Instructions instructions, Instruction i) {
    if (!(i instanceof InvokeVirtual)) {
        return;
    }
    InvokeVirtual iv = (InvokeVirtual) i;
    if (iv.getMethod().getClazz().getName().equals("java/lang/reflect/Field") && iv.getMethod().getName().equals("getInt")) {
        InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "getInt", new Signature("(Ljava/lang/reflect/Field;Ljava/lang/Object;)I")));
        instructions.replace(iv, is);
        logger.info("Transformed Field.getInt call");
    }
}
Also used : InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Example 12 with InvokeVirtual

use of net.runelite.asm.attributes.code.instructions.InvokeVirtual in project runelite by runelite.

the class ReflectionTransformer method transformGetDeclaredField.

// invokevirtual         java/lang/Class/getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
// to
// invokestatic          net/runelite/rs/Reflection/findField
private void transformGetDeclaredField(Instructions instructions, Instruction i) {
    if (!(i instanceof InvokeVirtual)) {
        return;
    }
    InvokeVirtual iv = (InvokeVirtual) i;
    if (iv.getMethod().getClazz().getName().equals("java/lang/Class") && iv.getMethod().getName().equals("getDeclaredField")) {
        InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "findField", new Signature("(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/reflect/Field;")));
        instructions.replace(iv, is);
        logger.info("Transformed Class.getDeclaredField call");
    }
}
Also used : InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Example 13 with InvokeVirtual

use of net.runelite.asm.attributes.code.instructions.InvokeVirtual in project runelite by runelite.

the class ReflectionTransformer method transformSetInt.

// invokevirtual         java/lang/reflect/Field/setInt(Ljava/lang/Object;I)V
private void transformSetInt(Instructions instructions, Instruction i) {
    if (!(i instanceof InvokeVirtual)) {
        return;
    }
    InvokeVirtual iv = (InvokeVirtual) i;
    if (iv.getMethod().getClazz().getName().equals("java/lang/reflect/Field") && iv.getMethod().getName().equals("setInt")) {
        InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "setInt", new Signature("(Ljava/lang/reflect/Field;Ljava/lang/Object;I)V")));
        instructions.replace(iv, is);
        logger.info("Transformed Field.setInt call");
    }
}
Also used : InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Example 14 with InvokeVirtual

use of net.runelite.asm.attributes.code.instructions.InvokeVirtual in project runelite by runelite.

the class ReflectionTransformer method transformGetParameterTypes.

// invokevirtual         java/lang/reflect/Method/getParameterTypes()[Ljava/lang/Class;
// to
// invokestatic          net/runelite/rs/Reflection/getParameterTypes(Ljava/lang/reflect/Method;)[Ljava/lang/Class;
private void transformGetParameterTypes(Instructions instructions, Instruction i) {
    if (!(i instanceof InvokeVirtual)) {
        return;
    }
    InvokeVirtual iv = (InvokeVirtual) i;
    if (iv.getMethod().getClazz().getName().equals("java/lang/reflect/Method") && iv.getMethod().getName().equals("getParameterTypes")) {
        InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "getParameterTypes", new Signature("(Ljava/lang/reflect/Method;)[Ljava/lang/Class;")));
        instructions.replace(iv, is);
        logger.info("Transformed Method.getParameterTypes call");
    }
}
Also used : InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) InvokeStatic(net.runelite.asm.attributes.code.instructions.InvokeStatic)

Example 15 with InvokeVirtual

use of net.runelite.asm.attributes.code.instructions.InvokeVirtual 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)

Aggregations

InvokeVirtual (net.runelite.asm.attributes.code.instructions.InvokeVirtual)17 Signature (net.runelite.asm.signature.Signature)15 InvokeStatic (net.runelite.asm.attributes.code.instructions.InvokeStatic)8 Instruction (net.runelite.asm.attributes.code.Instruction)7 Instructions (net.runelite.asm.attributes.code.Instructions)6 Method (net.runelite.asm.Method)5 Code (net.runelite.asm.attributes.Code)5 LDC (net.runelite.asm.attributes.code.instructions.LDC)4 ALoad (net.runelite.asm.attributes.code.instructions.ALoad)3 GetStatic (net.runelite.asm.attributes.code.instructions.GetStatic)3 Field (net.runelite.asm.Field)2 Type (net.runelite.asm.Type)2 InstructionContext (net.runelite.asm.execution.InstructionContext)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ClassFile (net.runelite.asm.ClassFile)1 ClassGroup (net.runelite.asm.ClassGroup)1 InstructionType (net.runelite.asm.attributes.code.InstructionType)1