protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter != null && e.Parameter is NetworkInterface) { NetworkInterface netInterface = (NetworkInterface)(e.Parameter); var ipv4Properties = netInterface.GetIPProperties().GetIPv4Properties(); FilterCondition filterConditionOut = new FilterCondition { AddressLocation = AddressLocation.Local, FilteringLayer = FilteringLayer.LinkLayer, InterfaceIndex = (uint)ipv4Properties.Index, MatchType = FilterMatchType.Equal, PacketDirection = NetPacketDirection.Out }; var filterConditionIn = new FilterCondition { AddressLocation = AddressLocation.Local, FilteringLayer = FilteringLayer.LinkLayer, InterfaceIndex = (uint)ipv4Properties.Index, MatchType = FilterMatchType.Equal, PacketDirection = NetPacketDirection.In }; _conditions.Add(filterConditionOut); _conditions.Add(filterConditionIn); _filter.StartFilterWatcher(); } }
public MainPage() { this.InitializeComponent(); var nics = NetworkInterface.GetAllNetworkInterfaces(); foreach (var nic in nics) { NetworkInterfaceViewModels.Add(new NetworkInterfaceViewModel { Id = nic.Id, MacAddress = nic.GetPhysicalAddress().ToString(), Name = nic.Name, NetworkInterface = nic }); } var view = ApplicationView.GetForCurrentView(); view.Consolidated += View_Consolidated; _filter = new ShadowFilter(App.RandomAppIdGenerator.Next(), "ShadowDriver Demo"); _filter.StartFilterWatcher(); _filter.FilterReady += Filter_FilterReady; _filter.PacketReceived += Filter_PacketReceived; _dispatcherTimer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 3) }; _dispatcherTimer.Tick += DispatcherTimer_Tick; System.Diagnostics.Debug.WriteLine(string.Format("Filter {0} loaded.", _filter.AppId)); }
public MainWindow() { this.InitializeComponent(); var nics = NetworkInterface.GetAllNetworkInterfaces(); foreach (var nic in nics) { NetworkInterfaceViewModels.Add(new NetworkInterfaceViewModel { Id = nic.Id, MacAddress = nic.GetPhysicalAddress().ToString(), Name = nic.Name, NetworkInterface = nic }); } _filter = new ShadowFilter(App.RandomAppIdGenerator.Next(), "ShadowDriverWPFDemo"); _filter.FilterReady += Filter_FilterReady; _filter.StartFilterWatcher(); _filter.PacketReceived += Filter_PacketReceived; _dispatcherTimer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 3) }; _dispatcherTimer.Tick += DispatcherTimer_Tick; MacAddressBox.ItemsSource = NetworkInterfaceViewModels; LayerBox.ItemsSource = Layers; PacketsView.ItemsSource = NetPacketViewModels; DirectionBox.ItemsSource = Directions; MatchTypeBox.ItemsSource = MatchTypes; LocationBox.ItemsSource = Locations; System.Diagnostics.Debug.WriteLine(string.Format("Filter {0} loaded.", _filter.AppId)); }