/// <summary> /// Initializes a new instance of the <see cref="AProcessSharp" /> class. /// </summary> /// <param name="native">The native process.</param> /// <param name="type">The type of memory being manipulated.</param> public AProcessSharp(System.Diagnostics.Process native, AMemoryType type) { native.EnableRaisingEvents = true; native.Exited += (s, e) => { ProcessExited?.Invoke(s, e); HandleProcessExiting(); }; Native = native; Handle = AMemoryHelper.OpenProcess(ProcessAccessFlags.AllAccess, Native.Id); switch (type) { case AMemoryType.Local: Memory = new ALocalProcessMemory(Handle); break; case AMemoryType.Remote: Memory = new AExternalProcessMemory(Handle); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } native.ErrorDataReceived += OutputDataReceived; native.OutputDataReceived += OutputDataReceived; ThreadFactory = new AThreadFactory(this); ModuleFactory = new AModuleFactory(this); MemoryFactory = new AMemoryFactory(this); WindowFactory = new AWindowFactory(this); }
public static ASafeMemoryHandle Open(this System.Diagnostics.Process process, ProcessAccessFlags processAccessFlags = ProcessAccessFlags.AllAccess) { return(AMemoryHelper.OpenProcess(processAccessFlags, process.Id)); }