/[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/03 01:45:40	456
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/03 02:10:27	457
@@ -58,7 +58,7 @@
 #endif
 
         const bool USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE = false;
-
+        const bool USE_NONRANGE_SEARCH_RESULT_READER = false;
         private bool DefaultUnsignedState = true; // set unsigned to true
         public FloatingMemorySearcher() { InitializeComponent(); this.AcceptedPlugin = null; OnBrowseMemoryRegion = null; this.AcceptedProcess = null; SearchInProgess = false; Reload(); }
         public FloatingMemorySearcher(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
@@ -1432,8 +1432,18 @@
                     provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
                     provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), writer);
                     provider.CloseProvider();
-                    if (SearchWorkerThread.CancellationPending) { provider_st.Stop(); st.Stop(); writer.CancelRequest(); writer.Dispose(); e.Result = true; return; }
+                    if (SearchWorkerThread.CancellationPending)
+                    {
+                        provider_st.Stop(); 
+                        st.Stop();
+                        writer.CancelRequest();
+                        writer.Dispose();
+                        writer = null;
+                        e.Result = true;
+                        return;
+                    }
                     writer.Dispose();
+                    writer = null;
                 }
                 provider_st.Stop();
                 logger.Profiler.WriteLine("It took a total of {0} seconds for the memory provider to complete it's operation(s).", provider_st.Elapsed.TotalSeconds);
