//Shared by First & Next scan
        private bool ScanButtonShared(bool IsRescan, UInt64 FirstAddress, UInt64 LastAddress)
        {
            //Object that holds data of variable type and amount we wish to scan for
            object ScanValue;
            object SecondScanValue;

            SelectedScanType = (ScanDataType)ScanDataTypeComboBox.SelectedIndex;

            #region Collect scan data from form and check for errors

            //Check to see if a process has been selected
            if (TargetProcess == null)
            {
                MessageBox.Show("Please select a process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

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

            if (ScanValueTextBox.Enabled == true)
                ScanValue = Conversions.ToUnsigned(ScanValueTextBox.Text, SelectedScanType);
            else
                ScanValue = null;
            // ScanValue = Conversions.ToUnsigned("0", ScanType);

            if (ScanSecondValueTextBox.Visible == true)
                SecondScanValue = Conversions.ToUnsigned(ScanSecondValueTextBox.Text, SelectedScanType);
            else
                SecondScanValue = null;
            //SecondScanValue = Conversions.ToUnsigned("0", ScanType);

            #endregion

            #region Prescan events

            //Figure out what Protect types to scan based on check states
            uint[] Protect = new uint[8];
            int CheckedItems = ProtectionCheckedListBox.CheckedIndices.Count;
            for (int ecx = 0; ecx < CheckedItems; ecx++)
                Protect[ProtectionCheckedListBox.CheckedIndices[ecx]] = 1;
            uint[] Type = new uint[3];
            CheckedItems = TypeCheckedListBox.CheckedIndices.Count;
            for (int ecx = 0; ecx < CheckedItems; ecx++)
                Type[TypeCheckedListBox.CheckedIndices[ecx]] = 1;

            ScanOptimizationData ScanOptimizationData = new ScanOptimizationData(OptimizeScanCB.Checked, (UInt64)OptimizeScanVal.Value, LastDigitsRB.Checked);

            bool CompareToFirstScan = false;
            if (IsRescan && CompareToFirstCB.Checked == true)
                CompareToFirstScan = true;

            //Create new instance of scanner and pass it all necessary info
            Scan = new ScanMemory(TargetProcess, FirstAddress, LastAddress, SelectedScanType,
                Conversions.StringToScanType(ScanCompareTypeComboBox.Items[ScanCompareTypeComboBox.SelectedIndex].ToString()),
                ScanValue, SecondScanValue, Protect, Type, TruncatedRB.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);

            AddressListView.VirtualListSize = 0;
            AddressListView.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
        }
        private Int64 _ScanValue; //Rounded value for singles/doubles for significant digit comparisons

        #endregion Fields

        #region Constructors

        //Constructor
        public ScanMemory(Process Process, UInt64 StartAddress, UInt64 EndAddress, ScanDataType ScanDataType,
            ScanCompareType ScanCompareType, object ScanValue, object SecondScanValue, uint[] Protect,
            uint[] Type, bool Truncated, ScanOptimizationData ScanOptimizationData, string ExecutablePath, bool CompareToFirstScan)
        {
            ProcessMemoryEditor = new ProcessMemoryEditor();
            ProcessMemoryEditor.ReadProcess = Process;

            this.BaseAddress = (IntPtr)StartAddress;
            this.MaxAddress = (IntPtr)EndAddress;
            this.ScanDataType = ScanDataType;
            this.ScanCompareType = ScanCompareType;
            this.Protect = Protect;
            this.Type = Type;
            this.ScanValue = ScanValue;
            this.SecondScanValue = SecondScanValue;
            this.Truncated = Truncated;
            this.ScanOptimizationData = ScanOptimizationData;
            this.ExecutablePath = ExecutablePath;
            this.CompareToFirstScan = CompareToFirstScan;
        }