/[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 18:10:21	408
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/21 20:02:40	409
@@ -1214,246 +1214,337 @@
                     st_nonrange_search.Start();
                     //second_tmp_Results = new List<ResultType<object>>(SearchArgs.Results.Count * 1024);
                     ////second_tmp_Results.c
-
-                    using (SearchResultReader reader = new SearchResultReader())
+                    try
                     {
-                        for (int i = 0; i < reader.ResultCount; i += 1)
+                        using (SearchResultReader reader = new SearchResultReader())
                         {
-                            if (reader.ReadCurrentAddess)
+                            for (int i = 0; i < reader.ResultCount; i += 1)
                             {
-                                if (!reader.ReadCurrentValue)
+                                object result_value = 0;
+                                uint address = 0;
+                                #region switch (SearchArgs.DataType)
+                                switch (SearchArgs.DataType)
                                 {
-                                    switch (SearchArgs.DataType)
-                                    {
-                                        case SearchDataTypes._8bits: if (unsigned) { reader.CurrentResult<byte>(); } else { reader.CurrentResult<sbyte>(); } break;
-                                        case SearchDataTypes._16bits: if (unsigned) { reader.CurrentResult<ushort>(); } else { reader.CurrentResult<short>(); } break;
-                                        case SearchDataTypes._32bits: if (unsigned) { reader.CurrentResult<uint>(); } else { reader.CurrentResult<int>(); } break;
-                                        case SearchDataTypes._64bits: if (unsigned) { reader.CurrentResult<ulong>(); } else { reader.CurrentResult<long>(); } break;
-                                    }
-                                }
-                            }
-                            uint address = reader.CurrentAddress();
-                            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(); }
-                                        _8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address);
-                                        byte value = 0;
-                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                    case SearchDataTypes._8bits: if (unsigned)
                                         {
-                                            value = reader.CurrentResult<byte>();
-                                            comparer.Value = value;
+                                            using (ResultType<byte> result = reader.GetNextResult<byte>())
+                                            {
+                                                address = result.Address;
+                                                result_value = result.Value;
+                                            }
                                         }
                                         else
                                         {
-                                            value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                            comparer.Value = value;
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<sbyte>();
+                                            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
                                         {
-                                            value = Convert.ToSByte(SearchArgs.CompareStartValue);
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<ushort>();
-                                            comparer.Value = value;
+                                            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
                                         {
-                                            value = Convert.ToUInt16(SearchArgs.CompareStartValue);
-                                            comparer.Value = value;
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<short>();
+                                            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
                                         {
-                                            value = Convert.ToInt16(SearchArgs.CompareStartValue);
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        comparer = null; // free memory
-                                    }
-                                    break;
+                                            using (ResultType<long> result = reader.GetNextResult<long>())
+                                            {
+                                                address = result.Address;
+                                                result_value = result.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(); }
-                                        _32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address);
-                                        uint value = 0;
-                                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                        {
-                                            value = reader.CurrentResult<uint>();
-                                            comparer.Value = value;
+                                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(); }
+                                            _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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            comparer = null; // free memory
                                         }
                                         else
                                         {
-                                            value = Convert.ToUInt32(SearchArgs.CompareStartValue);
-                                            comparer.Value = value;
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<int>();
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            comparer = null; // free memory
                                         }
                                         else
                                         {
-                                            value = Convert.ToInt32(SearchArgs.CompareStartValue);
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<ulong>();
-                                            comparer.Value = value;
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            comparer = null; // free memory
+                                        }
+                                        break;
+                                    #endregion
+                                    #region case SearchDataTypes._32bits:
+                                    case SearchDataTypes._32bits:
+                                        if (SearchArgs.IsUnsignedDataType)
+                                        {
+                                            uint lookup_value = 0;
+                                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                            {
+                                                try
+                                                {
+                                                    gmp.OpenProvider(); gmp.ReadMemory(address, out lookup_value); gmp.CloseProvider();
+                                                }
+                                                catch (Exception ex)
+                                                {
+                                                    throw;
+                                                }
+                                            }
+                                            _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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            comparer = null; // free memory
                                         }
                                         else
                                         {
-                                            value = Convert.ToUInt64(SearchArgs.CompareStartValue);
-                                            comparer.Value = value;
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
-                                        {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
-                                        }
-                                        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 = reader.CurrentResult<long>();
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            comparer = null; // free memory
                                         }
                                         else
                                         {
-                                            value = Convert.ToInt64(SearchArgs.CompareStartValue);
-                                        }
-                                        if (comparer.Compare(lookup_value, value))
+                                            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))
+                                                {
+                                                    second_tmp_Results.Add(_tmp_result);
+                                                }
+                                            }
+                                            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)
+                                {
+                                    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)
                                         {
-                                            ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                            second_tmp_Results.Add(_tmp_result);
+                                            int local_k = 0;
                                         }
