ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/FloatingRamDumperDialog.cs
(Generate patch)

Comparing trunk/RomCheater/Docking/FloatingRamDumperDialog.cs (file contents):
Revision 155 by william, Mon May 28 03:04:05 2012 UTC vs.
Revision 156 by william, Mon May 28 04:14:03 2012 UTC

--- trunk/RomCheater/Docking/FloatingRamDumperDialog.cs	2012/05/28 04:10:38	155
+++ trunk/RomCheater/Docking/FloatingRamDumperDialog.cs	2012/05/28 04:14:03	156
@@ -137,5 +137,36 @@ namespace RomCheater.Docking
                     break;
             }
         }
+
+        private void btnDumpRam_Click(object sender, EventArgs e)
+        {
+            if (this.AcceptedProcess == null)
+            {
+                MessageBox.Show("Please select a process to dump memory from", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return;
+            }
+            DialogResult result = dumpsaver.ShowDialog();
+            if (result != DialogResult.OK) return;
+            DumpRam(txtStart.Value, txtEnd.Value, dumpsaver.FileName);
+        }
+
+
+        #region memory support
+        private void DumpRam(ulong start, ulong end, string filename)
+        {
+            uint byte_count = (uint)(end - start);
+            DumpRam(start, byte_count, filename);
+        }
+        private void DumpRam(ulong start, uint count, string filename)
+        {
+            if (this.AcceptedProcess == null) return;
+            Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader();
+            reader.ReadProcess = this.AcceptedProcess;
+            reader.OpenProcess();
+            int bytesReadSize;
+            byte[] data = reader.ReadProcessMemory((IntPtr)(uint)start, count, out bytesReadSize);
+            reader.CloseHandle();
+        }
+        #endregion
     }
 }