Beispiel #1
0
        private void FindNextButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(SearchTextBox.Text) || ByteViewer.ByteProvider == null)
            {
                return;
            }

            if (SearchBytesRadioButton.IsChecked == true && SearchOptionCheckBox.IsChecked == true)
            {
                SignatureSearchResult++;

                SignatureScan scan    = new SignatureScan(SearchTextBox.Text, ByteViewer.ByteProvider, SignatureSearchResult);
                long          address = scan.Address();
                if (address >= 0)
                {
                    ByteViewer.SelectionStart  = address;
                    ByteViewer.SelectionLength = scan.PatternSize;
                }
                else
                {
                    MessageBox.Show("The following specified hexadecimal bytes was not found: \n\n" + SearchTextBox.Text, "Binary Engine", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            try
            {
                const long NO_MATCH          = -1;
                const long OPERATION_ABORTED = -2;

                switch (ByteViewer.Find(ByteViewFindOptions))
                {
                case NO_MATCH:
                    MessageBox.Show("The following specified text or hexadecimal bytes was not found: \n\n" + SearchTextBox.Text, "Binary Engine", MessageBoxButton.OK, MessageBoxImage.Information);
                    break;

                case OPERATION_ABORTED:
                    break;

                default:
                    //success
                    if (!ByteViewer.Focused)
                    {
                        ByteViewer.Focus();
                    }
                    break;
                }
            }
            catch { }
        }
Beispiel #2
0
        private void GoToAddressCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (ByteViewer.ByteProvider == null)
            {
                return;
            }

            Func <char, bool> isxdigit = (c) =>
            {
                return
                    ('0' <= c && c <= '9' ||
                     'a' <= c && c <= 'f' ||
                     'A' <= c && c <= 'F');
            };

            /*
             * MainWindow mainwindow = (Window.GetWindow(this) as MainWindow);
             * mainwindow.TearableTabControl.Visibility = Visibility.Collapsed;
             * await mainwindow.ShowInputAsync("Binary Engine - Go to Address", "Address (Byte Index):");
             * mainwindow.TearableTabControl.Visibility = Visibility.Visible;
             */

            string address = InputWindow.InputBox("Address (Byte Index):", "Binary Engine: Go to Address");

            if (string.IsNullOrEmpty(address))
            {
                return;
            }

            for (int i = 0; i < address.Length; ++i)
            {
                if (!isxdigit(address[i]))
                {
                    return;
                }
            }

            long selectionStart = Convert.ToInt64(address, 16);

            if (selectionStart >= 0 && selectionStart < ByteViewer.ByteProvider.Length)
            {
                ByteViewer.SelectionStart  = selectionStart;
                ByteViewer.SelectionLength = 1;
                ByteViewer.Focus();
            }
        }