-                                        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)
-                            {
-                                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;
                                 }
                             }
-
                         }
                     }
+                    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;
@@ -1472,7 +1563,21 @@
                     {
                         for (int i = 0; i < reader.ResultCount; i += 1)
                         {
-                            uint address = reader.CurrentAddress();
+                            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)
@@ -1480,8 +1585,10 @@
                                 InRangeComparer comparer = new InRangeComparer(address, 0);
                                 if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
                                 {
-                                    ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                    second_tmp_Results.Add(_tmp_result);
+                                    using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                    {
+                                        second_tmp_Results.Add(_tmp_result);
+                                    }
                                 }
                                 comparer = null;
                             }
@@ -1490,8 +1597,10 @@
                                 NotInRangeComparer comparer = new NotInRangeComparer(address, 0);
                                 if (comparer.Compare(start, end, SearchArgs.DataType, SearchArgs.IsUnsignedDataType, (IAcceptsProcessAndConfig)this))
                                 {
-                                    ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value);
-                                    second_tmp_Results.Add(_tmp_result);
+                                    using (ResultType<object> _tmp_result = new ResultType<object>(comparer.Address, comparer.Value))
+                                    {
+                                        second_tmp_Results.Add(_tmp_result);
+                                    }
                                 }
                                 comparer = null;
                             }
@@ -1509,6 +1618,10 @@
                                     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;
+                                }
                             }
                         }
                     }
@@ -1571,15 +1684,87 @@
             }
             
             resultsprogress.Value = 100;
-
+            bool unsigned = SearchArgs.IsUnsignedDataType;
             using (SearchResultReader reader = new SearchResultReader())
             {
 
+                object result_value = 0;
+                uint address = 0;
+                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;
+                }
+
+
+
                 logger.Debug.WriteLine(string.Format("Results Count -> 0x{0:x8}", reader.ResultCount));
 
 
                 if (reader.ResultCount == 1) // debug message for 1 result using 32bit unsigned
-                    logger.Debug.WriteLine(string.Format("Debug: Found 1 result -> Address: 0x{0:x8} Value: 0x{1:x16}", reader.CurrentAddress(), reader.CurrentResult<ulong>()));
+                    logger.Debug.WriteLine(string.Format("Debug: Found 1 result -> Address: 0x{0:x8} Value: 0x{1:x16}", address, result_value));
 
                 logger.Info.WriteLine(string.Format("Found 0x{0:x8} results", reader.ResultCount));
 
@@ -1596,20 +1781,20 @@
                         {
 
                             case SearchDataTypes._8bits:
-                                if (SearchArgs.IsUnsignedDataType) { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<byte>()); }
-                                else { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<sbyte>()); }
+                                if (SearchArgs.IsUnsignedDataType) { ResultType<byte> result = reader.GetNextResult<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) { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<ushort>()); }
-                                else { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<short>()); }
+                                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) { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<uint>()); }
-                                else { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<int>()); }
+                                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) { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<ulong>()); }
-                                else { item = new ResultItem(reader.CurrentAddress(), false, reader.CurrentResult<long>()); }
+                                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;
                         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22