Skip to content

Commit ef9e601

Browse files
committed
Decouple form from Program class.
1 parent ff6e7b1 commit ef9e601

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

ReClass.NET/Forms/MainForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private void quitToolStripMenuItem_Click(object sender, EventArgs e)
318318

319319
private void memoryViewerToolStripMenuItem_Click(object sender, EventArgs e)
320320
{
321-
new ProcessInfoForm().Show();
321+
new ProcessInfoForm(Program.RemoteProcess).Show();
322322
}
323323

324324
private void memorySearcherToolStripMenuItem_Click(object sender, EventArgs e)

ReClass.NET/Forms/ProcessInfoForm.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Data;
3+
using System.Diagnostics.Contracts;
34
using System.Drawing;
45
using System.IO;
56
using System.Linq;
@@ -13,11 +14,17 @@ namespace ReClassNET.Forms
1314
{
1415
public partial class ProcessInfoForm : IconForm
1516
{
17+
private readonly RemoteProcess process;
18+
1619
/// <summary>The context menu of the sections grid view.</summary>
1720
public ContextMenuStrip GridContextMenu => contextMenuStrip;
1821

19-
public ProcessInfoForm()
22+
public ProcessInfoForm(RemoteProcess process)
2023
{
24+
Contract.Requires(process != null);
25+
26+
this.process = process;
27+
2128
InitializeComponent();
2229

2330
tabControl.ImageList = new ImageList();
@@ -54,7 +61,7 @@ protected override void OnFormClosed(FormClosedEventArgs e)
5461

5562
private async void ProcessInfoForm_Load(object sender, EventArgs e)
5663
{
57-
if (!Program.RemoteProcess.IsValid)
64+
if (!process.IsValid)
5865
{
5966
return;
6067
}
@@ -78,7 +85,7 @@ private async void ProcessInfoForm_Load(object sender, EventArgs e)
7885

7986
await Task.Run(() =>
8087
{
81-
Program.RemoteProcess.EnumerateRemoteSectionsAndModules(
88+
process.EnumerateRemoteSectionsAndModules(
8289
delegate (Section section)
8390
{
8491
var row = sections.NewRow();
@@ -180,7 +187,7 @@ private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
180187

181188
if (sfd.ShowDialog() == DialogResult.OK)
182189
{
183-
var dumper = new Dumper(Program.RemoteProcess);
190+
var dumper = new Dumper(process);
184191

185192
try
186193
{

0 commit comments

Comments
 (0)