protected override void OnUpdate()
        {
            Int32 processedPages = 0;

            // Read memory to get current values
            this.Snapshot.ReadAllMemory();

            Parallel.ForEach(
                this.Snapshot.Cast <Object>(),
                SettingsViewModel.GetInstance().ParallelSettings,
                (Object regionObject) =>
            {
                SnapshotRegion region = regionObject as SnapshotRegion;

                if (!region.CanCompare())
                {
                    return;
                }

                foreach (SnapshotElementRef element in region)
                {
                    if (element.Changed())
                    {
                        ((dynamic)element).ElementLabel++;
                    }
                }

                lock (this.ProgressLock)
                {
                    processedPages++;
                    this.UpdateProgress(processedPages, this.Snapshot.GetRegionCount());
                }
            });

            this.UpdateScanCount?.Invoke();

            base.OnUpdate();
        }
示例#2
0
        protected override void OnUpdate()
        {
            // Read memory to update previous and current values
            this.Snapshot.ReadAllMemory();

            Boolean conditionValid = this.IsInputConditionValid(this.Snapshot.GetTimeSinceLastUpdate());
            Int32   processedPages = 0;

            // Note the duplicated code here is an optimization to minimize comparisons done per iteration
            if (conditionValid)
            {
                Parallel.ForEach(
                    this.Snapshot.Cast <Object>(),
                    SettingsViewModel.GetInstance().ParallelSettings,
                    (regionObject) =>
                {
                    SnapshotRegion region = regionObject as SnapshotRegion;

                    if (!region.CanCompare())
                    {
                        return;
                    }

                    foreach (SnapshotElementRef element in region)
                    {
                        if (element.Changed())
                        {
                            ((dynamic)element).ElementLabel++;
                        }
                    }

                    lock (this.ProgressLock)
                    {
                        processedPages++;
                        this.UpdateProgress(processedPages, this.Snapshot.GetRegionCount());
                    }
                });
            }
            else
            {
                Parallel.ForEach(
                    this.Snapshot.Cast <Object>(),
                    SettingsViewModel.GetInstance().ParallelSettings,
                    (regionObject) =>
                {
                    SnapshotRegion region = regionObject as SnapshotRegion;

                    if (!region.CanCompare())
                    {
                        return;
                    }

                    foreach (SnapshotElementRef element in region)
                    {
                        if (element.Changed())
                        {
                            ((dynamic)element).ElementLabel--;
                        }
                    }

                    lock (this.ProgressLock)
                    {
                        processedPages++;
                        this.UpdateProgress(processedPages, this.Snapshot.GetRegionCount());
                    }
                });
            }

            this.UpdateScanCount?.Invoke();

            base.OnUpdate();
        }
        /// <summary>
        /// Called when the scan updates.
        /// </summary>
        protected override void OnUpdate()
        {
            Int32 processedPages = 0;

            // Read memory to get current values
            Parallel.ForEach(
                this.Snapshot.Cast <Object>(),
                SettingsViewModel.GetInstance().ParallelSettings,
                (regionObject) =>
            {
                SnapshotRegion region = regionObject as SnapshotRegion;
                Boolean readSuccess;

                region.ReadAllRegionMemory(out readSuccess, keepValues: true);

                if (!readSuccess)
                {
                    region.SetAllValidBits(false);
                    return;
                }

                // Ignore region if it requires current & previous values, but we cannot find them
                if (this.ScanConstraintManager.HasRelativeConstraint() && !region.CanCompare())
                {
                    region.SetAllValidBits(false);
                    return;
                }

                foreach (SnapshotElementRef element in region)
                {
                    // Enforce each value constraint on the element
                    foreach (ScanConstraint scanConstraint in this.ScanConstraintManager)
                    {
                        switch (scanConstraint.Constraint)
                        {
                        case ConstraintsEnum.Unchanged:
                            if (!element.Unchanged())
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.Changed:
                            if (!element.Changed())
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.Increased:
                            if (!element.Increased())
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.Decreased:
                            if (!element.Decreased())
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.IncreasedByX:
                            if (!element.IncreasedByValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.DecreasedByX:
                            if (!element.DecreasedByValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.Equal:
                            if (!element.EqualToValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.NotEqual:
                            if (!element.NotEqualToValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.GreaterThan:
                            if (!element.GreaterThanValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.GreaterThanOrEqual:
                            if (!element.GreaterThanOrEqualToValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.LessThan:
                            if (!element.LessThanValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.LessThanOrEqual:
                            if (!element.LessThanOrEqualToValue(scanConstraint.ConstraintValue))
                            {
                                element.SetValid(false);
                            }

                            break;

                        case ConstraintsEnum.NotScientificNotation:
                            if (element.IsScientificNotation())
                            {
                                element.SetValid(false);
                            }

                            break;
                        }
                    }
                    //// End foreach Constraint
                }
                //// End foreach Element

                lock (this.ProgressLock)
                {
                    processedPages++;
                    this.UpdateProgress(processedPages, this.Snapshot.GetRegionCount());
                }
            });
            //// End foreach Region

            base.OnUpdate();
        }