/[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	2012/06/21 20:02:40	409
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/21 20:45:35	410
@@ -1079,587 +1079,603 @@
         }
         private void SearchWorkerThread_DoWork(object sender, DoWorkEventArgs e)
         {
-            Stopwatch st = new Stopwatch();
-            st.Start();
-
-            Stopwatch st_first_search = new Stopwatch();
-            Stopwatch st_nonrange_search = new Stopwatch();
-            Stopwatch st_ranged_search = new Stopwatch();
-
-            e.Result = st;
-            //List<ResultType<object>> tmp_Results = new List<ResultType<object>>();
-            List<ResultType<object>> second_tmp_Results = new List<ResultType<object>>();
-            //const int ElementsBeforeDisplay = 100;
-            SearchArgs.LogSearchOptions();
-            uint STEP_SIZE = (uint)SearchArgs.DataType / 8;
-
-            bool unsigned = SearchArgs.IsUnsignedDataType;
-            SearchDataTypes sdt = SearchArgs.DataType;
-            //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
-            logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
-            resultsprogress.Value = 0;
-            resultsprogress.Message = string.Format("Search is Warming Up...Please Wait...");
-
-            Stopwatch provider_st = new Stopwatch();
-            provider_st.Start();
-            using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-            {
-                provider.OpenProvider();
-                int count = (int)(MemoryRangeSize - MemoryRangeStart) / (int)STEP_SIZE;
-                SearchResultWriter writer = new SearchResultWriter(count);
-                provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
-                provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), writer);
-                provider.CloseProvider();
-                writer.Dispose();
-            }
-            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);
-            //if (buffered_mem.Length == 0) { logger.Warn.WriteLine("Buffered Memory is Zero Length."); return; }            
-            int Last_Whole_Percent_Done = 0;
-
-            #region First Search
-            //if (SearchArgs.IsFirstSearch)
-            //{
-            //    st_first_search.Start();
-            //    //SearchArgs.Results.Clear();
-            //    r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
-            //    int count = (int)buffered_mem.Length / (int)STEP_SIZE;
-            //    #region using (SearchResultWriter writer = new SearchResultWriter(count))
-            //    using (SearchResultWriter writer = new SearchResultWriter(count))
-            //    {
-            //        //List<ResultType<object>> results_list = new List<ResultType<object>>();
-            //        //for (uint i = 0; i < buffered_mem.Length; i += STEP_SIZE)
-            //        //{
-            //        #region while (r_ms.BaseStream.Position < r_ms.BaseStream.Length)
-            //        while (r_ms.BaseStream.Position < r_ms.BaseStream.Length)
-            //        {
-            //            //using (ResultType<object> _tmp_result = new ResultType<object>())
-            //            //{
-            //            try
-            //            {
-            //                switch (sdt)
-            //                {
-            //                    case SearchDataTypes._8bits:
-            //                        if (unsigned) { writer.WriteResult<Byte>((uint)r_ms.BaseStream.Position, r_ms.ReadByte()); }
-            //                        else { writer.WriteResult<SByte>((uint)r_ms.BaseStream.Position, r_ms.ReadSByte()); } break;
-            //                    case SearchDataTypes._16bits:
-            //                        if (unsigned) { writer.WriteResult<UInt16>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt16()); }
-            //                        else { writer.WriteResult<Int16>((uint)r_ms.BaseStream.Position, r_ms.ReadInt16()); } break;
-            //                    case SearchDataTypes._32bits:
-            //                        if (unsigned) { writer.WriteResult<UInt32>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt32()); }
-            //                        else { writer.WriteResult<Int32>((uint)r_ms.BaseStream.Position, r_ms.ReadInt32()); } break;
-            //                    case SearchDataTypes._64bits:
-            //                        if (unsigned) { writer.WriteResult<UInt64>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt64()); }
-            //                        else { writer.WriteResult<Int64>((uint)r_ms.BaseStream.Position, r_ms.ReadInt64()); } break;
-            //                }
-            //            }
-            //            catch (EndOfStreamException)
-            //            {
-            //                //logger.VerboseError.WriteLine(ex.ToString());
-            //                break;
-            //            }
-            //            //results_list.Add(_tmp_result);
-            //            //SearchArgs.Results.Add(_tmp_result);
-            //            double double_percent_done = 100.0 * (double)((double)r_ms.BaseStream.Position / (double)r_ms.BaseStream.Length);
-            //            int int_percent_done = (int)double_percent_done;
-            //            if (int_percent_done != Last_Whole_Percent_Done)
-            //            {
-            //                if (int_percent_done <= 100)
-            //                {
-            //                    resultsprogress.Value = int_percent_done;
-            //                    resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", (r_ms.BaseStream.Position + MemoryRangeStart));
-            //                    Last_Whole_Percent_Done = int_percent_done;
-            //                }
-            //            }
-            //        }
-            //        if (SearchWorkerThread.CancellationPending == true)
-            //        {
-            //            e.Cancel = true;
-            //            return;
-            //        }
-            //        #endregion
-            //    }
-            //    #endregion
-            //    //}
-            //    //SearchArgs.Results.AddRange(results_list);
-            //    //results_list = null;
-            //    resultsprogress.Value = 100;
-            //    resultsprogress.Message = "";
-            //    //Application.DoEvents();
-            //    st_first_search.Stop();
-            //    logger.Profiler.WriteLine("First search took a total of {0} seconds to complete.", st_first_search.Elapsed.TotalSeconds);
-            //    Last_Whole_Percent_Done = 0;
-            //}
-            #endregion
-
-            #region Subsequent Searches
-            //r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
-
-
-            // hack to help with OutOfMemory Exceptions (OldValue and Equal compare will always add all found search results)
-            bool NeedToCompare = true;
-            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue &&
-                SearchArgs.CompareType == SearchCompareTypes.Equal &&
-                SearchArgs.IsFirstSearch)
+            try
             {
-                NeedToCompare = false;
-                //second_tmp_Results = null; // Free Memory
-            }
+                Stopwatch st = new Stopwatch();
+                st.Start();
 
