public Connection(IConnectionOwnerInfo ownerMod) { rawConnection = ownerMod; IsNew = true; Pid = ownerMod.OwningPid; SourceIP = ownerMod.LocalAddress; SourcePort = ownerMod.LocalPort.ToString(); CreationTime = ownerMod.CreationTime; Protocol = ownerMod.Protocol; TargetIP = ownerMod.RemoteAddress; TargetPort = (ownerMod.RemotePort == -1 ? String.Empty : ownerMod.RemotePort.ToString()); LastSeen = DateTime.Now; //this._state = Enum.GetName(typeof(ConnectionStatus), ownerMod.State); try { // Mainly for non-admin users, could use Process.GetProcessById for admins... var r = ProcessHelper.GetProcessOwnerWMI((int)ownerMod.OwningPid, ref LocalOwnerWMICache); Path = r[1] ?? "Unknown"; //FIXME: Move to resources! FileName = r[0] ?? "Unknown"; //FIXME: Use something else? } catch { FileName = "[Unknown or closed process]"; //FIXME: Move to resources! Path = "Unresolved"; //FIXME: Use something else? } if (ownerMod.OwnerModule is null) { if (Pid == 0) { FileName = "System"; Owner = "System"; Path = "-"; } else { Owner = "Unknown"; Path = Path ?? "Unresolved"; } } else { Owner = ownerMod.OwnerModule.ModuleName; IconPath = ownerMod.OwnerModule.ModulePath; } }
private void AddOrUpdateConnection(IConnectionOwnerInfo b) { var ic = ConnectionsRoutes.Count % LineChart.ColorsDic.Count; var br = new SolidColorBrush(LineChart.ColorsDic[ic]); GeoConnection2 existingRoute = ConnectionsRoutes.SingleOrDefault(l => l.RemoteAddress.Equals(b.RemoteAddress)); if (existingRoute is null) { ConnectionsRoutes.Add(new GeoConnection2(b) { Brush = br }); } }
public Connection(IConnectionOwnerInfo ownerMod) { PID = ownerMod.OwningPid; IsNew = true; this._localPort = ownerMod.LocalPort.ToString(); this.CreationTime = ownerMod.CreationTime; this._localAddress = ownerMod.LocalAddress; this._protocol = ownerMod.Protocol; this._remoteAddress = ownerMod.RemoteAddress; this._remotePort = (ownerMod.RemotePort == -1 ? String.Empty : ownerMod.RemotePort.ToString()); this.LastSeen = DateTime.Now; this._state = Enum.GetName(typeof(ConnectionStatus), ownerMod.State); try { // Mainly for non-admin users, could use Process.GetProcessById for admins... var r = ProcessHelper.GetProcessOwnerWMI((int)ownerMod.OwningPid, ref LocalOwnerWMICache); Path = r[1] ?? "Unknown"; //FIXME: Move to resources! ProcName = r[0] ?? "Unknown"; //FIXME: Use something else? } catch { ProcName = "[Unknown or closed process]"; //FIXME: Move to resources! Path = "Unresolved"; //FIXME: Use something else? } if (ownerMod.OwnerModule is null) { if (PID == 0) { ProcName = "System"; Owner = "System"; Path = "System"; } else { Owner = "Unknown"; Path = Path ?? "Unresolved"; } } else { Owner = ownerMod.OwnerModule.ModuleName; IconPath = ownerMod.OwnerModule.ModulePath; } GroupKey = String.Format("{0} ({1}) - [{2}]", ProcName, Path, PID); }
private void AddOrUpdateConnection(IConnectionOwnerInfo b) { Connection lvi = lstConnections.SingleOrDefault(l => l.PID == b.OwningPid && l.Protocol == b.Protocol && l.LocalPort == b.LocalPort.ToString()); if (lvi != null) { if (DateTime.Now.Subtract(lvi.LastSeen).TotalMilliseconds > ConnectionTimeoutNew) { lvi.IsNew = false; } lvi.UpdateValues(b); } else { lstConnections.Add(new Connection(b)); } }
public GeoConnection2(IConnectionOwnerInfo ownerMod) : base(ownerMod) { }
public MonitoredConnection(IConnectionOwnerInfo row) : base(row) { this.rawConnection = row; EnableStats(); }