Exemplo n.º 1
0
        public ProcessInfo[] GetRunningProcesses()
        {
            if (_debugKernel)
            {
                throw new InvalidOperationException("The monitor is debugging a kernel.");
            }

            try
            {
                List <ProcessInfo> ret = new List <ProcessInfo>();

                foreach (uint processId in _debuggee.Processes)
                {
                    string procName = _debuggee.GetProcessName(processId, GetRunningProcessDescriptionFlags.NoPaths);

                    if (processId != 0 && !String.IsNullOrEmpty(procName))
                    {
                        ProcessInfo procInfo = new ProcessInfo
                        {
                            ImageName = procName,
                            ProcessId = (int)processId,
                        };

                        ret.Add(procInfo);
                    }
                }

                return(ret.ToArray());
            }
            catch (COMException ce)
            {
                throw new DebugMonitorException("Failed to get process list.", ce);
            }
            catch (InvalidCastException ic)
            {
                throw new DebugMonitorException("Failed to get process list.", ic);
            }
        }