@@ -1460,439 +1470,442 @@
                     if (SearchArgs.CompareType != SearchCompareTypes.Between && SearchArgs.CompareType != SearchCompareTypes.NotBetween)
                     {
                         #region Non-Range Searches
-                        st_nonrange_search.Start();
-                        //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
-                        ////second_tmp_Results.c
-                        try
+                        if (USE_NONRANGE_SEARCH_RESULT_READER)
                         {
-                            using (SearchResultReader reader = new SearchResultReader(SearchGuid))
+                            st_nonrange_search.Start();
+                            //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
+                            ////second_tmp_Results.c
+                            try
                             {
-                                try
+                                using (SearchResultReader reader = new SearchResultReader(SearchGuid))
                                 {
+                                    try
+                                    {
 
-                                    #region new comparator-support
-                                    second_tmp_Results = reader.GetResults(SearchArgs, (IAcceptsProcessAndConfig)this, resultsprogress);
-                                    #endregion
+                                        #region new comparator-support
+                                        second_tmp_Results = new List<ResultType<object>>(reader.GetResults(SearchArgs, (IAcceptsProcessAndConfig)this, resultsprogress));
+                                        #endregion
 
-                                    #region USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE
-                                    if (USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE)
-                                    {
-                                        for (int i = 0; i < reader.ResultCount; i += 1)
+                                        #region USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE
+                                        if (USE_OLD_SEARCH_RESULTS_COMPRATOR_CODE)
                                         {
-                                            object result_value = 0;
-                                            uint address = 0;
-                                            #region switch (SearchArgs.DataType)
-                                            switch (SearchArgs.DataType)
+                                            for (int i = 0; i < reader.ResultCount; i += 1)
                                             {
-                                                case SearchDataTypes._8bits: if (unsigned)
-                                                    {
-                                                        using (ResultType<byte> result = reader.GetNextResult<byte>())
+                                                object result_value = 0;
+                                                uint address = 0;
+                                                #region switch (SearchArgs.DataType)
+                                                switch (SearchArgs.DataType)
+                                                {
+                                                    case SearchDataTypes._8bits: if (unsigned)
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
+                                                            using (ResultType<byte> result = reader.GetNextResult<byte>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        using (ResultType<sbyte> result = reader.GetNextResult<sbyte>())
+                                                        else
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
-                                                        }
-                                                    } break;
-                                                case SearchDataTypes._16bits: if (unsigned)
-                                                    {
-                                                        using (ResultType<ushort> result = reader.GetNextResult<ushort>())
+                                                            using (ResultType<sbyte> result = reader.GetNextResult<sbyte>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
+                                                        } break;
+                                                    case SearchDataTypes._16bits: if (unsigned)
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
+                                                            using (ResultType<ushort> result = reader.GetNextResult<ushort>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        using (ResultType<short> result = reader.GetNextResult<short>())
+                                                        else
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
-                                                        }
-                                                    } break;
-                                                case SearchDataTypes._32bits: if (unsigned)
-                                                    {
-                                                        using (ResultType<uint> result = reader.GetNextResult<uint>())
+                                                            using (ResultType<short> result = reader.GetNextResult<short>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
+                                                        } break;
+                                                    case SearchDataTypes._32bits: if (unsigned)
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
+                                                            using (ResultType<uint> result = reader.GetNextResult<uint>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        using (ResultType<int> result = reader.GetNextResult<int>())
+                                                        else
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
-                                                        }
-                                                    } break;
-                                                case SearchDataTypes._64bits: if (unsigned)
-                                                    {
-                                                        using (ResultType<ulong> result = reader.GetNextResult<ulong>())
+                                                            using (ResultType<int> result = reader.GetNextResult<int>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
+                                                        } break;
+                                                    case SearchDataTypes._64bits: if (unsigned)
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
+                                                            using (ResultType<ulong> result = reader.GetNextResult<ulong>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        using (ResultType<long> result = reader.GetNextResult<long>())
+                                                        else
                                                         {
-                                                            address = result.Address;
-                                                            result_value = result.Value;
-                                                        }
-                                                    } break;
-                                            }
-                                            #endregion
-                                            if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
-                                            try
-                                            {
-                                                //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
-                                            }
-                                            catch (Exception)
-                                            {
-                                                throw;
-                                            }
-                                            switch (SearchArgs.DataType)
-                                            {
-                                                #region Comparer Support
-                                                #region case SearchDataTypes._8bits:
-                                                case SearchDataTypes._8bits:
-                                                    if (SearchArgs.IsUnsignedDataType)
-                                                    {
-                                                        byte lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToByte(result_value);
-                                                        using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address))
+                                                            using (ResultType<long> result = reader.GetNextResult<long>())
+                                                            {
+                                                                address = result.Address;
+                                                                result_value = result.Value;
+                                                            }
+                                                        } break;
+                                                }
+                                                #endregion
+                                                if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
+                                                try
+                                                {
+                                                    //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
+                                                }
+                                                catch (Exception)
+                                                {
+                                                    throw;
+                                                }
+                                                switch (SearchArgs.DataType)
+                                                {
+                                                    #region Comparer Support
+                                                    #region case SearchDataTypes._8bits:
+                                                    case SearchDataTypes._8bits:
+                                                        if (SearchArgs.IsUnsignedDataType)
                                                         {
-                                                            byte value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                            byte lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToByte(result_value);
+                                                            using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                byte value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
-                                                                    {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, 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(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                                                comparer.Value = value;
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        sbyte lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToSByte(result_value);
-                                                        using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address))
+                                                        else
                                                         {
-                                                            sbyte value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                            sbyte lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToSByte(result_value);
+                                                            using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                sbyte value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
-                                                                    {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, out value);
+                                                                            gmp.CloseProvider();
+                                                                        }
+                                                                        catch (Exception ex)
+                                                                        {
+                                                                            logger.VerboseError.WriteLine(ex.ToString());
+                                                                        }
                                                                     }
+                                                                    comparer.Value = value;
+                                                                }
+                                                                else
+                                                                {
+                                                                    value = Convert.ToSByte(SearchArgs.CompareStartValue);
+                                                                }
+                                                                if (comparer.Compare(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToSByte(SearchArgs.CompareStartValue);
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    break;
-                                                #endregion
-                                                #region case SearchDataTypes._16bits:
-                                                case SearchDataTypes._16bits:
-                                                    if (SearchArgs.IsUnsignedDataType)
-                                                    {
-                                                        ushort lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToUInt16(result_value);
-                                                        using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address))
-                                                        {
-                                                            ushort value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        break;
+                                                    #endregion
+                                                    #region case SearchDataTypes._16bits:
+                                                    case SearchDataTypes._16bits:
+                                                        if (SearchArgs.IsUnsignedDataType)
+                                                        {
+                                                            ushort lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToUInt16(result_value);
+                                                            using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                ushort value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
-                                                                    {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, 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(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToUInt16(SearchArgs.CompareStartValue);
-                                                                comparer.Value = value;
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        short lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToInt16(result_value);
-                                                        using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address))
+                                                        else
                                                         {
-                                                            short value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                            short lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToInt16(result_value);
+                                                            using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                short value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
-                                                                    {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, out value);
+                                                                            gmp.CloseProvider();
+                                                                        }
+                                                                        catch (Exception ex)
+                                                                        {
+                                                                            logger.VerboseError.WriteLine(ex.ToString());
+                                                                        }
                                                                     }
+                                                                    comparer.Value = value;
+                                                                }
+                                                                else
+                                                                {
+                                                                    value = Convert.ToInt16(SearchArgs.CompareStartValue);
+                                                                }
+                                                                if (comparer.Compare(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToInt16(SearchArgs.CompareStartValue);
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    break;
-                                                #endregion
-                                                #region case SearchDataTypes._32bits:
-                                                case SearchDataTypes._32bits:
-                                                    if (SearchArgs.IsUnsignedDataType)
-                                                    {
-                                                        uint lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToUInt32(result_value);
-                                                        using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address))
-                                                        {
-                                                            uint value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        break;
+                                                    #endregion
+                                                    #region case SearchDataTypes._32bits:
+                                                    case SearchDataTypes._32bits:
+                                                        if (SearchArgs.IsUnsignedDataType)
+                                                        {
+                                                            uint lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToUInt32(result_value);
+                                                            using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                uint value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
-                                                                    {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, 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(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToUInt32(SearchArgs.CompareStartValue);
-                                                                comparer.Value = value;
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        int lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToInt32(result_value);
-                                                        using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address))
+                                                        else
                                                         {
-                                                            int value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                            int lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToInt32(result_value);
+                                                            using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                int value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
-                                                                    {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, out value);
+                                                                            gmp.CloseProvider();
+                                                                        }
+                                                                        catch (Exception ex)
+                                                                        {
+                                                                            logger.VerboseError.WriteLine(ex.ToString());
+                                                                        }
                                                                     }
+                                                                    comparer.Value = value;
+                                                                }
+                                                                else
+                                                                {
+                                                                    value = Convert.ToInt32(SearchArgs.CompareStartValue);
+                                                                }
+                                                                if (comparer.Compare(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToInt32(SearchArgs.CompareStartValue);
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    break;
-                                                #endregion
-                                                #region case SearchDataTypes._64bits:
-                                                case SearchDataTypes._64bits:
-                                                    if (SearchArgs.IsUnsignedDataType)
-                                                    {
-                                                        ulong lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToUInt64(result_value);
-                                                        using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address))
-                                                        {
-                                                            ulong value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        break;
+                                                    #endregion
+                                                    #region case SearchDataTypes._64bits:
+                                                    case SearchDataTypes._64bits:
+                                                        if (SearchArgs.IsUnsignedDataType)
+                                                        {
+                                                            ulong lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToUInt64(result_value);
+                                                            using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                ulong value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
-                                                                    {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, 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(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToUInt64(SearchArgs.CompareStartValue);
-                                                                comparer.Value = value;
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    else
-                                                    {
-                                                        long lookup_value = 0;
-                                                        //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                                        lookup_value = Convert.ToInt64(result_value);
-                                                        using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address))
+                                                        else
                                                         {
-                                                            long value = 0;
-                                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                            long lookup_value = 0;
+                                                            //using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
+                                                            lookup_value = Convert.ToInt64(result_value);
+                                                            using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address))
                                                             {
-                                                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                                long value = 0;
+                                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                                 {
-                                                                    try
+                                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                                     {
-                                                                        gmp.OpenProvider();
-                                                                        gmp.ReadMemory(address, out value);
-                                                                        gmp.CloseProvider();
-                                                                    }
-                                                                    catch (Exception ex)
-                                                                    {
-                                                                        logger.VerboseError.WriteLine(ex.ToString());
+                                                                        try
+                                                                        {
+                                                                            gmp.OpenProvider();
+                                                                            gmp.ReadMemory(address, out value);
+                                                                            gmp.CloseProvider();
+                                                                        }
+                                                                        catch (Exception ex)
+                                                                        {
+                                                                            logger.VerboseError.WriteLine(ex.ToString());
+                                                                        }
                                                                     }
+                                                                    comparer.Value = value;
+                                                                }
+                                                                else
+                                                                {
+                                                                    value = Convert.ToInt64(SearchArgs.CompareStartValue);
+                                                                }
+                                                                if (comparer.Compare(lookup_value, value))
+                                                                {
+                                                                    second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                                 }
-                                                                comparer.Value = value;
-                                                            }
-                                                            else
-                                                            {
-                                                                value = Convert.ToInt64(SearchArgs.CompareStartValue);
-                                                            }
-                                                            if (comparer.Compare(lookup_value, value))
-                                                            {
-                                                                second_tmp_Results.Add(new ResultType<object>(comparer.Address, comparer.Value));
                                                             }
                                                         }
-                                                    }
-                                                    break;
-                                                #endregion
-                                                #endregion
-                                            }
-                                            double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
-                                            int int_percent_done = (int)double_percent_done;
-                                            //if (int_percent_done != Last_Whole_Percent_Done && i % 100000 == 0)
-                                            //{
-                                            if (int_percent_done <= 100)
-                                            {
-                                                resultsprogress.Value = int_percent_done;
-                                                resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
-                                                //Last_Whole_Percent_Done = int_percent_done;
+                                                        break;
+                                                    #endregion
+                                                    #endregion
+                                                }
+                                                double double_percent_done = 100.0 * (double)((double)i / (double)reader.ResultCount);
+                                                int int_percent_done = (int)double_percent_done;
+                                                //if (int_percent_done != Last_Whole_Percent_Done && i % 100000 == 0)
+                                                //{
+                                                if (int_percent_done <= 100)
+                                                {
+                                                    resultsprogress.Value = int_percent_done;
+                                                    resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
+                                                    //Last_Whole_Percent_Done = int_percent_done;
+                                                }
+                                                //}
+                                                //this.Refresh();
                                             }
-                                            //}
-                                            //this.Refresh();
                                         }
+                                        #endregion
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        throw ex;
                                     }
-                                    #endregion
-                                }
-                                catch (Exception ex)
-                                {
-                                    throw ex;
                                 }
                             }
+                            catch (Exception ex)
+                            {
+                                throw ex;
+                            }
+                            st_nonrange_search.Stop();
+                            logger.Profiler.WriteLine("Non-Ranged search took a total of {0} seconds to complete.", st_nonrange_search.Elapsed.TotalSeconds);
+                            //Last_Whole_Percent_Done = 0;
                         }
-                        catch (Exception ex)
-                        {
-                            throw ex;
-                        }
-                        st_nonrange_search.Stop();
-                        logger.Profiler.WriteLine("Non-Ranged search took a total of {0} seconds to complete.", st_nonrange_search.Elapsed.TotalSeconds);
-                        //Last_Whole_Percent_Done = 0;
                         #endregion
                     }
                     #region Ranged Searches
@@ -1976,34 +1989,34 @@
 
                 }
                 #endregion
-                // leave SearchArgs.Results alone, if false
-                if (NeedToCompare)
-                {
-                    // fix addresses when memory start is not zero
-                    if (MemoryRangeStart > 0 && SearchArgs.IsFirstSearch) { for (int i = 0; i < second_tmp_Results.Count; i++) { second_tmp_Results[i].Address = second_tmp_Results[i].Address + MemoryRangeStart; } }
-                    using (SearchResultWriter writer = new SearchResultWriter(second_tmp_Results.Count, SearchGuid))
-                    {
-                        for (int i = 0; i < second_tmp_Results.Count; i++)
-                        {
-                            switch (sdt)
-                            {
-                                case SearchDataTypes._8bits:
-                                    if (unsigned) { writer.WriteResult<Byte>(second_tmp_Results[i].Address, Convert.ToByte(second_tmp_Results[i].Value)); }
-                                    else { writer.WriteResult<SByte>(second_tmp_Results[i].Address, Convert.ToSByte(second_tmp_Results[i].Value)); } break;
-                                case SearchDataTypes._16bits:
-                                    if (unsigned) { writer.WriteResult<UInt16>(second_tmp_Results[i].Address, Convert.ToUInt16(second_tmp_Results[i].Value)); }
-                                    else { writer.WriteResult<Int16>(second_tmp_Results[i].Address, Convert.ToInt16(second_tmp_Results[i].Value)); } break;
-                                case SearchDataTypes._32bits:
-                                    if (unsigned) { writer.WriteResult<UInt32>(second_tmp_Results[i].Address, Convert.ToUInt32(second_tmp_Results[i].Value)); }
-                                    else { writer.WriteResult<Int32>(second_tmp_Results[i].Address, Convert.ToInt32(second_tmp_Results[i].Value)); } break;
-                                case SearchDataTypes._64bits:
-                                    if (unsigned) { writer.WriteResult<UInt64>(second_tmp_Results[i].Address, Convert.ToUInt64(second_tmp_Results[i].Value)); }
-                                    else { writer.WriteResult<Int64>(second_tmp_Results[i].Address, Convert.ToInt64(second_tmp_Results[i].Value)); } break;
-                            }
-                        }
-                    }
-                    second_tmp_Results = null; // free memory                       
-                }
+                //// leave SearchArgs.Results alone, if false
+                //if (NeedToCompare)
+                //{
+                //    // fix addresses when memory start is not zero
+                //    if (MemoryRangeStart > 0 && SearchArgs.IsFirstSearch) { for (int i = 0; i < second_tmp_Results.Count; i++) { second_tmp_Results[i].Address = second_tmp_Results[i].Address + MemoryRangeStart; } }
+                //    using (SearchResultWriter writer = new SearchResultWriter(second_tmp_Results.Count, SearchGuid))
+                //    {
+                //        for (int i = 0; i < second_tmp_Results.Count; i++)
+                //        {
+                //            switch (sdt)
+                //            {
+                //                case SearchDataTypes._8bits:
+                //                    if (unsigned) { writer.WriteResult<Byte>(second_tmp_Results[i].Address, Convert.ToByte(second_tmp_Results[i].Value)); }
+                //                    else { writer.WriteResult<SByte>(second_tmp_Results[i].Address, Convert.ToSByte(second_tmp_Results[i].Value)); } break;
+                //                case SearchDataTypes._16bits:
+                //                    if (unsigned) { writer.WriteResult<UInt16>(second_tmp_Results[i].Address, Convert.ToUInt16(second_tmp_Results[i].Value)); }
+                //                    else { writer.WriteResult<Int16>(second_tmp_Results[i].Address, Convert.ToInt16(second_tmp_Results[i].Value)); } break;
+                //                case SearchDataTypes._32bits:
+                //                    if (unsigned) { writer.WriteResult<UInt32>(second_tmp_Results[i].Address, Convert.ToUInt32(second_tmp_Results[i].Value)); }
+                //                    else { writer.WriteResult<Int32>(second_tmp_Results[i].Address, Convert.ToInt32(second_tmp_Results[i].Value)); } break;
+                //                case SearchDataTypes._64bits:
+                //                    if (unsigned) { writer.WriteResult<UInt64>(second_tmp_Results[i].Address, Convert.ToUInt64(second_tmp_Results[i].Value)); }
+                //                    else { writer.WriteResult<Int64>(second_tmp_Results[i].Address, Convert.ToInt64(second_tmp_Results[i].Value)); } break;
+                //            }
+                //        }
+                //    }
+                //    second_tmp_Results = null; // free memory                       
+                //}
             }
             catch (Exception ex)
             {
@@ -2044,37 +2057,35 @@
                 if (reader.ResultCount <= MIN_NUMBER_OF_RESULTS_BEFORE_DISPLAY)
                 {
                     lstResults.Items.Clear();
-                    List<ResultItem> items = new List<ResultItem>();
-                    for (int i = 0; i < reader.ResultCount; i++)
-                    {
-                        ResultItem item = new ResultItem(0, false);
-                        //item.Text = string.Format("0x{0:x8}", SearchArgs.Results[i].Address);
-                        //item.SubItems.Add(string.Format("0x{0:x8}", SearchArgs.Results[i].Address));
-                        switch (SearchArgs.DataType)
-                        {
-
-                            case SearchDataTypes._8bits:
-                                if (SearchArgs.IsUnsignedDataType) { ResultType<byte> result = new ResultType<byte>(); item = new ResultItem(result.Address, false, result.Value); }
-                                else { ResultType<sbyte> result = reader.GetNextResult<sbyte>(); item = new ResultItem(result.Address, false, result.Value); }
-                                break;
-                            case SearchDataTypes._16bits:
-                                if (SearchArgs.IsUnsignedDataType) { ResultType<ushort> result = reader.GetNextResult<ushort>(); item = new ResultItem(result.Address, false, result.Value); }
-                                else { ResultType<short> result = reader.GetNextResult<short>(); item = new ResultItem(result.Address, false, result.Value); }
-                                break;
-                            case SearchDataTypes._32bits:
-                                if (SearchArgs.IsUnsignedDataType) { ResultType<uint> result = reader.GetNextResult<uint>(); item = new ResultItem(result.Address, false, result.Value); }
-                                else { ResultType<int> result = reader.GetNextResult<int>(); item = new ResultItem(result.Address, false, result.Value); }
-                                break;
-                            case SearchDataTypes._64bits:
-                                if (SearchArgs.IsUnsignedDataType) { ResultType<ulong> result = reader.GetNextResult<ulong>(); item = new ResultItem(result.Address, false, result.Value); }
-                                else { ResultType<long> result = reader.GetNextResult<long>(); item = new ResultItem(result.Address, false, result.Value); }
-                                break;
-                        }
-
-                        if (!items.Contains(item))
-                            items.Add(item);
-                    }
-                    lstResults.Items.AddRange(items.ToArray());
+                    //List<ResultItem> items = new List<ResultItem>();
+                    //for (int i = 0; i < reader.ResultCount; i++)
+                    //{
+                    //    ResultItem item = new ResultItem(0, false);
+                    //    //item.Text = string.Format("0x{0:x8}", SearchArgs.Results[i].Address);
+                    //    //item.SubItems.Add(string.Format("0x{0:x8}", SearchArgs.Results[i].Address));
+                    //    switch (SearchArgs.DataType)
+                    //    {
+                    //        case SearchDataTypes._8bits:
+                    //            if (SearchArgs.IsUnsignedDataType) { ResultType<byte> result = new ResultType<byte>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            else { ResultType<sbyte> result = reader.GetNextResult<sbyte>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            break;
+                    //        case SearchDataTypes._16bits:
+                    //            if (SearchArgs.IsUnsignedDataType) { ResultType<ushort> result = reader.GetNextResult<ushort>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            else { ResultType<short> result = reader.GetNextResult<short>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            break;
+                    //        case SearchDataTypes._32bits:
+                    //            if (SearchArgs.IsUnsignedDataType) { ResultType<uint> result = reader.GetNextResult<uint>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            else { ResultType<int> result = reader.GetNextResult<int>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            break;
+                    //        case SearchDataTypes._64bits:
+                    //            if (SearchArgs.IsUnsignedDataType) { ResultType<ulong> result = reader.GetNextResult<ulong>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            else { ResultType<long> result = reader.GetNextResult<long>(); item = new ResultItem(result.Address, false, result.Value); }
+                    //            break;
+                    //    }
+                    //    if (!items.Contains(item))
+                    //        items.Add(item);
+                    //}
+                    lstResults.Items.AddRange(reader.GetResultItems(SearchArgs, (IAcceptsProcessAndConfig)this, resultsprogress));
                 }
             }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22