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));
}
Aggregations