/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/04 21:25:01	509
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/04 22:38:40	511
@@ -40,6 +40,7 @@
 using Sojaner.MemoryScanner;
 using System.Collections;
 using RomCheater.Serialization;
+using RomCheater.Core;
 
 namespace RomCheater.Docking
 {
@@ -65,15 +66,21 @@
         public FloatingMemorySearcher(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
 
         //new Action<int, string>(UpdateProgress) to use this as a delegate
-        private void UpdateProgress(int value, string message)
+
+        private void thread_UpdateProgress(object o)
         {
-            //string stacktrace = string.Empty;
-            //if (value == 0 && message == string.Empty)
-            //{
-            //    stacktrace = System.Environment.StackTrace;
-            //}
-            resultsprogress.Value = value;
-            resultsprogress.Message = message;
+            IProgressMessage pm = (o as IProgressMessage);
+            if (pm == null) { return; }
+            resultsprogress.Value = pm.Progress;
+            resultsprogress.Message = pm.Message;           
+        }
+
+        private void UpdateProgress(int progress, string message)
+        {
+            // detach the progress update from execution within the current thread (so it does not block a cpu-intensive or long running sequence)
+            Thread t = new Thread(new ParameterizedThreadStart(thread_UpdateProgress));
+            t.SetApartmentState(ApartmentState.MTA);
+            t.Start(new ProgressMessage(progress, message));
         }
 
         #region IAcceptsProcess<Process> Members
@@ -1056,359 +1063,362 @@
                 Debug.WriteLine(ex.ToString());
             }
         }
