6
6
using System . Windows . Forms ;
7
7
using ReClassNET . Core ;
8
8
using ReClassNET . Debugger ;
9
- using ReClassNET . Memory ;
10
9
using ReClassNET . Plugins ;
11
10
12
11
namespace LoadBinaryPlugin
13
12
{
14
13
public class LoadBinaryPluginExt : Plugin , ICoreProcessFunctions
15
14
{
16
- private object sync = new object ( ) ;
15
+ private readonly object sync = new object ( ) ;
17
16
18
17
private IPluginHost host ;
19
18
@@ -26,15 +25,7 @@ public class LoadBinaryPluginExt : Plugin, ICoreProcessFunctions
26
25
public override bool Initialize ( IPluginHost host )
27
26
{
28
27
Contract . Requires ( host != null ) ;
29
-
30
- //System.Diagnostics.Debugger.Launch();
31
-
32
- if ( host == null )
33
- {
34
- throw new ArgumentNullException ( nameof ( host ) ) ;
35
- }
36
-
37
- this . host = host ;
28
+ this . host = host ?? throw new ArgumentNullException ( nameof ( host ) ) ;
38
29
39
30
host . Process . CoreFunctions . RegisterFunctions ( "Load Binary" , this ) ;
40
31
@@ -59,8 +50,7 @@ public override void Terminate()
59
50
/// <returns>The file or null if the identifier doesn't exist.</returns>
60
51
private MemoryMappedFile GetMappedFileById ( IntPtr id )
61
52
{
62
- MemoryMappedFile file ;
63
- openFiles . TryGetValue ( id , out file ) ;
53
+ openFiles . TryGetValue ( id , out var file ) ;
64
54
return file ;
65
55
}
66
56
@@ -71,8 +61,7 @@ private void LogErrorAndRemoveFile(IntPtr id, Exception ex)
71
61
{
72
62
Contract . Requires ( ex != null ) ;
73
63
74
- MemoryMappedFile file ;
75
- if ( openFiles . TryGetValue ( id , out file ) )
64
+ if ( openFiles . TryGetValue ( id , out var file ) )
76
65
{
77
66
file . Dispose ( ) ;
78
67
}
@@ -94,7 +83,7 @@ public bool IsProcessValid(IntPtr process)
94
83
}
95
84
96
85
/// <summary>Opens the file.</summary>
97
- /// <param name="pid ">The file id.</param>
86
+ /// <param name="id ">The file id.</param>
98
87
/// <param name="desiredAccess">The desired access. (ignored)</param>
99
88
/// <returns>A plugin internal handle to the file.</returns>
100
89
public IntPtr OpenRemoteProcess ( IntPtr id , ProcessAccess desiredAccess )
@@ -129,8 +118,7 @@ public void CloseRemoteProcess(IntPtr process)
129
118
{
130
119
lock ( sync )
131
120
{
132
- MemoryMappedFile file ;
133
- if ( openFiles . TryGetValue ( process , out file ) )
121
+ if ( openFiles . TryGetValue ( process , out var file ) )
134
122
{
135
123
openFiles . Remove ( process ) ;
136
124
0 commit comments