/[RomCheater]/trunk/RomCheater/Docking/FloatingRamDumperDialog.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingRamDumperDialog.cs

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

--- trunk/RomCheater/Docking/FloatingRamDumperDialog.cs	2012/05/28 07:22:19	163
+++ trunk/RomCheater/Docking/FloatingRamDumperDialog.cs	2012/05/28 07:49:48	164
@@ -10,6 +10,8 @@
 using RomCheater.PluginFramework.Interfaces;
 using System.Diagnostics;
 using System.IO;
+using RomCheater.Logging;
+using System.Reflection;
 
 namespace RomCheater.Docking
 {
@@ -156,6 +158,21 @@
         private void DumpRam(ulong start, ulong end, string filename)
         {
             uint byte_count = (uint)(end - start);
+
+            //string arch = ProcessorAssemblyArchitecture.GetProcessorArchitecture(typeof(FloatingRamDumperDialog).Assembly);
+            //if (arch == ProcessorAssemblyArchitecture.x86)
+            //{
+                if (end > int.MaxValue)
+                    logger.Warn.WriteLine("Warning: DumpRam(): ending address is greater than 0x{0:x8} and we are running x86, this will exceed the ", int.MaxValue);                
+            //}
+            //else if (arch == ProcessorAssemblyArchitecture.x64)
+            //{
+            //}
+            //else
+            //{
+            //    // don't know
+            //}
+
             DumpRam(start, byte_count, filename);
         }
         private void DumpRam(ulong start, uint count, string filename)
@@ -165,15 +182,8 @@
             reader.ReadProcess = this.AcceptedProcess;
             reader.OpenProcess();
             int bytesReadSize;
-            byte[] data = reader.ReadProcessMemory((IntPtr)(uint)start, count, out bytesReadSize);
-            reader.CloseHandle();
-            using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
-            {
-                BinaryWriter bw = new BinaryWriter(fs);
-                foreach (byte b in data) { bw.Write(b); }
-                bw.Flush();
-                bw.Close();
-            }
+            reader.DumpMemory(filename, (uint)start, count, out bytesReadSize);
+            reader.CloseHandle();            
         }
         #endregion
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22