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

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

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

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/06 06:23:19	568
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/06 06:44:39	569
@@ -1552,492 +1552,551 @@
                         #region result writing
                         using (SearchResultWriter writer = new SearchResultWriter(0, new_SearchGuid))
                         {
-                            Last_Whole_Percent_Done = 0;
-                            //int index = 0;
 
-                            provider.OpenProvider();
-                            //int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
-                            //SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);                                
-                            uint size = 0;                           
-                            switch (sdt)
+                            if (SearchWorkerThread.CancellationPending)
                             {
-                                case SearchDataTypes._8bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
-                                case SearchDataTypes._16bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
-                                case SearchDataTypes._32bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
-                                case SearchDataTypes._64bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                                provider_st.Stop();
+                                st.Stop();
+                                writer.CancelRequest();
+                                writer.Dispose();
+                                e.Result = true;
+                                provider.CloseProvider();
+                                return;
                             }
-                            //size = STEP_SIZE * 4096;
-                            for (uint i = MemoryRangeStart; i < MemoryRangeSize; i += size)
-                            {
 
-                                int bytesRead = 0;
-                                byte[] data = new byte[size];
-                                provider.ReadProcessMemoryAtOnce(i, size, out bytesRead, out data);
-                                string message = string.Format(" -> Reading Address: 0x{0:x8}", (i + MemoryRangeStart));
-                                double double_percent_done = 100.0 * (double)((double)i / (double)MemoryRangeSize);
-                                int int_percent_done = (int)double_percent_done;
-                                if ((int_percent_done != Last_Whole_Percent_Done))// && (i % 10000) == 0)
+
+                            for (int i = 0; i < reader_addresses.Length; i++)
+                            {
+                                if (SearchWorkerThread.CancellationPending)
                                 {
-                                    UpdateProgress(int_percent_done, message);
-                                    Last_Whole_Percent_Done = int_percent_done;
+                                    provider_st.Stop();
+                                    st.Stop();
+                                    writer.CancelRequest();
+                                    writer.Dispose();
+                                    e.Result = true;
+                                    provider.CloseProvider();
+                                    return;
                                 }
+                                var address = reader_addresses[i];
+                                provider.OpenProvider();
+
+                                int bytesRead =0;
+                                byte[] data = new byte[STEP_SIZE];
+                                provider.ReadProcessMemory(address, 0, out bytesRead, out data);
 
-                                uint address_index = i;
-                                int inner_Last_Whole_Percent_Done = 0;
-                                #region comparison and serialization
                                 switch (sdt)
                                 {
                                     case SearchDataTypes._8bits:
                                         if (unsigned)
                                         {
                                             #region 8bits - unsigned
-                                            var t_data = data;
-                                            foreach (var Value in t_data)
+                                            byte Value = data[0];
+                                            using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address))
                                             {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, address_index))
+                                                byte value = 0;
+                                                if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
                                                 {
-                                                    byte value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                                                    using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                                                     {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                        try
                                                         {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
+                                                            gmp.OpenProvider();
+                                                            gmp.ReadMemory(address, out value);
+                                                            gmp.CloseProvider();
                                                         }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToByte(Value), value))
-                                                    {
-                                                        writer.WriteResult<byte>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 8bits - signed
-                                            var t_data = data;
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8} of 0x{1:x8}", address_index, MemoryRangeSize);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address_index))
-                                                {
-                                                    sbyte value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                                        catch (Exception ex)
                                                         {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
+                                                            logger.VerboseError.WriteLine(ex.ToString());
                                                         }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToSByte(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
                                                     }
-                                                    if (comparer.Compare(Convert.ToSByte(Value), value))
-                                                    {
-                                                        writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        } break;
-                                    case SearchDataTypes._16bits:
-                                        if (unsigned)
-                                        {
-                                            #region 16bits - unsigned
-                                            var t_data = BitTools.ConvertByteArray<ushort>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                                                    comparer.Value = value;
                                                 }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
+                                                else
                                                 {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
+                                                    value = Convert.ToByte(SearchArgs.CompareStartValue);
+                                                    comparer.Value = value;
                                                 }
-                                                using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address_index))
+                                                if (comparer.Compare(Convert.ToByte(Value), value))
                                                 {
-                                                    ushort value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToUInt16(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToUInt16(Value), value))
-                                                    {
-                                                        writer.WriteResult<ushort>(comparer.Address, comparer.Value);
-                                                    }
+                                                    writer.WriteResult<ushort>(comparer.Address, comparer.Value);
                                                 }
-                                                address_index += STEP_SIZE;
                                             }
                                             #endregion
                                         }
                                         else
                                         {
-                                            #region 16bits - signed
-                                            var t_data = BitTools.ConvertByteArray<short>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address_index))
-                                                {
-                                                    short value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToInt16(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToSByte(Value), value))
-                                                    {
-                                                        writer.WriteResult<short>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        } break;
-                                    case SearchDataTypes._32bits:
-                                        if (unsigned)
-                                        {
-                                            #region 32bits - unsigned
-                                            var t_data = BitTools.ConvertByteArray<uint>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address_index))
-                                                {
-                                                    uint value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToUInt32(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToUInt32(Value), value))
-                                                    {
-                                                        writer.WriteResult<uint>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
+                                            sbyte value = Convert.ToSByte(data[0]);
                                         }
