--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs 2012/06/21 03:37:14 400 +++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs 2012/06/21 05:14:38 401 @@ -26,6 +26,7 @@ using RomCheater.PluginFramework.Events; using System.Reflection; using Sojaner.MemoryScanner; using System.Collections; +using RomCheater.Serialization; namespace RomCheater.Docking { @@ -82,7 +83,7 @@ namespace RomCheater.Docking #if FORCE_USE_OF_MEMORYSIZECONSTANTS // force use of MemorySizeConstants txtMemoryRangeStart.Value = MemorySizeConstants.MinimumSearchAddress; - unchecked { txtMemoryRangeSize.Value = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize; } + txtMemoryRangeSize.Value = MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize; #endif #if USE_AUTOMATIC_MEMORY_SEARCH_RANGE && !FORCE_USE_OF_MEMORYSIZECONSTANTS ////// code to automatically choose the best starting memory address and size @@ -148,7 +149,7 @@ namespace RomCheater.Docking get { #if FORCE_USE_OF_MEMORYSIZECONSTANTS - unchecked { return MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize; } + return MemorySizeConstants.MinimumSearchAddress + MemorySizeConstants.MaximumSearchSize; #else return _MemoryRangeSize; #endif @@ -1061,49 +1062,51 @@ namespace RomCheater.Docking if (SearchArgs.IsFirstSearch) { st_first_search.Start(); - SearchArgs.Results.Clear(); + //SearchArgs.Results.Clear(); r_ms.BaseStream.Seek(0, SeekOrigin.Begin); - //List<ResultType<object>> results_list = new List<ResultType<object>>(); - //for (uint i = 0; i < buffered_mem.Length; i += STEP_SIZE) - //{ - while (r_ms.BaseStream.Position < r_ms.BaseStream.Length) + using (SearchResultWriter writer = new SearchResultWriter((int)buffered_mem.Length / (int)STEP_SIZE)) { - using (ResultType<object> _tmp_result = new ResultType<object>()) + //List<ResultType<object>> results_list = new List<ResultType<object>>(); + //for (uint i = 0; i < buffered_mem.Length; i += STEP_SIZE) + //{ + #region while (r_ms.BaseStream.Position < r_ms.BaseStream.Length) + while (r_ms.BaseStream.Position < r_ms.BaseStream.Length) { + //using (ResultType<object> _tmp_result = new ResultType<object>()) + //{ switch (sdt) { case SearchDataTypes._8bits: - if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadByte(); } - else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadSByte(); } break; + if (unsigned) { writer.WriteResult<Byte>((uint)r_ms.BaseStream.Position, r_ms.ReadByte()); } + else { writer.WriteResult<SByte>((uint)r_ms.BaseStream.Position, r_ms.ReadSByte()); } break; case SearchDataTypes._16bits: - if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt16(); } - else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt16(); } break; + if (unsigned) { writer.WriteResult<UInt16>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt16()); } + else { writer.WriteResult<Int16>((uint)r_ms.BaseStream.Position, r_ms.ReadInt16()); } break; case SearchDataTypes._32bits: - if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt32(); } - else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt32(); } break; + if (unsigned) { writer.WriteResult<UInt32>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt32()); } + else { writer.WriteResult<Int32>((uint)r_ms.BaseStream.Position, r_ms.ReadInt32()); } break; case SearchDataTypes._64bits: - if (unsigned) { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadUInt64(); } - else { _tmp_result.Address = (uint)r_ms.BaseStream.Position; _tmp_result.Value = r_ms.ReadInt64(); } break; + if (unsigned) { writer.WriteResult<UInt64>((uint)r_ms.BaseStream.Position, r_ms.ReadUInt64()); } + else { writer.WriteResult<Int64>((uint)r_ms.BaseStream.Position, r_ms.ReadInt64()); } break; } //results_list.Add(_tmp_result); - SearchArgs.Results.Add(_tmp_result); - } - double double_percent_done = 100.0 * (double)((double)r_ms.BaseStream.Position / (double)r_ms.BaseStream.Length); - int int_percent_done = (int)double_percent_done; - if (int_percent_done != Last_Whole_Percent_Done && r_ms.BaseStream.Position % ElementsBeforeDisplay == 0) - { - resultsprogress.Value = int_percent_done; - resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", r_ms.BaseStream.Position + MemoryRangeStart); - Last_Whole_Percent_Done = int_percent_done; - //Application.DoEvents(); + //SearchArgs.Results.Add(_tmp_result); + double double_percent_done = 100.0 * (double)((double)r_ms.BaseStream.Position / (double)r_ms.BaseStream.Length); + int int_percent_done = (int)double_percent_done; + if (int_percent_done != Last_Whole_Percent_Done) + { + resultsprogress.Value = int_percent_done; + resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", (r_ms.BaseStream.Position + MemoryRangeStart)); + Last_Whole_Percent_Done = int_percent_done; + //Application.DoEvents(); + } } - if (SearchWorkerThread.CancellationPending == true) - { - e.Cancel = true; - return; - } - //Application.DoEvents(); + { + e.Cancel = true; + return; + } + #endregion } //} //SearchArgs.Results.AddRange(results_list); |