Search in sources :

Example 1 with InvokeVirtual

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

the class PacketWriteDeobfuscator method translate.

private Instruction translate(Instruction i) {
    if (!(i instanceof InvokeVirtual)) {
        return i;
    }
    InvokeVirtual ii = (InvokeVirtual) i;
    Method invoked = ii.getMethod();
    assert invoked.getType().size() == 1;
    Type argumentType = invoked.getType().getTypeOfArg(0);
    Method invokeMethod;
    if (argumentType.equals(Type.BYTE)) {
        invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteByte", new Signature("(B)V"));
    } else if (argumentType.equals(Type.SHORT)) {
        invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteShort", new Signature("(S)V"));
    } else if (argumentType.equals(Type.INT)) {
        invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteInt", new Signature("(I)V"));
    } else if (argumentType.equals(Type.LONG)) {
        invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteLong", new Signature("(J)V"));
    } else if (argumentType.equals(Type.STRING)) {
        invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteString", new Signature("(Ljava/lang/String;)V"));
    } else {
        throw new IllegalStateException("Unknown type " + argumentType);
    }
    return new InvokeVirtual(i.getInstructions(), invokeMethod);
}
Also used : Type(net.runelite.asm.Type) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) Method(net.runelite.asm.pool.Method)

Example 2 with InvokeVirtual

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

the class ClientErrorTransformer method transform.

private void transform(Method m) {
    if (!m.isStatic() || m.getDescriptor().size() != 2 || !m.getDescriptor().getTypeOfArg(0).equals(Type.STRING) || !m.getDescriptor().getTypeOfArg(1).equals(Type.THROWABLE))
        return;
    Code code = m.getCode();
    Instructions ins = code.getInstructions();
    /*
			Makes it so the old code in this method is logically dead,
			letting the mapper map it but making it so it's never executed.
		 */
    // load throwable
    Instruction aload0 = new ALoad(ins, 1);
    IfNull ifNull = new IfNull(ins, InstructionType.IFNULL);
    ifNull.setTo(ins.createLabelFor(ins.getInstructions().get(0)));
    // load throwable
    Instruction aload1 = new ALoad(ins, 1);
    InvokeVirtual printStackTrace = new InvokeVirtual(ins, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("java/lang/Throwable"), "printStackTrace", new Signature("()V")));
    Instruction ret = new VReturn(ins);
    ins.addInstruction(0, aload0);
    ins.addInstruction(1, ifNull);
    ins.addInstruction(2, aload1);
    ins.addInstruction(3, printStackTrace);
    ins.addInstruction(4, ret);
    done = true;
}
Also used : Instructions(net.runelite.asm.attributes.code.Instructions) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) IfNull(net.runelite.asm.attributes.code.instructions.IfNull) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) ALoad(net.runelite.asm.attributes.code.instructions.ALoad)

Example 3 with InvokeVirtual

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

the class MaxMemoryTransformer method insert.

private void insert(Instructions ins, int idx) {
    Class randomClass = new net.runelite.asm.pool.Class("java/util/Random");
    ins.getInstructions().remove(idx);
    // pop runtime
    ins.getInstructions().add(idx++, new Pop(ins));
    ins.getInstructions().add(idx++, new New(ins, randomClass));
    ins.getInstructions().add(idx++, new Dup(ins));
    // new Random
    ins.getInstructions().add(idx++, new InvokeSpecial(ins, new net.runelite.asm.pool.Method(randomClass, "<init>", new Signature("()V"))));
    ins.getInstructions().add(idx++, new LDC(ins, 31457280));
    // nextInt(31457280)
    ins.getInstructions().add(idx++, new InvokeVirtual(ins, new net.runelite.asm.pool.Method(randomClass, "nextInt", new Signature("(I)I"))));
    ins.getInstructions().add(idx++, new LDC(ins, 230686720));
    // 230686720 + nextInt(31457280)
    ins.getInstructions().add(idx++, new IAdd(ins));
    ins.getInstructions().add(idx++, new I2L(ins));
}
Also used : New(net.runelite.asm.attributes.code.instructions.New) I2L(net.runelite.asm.attributes.code.instructions.I2L) InvokeSpecial(net.runelite.asm.attributes.code.instructions.InvokeSpecial) LDC(net.runelite.asm.attributes.code.instructions.LDC) Method(net.runelite.asm.Method) Pop(net.runelite.asm.attributes.code.instructions.Pop) InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Signature(net.runelite.asm.signature.Signature) Class(net.runelite.asm.pool.Class) IAdd(net.runelite.asm.attributes.code.instructions.IAdd) Dup(net.runelite.asm.attributes.code.instructions.Dup)

Example 4 with InvokeVirtual

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

the class ReflectionTransformer method transformInvokeVirtual.

// invokevirtual         java/lang/reflect/Method/invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
private void transformInvokeVirtual(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("invoke")) {
        InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "invoke", new Signature("(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")));
        instructions.replace(iv, is);
        logger.info("Transformed Method.invoke 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 5 with InvokeVirtual

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

the class BufferFinder method findModPow.

// Find encryptRsa in buffer
private boolean findModPow(Code code) {
    if (code == null) {
        return false;
    }
    Instructions instructions = code.getInstructions();
    for (Instruction i : instructions.getInstructions()) {
        if (!(i instanceof InvokeVirtual)) {
            continue;
        }
        InvokeVirtual iv = (InvokeVirtual) i;
        net.runelite.asm.pool.Method method = iv.getMethod();
        if (method.getName().equals("modPow")) {
            return true;
        }
    }
    return false;
}
Also used : InvokeVirtual(net.runelite.asm.attributes.code.instructions.InvokeVirtual) Instructions(net.runelite.asm.attributes.code.Instructions) Instruction(net.runelite.asm.attributes.code.Instruction)

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