-                                        else
-                                        {
-                                            #region 32bits - signed
-                                            var t_data = BitTools.ConvertByteArray<int>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address_index))
-                                                {
-                                                    int value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToInt32(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToInt32(Value), value))
-                                                    {
-                                                        writer.WriteResult<int>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        } break;
+                                        break;
+                                    case SearchDataTypes._16bits:
+                                        break;
+                                    case SearchDataTypes._32bits:
+                                        break;
                                     case SearchDataTypes._64bits:
-                                        if (unsigned)
-                                        {
-                                            #region 64bits - unsigned
-                                            var t_data = BitTools.ConvertByteArray<ulong>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address_index))
-                                                {
-                                                    ulong value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToUInt64(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToUInt64(Value), value))
-                                                    {
-                                                        writer.WriteResult<ulong>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        }
-                                        else
-                                        {
-                                            #region 64bits - signed
-                                            var t_data = BitTools.ConvertByteArray<long>(data, new Func<bool>(ShouldCancelAnySearchOperation));
-                                            foreach (var Value in t_data)
-                                            {
-                                                string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
-                                                double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
-                                                int inner_int_percent_done = (int)inner_double_percent_done;
-                                                if ((address_index % 10000) == 0)
-                                                {
-                                                    UpdateProgress(inner_int_percent_done, inner_message);
-                                                    inner_Last_Whole_Percent_Done = inner_int_percent_done;
-                                                }
-                                                if (SearchWorkerThread.CancellationPending) { break; }
-                                                if (!reader_addresses.Contains(address_index))
-                                                {
-                                                    address_index += STEP_SIZE;
-                                                    continue;
-                                                }
-                                                using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address_index))
-                                                {
-                                                    long value = 0;
-                                                    if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
-                                                    {
-                                                        using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
-                                                        {
-                                                            try
-                                                            {
-                                                                gmp.OpenProvider();
-                                                                gmp.ReadMemory(address_index, out value);
-                                                                gmp.CloseProvider();
-                                                            }
-                                                            catch (Exception ex)
-                                                            {
-                                                                logger.VerboseError.WriteLine(ex.ToString());
-                                                            }
-                                                        }
-                                                        comparer.Value = value;
-                                                    }
-                                                    else
-                                                    {
-                                                        value = Convert.ToInt64(SearchArgs.CompareStartValue);
-                                                        comparer.Value = value;
-                                                    }
-                                                    if (comparer.Compare(Convert.ToInt64(Value), value))
-                                                    {
-                                                        writer.WriteResult<long>(comparer.Address, comparer.Value);
-                                                    }
-                                                }
-                                                address_index += STEP_SIZE;
-                                            }
-                                            #endregion
-                                        } break;
-
+                                        break;
                                 }
-                                #endregion
 
-                                if (SearchWorkerThread.CancellationPending)
-                                {
-                                    provider_st.Stop();
-                                    st.Stop();
-                                    writer.CancelRequest();
-                                    writer.Dispose();
-                                    e.Result = true;
-                                    provider.CloseProvider();
-                                    return;
-                                }
+                                provider.CloseProvider();
                             }
