|
4 | 4 |
|
5 | 5 | namespace ReClassNET.Memory |
6 | 6 | { |
7 | | - public class Dumper |
| 7 | + public static class Dumper |
8 | 8 | { |
9 | | - private readonly IRemoteMemoryReader process; |
10 | | - |
11 | | - public Dumper(IRemoteMemoryReader process) |
12 | | - { |
13 | | - Contract.Requires(process != null); |
14 | | - Contract.Ensures(this.process != null); |
15 | | - |
16 | | - this.process = process; |
17 | | - } |
18 | | - |
19 | 9 | /// <summary>Dumps a chunk of memory to the given stream.</summary> |
| 10 | + /// <param name="reader">The memory reader to use.</param> |
20 | 11 | /// <param name="address">The begin of the chunk.</param> |
21 | 12 | /// <param name="size">The size of the chunk.</param> |
22 | 13 | /// <param name="stream">The stream to dump to.</param> |
23 | | - public void DumpRaw(IntPtr address, int size, Stream stream) |
| 14 | + public static void DumpRaw(IRemoteMemoryReader reader, IntPtr address, int size, Stream stream) |
24 | 15 | { |
25 | 16 | Contract.Requires(size >= 0); |
26 | 17 | Contract.Requires(stream != null); |
27 | 18 |
|
28 | | - var data = process.ReadRemoteMemory(address, size); |
| 19 | + var data = reader.ReadRemoteMemory(address, size); |
29 | 20 |
|
30 | 21 | stream.Write(data, 0, data.Length); |
31 | 22 | } |
32 | 23 |
|
33 | 24 | /// <summary>Dumps a section to the given stream.</summary> |
| 25 | + /// <param name="reader">The memory reader to use.</param> |
34 | 26 | /// <param name="section">The section to dump.</param> |
35 | 27 | /// <param name="stream">The stream to dump to.</param> |
36 | | - public void DumpSection(Section section, Stream stream) |
| 28 | + public static void DumpSection(IRemoteMemoryReader reader, Section section, Stream stream) |
37 | 29 | { |
38 | 30 | Contract.Requires(section != null); |
39 | 31 | Contract.Requires(stream != null); |
40 | 32 |
|
41 | | - DumpRaw(section.Start, section.Size.ToInt32(), stream); |
| 33 | + DumpRaw(reader, section.Start, section.Size.ToInt32(), stream); |
42 | 34 | } |
43 | 35 |
|
44 | 36 | /// <summary>Dumps a module to the given stream. The section headers of the pe header get fixed to build a valid pe file.</summary> |
| 37 | + /// <param name="reader">The memory reader to use.</param> |
45 | 38 | /// <param name="module">The module to dump.</param> |
46 | 39 | /// <param name="stream">The stream to dump to.</param> |
47 | | - public void DumpModule(Module module, Stream stream) |
| 40 | + public static void DumpModule(IRemoteMemoryReader reader, Module module, Stream stream) |
48 | 41 | { |
49 | 42 | Contract.Requires(module != null); |
50 | 43 | Contract.Requires(stream != null); |
51 | 44 |
|
52 | | - var data = process.ReadRemoteMemory(module.Start, module.Size.ToInt32()); |
| 45 | + var data = reader.ReadRemoteMemory(module.Start, module.Size.ToInt32()); |
53 | 46 |
|
54 | 47 | SimplePeHeader.FixSectionHeaders(data); |
55 | 48 |
|
|
0 commit comments