Ejemplo n.º 1
0
        void PopulatePackets()
        {
            viewPacket.Items.Clear();

            foreach (var file in packetFiles)
            {
                PacketItem packItem = new PacketItem(file.FullName);

                if (!packItem.IsValid)
                {
                    continue;
                }

                if (packItem.Direction == "out" && !chkOut.Checked)
                {
                    continue;
                }

                if (packItem.Direction == "in" && !chkIn.Checked)
                {
                    continue;
                }

                viewPacket.Items.Add(packItem);
            }

            viewPacket.Sort();
        }
Ejemplo n.º 2
0
        void Dump( PacketItem packet )
        {
            treePacket.Nodes.Clear();

            using ( FileStream packetStream = File.OpenRead( packet.FileName ) )
            {
                uint realEMsg = PeekUInt32( packetStream );
                EMsg eMsg = MsgUtil.GetMsg( realEMsg );

                var info = new
                {
                    EMsg = eMsg,
                    IsProto = MsgUtil.IsProtoBuf( realEMsg ),
                };
                var header = BuildHeader( realEMsg, packetStream );
                var body = BuildBody( realEMsg, packetStream );
                object payload = null;
                if ( body == null )
                {
                    body = "Unable to find body message!";
                    payload = "Unable to get payload: Body message missing!";
                }
                else
                {
                    payload = BuildPayload( packetStream );
                }

                TreeNode infoNode = new TreeNode( "Info: " );
                TreeNode headerNode = new TreeNode( "Header: " );
                TreeNode bodyNode = new TreeNode( "Body: " );
                TreeNode payloadNode = new TreeNode( "Payload: " );

                DumpType( info, infoNode );
                DumpType( header, headerNode );
                DumpType( body, bodyNode );
                DumpType( payload, payloadNode );

                treePacket.Nodes.Add( infoNode );
                treePacket.Nodes.Add( headerNode );
                treePacket.Nodes.Add( bodyNode );
                treePacket.Nodes.Add( payloadNode );
            }

            treePacket.ExpandAll();
        }
Ejemplo n.º 3
0
        private void viewPacket_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (viewPacket.SelectedItems.Count == 0)
            {
                return;
            }

            var packet = viewPacket.SelectedItems[0] as PacketItem;

            if (packet == lastPacket)
            {
                return;
            }

            lastPacket = packet;

            Dump(packet);
        }
Ejemplo n.º 4
0
        public int Compare(object x, object y)
        {
            PacketItem l = ( PacketItem )x;
            PacketItem r = ( PacketItem )y;

            switch (Column)
            {
            case 0:
                return(this.Order * Comparer <int> .Default.Compare(l.PacketNum, r.PacketNum));

            case 1:
                return(this.Order * StringComparer.OrdinalIgnoreCase.Compare(l.Direction, r.Direction));

            case 2:
                return(this.Order * StringComparer.OrdinalIgnoreCase.Compare(l.Name, r.Name));
            }

            return(0);
        }
Ejemplo n.º 5
0
        void PopulatePackets()
        {
            viewPacket.Items.Clear();

            foreach ( var file in packetFiles )
            {
                PacketItem packItem = new PacketItem( file.FullName );

                if ( !packItem.IsValid )
                    continue;

                if ( packItem.Direction == "out" && !chkOut.Checked )
                    continue;

                if ( packItem.Direction == "in" && !chkIn.Checked )
                    continue;

                viewPacket.Items.Add( packItem );
            }

            viewPacket.Sort();
        }
Ejemplo n.º 6
0
        private void viewPacket_SelectedIndexChanged( object sender, EventArgs e )
        {
            if ( viewPacket.SelectedItems.Count == 0 )
                return;

            var packet = viewPacket.SelectedItems[ 0 ] as PacketItem;

            if ( packet == lastPacket )
                return;

            lastPacket = packet;

            Dump( packet );
        }
Ejemplo n.º 7
0
        void Dump( PacketItem packet )
        {
            treePacket.Nodes.Clear();

            using ( FileStream packetStream = File.OpenRead( packet.FileName ) )
            {
                uint realEMsg = PeekUInt32( packetStream );
                EMsg eMsg = MsgUtil.GetMsg( realEMsg );

                var info = new
                {
                    EMsg = eMsg,
                    IsProto = MsgUtil.IsProtoBuf( realEMsg ),
                };
                var header = BuildHeader( realEMsg, packetStream );
                object body = null;
                
                if ( MsgUtil.IsProtoBuf( realEMsg ) && eMsg == EMsg.ServiceMethod )
                {
                    var protoHdr = (MsgHdrProtoBuf)header;
                    if ( !string.IsNullOrEmpty( protoHdr.Proto.target_job_name ) )
                    {
                        body = BuildServiceMethodBody( protoHdr.Proto.target_job_name,packetStream, x => x.GetParameters().First().ParameterType );
                    }
                }
                if ( body == null )
                {
                    body = BuildBody( realEMsg, packetStream );
                }

                object payload = null;
                if ( body == null )
                {
                    body = "Unable to find body message!";
                    payload = "Unable to get payload: Body message missing!";
                }
                else
                {
                    payload = BuildPayload( packetStream );
                }

                TreeNode infoNode = new TreeNode( "Info: " );
                TreeNode headerNode = new TreeNode( "Header: " );
                TreeNode bodyNode = new TreeNode( "Body: " );
                TreeNode gcBodyNode = new TreeNode( "GC Body: " );
                TreeNode payloadNode = new TreeNode( "Payload: " );
                TreeNode serviceMethodNode = new TreeNode( "Service Method Body: " );

                DumpType( info, infoNode );
                DumpType( header, headerNode );
                DumpType( body, bodyNode );
                if ( body is CMsgGCClient )
                {
                    var gcBody = body as CMsgGCClient;

                    using ( var ms = new MemoryStream( gcBody.payload ) )
                    {
                        var gc = new
                        {
                            emsg = BuildEMsg( gcBody.msgtype ),
                            header = BuildGCHeader( gcBody.msgtype, ms ),
                            body = BuildBody( gcBody.msgtype, ms ),
                        };

                        DumpType( gc, gcBodyNode );
                    }
                }
                else if ( body is CMsgClientServiceMethod )
                {
                    var request = body as CMsgClientServiceMethod;
                    var name = request.method_name;

                    var serviceBody = BuildServiceMethodBody( request.method_name, request.serialized_method, x => x.GetParameters().First().ParameterType );
                    DumpType( serviceBody, serviceMethodNode );
                }
                else if ( body is CMsgClientServiceMethodResponse )
                {
                    var response = body as CMsgClientServiceMethodResponse;
                    var name = response.method_name;

                    var serviceBody = BuildServiceMethodBody( response.method_name, response.serialized_method_response, x => x.ReturnType );
                    DumpType( serviceBody, serviceMethodNode );
                }

                DumpType( payload, payloadNode );

                treePacket.Nodes.Add( infoNode );
                treePacket.Nodes.Add( headerNode );
                treePacket.Nodes.Add( bodyNode );
                treePacket.Nodes.Add( gcBodyNode );
                treePacket.Nodes.Add( payloadNode );
                treePacket.Nodes.Add( serviceMethodNode );
            }

            treePacket.ExpandAll();
        }
Ejemplo n.º 8
0
        void Dump( PacketItem packet )
        {
            treePacket.Nodes.Clear();

            using ( FileStream packetStream = File.OpenRead( packet.FileName ) )
            {
                uint realEMsg = PeekUInt32( packetStream );
                EMsg eMsg = MsgUtil.GetMsg( realEMsg );

                var info = new
                {
                    EMsg = eMsg,
                    IsProto = MsgUtil.IsProtoBuf( realEMsg ),
                };
                var header = BuildHeader( realEMsg, packetStream );
                var body = BuildBody( realEMsg, packetStream );
                object payload = null;
                if ( body == null )
                {
                    body = "Unable to find body message!";
                    payload = "Unable to get payload: Body message missing!";
                }
                else
                {
                    payload = BuildPayload( packetStream );
                }

                TreeNode infoNode = new TreeNode( "Info: " );
                TreeNode headerNode = new TreeNode( "Header: " );
                TreeNode bodyNode = new TreeNode( "Body: " );
                TreeNode gcBodyNode = new TreeNode( "GC Body: " );
                TreeNode payloadNode = new TreeNode( "Payload: " );

                DumpType( info, infoNode );
                DumpType( header, headerNode );
                DumpType( body, bodyNode );
                if ( body is CMsgGCClient )
                {
                    var gcBody = body as CMsgGCClient;

                    using ( var ms = new MemoryStream( gcBody.payload ) )
                    {
                        var gc = new
                        {
                            emsg = BuildEMsg( gcBody.msgtype ),
                            header = BuildGCHeader( gcBody.msgtype, ms ),
                            body = BuildBody( gcBody.msgtype, ms ),
                        };

                        DumpType( gc, gcBodyNode );
                    }
                }
                DumpType( payload, payloadNode );

                treePacket.Nodes.Add( infoNode );
                treePacket.Nodes.Add( headerNode );
                treePacket.Nodes.Add( bodyNode );
                treePacket.Nodes.Add( gcBodyNode );
                treePacket.Nodes.Add( payloadNode );
            }

            treePacket.ExpandAll();
        }