+
+                            #region old-code:
+                            //Last_Whole_Percent_Done = 0;
+                            ////int index = 0;
+
+                            //provider.OpenProvider();
+                            ////int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
+                            ////SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);                                
+                            //uint size = 0;
+                            //switch (sdt)
+                            //{
+                            //    case SearchDataTypes._8bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                            //    case SearchDataTypes._16bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                            //    case SearchDataTypes._32bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                            //    case SearchDataTypes._64bits: size = (MEM_CHUNK_SIZE / BitTools.SizeOf<uint>(sdt)); break;
+                            //}
+                            ////size = STEP_SIZE * 4096;
+                            //for (uint i = MemoryRangeStart; i < MemoryRangeSize; i += size)
+                            //{
+                            //    int bytesRead = 0;
+                            //    byte[] data = new byte[size];
+                            //    provider.ReadProcessMemoryAtOnce(i, size, out bytesRead, out data);
+                            //    string message = string.Format(" -> Reading Address: 0x{0:x8}", (i + MemoryRangeStart));
+                            //    double double_percent_done = 100.0 * (double)((double)i / (double)MemoryRangeSize);
+                            //    int int_percent_done = (int)double_percent_done;
+                            //    if ((int_percent_done != Last_Whole_Percent_Done))// && (i % 10000) == 0)
+                            //    {
+                            //        UpdateProgress(int_percent_done, message);
+                            //        Last_Whole_Percent_Done = int_percent_done;
+                            //    }
+                            //    uint address_index = i;
+                            //    int inner_Last_Whole_Percent_Done = 0;
+                            //    #region comparison and serialization
+                            //    switch (sdt)
+                            //    {
+                            //        case SearchDataTypes._8bits:
+                            //            if (unsigned)
+                            //            {
+                            //                #region 8bits - unsigned
+                            //                var t_data = data;
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    else
+                            //                    {
+                            //                        writer.WriteResult<byte>(address_index, Value);
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            }
+                            //            else
+                            //            {
+                            //                #region 8bits - signed
+                            //                var t_data = data;
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8} of 0x{1:x8}", address_index, MemoryRangeSize);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_8bit_signed_comparer_ comparer = new _8bit_signed_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        sbyte value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToSByte(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToSByte(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<sbyte>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            } break;
+                            //        case SearchDataTypes._16bits:
+                            //            if (unsigned)
+                            //            {
+                            //                #region 16bits - unsigned
+                            //                var t_data = BitTools.ConvertByteArray<ushort>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_16bit_unsigned_comparer_ comparer = new _16bit_unsigned_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        ushort value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToUInt16(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToUInt16(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<ushort>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            }
+                            //            else
+                            //            {
+                            //                #region 16bits - signed
+                            //                var t_data = BitTools.ConvertByteArray<short>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_16bit_signed_comparer_ comparer = new _16bit_signed_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        short value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToInt16(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToSByte(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<short>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            } break;
+                            //        case SearchDataTypes._32bits:
+                            //            if (unsigned)
+                            //            {
+                            //                #region 32bits - unsigned
+                            //                var t_data = BitTools.ConvertByteArray<uint>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        uint value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToUInt32(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToUInt32(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<uint>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            }
+                            //            else
+                            //            {
+                            //                #region 32bits - signed
+                            //                var t_data = BitTools.ConvertByteArray<int>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_32bit_signed_comparer_ comparer = new _32bit_signed_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        int value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToInt32(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToInt32(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<int>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            } break;
+                            //        case SearchDataTypes._64bits:
+                            //            if (unsigned)
+                            //            {
+                            //                #region 64bits - unsigned
+                            //                var t_data = BitTools.ConvertByteArray<ulong>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_64bit_unsigned_comparer_ comparer = new _64bit_unsigned_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        ulong value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToUInt64(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToUInt64(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<ulong>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            }
+                            //            else
+                            //            {
+                            //                #region 64bits - signed
+                            //                var t_data = BitTools.ConvertByteArray<long>(data, new Func<bool>(ShouldCancelAnySearchOperation));
+                            //                foreach (var Value in t_data)
+                            //                {
+                            //                    string inner_message = string.Format(" -> Parsing value @ Address: 0x{0:x8}", address_index);
+                            //                    double inner_double_percent_done = 100.0 * (double)((double)address_index / (double)MemoryRangeSize);
+                            //                    int inner_int_percent_done = (int)inner_double_percent_done;
+                            //                    if ((address_index % 10000) == 0)
+                            //                    {
+                            //                        UpdateProgress(inner_int_percent_done, inner_message);
+                            //                        inner_Last_Whole_Percent_Done = inner_int_percent_done;
+                            //                    }
+                            //                    if (SearchWorkerThread.CancellationPending) { break; }
+                            //                    if (!reader_addresses.Contains(address_index))
+                            //                    {
+                            //                        address_index += STEP_SIZE;
+                            //                        continue;
+                            //                    }
+                            //                    using (_64bit_signed_comparer_ comparer = new _64bit_signed_comparer_(SearchArgs, address_index))
+                            //                    {
+                            //                        long value = 0;
+                            //                        if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
+                            //                        {
+                            //                            using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                            //                            {
+                            //                                try
+                            //                                {
+                            //                                    gmp.OpenProvider();
+                            //                                    gmp.ReadMemory(address_index, out value);
+                            //                                    gmp.CloseProvider();
+                            //                                }
+                            //                                catch (Exception ex)
+                            //                                {
+                            //                                    logger.VerboseError.WriteLine(ex.ToString());
+                            //                                }
+                            //                            }
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        else
+                            //                        {
+                            //                            value = Convert.ToInt64(SearchArgs.CompareStartValue);
+                            //                            comparer.Value = value;
+                            //                        }
+                            //                        if (comparer.Compare(Convert.ToInt64(Value), value))
+                            //                        {
+                            //                            writer.WriteResult<long>(comparer.Address, comparer.Value);
+                            //                        }
+                            //                    }
+                            //                    address_index += STEP_SIZE;
+                            //                }
+                            //                #endregion
+                            //            } break;
+                            //    }
+                            //    #endregion
+                            //    if (SearchWorkerThread.CancellationPending)
+                            //    {
+                            //        provider_st.Stop();
+                            //        st.Stop();
+                            //        writer.CancelRequest();
+                            //        writer.Dispose();
+                            //        e.Result = true;
+                            //        provider.CloseProvider();
+                            //        return;
+                            //    }
+                            //}
+                            #endregion
                         }
                         #endregion
 

 

  ViewVC Help
Powered by ViewVC 1.1.22