Search in sources :

Example 1 with Method

use of net.runelite.asm.pool.Method 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 Method

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

the class InvokeVirtual method removeParameter.

@Override
public void removeParameter(int idx) {
    net.runelite.asm.pool.Class clazz = method.getClazz();
    // create new signature
    Signature sig = new Signature(method.getType());
    sig.remove(idx);
    // create new method pool object
    method = new Method(clazz, method.getName(), sig);
}
Also used : Signature(net.runelite.asm.signature.Signature) Method(net.runelite.asm.pool.Method) Class(net.runelite.asm.pool.Class)

Example 3 with Method

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

the class InvokeSpecial method removeParameter.

@Override
public void removeParameter(int idx) {
    net.runelite.asm.pool.Class clazz = method.getClazz();
    // create new signature
    Signature sig = new Signature(method.getType());
    sig.remove(idx);
    // create new method pool object
    method = new Method(clazz, method.getName(), sig);
}
Also used : Signature(net.runelite.asm.signature.Signature) Method(net.runelite.asm.pool.Method)

Example 4 with Method

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

the class PacketWriteDeobfuscator method isEnd.

private boolean isEnd(InstructionContext ctx) {
    // conditions where packet write ends:
    // any invoke that isn't to the packet buffer
    // any variable assignment
    // any field assignment
    // any conditional jump
    // any return
    Instruction i = ctx.getInstruction();
    if (i instanceof InvokeInstruction) {
        InvokeInstruction ii = (InvokeInstruction) i;
        Method method = ii.getMethod();
        if (!method.getClazz().equals(rw.getSecretBuffer().getPoolClass()) && !method.getClazz().equals(rw.getBuffer().getPoolClass())) {
            return true;
        }
    }
    if (i instanceof LVTInstruction) {
        LVTInstruction lvt = (LVTInstruction) i;
        if (lvt.store()) {
            return true;
        }
    }
    if (i instanceof SetFieldInstruction) {
        return true;
    }
    if (i instanceof If || i instanceof If0) {
        return true;
    }
    if (i instanceof ReturnInstruction) {
        return true;
    }
    return false;
}
Also used : InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) ReturnInstruction(net.runelite.asm.attributes.code.instruction.types.ReturnInstruction) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) If0(net.runelite.asm.attributes.code.instructions.If0) Method(net.runelite.asm.pool.Method) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) ReturnInstruction(net.runelite.asm.attributes.code.instruction.types.ReturnInstruction) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) If(net.runelite.asm.attributes.code.instructions.If)

Example 5 with Method

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

the class InvokeInterface method removeParameter.

@Override
public void removeParameter(int idx) {
    net.runelite.asm.pool.Class clazz = method.getClazz();
    // create new signature
    Signature sig = new Signature(method.getType());
    sig.remove(idx);
    // create new method pool object
    method = new Method(clazz, method.getName(), sig);
}
Also used : Signature(net.runelite.asm.signature.Signature) Method(net.runelite.asm.pool.Method)

Aggregations

Method (net.runelite.asm.pool.Method)6 Signature (net.runelite.asm.signature.Signature)5 Type (net.runelite.asm.Type)1 Instruction (net.runelite.asm.attributes.code.Instruction)1 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)1 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)1 ReturnInstruction (net.runelite.asm.attributes.code.instruction.types.ReturnInstruction)1 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)1 If (net.runelite.asm.attributes.code.instructions.If)1 If0 (net.runelite.asm.attributes.code.instructions.If0)1 InvokeVirtual (net.runelite.asm.attributes.code.instructions.InvokeVirtual)1 Class (net.runelite.asm.pool.Class)1