Skip to content

Commit c4851e4

Browse files
committed
Made methods static.
1 parent 6ff0b3b commit c4851e4

2 files changed

Lines changed: 16 additions & 25 deletions

File tree

ReClass.NET/Forms/ProcessInfoForm.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void createClassAtAddressToolStripMenuItem_Click(object sender, EventArg
142142
private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
143143
{
144144
Func<SaveFileDialog> createDialogFn;
145-
Action<Dumper, Stream> dumpFn;
145+
Action<IRemoteMemoryReader, Stream> dumpFn;
146146

147147
if (GetToolStripSourceControl(sender) == modulesDataGridView)
148148
{
@@ -158,9 +158,9 @@ private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
158158
InitialDirectory = Path.GetDirectoryName(module.Path)
159159
};
160160

161-
dumpFn = (d, s) =>
161+
dumpFn = (reader, stream) =>
162162
{
163-
d.DumpModule(module, s);
163+
Dumper.DumpModule(reader, module, stream);
164164

165165
MessageBox.Show("Module successfully dumped.", Constants.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
166166
};
@@ -178,9 +178,9 @@ private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
178178
FileName = $"Section_{section.Start.ToString("X")}_{section.End.ToString("X")}.dat"
179179
};
180180

181-
dumpFn = (d, s) =>
181+
dumpFn = (reader, stream) =>
182182
{
183-
d.DumpSection(section, s);
183+
Dumper.DumpSection(reader, section, stream);
184184

185185
MessageBox.Show("Section successfully dumped.", Constants.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
186186
};
@@ -195,13 +195,11 @@ private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
195195
return;
196196
}
197197

198-
var dumper = new Dumper(process);
199-
200198
try
201199
{
202200
using (var stream = sfd.OpenFile())
203201
{
204-
dumpFn(dumper, stream);
202+
dumpFn(process, stream);
205203
}
206204
}
207205
catch (Exception ex)

ReClass.NET/Memory/Dumper.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,45 @@
44

55
namespace ReClassNET.Memory
66
{
7-
public class Dumper
7+
public static class Dumper
88
{
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-
199
/// <summary>Dumps a chunk of memory to the given stream.</summary>
10+
/// <param name="reader">The memory reader to use.</param>
2011
/// <param name="address">The begin of the chunk.</param>
2112
/// <param name="size">The size of the chunk.</param>
2213
/// <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)
2415
{
2516
Contract.Requires(size >= 0);
2617
Contract.Requires(stream != null);
2718

28-
var data = process.ReadRemoteMemory(address, size);
19+
var data = reader.ReadRemoteMemory(address, size);
2920

3021
stream.Write(data, 0, data.Length);
3122
}
3223

3324
/// <summary>Dumps a section to the given stream.</summary>
25+
/// <param name="reader">The memory reader to use.</param>
3426
/// <param name="section">The section to dump.</param>
3527
/// <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)
3729
{
3830
Contract.Requires(section != null);
3931
Contract.Requires(stream != null);
4032

41-
DumpRaw(section.Start, section.Size.ToInt32(), stream);
33+
DumpRaw(reader, section.Start, section.Size.ToInt32(), stream);
4234
}
4335

4436
/// <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>
4538
/// <param name="module">The module to dump.</param>
4639
/// <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)
4841
{
4942
Contract.Requires(module != null);
5043
Contract.Requires(stream != null);
5144

52-
var data = process.ReadRemoteMemory(module.Start, module.Size.ToInt32());
45+
var data = reader.ReadRemoteMemory(module.Start, module.Size.ToInt32());
5346

5447
SimplePeHeader.FixSectionHeaders(data);
5548

0 commit comments

Comments
 (0)