/[RomCheater]/trunk/RomCheater/Docking/UI/UIMemoryViewer.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/UI/UIMemoryViewer.cs

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

--- trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/06/20 11:18:56	397
+++ trunk/RomCheater/Docking/UI/UIMemoryViewer.cs	2012/06/20 12:16:34	398
@@ -265,24 +265,13 @@
             byte[] data = new byte[max_ram_view];
             try
             {
-                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
-                provider.OpenProvider();
-                int bytesReadSize;
-                provider.ReadProcessMemory(CURRENT_TOP_ADDR, (uint)max_ram_view, out bytesReadSize, out data);
-                try
+                using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
                 {
+                    provider.OpenProvider();
+                    int bytesReadSize;
+                    provider.ReadProcessMemory(CURRENT_TOP_ADDR, (uint)max_ram_view, out bytesReadSize, out data);
                     provider.CloseProvider();
                 }
-                catch (SEHException ex)
-                {
-                    logger.Error.WriteLine("UIMemoryViewer.GetMemory(): SEHException: (0x{0:x8} {1}", ex.ErrorCode, ex.Message);
-                    logger.Error.WriteLine(ex.ToString());
-                }
-                catch (Exception ex)
-                {
-                    logger.Error.WriteLine("UIMemoryViewer.GetMemory(): Exception: {0}", ex.Message);
-                    logger.Error.WriteLine(ex.ToString());
-                }
             }
             catch (Exception ex)
             {
@@ -332,11 +321,13 @@
                                 char c = (char)data[current_addr];
                                 if (char.IsControl(c)) { ascii_value = '.'; }
                                 else { ascii_value = c; }
-                                GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
-                                gmp.OpenProvider();
-                                byte t;
-                                if (!gmp.ReadMemory(current_real_address, out t)) { ascii_value = '?'; }
-                                gmp.CloseProvider();
+                                using (GenericMemoryProvider gmp = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                                {
+                                    gmp.OpenProvider();
+                                    byte t;
+                                    if (!gmp.ReadMemory(current_real_address, out t)) { ascii_value = '?'; }
+                                    gmp.CloseProvider();
+                                }
                                 builder.Append(ascii_value.ToString());
                             }
                             builder.AppendLine();
@@ -371,18 +362,20 @@
                 if (AcceptedPlugin == null) { return; }
                 // Byte changed
                 //byte[] data = (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray();
-                GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
-                provider.OpenProvider();
-                uint bytesReadSize;
+                using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
+                {
+                    provider.OpenProvider();
+                    uint bytesReadSize;
 
-                provider.WriteProcessMemory(start_address, data, out bytesReadSize);
-                //for (int i = 0; i < data.Length; i ++)
-                //{
-                //    int addr = (int)(start_address + i);
-                //    byte data_to_write = data[i];
+                    provider.WriteProcessMemory(start_address, data, out bytesReadSize);
+                    //for (int i = 0; i < data.Length; i ++)
+                    //{
+                    //    int addr = (int)(start_address + i);
+                    //    byte data_to_write = data[i];
 
-                //}
-                provider.CloseProvider();
+                    //}
+                    provider.CloseProvider();
+                }
             }
             catch (Exception ex) { logger.Error.WriteLine("{0}.WriteCurrentBytes():{1}{2}", this.GetType().Name, System.Environment.NewLine, ex.ToString()); }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22