/[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/03 21:30:41	490
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/04 17:33:28	496
@@ -1815,67 +1815,152 @@
                     }
                     else
                     {
+                       
+
                         // need to get the address list
                         using (SearchResultReader reader = new SearchResultReader(SearchGuid, true)) // delete the file on dispose
                         {
-                            byte[] guid = SearchGuid.ToByteArray();
-                            guid[guid.Length - 1]++; // increment the search guid by 1
-                            Guid new_SearchGuid = new Guid(guid);
-                            //const int item_count = 0x100;
-                            using (SearchResultWriter writer = new SearchResultWriter((int)(reader.ResultCount), new_SearchGuid))
+                            #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)
                             {
-                                var items = reader.GetSearchAddressValueMatches((IAcceptsProcessAndConfig)this, SearchArgs, new Action<int, string>(UpdateProgress));
+                                SearchDataTypes obre_sdt = SearchArgs.DataType;
+                                bool obre_unsigned = SearchArgs.IsUnsignedDataType;
+                                uint obre_CurrentIndex = obre.CurrentIndex; // this should represent the address
 
-                                reader.Dispose(); // delete the result file, if allowed
+                                
 
-                                foreach (var item in items)
+                                using (MemoryStream ms = new MemoryStream(obre.Data))
                                 {
-                                    switch (SearchArgs.DataType)
+                                    using (BinaryReader br = new BinaryReader(ms))
                                     {
-                                        case SearchDataTypes._8bits:
-                                            if (SearchArgs.IsUnsignedDataType)
-                                            {
-                                                writer.WriteResult<byte>(item.Address, Convert.ToByte(item.Value));
-                                            }
-                                            else
-                                            {
-                                                writer.WriteResult<sbyte>(item.Address, Convert.ToSByte(item.Value));
-                                            }
-                                            break;
-                                        case SearchDataTypes._16bits:
-                                            if (SearchArgs.IsUnsignedDataType)
-                                            {
-                                                writer.WriteResult<ushort>(item.Address, Convert.ToUInt16(item.Value));
-                                            }
-                                            else
-                                            {
-                                                writer.WriteResult<short>(item.Address, Convert.ToInt16(item.Value));
-                                            }
-                                            break;
-                                        case SearchDataTypes._32bits:
-                                            if (SearchArgs.IsUnsignedDataType)
-                                            {
-                                                writer.WriteResult<uint>(item.Address, Convert.ToUInt32(item.Value));
+                                        while (br.BaseStream.Position < br.BaseStream.Length)
+                                        {
+                                            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))
+                                                            {
+                                                                //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;
                                             }
-                                            else
-                                            {
-                                                writer.WriteResult<int>(item.Address, Convert.ToInt32(item.Value));
-                                            }
-                                            break;
-                                        case SearchDataTypes._64bits:
-                                            if (SearchArgs.IsUnsignedDataType)
-                                            {
-                                                writer.WriteResult<ulong>(item.Address, Convert.ToUInt64(item.Value));
-                                            }
-                                            else
-                                            {
-                                                writer.WriteResult<long>(item.Address, Convert.ToInt64(item.Value));
-                                            }
-                                            break;
+                                        }
                                     }
                                 }
+                            };
+                            #endregion
+
+                            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);
+                            if (SearchWorkerThread.CancellationPending)
+                            {
+                                provider_st.Stop();
+                                st.Stop();           
+                                e.Result = true;
+                                provider.CloseProvider();
+                                return;
                             }
-                            SearchGuid = new_SearchGuid;
+                            provider.CloseProvider();
+
+                        //byte[] guid = SearchGuid.ToByteArray();
+                        //guid[guid.Length - 1]++; // increment the search guid by 1
+                        //Guid new_SearchGuid = new Guid(guid);
+                        ////const int item_count = 0x100;
+                        //using (SearchResultWriter writer = new SearchResultWriter((int)(reader.ResultCount), new_SearchGuid))
+                        //{
+                        //    var items = reader.GetSearchAddressValueMatches((IAcceptsProcessAndConfig)this, SearchArgs, new Action<int, string>(UpdateProgress));
+                        //    reader.Dispose(); // delete the result file, if allowed
+                        //    foreach (var item in items)
+                        //    {
+                        //        switch (SearchArgs.DataType)
+                        //        {
+                        //            case SearchDataTypes._8bits:
+                        //                if (SearchArgs.IsUnsignedDataType)
+                        //                {
+                        //                    writer.WriteResult<byte>(item.Address, Convert.ToByte(item.Value));
+                        //                }
+                        //                else
+                        //                {
+                        //                    writer.WriteResult<sbyte>(item.Address, Convert.ToSByte(item.Value));
+                        //                }
+                        //                break;
+                        //            case SearchDataTypes._16bits:
+                        //                if (SearchArgs.IsUnsignedDataType)
+                        //                {
+                        //                    writer.WriteResult<ushort>(item.Address, Convert.ToUInt16(item.Value));
+                        //                }
+                        //                else
+                        //                {
+                        //                    writer.WriteResult<short>(item.Address, Convert.ToInt16(item.Value));
+                        //                }
+                        //                break;
+                        //            case SearchDataTypes._32bits:
+                        //                if (SearchArgs.IsUnsignedDataType)
+                        //                {
+                        //                    writer.WriteResult<uint>(item.Address, Convert.ToUInt32(item.Value));
+                        //                }
+                        //                else
+                        //                {
+                        //                    writer.WriteResult<int>(item.Address, Convert.ToInt32(item.Value));
+                        //                }
+                        //                break;
+                        //            case SearchDataTypes._64bits:
+                        //                if (SearchArgs.IsUnsignedDataType)
+                        //                {
+                        //                    writer.WriteResult<ulong>(item.Address, Convert.ToUInt64(item.Value));
+                        //                }
+                        //                else
+                        //                {
+                        //                    writer.WriteResult<long>(item.Address, Convert.ToInt64(item.Value));
+                        //                }
+                        //                break;
+                        //        }
+                        //    }
+                        //}
+                        //SearchGuid = new_SearchGuid;
                         }
                     }
                 }

 

  ViewVC Help
Powered by ViewVC 1.1.22