Search in sources :

Example 1 with PacketLengthFinder

use of net.runelite.deob.deobfuscators.packethandler.PacketLengthFinder in project runelite by runelite.

the class PacketHandlerOrder method insertPacketLength.

private void insertPacketLength(ClassGroup group, PacketTypeFinder ptf) {
    PacketLengthFinder pfl = new PacketLengthFinder(group, ptf);
    pfl.find();
    GetStatic getArray = pfl.getGetArray();
    // instruction to store packet length
    PutStatic ps = pfl.getStore();
    Instructions instructions = ps.getInstructions();
    List<Instruction> ins = instructions.getInstructions();
    Label getArrayLabel = instructions.createLabelFor(getArray);
    Label storeLabel = instructions.createLabelFor(ps);
    int idx = ins.indexOf(getArray);
    assert idx != -1;
    // to go before label, which must exist
    --idx;
    net.runelite.asm.pool.Field field = new net.runelite.asm.pool.Field(new net.runelite.asm.pool.Class(findClient(group).getName()), RUNELITE_PACKET, Type.BOOLEAN);
    instructions.addInstruction(idx++, new GetStatic(instructions, field));
    instructions.addInstruction(idx++, new IfEq(instructions, getArrayLabel));
    // 2 byte length
    instructions.addInstruction(idx++, new LDC(instructions, -2));
    instructions.addInstruction(idx++, new Goto(instructions, storeLabel));
}
Also used : Goto(net.runelite.asm.attributes.code.instructions.Goto) Label(net.runelite.asm.attributes.code.Label) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) PacketLengthFinder(net.runelite.deob.deobfuscators.packethandler.PacketLengthFinder) IfEq(net.runelite.asm.attributes.code.instructions.IfEq) PutStatic(net.runelite.asm.attributes.code.instructions.PutStatic) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) GetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction) ComparisonInstruction(net.runelite.asm.attributes.code.instruction.types.ComparisonInstruction) PushConstantInstruction(net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) JumpingInstruction(net.runelite.asm.attributes.code.instruction.types.JumpingInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) MappableInstruction(net.runelite.asm.attributes.code.instruction.types.MappableInstruction) Field(net.runelite.asm.Field) GetStatic(net.runelite.asm.attributes.code.instructions.GetStatic)

Aggregations

Field (net.runelite.asm.Field)1 Instruction (net.runelite.asm.attributes.code.Instruction)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 Label (net.runelite.asm.attributes.code.Label)1 ComparisonInstruction (net.runelite.asm.attributes.code.instruction.types.ComparisonInstruction)1 GetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.GetFieldInstruction)1 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)1 JumpingInstruction (net.runelite.asm.attributes.code.instruction.types.JumpingInstruction)1 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)1 MappableInstruction (net.runelite.asm.attributes.code.instruction.types.MappableInstruction)1 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)1 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)1 GetStatic (net.runelite.asm.attributes.code.instructions.GetStatic)1 Goto (net.runelite.asm.attributes.code.instructions.Goto)1 IfEq (net.runelite.asm.attributes.code.instructions.IfEq)1 LDC (net.runelite.asm.attributes.code.instructions.LDC)1 PutStatic (net.runelite.asm.attributes.code.instructions.PutStatic)1 PacketLengthFinder (net.runelite.deob.deobfuscators.packethandler.PacketLengthFinder)1