-        private void search_provider_OnBytesRead_compare_only(OnBytesReadEventArgs e)
-        {
-            if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-            SearchDataTypes sdt = SearchArgs.DataType;
-            bool unsigned = SearchArgs.IsUnsignedDataType;
-            //int Last_Whole_Percent_Done = 0;
-            uint CurrentIndex = e.CurrentIndex;
-            if (e.UserState != null)
-            {
-                SearchResultWriter writer = (e.UserState as SearchResultWriter);
-                if (writer == null)
-                    throw new InvalidOperationException("writer cannot be null");
-                using (MemoryStream ms = new MemoryStream(e.Data))
-                {
-                    using (BinaryReader br = new BinaryReader(ms))
-                    {
-                        while (br.BaseStream.Position < br.BaseStream.Length)
-                        {
-                            try
-                            {
-                                switch (sdt)
-                                {
-                                    case SearchDataTypes._8bits:
-                                        if (unsigned)
-                                        {
-                                            #region 8bits - unsigned
-                                            var Value = br.ReadByte();
-                                            using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                byte value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToByte(Value), value))
-                                                {
-                                                    writer.WriteResult<byte>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 8bits - signed
-                                            var Value = br.ReadSByte();
-                                            using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                sbyte value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToSByte(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToSByte(Value), value))
-                                                {
-                                                    writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        } break;
-                                    case SearchDataTypes._16bits:
-                                        if (unsigned)
-                                        {
-                                            #region 16bits - unsigned
-                                            var Value = br.ReadUInt16();
-                                            using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                ushort value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToUInt16(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToUInt16(Value), value))
-                                                {
-                                                    writer.WriteResult<ushort>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 16bits - signed
-                                            var Value = br.ReadInt16();
-                                            using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                short value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToInt16(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToSByte(Value), value))
-                                                {
-                                                    writer.WriteResult<short>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        } break;
-                                    case SearchDataTypes._32bits:
-                                        if (unsigned)
-                                        {
-                                            #region 32bits - unsigned
-                                            var Value = br.ReadUInt32();
-                                            using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                uint value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToUInt32(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToUInt32(Value), value))
-                                                {
-                                                    writer.WriteResult<uint>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 32bits - signed
-                                            var Value = br.ReadInt32();
-                                            using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                int value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToInt32(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToInt32(Value), value))
-                                                {
-                                                    writer.WriteResult<int>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        } break;
-                                    case SearchDataTypes._64bits:
-                                        if (unsigned)
-                                        {
-                                            #region 64bits - unsigned
-                                            var Value = br.ReadUInt64();
-                                            using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                ulong value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToUInt64(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToUInt64(Value), value))
-                                                {
-                                                    writer.WriteResult<ulong>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 64bits - signed
-                                            var Value = br.ReadInt64();
-                                            using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, CurrentIndex))
-                                            {
-                                                long value = 0;
-                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                {
-                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                    {
-                                                        try
-                                                        {
-                                                            gmp.OpenProvider();
-                                                            gmp.ReadMemory(CurrentIndex, out value);
-                                                            gmp.CloseProvider();
-                                                        }
-                                                        catch (Exception ex)
-                                                        {
-                                                            logger.VerboseError.WriteLine(ex.ToString());
-                                                        }
-                                                    }
-                                                    comparer.Value = value;
-                                                }
-                                                else
-                                                {
-                                                    value = Convert.ToInt64(SearchArgs.CompareStartValue);
-                                                    comparer.Value = value;
-                                                }
-                                                if (comparer.Compare(Convert.ToInt64(Value), value))
-                                                {
-                                                    writer.WriteResult<long>(comparer.Address, comparer.Value);
-                                                }
-                                            }
-                                            #endregion
-                                        } break;
-                                }
-                                if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-                            }
-                            catch (EndOfStreamException) { }
-                            if (e.ReportProgress)
-                            {
-                                double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
-                                int int_percent_done = (int)double_percent_done;
-                                //if (CurrentIndex % 10 == 0)
-                                //{
-                                //    if (int_percent_done <= 100)
-                                //    {
-                                new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Index: 0x{0:x8} of 0x{1:x8}", CurrentIndex, e.TotalCount));
-                                //    }
-                                //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-                                //}
-                            }
-                            //switch (sdt)
-                            //{
-                            //    case SearchDataTypes._8bits:
-                            //        CurrentIndex += sizeof(byte);
-                            //        break;
-                            //    case SearchDataTypes._16bits:
-                            //        CurrentIndex += sizeof(ushort);
-                            //        break;
-                            //    case SearchDataTypes._32bits:
-                            //        CurrentIndex += sizeof(uint);
-                            //        break;
-                            //    case SearchDataTypes._64bits:
-                            //        CurrentIndex += sizeof(ulong);
-                            //        break;
-                            //}
-                        }
 
-                    }
-                }
-            }
-            if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-        }
+        #region old-code: private void search_provider_OnBytesRead_compare_only(OnBytesReadEventArgs e)
+        //private void search_provider_OnBytesRead_compare_only(OnBytesReadEventArgs e)
+        //{
+        //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+        //    SearchDataTypes sdt = SearchArgs.DataType;
+        //    bool unsigned = SearchArgs.IsUnsignedDataType;
+        //    //int Last_Whole_Percent_Done = 0;
+        //    uint CurrentIndex = e.CurrentIndex;
+        //    if (e.UserState != null)
+        //    {
+        //        SearchResultWriter writer = (e.UserState as SearchResultWriter);
+        //        if (writer == null)
+        //            throw new InvalidOperationException("writer cannot be null");
+        //        using (MemoryStream ms = new MemoryStream(e.Data))
+        //        {
+        //            using (BinaryReader br = new BinaryReader(ms))
+        //            {
+        //                while (br.BaseStream.Position < br.BaseStream.Length)
+        //                {
+        //                    try
+        //                    {
+        //                        switch (sdt)
+        //                        {
+        //                            case SearchDataTypes._8bits:
+        //                                if (unsigned)
+        //                                {
+        //                                    #region 8bits - unsigned
+        //                                    var Value = br.ReadByte();
+        //                                    using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        byte value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToByte(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToByte(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<byte>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                }
+        //                                else
+        //                                {
+        //                                    #region 8bits - signed
+        //                                    var Value = br.ReadSByte();
+        //                                    using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        sbyte value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToSByte(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToSByte(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                } break;
+        //                            case SearchDataTypes._16bits:
+        //                                if (unsigned)
+        //                                {
+        //                                    #region 16bits - unsigned
+        //                                    var Value = br.ReadUInt16();
+        //                                    using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        ushort value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToUInt16(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToUInt16(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<ushort>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                }
+        //                                else
+        //                                {
+        //                                    #region 16bits - signed
+        //                                    var Value = br.ReadInt16();
+        //                                    using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        short value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToInt16(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToSByte(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<short>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                } break;
+        //                            case SearchDataTypes._32bits:
+        //                                if (unsigned)
+        //                                {
+        //                                    #region 32bits - unsigned
+        //                                    var Value = br.ReadUInt32();
+        //                                    using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        uint value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToUInt32(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToUInt32(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<uint>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                }
+        //                                else
+        //                                {
+        //                                    #region 32bits - signed
+        //                                    var Value = br.ReadInt32();
+        //                                    using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        int value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToInt32(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToInt32(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<int>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                } break;
+        //                            case SearchDataTypes._64bits:
+        //                                if (unsigned)
+        //                                {
+        //                                    #region 64bits - unsigned
+        //                                    var Value = br.ReadUInt64();
+        //                                    using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        ulong value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToUInt64(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToUInt64(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<ulong>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                }
+        //                                else
+        //                                {
+        //                                    #region 64bits - signed
+        //                                    var Value = br.ReadInt64();
+        //                                    using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, CurrentIndex))
+        //                                    {
+        //                                        long value = 0;
+        //                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+        //                                        {
+        //                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+        //                                            {
+        //                                                try
+        //                                                {
+        //                                                    gmp.OpenProvider();
+        //                                                    gmp.ReadMemory(CurrentIndex, out value);
+        //                                                    gmp.CloseProvider();
+        //                                                }
+        //                                                catch (Exception ex)
+        //                                                {
+        //                                                    logger.VerboseError.WriteLine(ex.ToString());
+        //                                                }
+        //                                            }
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        else
+        //                                        {
+        //                                            value = Convert.ToInt64(SearchArgs.CompareStartValue);
+        //                                            comparer.Value = value;
+        //                                        }
+        //                                        if (comparer.Compare(Convert.ToInt64(Value), value))
+        //                                        {
+        //                                            writer.WriteResult<long>(comparer.Address, comparer.Value);
+        //                                        }
+        //                                    }
+        //                                    #endregion
+        //                                } break;
+        //                        }
+        //                        if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+        //                    }
+        //                    catch (EndOfStreamException) { }
+        //                    if (e.ReportProgress)
+        //                    {
+        //                        double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
+        //                        int int_percent_done = (int)double_percent_done;
+        //                        //if (CurrentIndex % 10 == 0)
+        //                        //{
+        //                        //    if (int_percent_done <= 100)
+        //                        //    {
+        //                        new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Index: 0x{0:x8} of 0x{1:x8}", CurrentIndex, e.TotalCount));
+        //                        //    }
+        //                        //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+        //                        //}
+        //                    }
+        //                    //switch (sdt)
+        //                    //{
+        //                    //    case SearchDataTypes._8bits:
+        //                    //        CurrentIndex += sizeof(byte);
+        //                    //        break;
+        //                    //    case SearchDataTypes._16bits:
+        //                    //        CurrentIndex += sizeof(ushort);
+        //                    //        break;
+        //                    //    case SearchDataTypes._32bits:
+        //                    //        CurrentIndex += sizeof(uint);
+        //                    //        break;
+        //                    //    case SearchDataTypes._64bits:
+        //                    //        CurrentIndex += sizeof(ulong);
+        //                    //        break;
+        //                    //}
+        //                }
+        //            }
+        //        }
+        //    }
+        //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+        //}
+        #endregion
+
         private void search_provider_OnBytesRead(OnBytesReadEventArgs e)
         {
             if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
@@ -1731,15 +1741,19 @@
                             {
                                 double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
                                 int int_percent_done = (int)double_percent_done;
-                                if (int_percent_done != Last_Whole_Percent_Done && CurrentIndex % 100000 == 0)
-                                {
-                                    if (int_percent_done <= 100)
-                                    {
-                                        new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart)));
-                                        Last_Whole_Percent_Done = int_percent_done;
-                                    }
-                                    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
-                                }
+
+                                //int align_base = 1000;
+                                //int align_magnitude = 1;
+                                //int alignment = align_base * align_magnitude;
+                                //if (int_percent_done != Last_Whole_Percent_Done && (CurrentIndex % alignment) == 0)
+                                //{
+                                //    if (int_percent_done <= 100)
+                                //    {
+                                new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart)));
+                                //        Last_Whole_Percent_Done = int_percent_done;
+                                //    }
+                                //    if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
+                                //}
                             }
                             uint size = 0;
                             BitTools.SizeOf(sdt, out size);

 

  ViewVC Help
Powered by ViewVC 1.1.22