⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 captureoptions.cs

📁 一个抓包工具
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.TxtMinBytesToCopy.Location = new System.Drawing.Point(128, 64);
			this.TxtMinBytesToCopy.Name = "TxtMinBytesToCopy";
			this.TxtMinBytesToCopy.Size = new System.Drawing.Size(128, 20);
			this.TxtMinBytesToCopy.TabIndex = 18;
			this.TxtMinBytesToCopy.Text = "4096";
			// 
			// TxtBufferSize
			// 
			this.TxtBufferSize.Location = new System.Drawing.Point(128, 40);
			this.TxtBufferSize.Name = "TxtBufferSize";
			this.TxtBufferSize.Size = new System.Drawing.Size(128, 20);
			this.TxtBufferSize.TabIndex = 17;
			this.TxtBufferSize.Text = "256000";
			// 
			// label10
			// 
			this.label10.AutoSize = true;
			this.label10.Location = new System.Drawing.Point(8, 120);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(106, 13);
			this.label10.TabIndex = 3;
			this.label10.Text = "Read time out ( ms )";
			// 
			// label9
			// 
			this.label9.AutoSize = true;
			this.label9.Location = new System.Drawing.Point(8, 96);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(90, 13);
			this.label9.TabIndex = 2;
			this.label9.Text = "Number of writes";
			// 
			// label8
			// 
			this.label8.AutoSize = true;
			this.label8.Location = new System.Drawing.Point(8, 72);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(120, 13);
			this.label8.TabIndex = 1;
			this.label8.Text = "Minimum bytes to copy";
			// 
			// label7
			// 
			this.label7.AutoSize = true;
			this.label7.Location = new System.Drawing.Point(8, 48);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(60, 13);
			this.label7.TabIndex = 0;
			this.label7.Text = "Buffer Size";
			// 
			// CaptureOptions
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(730, 509);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.GrpPacket,
																		  this.BtnCancel,
																		  this.BtnOk,
																		  this.GrpBoxNameResolution,
																		  this.GrpBoxCaptureLimits,
																		  this.GrpBoxDisplayOptions,
																		  this.GrpBoxCapture});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "CaptureOptions";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "CaptureOptions - r.ysie.ysse.ysmu.r.bb";
			this.Enter += new System.EventHandler(this.CaptureOptions_Enter);
			this.GrpBoxCapture.ResumeLayout(false);
			this.GrpBoxDisplayOptions.ResumeLayout(false);
			this.GrpBoxCaptureLimits.ResumeLayout(false);
			this.GrpBoxNameResolution.ResumeLayout(false);
			this.GrpPacket.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion


		private void BtnOk_Click(object sender, System.EventArgs e)
		{
			string str = "";
		
			str = TxtEachPacketSize.Text;
			thisCaptureOptions.PacketSize = int.Parse( str );

			thisCaptureOptions.LimitPackets = ChkCaptureLimit.Checked;

			thisCaptureOptions.PromiscuousMode = ChkCaptureMode.Checked;
			thisCaptureOptions.Filter = TxtFilter.Text;
			thisCaptureOptions.AdapterIndex = CmbAdapter.SelectedIndex;

			str = TxtAdapterBufferSize.Text;
			thisCaptureOptions.AdapterBufferSize = int.Parse( str );
			str = TxtBufferSize.Text;
			thisCaptureOptions.BufferSize = int.Parse( str );
			str = TxtMinBytesToCopy.Text;
			thisCaptureOptions.MinBytesToCopy = int.Parse( str );
			str = TxtNumWrites.Text;
			thisCaptureOptions.NumWrites = int.Parse( str );
			str = TxtReadTimeOut.Text;
			thisCaptureOptions.ReadTimeOut = int.Parse( str );

			if( CmbCaptureMode.SelectedIndex == 0 )
				thisCaptureOptions.CaptureMode = (int) Packet32h.PACKET_MODE_CAPT;
			if( CmbCaptureMode.SelectedIndex == 1 )
				thisCaptureOptions.CaptureMode = (int) Packet32h.PACKET_MODE_STAT;
			if( CmbCaptureMode.SelectedIndex == 2 )
				thisCaptureOptions.CaptureMode = (int) Packet32h.PACKET_MODE_DUMP;
			if( CmbCaptureMode.SelectedIndex == 3 )
				thisCaptureOptions.CaptureMode = (int) Packet32h.PACKET_MODE_STAT_DUMP;

			thisCaptureOptions.HardwareFilter = 0;

			if( (( CheckBox )(ChkBoxHardwareFilter.Items[0])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_DIRECTED;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[1])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_MULTICAST;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[2])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_ALL_MULTICAST;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[3])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_BROADCAST;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[4])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_SOURCE_ROUTING;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[5])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_PROMISCUOUS;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[6])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_SMT;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[7])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_ALL_LOCAL;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[8])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_MAC_FRAME;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[9])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_FUNCTIONAL;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[10])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_ALL_FUNCTIONAL;
			if( (( CheckBox )(ChkBoxHardwareFilter.Items[11])).Checked )
				thisCaptureOptions.HardwareFilter |= Packet32h.NDIS_PACKET_TYPE_GROUP;


			thisDisplayOptions.UpdateListInRealTime = ChkDisplayOptionsRealTime.Checked;
			thisDisplayOptions.AutomaticScrollInLiveCapture = ChkDisplayOptionsAutomaticScroll.Checked;

			thisCaptureLimits.LimitToPackets = ChkCaptureLimitsPackets.Checked;
			thisCaptureLimits.LimitToKiloBytes = ChkCaptureLimitsKiloBytes.Checked;
			thisCaptureLimits.LimitToSeconds = ChkCaptureLimitsSeconds.Checked;
			str = TxtCaptureLimitsPackets.Text;
			thisCaptureLimits.PacketSize = int.Parse( str );
			str = TxtCaptureLimitsKiloBytes.Text;
			thisCaptureLimits.KilobyteSize = int.Parse( str );
			str = TxtCaptureLimitsSeconds.Text;
			thisCaptureLimits.SecondSize = int.Parse( str );

			thisNameResolution.EnableMAC = ChkNameResolutionMAC.Checked;
			thisNameResolution.EnableNetwork = ChkNameResolutionNetwork.Checked;
			thisNameResolution.EnableTransport = ChkNameResolutionTransport.Checked;

