Example #1
0
        private void frmMainClosed(object sender, EventArgs e)
        {
            Settings.LogOpened  = LogForm.Visible;
            Settings.ViewAsHex  = tsmiViewAsHex.Checked;
            Settings.AutoScroll = tsmiAutoScroll.Checked;
            Settings.SpliterDistanceTabsAndHex           = splitContainerTabsAndHex.SplitterDistance;
            Settings.SpliterDistanceFilterAndConversions = splitFilterAndConversions.SplitterDistance;

            if (WindowState == FormWindowState.Normal)
            {
                Settings.FormLocation = Location;
                Settings.FormSize     = Size;
                Settings.FormState    = FormWindowState.Normal;
            }
            else
            {
                Settings.FormState = WindowState;
            }

            Settings.CurrentTab = tabControlMain.SelectedIndex;
            Settings.CurrentCaptureFilterTab = tabControlCapturesAndFilters.SelectedIndex;
            if (FilterManager.GetNumberOfFiltersInList() > 0)
            {
                FilterManager.SaveTempFilterList();
            }
        }
Example #2
0
 private void tsmiFilterListAddNew_Click(object sender, EventArgs e)
 {
     if (FilterManager.GetNumberOfFiltersInList() >= 40)
     {
         MessageBox.Show("Cannot create more than 40 filters.");
     }
     else
     {
         new FilterEditorForm();
     }
 }
Example #3
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            var         searches   = new Dictionary <int, byte>();
            var         replaces   = new Dictionary <int, byte>();
            FilterModes filterMode = FilterModes.SearchAndReplaceFromBegin;
            Byte        result;

            for (var i = 0; i < 501; i++)
            {
                if (dataGridViewSearch[i, 0].Value != null && Byte.TryParse(dataGridViewSearch[i, 0].Value.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result))
                {
                    searches.Add(i, result);
                }
            }

            if ((radioButton2.Checked || radioButton3.Checked) && (searches.Count == 0 || !searches.ContainsKey(0)))
            {
                MessageBox.Show(@"The chain to search must start at the offset 0");
                return;
            }

            if (radioButton1.Checked)
            {
                filterMode = FilterModes.SearchAndReplaceFromBegin;
                for (var i = 0; i < 501; i++)
                {
                    if (dataGridViewSearch[i, 1].Value != null && Byte.TryParse(dataGridViewSearch[i, 1].Value.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result))
                    {
                        replaces.Add(i, result);
                    }
                }
            }
            else if (radioButton2.Checked)
            {
                filterMode = FilterModes.SearchOcurrenceReplaceFromBegin;
                for (var i = 0; i < 501; i++)
                {
                    if (dataGridViewReplace[i, 0].Value != null && Byte.TryParse(dataGridViewReplace[i, 0].Value.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result))
                    {
                        replaces.Add(i, result);
                    }
                }
            }
            else if (radioButton3.Checked)
            {
                filterMode = FilterModes.SearchOcurrenceReplaceFromPosition;
                for (var i = 0; i < 501; i++)
                {
                    if (dataGridViewReplace2[i, 0].Value != null && Byte.TryParse(dataGridViewReplace2[i, 0].Value.ToString(), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result))
                    {
                        replaces.Add(i, result);
                    }
                }
            }

            FilterCaptureFuncs functions = BuildFunctionsBitMask();
            FilterActions      actions   = BuildActionsBitMask();
            uint packetLengthMin         = 0;
            uint packetLengthMax         = 0;

            if (chkPackeLength.Checked)
            {
                packetLengthMin = (uint)nudPacketLengthMin.Value;
                packetLengthMax = (uint)nudPacketLengthMax.Value;
            }

            string name = txtFilterName.Text;

            if (name == "" && _filterIndex == -1)
            {
                name = "Filter " + (FilterManager.GetNumberOfFiltersInList() + 1).ToString("D2");
            }

            if (_filterIndex == -1)
            {
                FilterManager.NewFilter(chkActive.Checked, filterMode, functions, actions, name, packetLengthMin, packetLengthMax, (uint)nudNumTimesApply.Value, searches, replaces);
            }
            else
            {
                FilterManager.EditFilter(_filterIndex, chkActive.Checked, filterMode, functions, actions, name, packetLengthMin, packetLengthMax, (uint)nudNumTimesApply.Value, searches, replaces);
            }

            Program.mainForm.LoadFilterItems();
            Program.mainForm.ActionStartStopFiltering(false);
            Close();
        }