Пример #1
0
        /// <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);
        }
Пример #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AProcessSharp" /> class.
 /// </summary>
 /// <param name="processId">The process id of the process to open with all rights.</param>
 /// <param name="type">The type of memory being manipulated.</param>
 public AProcessSharp(int processId, AMemoryType type) : this(AProcessHelper.FromProcessId(processId), type)
 {
 }
Пример #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AProcessSharp" /> class.
 /// </summary>
 /// <param name="processName">Name of the process.</param>
 /// <param name="type">The type of memory being manipulated.</param>
 public AProcessSharp(string processName, AMemoryType type) : this(AProcessHelper.FromName(processName), type)
 {
 }