/[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 06:30:33	402
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/21 07:13:04	403
@@ -1146,9 +1146,29 @@
                             {
                                 for (int i = 0; i < reader.ResultCount; i += 1)
                                 {
+                                    if (reader.ReadCurrentAddess)
+                                    {
+                                        if (!reader.ReadCurrentValue)
+                                        {
+                                            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; }
-                                    r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
+                                    try
+                                    {
+                                        r_ms.BaseStream.Seek(address, SeekOrigin.Begin);
+                                    }
+                                    catch(Exception)
+                                    {
+                                        throw;
+                                    }
                                     switch (SearchArgs.DataType)
                                     {
                                         #region Comparer Support
@@ -1248,7 +1268,7 @@
                                         case SearchDataTypes._32bits:
                                             if (SearchArgs.IsUnsignedDataType)
                                             {
-                                                uint lookup_value = reader.CurrentResult<uint>();
+                                                uint lookup_value = r_ms.ReadUInt32();
                                                 _32bit_unsigned_comparer_ comparer = new _32bit_unsigned_comparer_(SearchArgs, address);
                                                 uint value = 0;
                                                 if (SearchArgs.CompareValueType == CompareValueTypes.OldValue)
@@ -1418,31 +1438,28 @@
                     if (NeedToCompare)
                     {
                         // fix addresses when memory start is not zero
-                        if (MemoryRangeStart > 0 && SearchArgs.IsFirstSearch)
+                        if (MemoryRangeStart > 0 && SearchArgs.IsFirstSearch) { for (int i = 0; i < second_tmp_Results.Count; i++) { second_tmp_Results[i].Address = second_tmp_Results[i].Address + MemoryRangeStart; } }
+                        using (SearchResultWriter writer = new SearchResultWriter(second_tmp_Results.Count))
                         {
-                            using (SearchResultWriter writer = new SearchResultWriter(second_tmp_Results.Count))
+                            for (int i = 0; i < second_tmp_Results.Count; i++)
                             {
-                                for (int i = 0; i < second_tmp_Results.Count; i++)
+                                switch (sdt)
                                 {
-                                    second_tmp_Results[i].Address = second_tmp_Results[i].Address + MemoryRangeStart;
-                                    switch (sdt)
-                                    {
-                                        case SearchDataTypes._8bits:
-                                            if (unsigned) { writer.WriteResult<Byte>((uint)i, Convert.ToByte(second_tmp_Results[i].Value)); }
-                                            else { writer.WriteResult<SByte>((uint)i, Convert.ToSByte(second_tmp_Results[i].Value)); } break;
-                                        case SearchDataTypes._16bits:
-                                            if (unsigned) { writer.WriteResult<UInt16>((uint)i, Convert.ToUInt16(second_tmp_Results[i].Value)); }
-                                            else { writer.WriteResult<Int16>((uint)i, Convert.ToInt16(second_tmp_Results[i].Value)); } break;
-                                        case SearchDataTypes._32bits:
-                                            if (unsigned) { writer.WriteResult<UInt32>((uint)i, Convert.ToUInt32(second_tmp_Results[i].Value)); }
-                                            else { writer.WriteResult<Int32>((uint)i,Convert.ToInt32(second_tmp_Results[i].Value)); } break;
-                                        case SearchDataTypes._64bits:
-                                            if (unsigned) { writer.WriteResult<UInt64>((uint)i, Convert.ToUInt64(second_tmp_Results[i].Value)); }
-                                            else { writer.WriteResult<Int64>((uint)i, Convert.ToInt64(second_tmp_Results[i].Value)); } break;
-                                    }
+                                    case SearchDataTypes._8bits:
+                                        if (unsigned) { writer.WriteResult<Byte>(second_tmp_Results[i].Address, Convert.ToByte(second_tmp_Results[i].Value)); }
+                                        else { writer.WriteResult<SByte>(second_tmp_Results[i].Address, Convert.ToSByte(second_tmp_Results[i].Value)); } break;
+                                    case SearchDataTypes._16bits:
+                                        if (unsigned) { writer.WriteResult<UInt16>(second_tmp_Results[i].Address, Convert.ToUInt16(second_tmp_Results[i].Value)); }
+                                        else { writer.WriteResult<Int16>(second_tmp_Results[i].Address, Convert.ToInt16(second_tmp_Results[i].Value)); } break;
+                                    case SearchDataTypes._32bits:
+                                        if (unsigned) { writer.WriteResult<UInt32>(second_tmp_Results[i].Address, Convert.ToUInt32(second_tmp_Results[i].Value)); }
+                                        else { writer.WriteResult<Int32>(second_tmp_Results[i].Address, Convert.ToInt32(second_tmp_Results[i].Value)); } break;
+                                    case SearchDataTypes._64bits:
+                                        if (unsigned) { writer.WriteResult<UInt64>(second_tmp_Results[i].Address, Convert.ToUInt64(second_tmp_Results[i].Value)); }
+                                        else { writer.WriteResult<Int64>(second_tmp_Results[i].Address, Convert.ToInt64(second_tmp_Results[i].Value)); } break;
                                 }
                             }
-                        }
+                        }                      
                         second_tmp_Results = null; // free memory                       
                     }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22