protected void EventHandler(object sender, EtwEvent e) { NetworkEvent ev = new TransportLayerEvent(e); lock (_Sync) { if (_Events.Count > this.MaxEvents) { _Events.RemoveAt(0); } _Events.Add(ev); this.OnNewEvent(ev); } }
private void UpdateDataGridUI(EtwEvent e) { if (lstItems.InvokeRequired) { lstItems.Invoke(new MethodInvoker(delegate() { UpdateDataGridUI(e); })); } else { TimeSpan offset = firstEvent.Value - e.Timestamp; string timeOffset = String.Format("+{0}ms", (Math.Abs(offset.TotalMilliseconds)).ToString("##,#0")); ListViewItem item = new ListViewItem(timeOffset, 0); item.SubItems.Add(e.PID.ToString()); item.SubItems.Add(e.Name); item.SubItems.Add(e.Text); lstItems.Items.Add(item); } }
public EtwEventViewModel(EtwEvent evt, EtwManifest manifest) { Event = evt; _manifest = manifest; }
/// <summary> /// Creates new TransportLayerEvent based on the data returned from "Event Tracing for Windows" native API /// </summary> /// <param name="ev"></param> public TransportLayerEvent(EtwEvent ev) { this._EventGuid = ev.guid; this._Timestamp = ev.timestamp; this._EventType = (TransportLayerEventTypes)ev.type; this._EventVersion = ev.version; if (this._EventType == TransportLayerEventTypes.EVENT_TRACE_TYPE_RECEIVE || this._EventType == TransportLayerEventTypes.RECV_IP6_EVENT) { this._Direction = TrafficDirections.Recv; } else if (this._EventType == TransportLayerEventTypes.EVENT_TRACE_TYPE_SEND || this._EventType == TransportLayerEventTypes.SEND_IP6_EVENT) { this._Direction = TrafficDirections.Send; } if (this._EventGuid.Equals(TcpEventGuid)) { this._Proto = TransportProtocols.TCP; } else if (this._EventGuid.Equals(UdpEventGuid)) { this._Proto = TransportProtocols.UDP; } foreach (EtwEventProperty prop in ev.properties) { try { switch (prop.name) { case "PID": this._PID = Convert.ToInt32(prop.value); break; case "size": this._TotalLen = Convert.ToUInt32(prop.value); break; case "daddr": this._Dst = IPAddress.Parse(prop.value); break; case "saddr": this._Src = IPAddress.Parse(prop.value); break; case "dport": this._DstPort = Convert.ToInt32(prop.value); break; case "sport": this._SrcPort = Convert.ToInt32(prop.value); break; case "seqnum": this._seqnum = Convert.ToInt32(prop.value); break; case "connid": this._connid = prop.value; break; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine( "Error while processing event property: " + prop.name ); System.Diagnostics.Debug.WriteLine(ex.ToString()); } } }