-            if (NeedToCompare)
-            {
-                if (SearchArgs.CompareType != SearchCompareTypes.Between && SearchArgs.CompareType != SearchCompareTypes.NotBetween)
+                Stopwatch st_first_search = new Stopwatch();
+                Stopwatch st_nonrange_search = new Stopwatch();
+                Stopwatch st_ranged_search = new Stopwatch();
+
+                e.Result = st;
+                //List<ResultType<object>> tmp_Results = new List<ResultType<object>>();
+                List<ResultType<object>> second_tmp_Results = new List<ResultType<object>>();
+                //const int ElementsBeforeDisplay = 100;
+                SearchArgs.LogSearchOptions();
+                uint STEP_SIZE = (uint)SearchArgs.DataType / 8;
+
+                bool unsigned = SearchArgs.IsUnsignedDataType;
+                SearchDataTypes sdt = SearchArgs.DataType;
+                //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
+                logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
+                resultsprogress.Value = 0;
+                resultsprogress.Message = string.Format("Search is Warming Up...Please Wait...");
+
+                Stopwatch provider_st = new Stopwatch();
+                provider_st.Start();
+                using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                 {
-                    #region Non-Range Searches
-                    st_nonrange_search.Start();
-                    //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
-                    ////second_tmp_Results.c
-                    try
+                    provider.OpenProvider();
+                    int count = (int)(MemoryRangeSize - MemoryRangeStart) / (int)STEP_SIZE;
+                    SearchResultWriter writer = new SearchResultWriter(count);
+                    provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
+                    provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), writer);
+                    provider.CloseProvider();
+                    writer.Dispose();
+                }
+                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);
+                //if (buffered_mem.Length == 0) { logger.Warn.WriteLine("Buffered Memory is Zero Length."); return; }            
+                int Last_Whole_Percent_Done = 0;
+
+
+                #region Subsequent Searches
+                //r_ms.BaseStream.Seek(0, SeekOrigin.Begin);
+
+
+                // hack to help with OutOfMemory Exceptions (OldValue and Equal compare will always add all found search results)
+                bool NeedToCompare = true;
+                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue &&
+                    SearchArgs.CompareType == SearchCompareTypes.Equal &&
+                    SearchArgs.IsFirstSearch)
+                {
+                    NeedToCompare = false;
+                    //second_tmp_Results = null; // Free Memory
+                }
+
+                if (NeedToCompare)
+                {
+                    if (SearchArgs.CompareType != SearchCompareTypes.Between && SearchArgs.CompareType != SearchCompareTypes.NotBetween)
                     {
-                        using (SearchResultReader reader = new SearchResultReader())
+                        #region Non-Range Searches
+                        st_nonrange_search.Start();
+                        //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
+                        ////second_tmp_Results.c
+                        try
                         {
-                            for (int i = 0; i < reader.ResultCount; i += 1)
+                            using (SearchResultReader reader = new SearchResultReader())
                             {
-                                object result_value = 0;
-                                uint address = 0;
-                                #region switch (SearchArgs.DataType)
-                                switch (SearchArgs.DataType)
-                                {
-                                    case SearchDataTypes._8bits: if (unsigned)
-                                        {
-                                            using (ResultType<byte> result = reader.GetNextResult<byte>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        }
-                                        else
-                                        {
-                                            using (ResultType<sbyte> result = reader.GetNextResult<sbyte>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        } break;
-                                    case SearchDataTypes._16bits: if (unsigned)
-                                        {
-                                            using (ResultType<ushort> result = reader.GetNextResult<ushort>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        }
-                                        else
-                                        {
-                                            using (ResultType<short> result = reader.GetNextResult<short>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        } break;
-                                    case SearchDataTypes._32bits: if (unsigned)
-                                        {
-                                            using (ResultType<uint> result = reader.GetNextResult<uint>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        }
-                                        else
-                                        {
-                                            using (ResultType<int> result = reader.GetNextResult<int>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        } break;
-                                    case SearchDataTypes._64bits: if (unsigned)
-                                        {
-                                            using (ResultType<ulong> result = reader.GetNextResult<ulong>())
-                                            {
-                                                address = result.Address;
-                                                result_value = result.Value;
-                                            }
-                                        }
-                                        else
-                                        {
-                                            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)
+                                    for (int i = 0; i < reader.ResultCount; i += 1)
+                                    {
+                                        object result_value = 0;
+                                        uint address = 0;
+                                        #region switch (SearchArgs.DataType)
+                                        switch (SearchArgs.DataType)
                                         {
-                                            byte lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                            _8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address);
-                                            byte value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToByte(result_value);
-                                                comparer.Value = value;
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                                comparer.Value = value;
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                            case SearchDataTypes._8bits: if (unsigned)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    using (ResultType<byte> result = reader.GetNextResult<byte>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
                                                 }
-                                            }
-                                            comparer = null; // free memory
-                                        }
-                                        else
-                                        {
-                                            sbyte lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                            _8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address);
-                                            sbyte value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToSByte(result_value);
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToSByte(SearchArgs.CompareStartValue);
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                else
+                                                {
+                                                    using (ResultType<sbyte> result = reader.GetNextResult<sbyte>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
+                                                } break;
+                                            case SearchDataTypes._16bits: if (unsigned)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    using (ResultType<ushort> result = reader.GetNextResult<ushort>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
                                                 }
-                                            }
-                                            comparer = null; // free memory
-                                        }
-                                        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(); }
-                                            _16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address);
-                                            ushort value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToUInt16(result_value);
-                                                comparer.Value = value;
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToUInt16(SearchArgs.CompareStartValue);
-                                                comparer.Value = value;
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                else
+                                                {
+                                                    using (ResultType<short> result = reader.GetNextResult<short>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
+                                                } break;
+                                            case SearchDataTypes._32bits: if (unsigned)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    using (ResultType<uint> result = reader.GetNextResult<uint>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
                                                 }
-                                            }
-                                            comparer = null; // free memory
-                                        }
-                                        else
-                                        {
-                                            short lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                            _16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address);
-                                            short value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToInt16(result_value);
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToInt16(SearchArgs.CompareStartValue);
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                else
+                                                {
+                                                    using (ResultType<int> result = reader.GetNextResult<int>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
+                                                } break;
+                                            case SearchDataTypes._64bits: if (unsigned)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    using (ResultType<ulong> result = reader.GetNextResult<ulong>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
                                                 }
-                                            }
-                                            comparer = null; // free memory
+                                                else
+                                                {
+                                                    using (ResultType<long> result = reader.GetNextResult<long>())
+                                                    {
+                                                        address = result.Address;
+                                                        result_value = result.Value;
+                                                    }
+                                                } break;
                                         }
-                                        break;
-                                    #endregion
-                                    #region case SearchDataTypes._32bits:
-                                    case SearchDataTypes._32bits:
-                                        if (SearchArgs.IsUnsignedDataType)
+                                        #endregion
+                                        if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
+                                        try
                                         {
-                                            uint lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                            {
-                                                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)
                                                 {
-                                                    gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider();
+                                                    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))
+                                                    {
+                                                        byte value = 0;
+                                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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));
+                                                        }
+                                                    }
                                                 }
-                                                catch (Exception ex)
+                                                else
                                                 {
-                                                    throw;
+                                                    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))
+                                                    {
+                                                        sbyte value = 0;
+                                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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));
+                                                        }
+                                                    }
                                                 }
