/[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/04 20:15:03	504
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/04 20:19:31	505
@@ -1803,120 +1803,113 @@
                     }
                     else
                     {
-                       
 
-                        // need to get the address list
-                        using (SearchResultReader reader = new SearchResultReader(SearchGuid, false)) // delete the file on dispose
+                        #region action_onbytesread :: custom in-line delegate for processing read bytes
+                        // custom in-line delegate for processing read bytes
+                        Action<OnBytesReadEventArgs> action_onbytesread = delegate(OnBytesReadEventArgs obre)
                         {
-                            #region action_onbytesread :: custom in-line delegate for processing read bytes
-                            // custom in-line delegate for processing read bytes
-                            Action<OnBytesReadEventArgs> action_onbytesread = delegate(OnBytesReadEventArgs obre)
+                            SearchDataTypes obre_sdt = SearchArgs.DataType;
+                            bool obre_unsigned = SearchArgs.IsUnsignedDataType;
+                            uint obre_CurrentIndex = obre.CurrentIndex; // this should represent the address
+                            SearchResultReader reader = null;
+                            if (obre.UserState != null)
                             {
-                                SearchDataTypes obre_sdt = SearchArgs.DataType;
-                                bool obre_unsigned = SearchArgs.IsUnsignedDataType;
-                                uint obre_CurrentIndex = obre.CurrentIndex; // this should represent the address
-
-
-
-                                ISerializedResult sr = (reader as ISerializedResult);
-                                if (sr == null)
-                                {
-                                    throw new ArgumentNullException("sr", string.Format("Unable to cast: '{0}' to '{1}'", reader.GetType().Name, typeof(ISerializedResult).Name));
-                                }
-                                int sr_index = 0;
-                                if (sr.ContainsAddress(obre_CurrentIndex, obre_unsigned, obre_sdt, new Action<int, string>(this.UpdateProgress), out sr_index))
-                                {
-                                    StructResultType<ulong> result = StructResultType<ulong>.Empty;
-                                    sr.GetResultAtAddress(obre_CurrentIndex, obre_unsigned, obre_sdt, new Action<int, string>(this.UpdateProgress), out result);
-                                    if (Debugger.IsAttached)
-                                    {
-                                        Debugger.Break();
-                                    }
-                                    
-                                }
-
-                                //// walk through each address in the reader
-                                //foreach (var k in reader.GetResults(obre_unsigned, obre_sdt, new Action<int, string>(this.UpdateProgress)))
-                                //{
-                                //    if (obre_CurrentIndex == k.Address)
-                                //    {
-                                //        if (Debugger.IsAttached)
-                                //        {
-                                //            Debugger.Break();
-                                //        }
-                                //    }
-                                //}
-                                
-                                
-
-                                using (MemoryStream ms = new MemoryStream(obre.Data))
+                                reader = (obre.UserState as SearchResultReader);
+                                if (reader == null)
+                                    throw new InvalidOperationException("writer cannot be null");
+                            }
+                            else
+                            {
+                                throw new ArgumentNullException("UserState", "UserState cannot be null, it must be an instance of a SearchResultReader");
+                            }
+                            using (MemoryStream ms = new MemoryStream(obre.Data))
+                            {
+                                using (BinaryReader br = new BinaryReader(ms))
                                 {
-                                    using (BinaryReader br = new BinaryReader(ms))
+                                    while (br.BaseStream.Position < br.BaseStream.Length)
                                     {
-                                        while (br.BaseStream.Position < br.BaseStream.Length)
+                                        ISerializedResult sr = (reader as ISerializedResult);
+                                        if (sr == null)
                                         {
-                                            switch (obre_sdt)
+                                            throw new ArgumentNullException("sr", string.Format("Unable to cast: '{0}' to '{1}'", reader.GetType().Name, typeof(ISerializedResult).Name));
+                                        }
+                                        int sr_index = 0;
+                                        if (sr.ContainsAddress(obre_CurrentIndex, obre_unsigned, obre_sdt, new Action<int, string>(this.UpdateProgress), out sr_index))
+                                        {
+                                            StructResultType<ulong> result = StructResultType<ulong>.Empty;
+                                            sr.GetResultAtAddress(obre_CurrentIndex, obre_unsigned, obre_sdt, new Action<int, string>(this.UpdateProgress), out result);
+                                            if (Debugger.IsAttached)
                                             {
-                                                case SearchDataTypes._8bits:
-                                                    if (obre_unsigned)
-                                                    {
-                                                        #region 8bit - unsigned
-                                                        var new_value = br.ReadByte(); // this should contain the updated value from memory
-                                                        using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, obre_CurrentIndex))
+                                                Debugger.Break();
+                                            }
+
+                                        }
+                                        switch (obre_sdt)
+                                        {
+                                            case SearchDataTypes._8bits:
+                                                if (obre_unsigned)
+                                                {
+                                                    #region 8bit - unsigned
+                                                    var new_value = br.ReadByte(); // this should contain the updated value from memory
+                                                    using (_8bit_unsigned_comparer_ comparer = new _8bit_unsigned_comparer_(SearchArgs, obre_CurrentIndex))
+                                                    {
+                                                        byte value = 0; // this is the vaule we want to compare against
+                                                        value = Convert.ToByte(SearchArgs.CompareStartValue);
+                                                        comparer.Value = value;
+                                                        if (comparer.Compare(new_value, value))
                                                         {
-                                                            byte value = 0; // this is the vaule we want to compare against
-                                                            value = Convert.ToByte(SearchArgs.CompareStartValue);
-                                                            comparer.Value = value;
-                                                            if (comparer.Compare(new_value, value))
-                                                            {
-                                                                //writer.WriteResult<byte>(comparer.Address, comparer.Value);
-                                                            }
+                                                            //writer.WriteResult<byte>(comparer.Address, comparer.Value);
                                                         }
-                                                        #endregion
-                                                    }
-                                                    else
-                                                    {
-                                                    }
-                                                    break;
-                                                case SearchDataTypes._16bits:
-                                                    if (obre_unsigned)
-                                                    {
-                                                    }
-                                                    else
-                                                    {
-                                                    }
-                                                    break;
-                                                case SearchDataTypes._32bits:
-                                                    if (obre_unsigned)
-                                                    {
                                                     }
-                                                    else
-                                                    {
-                                                    }
-                                                    break;
-                                                case SearchDataTypes._64bits:
-                                                    if (obre_unsigned)
-                                                    {
-                                                    }
-                                                    else
-                                                    {
-                                                    }
-                                                    break;
-                                            }
-                                            uint size = 0;
-                                            BitTools.SizeOf(obre_sdt, out size);
-                                            obre_CurrentIndex += size;
+                                                    #endregion
+                                                }
+                                                else
+                                                {
+                                                }
+                                                break;
+                                            case SearchDataTypes._16bits:
+                                                if (obre_unsigned)
+                                                {
+                                                }
+                                                else
+                                                {
+                                                }
+                                                break;
+                                            case SearchDataTypes._32bits:
+                                                if (obre_unsigned)
+                                                {
+                                                }
+                                                else
+                                                {
+                                                }
+                                                break;
+                                            case SearchDataTypes._64bits:
+                                                if (obre_unsigned)
+                                                {
+                                                }
+                                                else
+                                                {
+                                                }
+                                                break;
                                         }
+                                        uint size = 0;
+                                        BitTools.SizeOf(obre_sdt, out size);
+                                        obre_CurrentIndex += size;
                                     }
                                 }
-                            };
-                            #endregion
+                            }
+                        };
+                        #endregion
+                        // need to get the address list
+                        using (SearchResultReader reader = new SearchResultReader(SearchGuid, true)) // delete the file on dispose
+                        {
+                           
 
                             provider.OpenProvider();
                             //int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
                             //SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);
                             provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(action_onbytesread);
-                            provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), null);
+                            provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), reader);
                             if (SearchWorkerThread.CancellationPending)
                             {
                                 provider_st.Stop();

 

  ViewVC Help
Powered by ViewVC 1.1.22