Ejemplo n.º 9
0
        void Dump(PacketItem packet)
        {
            treePacket.Nodes.Clear();

            using (FileStream packetStream = File.OpenRead(packet.FileName))
            {
                uint realEMsg = PeekUInt32(packetStream);
                EMsg eMsg     = MsgUtil.GetMsg(realEMsg);

                var info = new
                {
                    EMsg    = eMsg,
                    IsProto = MsgUtil.IsProtoBuf(realEMsg),
                };
                var    header  = BuildHeader(realEMsg, packetStream);
                var    body    = BuildBody(realEMsg, packetStream);
                object payload = null;
                if (body == null)
                {
                    body    = "Unable to find body message!";
                    payload = "Unable to get payload: Body message missing!";
                }
                else
                {
                    payload = BuildPayload(packetStream);
                }

                TreeNode infoNode    = new TreeNode("Info: ");
                TreeNode headerNode  = new TreeNode("Header: ");
                TreeNode bodyNode    = new TreeNode("Body: ");
                TreeNode gcBodyNode  = new TreeNode("GC Body: ");
                TreeNode payloadNode = new TreeNode("Payload: ");

                DumpType(info, infoNode);
                DumpType(header, headerNode);
                DumpType(body, bodyNode);
                if (body is CMsgGCClient)
                {
                    var gcBody = body as CMsgGCClient;

                    using (var ms = new MemoryStream(gcBody.payload))
                    {
                        var gc = new
                        {
                            emsg   = BuildEMsg(gcBody.msgtype),
                            header = BuildGCHeader(gcBody.msgtype, ms),
                            body   = BuildBody(gcBody.msgtype, ms),
                        };

                        DumpType(gc, gcBodyNode);
                    }
                }
                DumpType(payload, payloadNode);

                treePacket.Nodes.Add(infoNode);
                treePacket.Nodes.Add(headerNode);
                treePacket.Nodes.Add(bodyNode);
                treePacket.Nodes.Add(gcBodyNode);
                treePacket.Nodes.Add(payloadNode);
            }

            treePacket.ExpandAll();
        }
Ejemplo n.º 10
0
        void Dump(PacketItem packet)
        {
            treePacket.Nodes.Clear();

            using (FileStream packetStream = File.OpenRead(packet.FileName))
            {
                uint realEMsg = PeekUInt32(packetStream);
                EMsg eMsg     = MsgUtil.GetMsg(realEMsg);

                var info = new
                {
                    EMsg    = eMsg,
                    IsProto = MsgUtil.IsProtoBuf(realEMsg),
                };
                var    header = BuildHeader(realEMsg, packetStream);
                object body   = null;

                if (MsgUtil.IsProtoBuf(realEMsg) && eMsg == EMsg.ServiceMethod && !string.IsNullOrEmpty(((MsgHdrProtoBuf)header).Proto.target_job_name))
                {
                    body = BuildServiceMethodBody(((MsgHdrProtoBuf)header).Proto.target_job_name, packetStream, x => x.GetParameters().First().ParameterType);
                }
                else if (body == null)
                {
                    body = BuildBody(realEMsg, packetStream);
                }

                object payload = null;
                if (body == null)
                {
                    body    = "Unable to find body message!";
                    payload = "Unable to get payload: Body message missing!";
                }
                else
                {
                    payload = BuildPayload(packetStream);
                }

                TreeNode infoNode          = new TreeNode("Info: ");
                TreeNode headerNode        = new TreeNode("Header: ");
                TreeNode bodyNode          = new TreeNode("Body: ");
                TreeNode gcBodyNode        = new TreeNode("GC Body: ");
                TreeNode payloadNode       = new TreeNode("Payload: ");
                TreeNode serviceMethodNode = new TreeNode("Service Method Body: ");

                DumpType(info, infoNode);
                DumpType(header, headerNode);
                DumpType(body, bodyNode);
                if (body is CMsgGCClient)
                {
                    var gcBody = body as CMsgGCClient;

                    using (var ms = new MemoryStream(gcBody.payload))
                    {
                        var gc = new
                        {
                            emsg   = BuildEMsg(gcBody.msgtype),
                            header = BuildGCHeader(gcBody.msgtype, ms),
                            body   = BuildBody(gcBody.msgtype, ms, gcBody.appid),
                        };

                        DumpType(gc, gcBodyNode);
                    }
                }
                else if (body is CMsgClientServiceMethod)
                {
                    var request = body as CMsgClientServiceMethod;
                    var name    = request.method_name;

                    var serviceBody = BuildServiceMethodBody(request.method_name, request.serialized_method, x => x.GetParameters().First().ParameterType);
                    DumpType(serviceBody, serviceMethodNode);
                }
                else if (body is CMsgClientServiceMethodResponse)
                {
                    var response = body as CMsgClientServiceMethodResponse;
                    var name     = response.method_name;

                    var serviceBody = BuildServiceMethodBody(response.method_name, response.serialized_method_response, x => x.ReturnType);
                    DumpType(serviceBody, serviceMethodNode);
                }

                DumpType(payload, payloadNode);

                treePacket.Nodes.Add(infoNode);
                treePacket.Nodes.Add(headerNode);
                treePacket.Nodes.Add(bodyNode);
                treePacket.Nodes.Add(gcBodyNode);
                treePacket.Nodes.Add(payloadNode);
                treePacket.Nodes.Add(serviceMethodNode);
            }

            treePacket.ExpandAll();
        }