예제 #1
0
        private void AddProcess(uint id)
        {
            if (_processTable.ContainsKey(id))
            {
                return;
            }

            var p = Process.GetProcessById((int)id);

            _processTable.Add(id, p);
            DebugProcess parent;

            try
            {
                parent = FindProcess(Processes, (uint)p.GetParentId());
            }
            catch
            {
                parent = null;
            }

            var dp = new DebugProcess(p, parent);

            if (parent != null)
            {
                parent.Children.Add(dp);
            }
            else
            {
                Processes.Add(dp);
            }
        }
예제 #2
0
        public void Detach(DebugProcess process)
        {
            foreach (var p in process.Children)
            {
                Detach(p);
            }

            DetachNode(process);
        }
예제 #3
0
        private void DetachNode(DebugProcess process)
        {
            var result = Kernel32.DebugActiveProcessStop((uint)process.Process.Id);

            if (!result)
            {
                throw new InvalidOperationException("Could not detach");
            }

            lock (_loaderBreakpointTable)
            {
                _loaderBreakpointTable.Remove((uint)process.Process.Id);
            }
        }
예제 #4
0
        private void Kill(DebugProcess process)
        {
            foreach (var p in process.Children)
            {
                Kill(p);
            }

            try
            {
                DetachNode(process);
            }
            catch { }

            try
            {
                process.Process.Kill();
            }
            catch { }

            process.Process.WaitForExit();
        }
예제 #5
0
 public DebugProcess(Process process, DebugProcess parent)
 {
     Process  = process;
     Parent   = parent;
     Children = new List <DebugProcess>();
 }