/[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 08:13:31	165
+++ trunk/RomCheater/Docking/FloatingRamDumperDialog.cs	2012/05/28 08:49:42	169
@@ -158,21 +158,23 @@
         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)
-            //{
+            string arch = ProcessorAssemblyArchitecture.GetProcessorArchitecture(typeof(FloatingRamDumperDialog).Assembly);
+            if (arch == ProcessorAssemblyArchitecture.x86)
+            {
+                // intptr is 4 bytes on 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
-            //}
-
+                    logger.Warn.WriteLine("Warning: DumpRam(): ending address is greater than 0x{0:x8} and we are running x86, this will exceed the max value for IntPtr", int.MaxValue);
+            }
+            else if (arch == ProcessorAssemblyArchitecture.x64)
+            {
+                // inptr is 8 bytes on x64
+                if (end > uint.MaxValue)
+                    logger.Warn.WriteLine("Warning: DumpRam(): ending address is greater than 0x{0:x8} and we are running x64, this will exceed the max value for UIntPtr", int.MaxValue);
+            }
+            else
+            {
+                throw new InvalidProgramException(string.Format("Unexcepted processor aritecture: expected x86 or x64 but we have: {0}", arch));
+            }
             DumpRam(start, byte_count, filename);
         }
         private void DumpRam(ulong start, uint count, string filename)
@@ -182,7 +184,14 @@
             reader.ReadProcess = this.AcceptedProcess;
             reader.OpenProcess();
             int bytesReadSize;
-            reader.DumpMemory(filename, (uint)start, count, out bytesReadSize);
+            if (reader.DumpMemory(this.AcceptedProcess,filename, (uint)start, count, out bytesReadSize))
+            {
+                MessageBox.Show(string.Format("Succefully dumped memory (0x{0:x8}-0x{1:x8}) from pid=({3}) to file {2}", start, start + count, filename, string.Format("0x{0:x4} {1}.exe", this.AcceptedProcess.Id, AcceptedProcess.ProcessName)), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
+            }
+            else
+            {
+                MessageBox.Show(string.Format("Failed to dump memory (0x{0:x8}-0x{1:x8}) from pid=({3}) to file {2}", start, start + count, filename, string.Format("0x{0:x4} {1}.exe", this.AcceptedProcess.Id, AcceptedProcess.ProcessName)), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
             reader.CloseHandle();            
         }
         #endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22