-                                            }
-                                            _32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address);
-                                            uint value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToUInt32(result_value);
-                                                comparer.Value = value;
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToUInt32(SearchArgs.CompareStartValue);
-                                                comparer.Value = value;
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                break;
+                                            #endregion
+                                            #region case SearchDataTypes._16bits:
+                                            case SearchDataTypes._16bits:
+                                                if (SearchArgs.IsUnsignedDataType)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    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)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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 = null; // free memory
-                                        }
-                                        else
-                                        {
-                                            int lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                            _32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address);
-                                            int value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToInt32(result_value);
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToInt32(SearchArgs.CompareStartValue);
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                else
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    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))
+                                                    {
+                                                        short value = 0;
+                                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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 = null; // free memory
-                                        }
-                                        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(); }
-                                            _64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address);
-                                            ulong value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToUInt64(result_value);
-                                                comparer.Value = value;
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToUInt64(SearchArgs.CompareStartValue);
-                                                comparer.Value = value;
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                                break;
+                                            #endregion
+                                            #region case SearchDataTypes._32bits:
+                                            case SearchDataTypes._32bits:
+                                                if (SearchArgs.IsUnsignedDataType)
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    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)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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 = null; // free memory
-                                        }
-                                        else
-                                        {
-                                            long lookup_value = 0;
-                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this)) { gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider(); }
-                                            _64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address);
-                                            long value = 0;
-                                            if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                            {
-                                                value = Convert.ToInt64(result_value);
-                                            }
-                                            else
-                                            {
-                                                value = Convert.ToInt64(SearchArgs.CompareStartValue);
-                                            }
-                                            if (comparer.Compare(lookup_value, value))
-                                            {
-                                                using (ResultType<object> _tmp_result = 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))
+                                                    {
+                                                        int value = 0;
+                                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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));
+                                                        }
+                                                    }
+                                                }
+                                                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)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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));
+                                                        }
+                                                    }
+                                                }
+                                                else
                                                 {
-                                                    second_tmp_Results.Add(_tmp_result);
+                                                    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))
+                                                    {
+                                                        long value = 0;
+                                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                        {
+                                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                            {
+                                                                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));
+                                                        }
+                                                    }
                                                 }
