/[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

revision 168 by william, Mon May 28 08:32:18 2012 UTC revision 196 by william, Thu May 31 05:52:41 2012 UTC
# Line 15  using System.Reflection; Line 15  using System.Reflection;
15    
16  namespace RomCheater.Docking  namespace RomCheater.Docking
17  {  {
18      public partial class FloatingRamDumperDialog : DockContent, IProcessConfig      public partial class FloatingRamDumperDialog : DockContent, IProcessConfig, IAcceptsPlugin<IConfigPlugin>
19      {      {
20          #region sub-classes          #region sub-classes
21          private const int BYTE_CORRECTION_VALUE = 23;          private const int BYTE_CORRECTION_VALUE = 23;
# Line 40  namespace RomCheater.Docking Line 40  namespace RomCheater.Docking
40          }          }
41    
42    
43          #region IProcessConfig Members'          #region IProcessConfig Members
44          public Process AcceptedProcess { get; set; }          public Process AcceptedProcess { get; set; }
45          #endregion          #endregion
46          #region IAcceptsPlugin<IConfigPlugin> Members          #region IAcceptsPlugin<IConfigPlugin> Members
47          public IConfigPlugin AcceptedPlugin { get; set; }          public IConfigPlugin AcceptedPlugin { get; set; }
48          #endregion          #endregion
49            #region ram-dump specific
50          private void radioBTNBytes_CheckedChanged(object sender, EventArgs e)          private void radioBTNBytes_CheckedChanged(object sender, EventArgs e) { dumpSize = DumpSize.Bytes; }
51          {          private void radioBTNKiloBytes_CheckedChanged(object sender, EventArgs e) { dumpSize = DumpSize.KiloBytes; }
52              dumpSize = DumpSize.Bytes;          private void radioBTNMegaBytes_CheckedChanged(object sender, EventArgs e) { dumpSize = DumpSize.MegaBytes; }
53          }          private void radioBTNGigaBytes_CheckedChanged(object sender, EventArgs e) { dumpSize = DumpSize.GigaBytes; }
   
         private void radioBTNKiloBytes_CheckedChanged(object sender, EventArgs e)  
         {  
             dumpSize = DumpSize.KiloBytes;  
         }  
   
         private void radioBTNMegaBytes_CheckedChanged(object sender, EventArgs e)  
         {  
             dumpSize = DumpSize.MegaBytes;  
         }  
   
         private void radioBTNGigaBytes_CheckedChanged(object sender, EventArgs e)  
         {  
             dumpSize = DumpSize.GigaBytes;  
         }  
   
54          private void btnCalcEndAddr_Click(object sender, EventArgs e)          private void btnCalcEndAddr_Click(object sender, EventArgs e)
55          {          {
56              ulong start = 0;              ulong start = 0;
# Line 92  namespace RomCheater.Docking Line 76  namespace RomCheater.Docking
76                      break;                      break;
77              }              }
78          }          }
   
79          private void btnCalcStartAddr_Click(object sender, EventArgs e)          private void btnCalcStartAddr_Click(object sender, EventArgs e)
80          {          {
81              long start = 0;              long start = 0;
# Line 102  namespace RomCheater.Docking Line 85  namespace RomCheater.Docking
85              {              {
86                  case DumpSize.Bytes:                  case DumpSize.Bytes:
87                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1.0)) + BYTE_CORRECTION_VALUE;                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1.0)) + BYTE_CORRECTION_VALUE;
88                      txtStart.Value = (ulong)start;;                      txtStart.Value = (ulong)start; ;
89                      break;                      break;
90                  case DumpSize.KiloBytes:                  case DumpSize.KiloBytes:
91                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000.0)) + BYTE_CORRECTION_VALUE;                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000.0)) + BYTE_CORRECTION_VALUE;
92                      txtStart.Value = (ulong)start;;                      txtStart.Value = (ulong)start; ;
93                      break;                      break;
94                  case DumpSize.MegaBytes:                  case DumpSize.MegaBytes:
95                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000.0)) + BYTE_CORRECTION_VALUE;                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000.0)) + BYTE_CORRECTION_VALUE;
96                      txtStart.Value = (ulong)start;;                      txtStart.Value = (ulong)start; ;
97                      break;                      break;
98                  case DumpSize.GigaBytes:                  case DumpSize.GigaBytes:
99                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000000.0)) + BYTE_CORRECTION_VALUE;                      start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000000.0)) + BYTE_CORRECTION_VALUE;
# Line 118  namespace RomCheater.Docking Line 101  namespace RomCheater.Docking
101                      break;                      break;
102              }              }
103          }          }
   
104          private void btnCalcDumpSize_Click(object sender, EventArgs e)          private void btnCalcDumpSize_Click(object sender, EventArgs e)
105          {          {
106              ulong start = txtStart.Value;              ulong start = txtStart.Value;
# Line 140  namespace RomCheater.Docking Line 122  namespace RomCheater.Docking
122                      break;                      break;
123              }              }
124          }          }
   
125          private void btnDumpRam_Click(object sender, EventArgs e)          private void btnDumpRam_Click(object sender, EventArgs e)
126          {          {
127              if (this.AcceptedProcess == null)              if (this.AcceptedProcess == null)
# Line 152  namespace RomCheater.Docking Line 133  namespace RomCheater.Docking
133              if (result != DialogResult.OK) return;              if (result != DialogResult.OK) return;
134              DumpRam(txtStart.Value, txtEnd.Value, dumpsaver.FileName);              DumpRam(txtStart.Value, txtEnd.Value, dumpsaver.FileName);
135          }          }
136            #endregion
137    
138          #region memory support          #region memory support
139          private void DumpRam(ulong start, ulong end, string filename)          private void DumpRam(ulong start, ulong end, string filename)
# Line 184  namespace RomCheater.Docking Line 165  namespace RomCheater.Docking
165              reader.ReadProcess = this.AcceptedProcess;              reader.ReadProcess = this.AcceptedProcess;
166              reader.OpenProcess();              reader.OpenProcess();
167              int bytesReadSize;              int bytesReadSize;
168              reader.DumpMemory(filename, (uint)start, count, out bytesReadSize);              if (reader.DumpMemory(this.AcceptedProcess,filename, (uint)start, count, out bytesReadSize))
169                {
170                    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);
171                }
172                else
173                {
174                    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);
175                }
176              reader.CloseHandle();                          reader.CloseHandle();            
177          }          }
178          #endregion          #endregion

Legend:
Removed from v.168  
changed lines
  Added in v.196

  ViewVC Help
Powered by ViewVC 1.1.22