File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ namespace ReClassNET.Memory
66{
77 public class ProcessInfo : IDisposable
88 {
9+ private readonly object sync = new object ( ) ;
10+
911 private readonly NativeHelper nativeHelper ;
1012
1113 private IntPtr handle ;
@@ -37,7 +39,13 @@ public IntPtr Open()
3739 {
3840 if ( handle . IsNull ( ) )
3941 {
40- handle = nativeHelper . OpenRemoteProcess ( Id , NativeMethods . PROCESS_ALL_ACCESS ) ;
42+ lock ( sync )
43+ {
44+ if ( handle . IsNull ( ) )
45+ {
46+ handle = nativeHelper . OpenRemoteProcess ( Id , NativeMethods . PROCESS_ALL_ACCESS ) ;
47+ }
48+ }
4149 }
4250 return handle ;
4351 }
@@ -46,9 +54,15 @@ public void Close()
4654 {
4755 if ( ! handle . IsNull ( ) )
4856 {
49- nativeHelper . CloseRemoteProcess ( handle ) ;
57+ lock ( sync )
58+ {
59+ if ( ! handle . IsNull ( ) )
60+ {
61+ nativeHelper . CloseRemoteProcess ( handle ) ;
5062
51- handle = IntPtr . Zero ;
63+ handle = IntPtr . Zero ;
64+ }
65+ }
5266 }
5367 }
5468 }
You can’t perform that action at this time.
0 commit comments