/// <summary> /// Initializes a new instance of the <see cref="NativeMemory" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="access">The access.</param> /// <param name="injectorOptions">The injector options.</param> protected NativeMemory(Process process, ProcessAccess access, InjectorCreationOptions injectorOptions) { Requires.NotNull(process, nameof(process)); Process = process; Process.EnableRaisingEvents = true; Process.Exited += async(sender, args) => { // Just pass the exit code and the EventArgs to the handler. await OnExited(Process.ExitCode, args); }; if (injectorOptions.CreateInjector) { if (IsExternal) { ProcessHandle = OpenProcess(access, false, process.Id); } Injector = new Injector(this); } PatternScanner = new PatternScanner(this); }
/// <summary> /// Initializes a new instance of the <see cref="ExternalProcessMemory" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="access">The access flags.</param> /// <param name="injectorOptions">The injector options.</param> /// <exception cref="PlatformNotSupportedException"> /// The platform is Windows 98 or Windows Millennium Edition (Windows Me); /// set the <see cref="P:System.Diagnostics.ProcessStartInfo.UseShellExecute" /> property to false to access this /// property on Windows 98 and Windows Me. /// </exception> /// <exception cref="InvalidOperationException"> /// The process's <see cref="P:System.Diagnostics.Process.Id" /> property has /// not been set.-or- There is no process associated with this <see cref="T:System.Diagnostics.Process" /> object. /// </exception> public ExternalProcessMemory(Process process, ProcessAccess access, InjectorCreationOptions injectorOptions) : base(process, injectorOptions) { // If we instantiate an injector, the NativeMemory ctor will take care of opening a handle. // Otherwise, we'll have to open a handle here. if (!injectorOptions.CreateInjector) { ProcessHandle = OpenProcess(access, false, process.Id); } // Obtain a handle to the process' main thread so we can suspend/resume it whenever we need to.0 _mainThreadHandle = OpenThread(ThreadAccess.ALL, false, (uint)process.Threads[0].Id); Process.EnterDebugMode(); }
/// <summary> /// Initializes a new instance of the <see cref="NativeMemory" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="injectorOptions">The injector options.</param> protected NativeMemory(Process process, InjectorCreationOptions injectorOptions) : this(process, DefaultProcessAccess, injectorOptions) { }
/// <summary> /// Initializes a new instance of the <see cref="ExternalProcessMemory" /> class. /// This constructor opens a handle to the specified process using the following flags: /// ProcessAccess.CreateThread | ProcessAccess.QueryInformation | ProcessAccess.VMRead | ProcessAccess.VMWrite | /// ProcessAccess.VMOperation | ProcessAccess.SetInformation /// </summary> /// <param name="process">The process.</param> /// <param name="injectorOptions">The injector options.</param> /// <exception cref="PlatformNotSupportedException"> /// The platform is Windows 98 or Windows Millennium Edition (Windows Me); /// set the <see cref="P:System.Diagnostics.ProcessStartInfo.UseShellExecute" /> property to false to access this /// property on Windows 98 and Windows Me. /// </exception> /// <exception cref="InvalidOperationException"> /// The process's <see cref="P:System.Diagnostics.Process.Id" /> property has /// not been set.-or- There is no process associated with this <see cref="T:System.Diagnostics.Process" /> object. /// </exception> public ExternalProcessMemory(Process process, InjectorCreationOptions injectorOptions) : this(process, DefaultProcessAccess, injectorOptions) { }
/// <summary> /// Initializes a new instance of the <see cref="LocalProcessMemory" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="injectorOptions">The injector options.</param> public LocalProcessMemory(Process process, InjectorCreationOptions injectorOptions) : base(process, injectorOptions) { }