//			P32.CaptureLimits = thisCaptureLimits;
//			P32.CaptureOptions = thisCaptureOptions;
//			P32.DisplayOptions = thisDisplayOptions;
//			P32.NameResolution = thisNameResolution;

			this.Hide();

		}

		private void BtnCancel_Click(object sender, System.EventArgs e)
		{
			this.Hide();

		}

		private void CaptureOptions_Enter(object sender, System.EventArgs e)
		{
			int i = 0;

//			thisCaptureLimits = P32.CaptureLimits;
//			thisCaptureOptions = P32.CaptureOptions;
//			thisDisplayOptions = P32.DisplayOptions;
//			thisNameResolution = P32.NameResolution;

			CmbAdapter.Items.Clear();
			for( i = 0; i < Adapters.GetLength(0); i ++ )
				CmbAdapter.Items.Add( Adapters[i] );

			TxtEachPacketSize.Text = thisCaptureOptions.PacketSize.ToString();
			ChkCaptureLimit.Checked = thisCaptureOptions.LimitPackets;
			TxtEachPacketSize.Enabled = thisCaptureOptions.LimitPackets;
			ChkCaptureMode.Checked = thisCaptureOptions.PromiscuousMode;
			TxtFilter.Text = thisCaptureOptions.Filter;
			CmbAdapter.SelectedIndex = thisCaptureOptions.AdapterIndex;

			TxtAdapterBufferSize.Text = thisCaptureOptions.AdapterBufferSize.ToString();
			TxtBufferSize.Text = thisCaptureOptions.BufferSize.ToString();
			TxtMinBytesToCopy.Text = thisCaptureOptions.MinBytesToCopy.ToString();
			TxtNumWrites.Text = thisCaptureOptions.NumWrites.ToString();
			TxtReadTimeOut.Text = thisCaptureOptions.ReadTimeOut.ToString();

			if( thisCaptureOptions.CaptureMode == Packet32h.PACKET_MODE_CAPT )
				CmbCaptureMode.SelectedIndex = 0;
			else if( thisCaptureOptions.CaptureMode == Packet32h.PACKET_MODE_STAT )
				CmbCaptureMode.SelectedIndex = 1;
			else if( thisCaptureOptions.CaptureMode == Packet32h.PACKET_MODE_DUMP )
				CmbCaptureMode.SelectedIndex = 2;
			else if( thisCaptureOptions.CaptureMode == Packet32h.PACKET_MODE_STAT_DUMP )
				CmbCaptureMode.SelectedIndex = 3;

			TxtMinBytesToCopy.Text = thisCaptureOptions.MinBytesToCopy.ToString();
			TxtMinBytesToCopy.Text = thisCaptureOptions.MinBytesToCopy.ToString();

			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_DIRECTED ) == Packet32h.NDIS_PACKET_TYPE_DIRECTED )
				(( CheckBox )(ChkBoxHardwareFilter.Items[0])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_MULTICAST ) == Packet32h.NDIS_PACKET_TYPE_MULTICAST )
				(( CheckBox )(ChkBoxHardwareFilter.Items[1])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_ALL_MULTICAST ) == Packet32h.NDIS_PACKET_TYPE_ALL_MULTICAST )
				(( CheckBox )(ChkBoxHardwareFilter.Items[2])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_BROADCAST ) == Packet32h.NDIS_PACKET_TYPE_BROADCAST )
				(( CheckBox )(ChkBoxHardwareFilter.Items[3])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_SOURCE_ROUTING ) == Packet32h.NDIS_PACKET_TYPE_SOURCE_ROUTING )
				(( CheckBox )(ChkBoxHardwareFilter.Items[4])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_PROMISCUOUS ) == Packet32h.NDIS_PACKET_TYPE_PROMISCUOUS )
				(( CheckBox )(ChkBoxHardwareFilter.Items[5])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_SMT ) == Packet32h.NDIS_PACKET_TYPE_SMT )
				(( CheckBox )(ChkBoxHardwareFilter.Items[6])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_ALL_LOCAL ) == Packet32h.NDIS_PACKET_TYPE_ALL_LOCAL )
				(( CheckBox )(ChkBoxHardwareFilter.Items[7])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_MAC_FRAME ) == Packet32h.NDIS_PACKET_TYPE_MAC_FRAME )
				(( CheckBox )(ChkBoxHardwareFilter.Items[8])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_FUNCTIONAL ) == Packet32h.NDIS_PACKET_TYPE_FUNCTIONAL )
				(( CheckBox )(ChkBoxHardwareFilter.Items[9])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_ALL_FUNCTIONAL ) == Packet32h.NDIS_PACKET_TYPE_ALL_FUNCTIONAL )
				(( CheckBox )(ChkBoxHardwareFilter.Items[10])).Checked = true;
			if( ( thisCaptureOptions.HardwareFilter & Packet32h.NDIS_PACKET_TYPE_GROUP ) == Packet32h.NDIS_PACKET_TYPE_GROUP )
				(( CheckBox )(ChkBoxHardwareFilter.Items[11])).Checked = true;

			ChkDisplayOptionsRealTime.Checked = thisDisplayOptions.UpdateListInRealTime;
			ChkDisplayOptionsAutomaticScroll.Checked = thisDisplayOptions.AutomaticScrollInLiveCapture;

			ChkCaptureLimitsPackets.Checked = thisCaptureLimits.LimitToPackets;
			ChkCaptureLimitsKiloBytes.Checked = thisCaptureLimits.LimitToKiloBytes;
			ChkCaptureLimitsSeconds.Checked = thisCaptureLimits.LimitToSeconds;
			TxtCaptureLimitsPackets.Text = thisCaptureLimits.PacketSize.ToString();
			TxtCaptureLimitsKiloBytes.Text = thisCaptureLimits.KilobyteSize.ToString();
			TxtCaptureLimitsSeconds.Text = thisCaptureLimits.SecondSize.ToString();
			TxtCaptureLimitsPackets.Enabled = ChkCaptureLimitsPackets.Checked;
			TxtCaptureLimitsKiloBytes.Enabled = ChkCaptureLimitsKiloBytes.Checked;
			TxtCaptureLimitsSeconds.Enabled = ChkCaptureLimitsSeconds.Checked;

			ChkNameResolutionMAC.Checked = thisNameResolution.EnableMAC;
			ChkNameResolutionNetwork.Checked = thisNameResolution.EnableNetwork;
			ChkNameResolutionTransport.Checked = thisNameResolution.EnableTransport;

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -