9 |
using WeifenLuo.WinFormsUI.Docking; |
using WeifenLuo.WinFormsUI.Docking; |
10 |
using RomCheater.PluginFramework.Interfaces; |
using RomCheater.PluginFramework.Interfaces; |
11 |
using System.Diagnostics; |
using System.Diagnostics; |
12 |
|
using System.IO; |
13 |
|
|
14 |
namespace RomCheater.Docking |
namespace RomCheater.Docking |
15 |
{ |
{ |
138 |
break; |
break; |
139 |
} |
} |
140 |
} |
} |
141 |
|
|
142 |
|
private void btnDumpRam_Click(object sender, EventArgs e) |
143 |
|
{ |
144 |
|
if (this.AcceptedProcess == null) |
145 |
|
{ |
146 |
|
MessageBox.Show("Please select a process to dump memory from", "", MessageBoxButtons.OK, MessageBoxIcon.Error); |
147 |
|
return; |
148 |
|
} |
149 |
|
DialogResult result = dumpsaver.ShowDialog(); |
150 |
|
if (result != DialogResult.OK) return; |
151 |
|
DumpRam(txtStart.Value, txtEnd.Value, dumpsaver.FileName); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
#region memory support |
156 |
|
private void DumpRam(ulong start, ulong end, string filename) |
157 |
|
{ |
158 |
|
uint byte_count = (uint)(end - start); |
159 |
|
DumpRam(start, byte_count, filename); |
160 |
|
} |
161 |
|
private void DumpRam(ulong start, uint count, string filename) |
162 |
|
{ |
163 |
|
if (this.AcceptedProcess == null) return; |
164 |
|
Sojaner.MemoryScanner.ProcessMemoryReader reader = new Sojaner.MemoryScanner.ProcessMemoryReader(); |
165 |
|
reader.ReadProcess = this.AcceptedProcess; |
166 |
|
reader.OpenProcess(); |
167 |
|
int bytesReadSize; |
168 |
|
byte[] data = reader.ReadProcessMemory((IntPtr)(uint)start, count, out bytesReadSize); |
169 |
|
reader.CloseHandle(); |
170 |
|
using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) |
171 |
|
{ |
172 |
|
BinaryWriter bw = new BinaryWriter(fs); |
173 |
|
foreach (byte b in data) { bw.Write(b); } |
174 |
|
bw.Flush(); |
175 |
|
bw.Close(); |
176 |
|
} |
177 |
|
} |
178 |
|
#endregion |
179 |
} |
} |
180 |
} |
} |