예제 #1
0
        public bool DumpPackets(string FileName, bool ShowTimeStamps)
        {
            StreamWriter PacketDumpStream;

            try
            {
                PacketDumpStream = new StreamWriter(FileName);
            }
            catch
            {
                return(false);
            }

            string Direction = "";

            foreach (EQApplicationPacket p in Packets.PacketList)
            {
                if (ShowTimeStamps)
                {
                    PacketDumpStream.WriteLine(p.PacketTime.ToString());
                }

                if (p.Direction == PacketDirection.ServerToClient)
                {
                    Direction = "[Server->Client]";
                }
                else
                {
                    Direction = "[Client->Server]";
                }

                OpCode oc = OpManager.GetOpCodeByNumber(p.OpCode);

                string OpCodeName = (oc != null) ? oc.Name : "OP_Unknown";

                PacketDumpStream.WriteLine("[OPCode: 0x" + p.OpCode.ToString("x4") + "] " + OpCodeName + " " + Direction + " [Size: " + p.Buffer.Length + "]");
                PacketDumpStream.WriteLine(Utils.HexDump(p.Buffer));

                if ((oc != null) && (oc.Explorer != null))
                {
                    oc.Explorer(PacketDumpStream, new ByteStream(p.Buffer), p.Direction);
                }
            }

            PacketDumpStream.Close();

            return(true);
        }