Exemplo n.º 1
0
        private bool ScanButtonShared(bool IsRescan, UInt64 FirstAddress, UInt64 LastAddress)
        {
            object ScanValue;
            object SecondScanValue;

            SelectedScanType = (ScanDataType)ComboBox_DataType.SelectedIndex;

            #region Collect scan data from form and check for errors
            if (TargetProcess == null)
            {
                MessageBox.Show("Please select a process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (!CheckSyntax.Value(TextBox_ScanValue.Text, (ScanDataType)ComboBox_DataType.SelectedIndex, CheckBox_IsHex.Checked) && TextBox_ScanValue.Enabled == true ||
                !CheckSyntax.Value(ScanSecondValueTextBox.Text, (ScanDataType)ComboBox_DataType.SelectedIndex, CheckBox_IsHex.Checked) && ScanSecondValueTextBox.Visible == true)
            {
                MessageBox.Show("Invalid value format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (TextBox_ScanValue.Enabled == true)
            {
                ScanValue = Conversions.Conversions.ToUnsigned(TextBox_ScanValue.Text, SelectedScanType);
            }
            else
            {
                ScanValue = null;
            }

            if (ScanSecondValueTextBox.Visible == true)
            {
                SecondScanValue = Conversions.Conversions.ToUnsigned(ScanSecondValueTextBox.Text, SelectedScanType);
            }
            else
            {
                SecondScanValue = null;
            }
            #endregion

            #region Prescan events
            uint[] Protect      = new uint[8];
            int    CheckedItems = CheckedListBox_Protection.CheckedIndices.Count;
            for (int ecx = 0; ecx < CheckedItems; ecx++)
            {
                Protect[CheckedListBox_Protection.CheckedIndices[ecx]] = 1;
            }
            uint[] Type = new uint[3];
            CheckedItems = CheckedListBox_Type.CheckedIndices.Count;
            for (int ecx = 0; ecx < CheckedItems; ecx++)
            {
                Type[CheckedListBox_Type.CheckedIndices[ecx]] = 1;
            }

            ScanOptimizationData ScanOptimizationData = new ScanOptimizationData(CheckBox_OptimizeScan.Checked, (UInt64)NUD_OptimizeScan.Value, RadioButton_LastDigits.Checked);

            bool CompareToFirstScan = false;
            if (IsRescan && CheckBox_CompareToFirstCB.Checked == true)
            {
                CompareToFirstScan = true;
            }

            Scan = new ScanMemory(TargetProcess, FirstAddress, LastAddress, SelectedScanType,
                                  Conversions.Conversions.StringToScanType(ComboBox_CompareType.Items[ComboBox_CompareType.SelectedIndex].ToString()),
                                  ScanValue, SecondScanValue, Protect, Type, RadioButton_Truncated.Checked, ScanOptimizationData, ExecutablePath, CompareToFirstScan);

            Scan.ScanProgressChanged += new ScanMemory.ScanProgressedEventHandler(scan_ScanProgressChanged);
            Scan.ScanCompleted       += new ScanMemory.ScanCompletedEventHandler(scan_ScanCompleted);
            Scan.ScanCanceled        += new ScanMemory.ScanCanceledEventHandler(scan_ScanCanceled);

            ListView_Address.VirtualListSize = 0;
            ListView_Address.Items.Clear();

            if (CurrentAddressAccessor != null)
            {
                CurrentAddressAccessor.Dispose();
            }
            if (CurrentScanAddresses != null)
            {
                CurrentScanAddresses.Dispose();
            }

            ProgressBar.Value = 0;
            #endregion

            #region Start scan
            ScanTimeStopwatch = Stopwatch.StartNew();
            try
            {
                Scan.StartScan(IsRescan);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Scan.CancelScan();
                return(false);
            }
            return(true);

            #endregion
        }