88using System . Threading ;
99using System . Threading . Tasks ;
1010using ReClassNET . AddressParser ;
11+ using ReClassNET . Debugger ;
1112using ReClassNET . Native ;
1213using ReClassNET . Symbols ;
1314using ReClassNET . Util ;
1415
1516namespace ReClassNET . Memory
1617{
18+ public delegate void UnderlayingProcessChangedEvent ( RemoteProcess sender ) ;
19+
1720 public class RemoteProcess : IDisposable
1821 {
1922 private readonly object processSync = new object ( ) ;
2023
2124 private readonly NativeHelper nativeHelper ;
22- public NativeHelper NativeHelper => nativeHelper ;
2325
24- private ProcessInfo process ;
25- private IntPtr handle ;
26- public ProcessInfo UnderlayingProcess => process ;
27-
28- public delegate void RemoteProcessChangedEvent ( RemoteProcess sender ) ;
29- public event RemoteProcessChangedEvent ProcessChanged ;
26+ private readonly RemoteDebugger debugger ;
3027
3128 private readonly Dictionary < IntPtr , string > rttiCache = new Dictionary < IntPtr , string > ( ) ;
3229
@@ -35,6 +32,18 @@ public class RemoteProcess : IDisposable
3532 private readonly List < Section > sections = new List < Section > ( ) ;
3633
3734 private readonly SymbolStore symbols = new SymbolStore ( ) ;
35+
36+ private ProcessInfo process ;
37+ private IntPtr handle ;
38+
39+ public event UnderlayingProcessChangedEvent ProcessChanged ;
40+
41+ public NativeHelper NativeHelper => nativeHelper ;
42+
43+ public RemoteDebugger Debugger => debugger ;
44+
45+ public ProcessInfo UnderlayingProcess => process ;
46+
3847 public SymbolStore Symbols => symbols ;
3948
4049 public bool IsValid => process != null && nativeHelper . IsProcessValid ( handle ) ;
@@ -44,13 +53,17 @@ public RemoteProcess(NativeHelper nativeHelper)
4453 Contract . Requires ( nativeHelper != null ) ;
4554
4655 this . nativeHelper = nativeHelper ;
56+
57+ debugger = new RemoteDebugger ( this ) ;
4758 }
4859
4960 public void Dispose ( )
5061 {
5162 Close ( ) ;
5263 }
5364
65+ /// <summary>Opens the given process to gather informations from.</summary>
66+ /// <param name="info">The process information.</param>
5467 public void Open ( ProcessInfo info )
5568 {
5669 Contract . Requires ( info != null ) ;
@@ -72,13 +85,14 @@ public void Open(ProcessInfo info)
7285 }
7386 }
7487
88+ /// <summary>Closes the underlaying process. If the debugger is attached, it will automaticly detached.</summary>
7589 public void Close ( )
7690 {
7791 if ( process != null )
7892 {
7993 lock ( processSync )
8094 {
81- //detach debugger, remove breakpoints
95+ debugger . Detach ( ) ;
8296
8397 nativeHelper . CloseRemoteProcess ( handle ) ;
8498
0 commit comments