+                                                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;
                                             }
-                                            comparer = null; // free memory
                                         }
-                                        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)
+                                catch (Exception ex)
                                 {
-                                    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;
-                                        if (int_percent_done == 11)
-                                        {
-                                            int local_k = 0;
-                                        }
-                                    }
+                                    throw;
                                 }
                             }
                         }
+                        catch (Exception ex)
+                        {
+                            throw;
+                        }
+                        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
                     }
-                    catch (Exception ex)
-                    {
-                        throw;
-                    }
-                    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
+                    #region Ranged Searches
 #if !DONOT_HAVE_RANGED_SEARCH_SUPPORT
-                if (SearchArgs.CompareType == SearchCompareTypes.Between || SearchArgs.CompareType == SearchCompareTypes.NotBetween)
-                {
-                    st_ranged_search.Start();
-                    object start, end;
-
-                    start = SearchArgs.CompareStartValue;
-                    end = SearchArgs.CompareEndValue;
-                    using (SearchResultReader reader = new SearchResultReader())
+                    if (SearchArgs.CompareType == SearchCompareTypes.Between || SearchArgs.CompareType == SearchCompareTypes.NotBetween)
                     {
-                        for (int i = 0; i < reader.ResultCount; i += 1)
+                        st_ranged_search.Start();
+                        object start, end;
+
+                        start = SearchArgs.CompareStartValue;
+                        end = SearchArgs.CompareEndValue;
+                        using (SearchResultReader reader = new SearchResultReader())
                         {
-                            uint address = 0;
-                            #region switch (SearchArgs.DataType)
-                            switch (SearchArgs.DataType)
-                            {
-                                case SearchDataTypes._8bits: if (unsigned) { using (ResultType<byte> result = reader.GetNextResult<byte>()) { address = result.Address; } }
-                                    else { using (ResultType<sbyte> result = reader.GetNextResult<sbyte>()) { address = result.Address; } } break;
-                                case SearchDataTypes._16bits: if (unsigned) { using (ResultType<ushort> result = reader.GetNextResult<ushort>()) { address = result.Address; } }
-                                    else { using (ResultType<short> result = reader.GetNextResult<short>()) { address = result.Address; } } break;
-                                case SearchDataTypes._32bits: if (unsigned) { using (ResultType<uint> result = reader.GetNextResult<uint>()) { address = result.Address; } }
-                                    else { using (ResultType<int> result = reader.GetNextResult<int>()) { address = result.Address; } } break;
-                                case SearchDataTypes._64bits: if (unsigned) { using (ResultType<ulong> result = reader.GetNextResult<ulong>()) { address = result.Address; } }
-                                    else { using (ResultType<long> result = reader.GetNextResult<long>()) { address = result.Address; } } break;
-                            }
-                            #endregion
-                            
-                            if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
-                            //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
-                            if (SearchArgs.CompareType == SearchCompareTypes.Between)
+                            for (int i = 0; i < reader.ResultCount; i += 1)
                             {
-                                InRangeComparer comparer = new InRangeComparer(address, 0);
-                                if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
+                                uint address = 0;
+                                #region switch (SearchArgs.DataType)
+                                switch (SearchArgs.DataType)
                                 {
-                                    using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                    case SearchDataTypes._8bits: if (unsigned) { using (ResultType<byte> result = reader.GetNextResult<byte>()) { address = result.Address; } }
+                                        else { using (ResultType<sbyte> result = reader.GetNextResult<sbyte>()) { address = result.Address; } } break;
+                                    case SearchDataTypes._16bits: if (unsigned) { using (ResultType<ushort> result = reader.GetNextResult<ushort>()) { address = result.Address; } }
+                                        else { using (ResultType<short> result = reader.GetNextResult<short>()) { address = result.Address; } } break;
+                                    case SearchDataTypes._32bits: if (unsigned) { using (ResultType<uint> result = reader.GetNextResult<uint>()) { address = result.Address; } }
+                                        else { using (ResultType<int> result = reader.GetNextResult<int>()) { address = result.Address; } } break;
+                                    case SearchDataTypes._64bits: if (unsigned) { using (ResultType<ulong> result = reader.GetNextResult<ulong>()) { address = result.Address; } }
+                                        else { using (ResultType<long> result = reader.GetNextResult<long>()) { address = result.Address; } } break;
+                                }
+                                #endregion
+
+                                if (MemoryRangeStart > 0 && !SearchArgs.IsFirstSearch) { address = address - MemoryRangeStart; }
+                                //r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
+                                if (SearchArgs.CompareType == SearchCompareTypes.Between)
+                                {
+                                    using (InRangeComparer comparer = new InRangeComparer(address, 0))
                                     {
-                                        second_tmp_Results.Add(_tmp_result);
+                                        if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
+                                        {
+                                            using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                            {
+                                                second_tmp_Results.Add(_tmp_result);
+                                            }
+                                        }
                                     }
                                 }
-                                comparer = null;
-                            }
-                            else if (SearchArgs.CompareType == SearchCompareTypes.NotBetween)
-                            {
-                                NotInRangeComparer comparer = new NotInRangeComparer(address, 0);
-                                if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
+                                else if (SearchArgs.CompareType == SearchCompareTypes.NotBetween)
                                 {
-                                    using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                    using (NotInRangeComparer comparer = new NotInRangeComparer(address, 0))
                                     {
-                                        second_tmp_Results.Add(_tmp_result);
+                                        if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
+                                        {
+                                            using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                            {
+                                                second_tmp_Results.Add(_tmp_result);
+                                            }
+                                        }
                                     }
                                 }
-                                comparer = null;
-                            }
-                            else
-                            {
-                                throw new InvalidOperationException("Encounted unkown range search type: " + SearchArgs.CompareType);
-                            }
-                            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)
-                            {
-                                if (int_percent_done <= 100)
+                                else
                                 {
-                                    resultsprogress.Value = int_percent_done;
-                                    resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart);
-                                    Last_Whole_Percent_Done = int_percent_done;
+                                    throw new InvalidOperationException("Encounted unkown range search type: " + SearchArgs.CompareType);
                                 }
-                                if (int_percent_done == 11)
+                                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)
                                 {
-                                    int local_k = 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;
+                                    }
                                 }
                             }
                         }
+                        st_ranged_search.Stop();
+                        logger.Profiler.WriteLine("Ranged search took a total of {0} seconds to complete.", st_ranged_search.Elapsed.TotalSeconds);
                     }
-                    st_ranged_search.Stop();
-                    logger.Profiler.WriteLine("Ranged search took a total of {0} seconds to complete.", st_ranged_search.Elapsed.TotalSeconds);
-                }
 #endif
-                #endregion
+                    #endregion
 
-            }
-            #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))
+                }
+                #endregion
+                // leave SearchArgs.Results alone, if false
+                if (NeedToCompare)
                 {
-                    for (int i = 0; i < second_tmp_Results.Count; i++)
+                    // 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))
                     {
-                        switch (sdt)
+                        for (int i = 0; i < second_tmp_Results.Count; i++)
                         {
-                            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;
+                            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                       
                 }
-                second_tmp_Results = null; // free memory                       
+            }
+            catch (Exception ex)
+            {
+                throw;
             }
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22