66using System . Windows . Forms ;
77using ReClassNET . Core ;
88using ReClassNET . Debugger ;
9- using ReClassNET . Memory ;
109using ReClassNET . Plugins ;
1110
1211namespace LoadBinaryPlugin
1312{
1413 public class LoadBinaryPluginExt : Plugin , ICoreProcessFunctions
1514 {
16- private object sync = new object ( ) ;
15+ private readonly object sync = new object ( ) ;
1716
1817 private IPluginHost host ;
1918
@@ -26,15 +25,7 @@ public class LoadBinaryPluginExt : Plugin, ICoreProcessFunctions
2625 public override bool Initialize ( IPluginHost host )
2726 {
2827 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 ) ) ;
3829
3930 host . Process . CoreFunctions . RegisterFunctions ( "Load Binary" , this ) ;
4031
@@ -59,8 +50,7 @@ public override void Terminate()
5950 /// <returns>The file or null if the identifier doesn't exist.</returns>
6051 private MemoryMappedFile GetMappedFileById ( IntPtr id )
6152 {
62- MemoryMappedFile file ;
63- openFiles . TryGetValue ( id , out file ) ;
53+ openFiles . TryGetValue ( id , out var file ) ;
6454 return file ;
6555 }
6656
@@ -71,8 +61,7 @@ private void LogErrorAndRemoveFile(IntPtr id, Exception ex)
7161 {
7262 Contract . Requires ( ex != null ) ;
7363
74- MemoryMappedFile file ;
75- if ( openFiles . TryGetValue ( id , out file ) )
64+ if ( openFiles . TryGetValue ( id , out var file ) )
7665 {
7766 file . Dispose ( ) ;
7867 }
@@ -94,7 +83,7 @@ public bool IsProcessValid(IntPtr process)
9483 }
9584
9685 /// <summary>Opens the file.</summary>
97- /// <param name="pid ">The file id.</param>
86+ /// <param name="id ">The file id.</param>
9887 /// <param name="desiredAccess">The desired access. (ignored)</param>
9988 /// <returns>A plugin internal handle to the file.</returns>
10089 public IntPtr OpenRemoteProcess ( IntPtr id , ProcessAccess desiredAccess )
@@ -129,8 +118,7 @@ public void CloseRemoteProcess(IntPtr process)
129118 {
130119 lock ( sync )
131120 {
132- MemoryMappedFile file ;
133- if ( openFiles . TryGetValue ( process , out file ) )
121+ if ( openFiles . TryGetValue ( process , out var file ) )
134122 {
135123 openFiles . Remove ( process ) ;
136124
0 commit comments