public static void ReadClientAddonsList(ref Packet packet) { var decompCount = packet.ReadInt32(); packet = packet.Inflate(decompCount); if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_8_9464)) { var count = packet.ReadInt32("Addons Count"); _addonCount = count; for (var i = 0; i < count; i++) { packet.ReadCString("Name", i); packet.ReadBoolean("Enabled", i); packet.ReadInt32("CRC", i); packet.ReadInt32("Unk Int32", i); } packet.ReadTime("Time"); } else { int count = 0; while (packet.GetPosition() != packet.GetLength()) { packet.ReadCString("Name"); packet.ReadBoolean("Enabled"); packet.ReadInt32("CRC"); packet.ReadInt32("Unk Int32"); count++; } _addonCount = count; } }
public static void Parse(Packet packet, bool headerOnly = false, bool isMultiple = false) { ParsedStatus status; var opcode = packet.Opcode; packet.WriteLine("{0}: {1} (0x{2}) Length: {3} Time: {4} Number: {5}{6}", packet.Direction, Opcodes.GetOpcodeName(opcode), opcode.ToString("X4"), packet.GetLength(), packet.Time.ToString("MM/dd/yyyy HH:mm:ss.fff"), packet.Number, isMultiple ? " (part of another packet)" : String.Empty); if (opcode == 0) return; if (headerOnly) status = ParsedStatus.Success; else { Action<Packet> handler; if (Handlers.TryGetValue(opcode, out handler)) { try { handler(packet); if (packet.GetPosition() == packet.GetLength()) status = ParsedStatus.Success; else { var pos = packet.GetPosition(); var len = packet.GetLength(); packet.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.", pos, len, len - pos); if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table packet.AsHex(); status = ParsedStatus.WithErrors; } } catch (Exception ex) { packet.WriteLine(ex.GetType()); packet.WriteLine(ex.Message); packet.WriteLine(ex.StackTrace); status = ParsedStatus.WithErrors; } } else { packet.AsHex(); status = ParsedStatus.NotParsed; } } if (isMultiple == false) { packet.Status = status; var data = status == ParsedStatus.Success ? Opcodes.GetOpcodeName(packet.Opcode) : status.ToString(); packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, data); } }
public static void Parse(Packet packet, bool headerOnly = false) { var opcode = packet.Opcode; packet.Writer.WriteLine("{0}: {1} (0x{2}) Length: {3} Time: {4} Number: {5}", packet.Direction, Opcodes.GetOpcodeName(opcode), opcode.ToString("X4"), packet.GetLength(), packet.Time.ToString("MM/dd/yyyy HH:mm:ss.fff"), packet.Number); if (headerOnly) { lock (Handlers) { Statistics.PacketsSuccessfullyParsed++; } return; } Action<Packet> handler; if (Handlers.TryGetValue(opcode, out handler)) { try { handler(packet); if (packet.GetPosition() == packet.GetLength()) lock (Handlers) { Statistics.PacketsSuccessfullyParsed++; } else { var pos = packet.GetPosition(); var len = packet.GetLength(); packet.Writer.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.", pos, len, len - pos); if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table packet.Writer.WriteLine(packet.AsHex()); lock (Handlers) { Statistics.PacketsParsedWithErrors++; } } } catch (Exception ex) { packet.Writer.WriteLine(ex.GetType()); packet.Writer.WriteLine(ex.Message); packet.Writer.WriteLine(ex.StackTrace); lock (Handlers) { Statistics.PacketsParsedWithErrors++; } } } else { packet.Writer.WriteLine(packet.AsHex()); lock (Handlers) { Statistics.PacketsNotParsed++; } } }