コード例 #1
0
ファイル: PhUtils.cs プロジェクト: wumn290/processhacker-3
        public static bool IsDotNetProcess(int pid)
        {
            var publish = new Debugger.Core.Wrappers.CorPub.ICorPublish();

            Debugger.Core.Wrappers.CorPub.ICorPublishProcess process = null;

            try
            {
                process = publish.GetProcess(pid);

                if (process == null)
                {
                    return(false);
                }

                return(process.IsManaged);
            }
            finally
            {
                if (process != null)
                {
                    Debugger.Wrappers.ResourceManager.ReleaseCOMObject(process.WrappedObject, process.GetType());
                }
            }
        }
コード例 #2
0
        public void Initialize()
        {
            // The .NET counters remove the file name extension in the
            // instance names, even if the extension is something other than
            // ".exe".
            {
                int indexOfDot = _name.LastIndexOf('.');

                if (indexOfDot != -1)
                {
                    _instanceName = _name.Substring(0, indexOfDot);
                }
                else
                {
                    _instanceName = _name;
                }
            }

            try
            {
                var publish = new Debugger.Core.Wrappers.CorPub.ICorPublish();
                var process = publish.GetProcess(_pid);
                Debugger.Interop.CorPub.ICorPublishAppDomainEnum appDomainEnum;

                try
                {
                    process.WrappedObject.EnumAppDomains(out appDomainEnum);

                    if (appDomainEnum != null)
                    {
                        uint count;
                        Debugger.Interop.CorPub.ICorPublishAppDomain appDomain;

                        try
                        {
                            while (true)
                            {
                                appDomainEnum.Next(1, out appDomain, out count);

                                if (count == 0)
                                {
                                    break;
                                }

                                try
                                {
                                    StringBuilder sb = new StringBuilder(0x100);
                                    uint          strCount;

                                    appDomain.GetName((uint)sb.Capacity, out strCount, sb);
                                    listAppDomains.Items.Add(new ListViewItem(sb.ToString(0, (int)strCount - 1)));
                                }
                                finally
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(appDomain);
                                }
                            }
                        }
                        finally
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(appDomainEnum);
                        }
                    }
                }
                finally
                {
                    Debugger.Wrappers.ResourceManager.ReleaseCOMObject(process.WrappedObject, process.GetType());
                }
            }
            catch
            { }

            var           categories = PerformanceCounterCategory.GetCategories();
            List <string> names      = new List <string>();

            foreach (var category in categories)
            {
                if (category.CategoryName.StartsWith(".NET CLR", StringComparison.OrdinalIgnoreCase))
                {
                    names.Add(category.CategoryName);
                }
            }

            names.Sort();
            comboCategories.Items.AddRange(names.ToArray());
            comboCategories.SelectedItem = comboCategories.Items[0];

            _initialized = true;
        }
コード例 #3
0
        public void Initialize()
        {
            // The .NET counters remove the file name extension in the 
            // instance names, even if the extension is something other than 
            // ".exe".
            {
                int indexOfDot = _name.LastIndexOf('.');

                if (indexOfDot != -1)
                    _instanceName = _name.Substring(0, indexOfDot);
                else
                    _instanceName = _name;
            }

            try
            {
                var publish = new Debugger.Core.Wrappers.CorPub.ICorPublish();
                var process = publish.GetProcess(_pid);
                Debugger.Interop.CorPub.ICorPublishAppDomainEnum appDomainEnum;

                try
                {
                    process.WrappedObject.EnumAppDomains(out appDomainEnum);

                    if (appDomainEnum != null)
                    {
                        uint count;
                        Debugger.Interop.CorPub.ICorPublishAppDomain appDomain;

                        try
                        {
                            while (true)
                            {
                                appDomainEnum.Next(1, out appDomain, out count);

                                if (count == 0)
                                    break;

                                try
                                {
                                    StringBuilder sb = new StringBuilder(0x100);
                                    uint strCount;

                                    appDomain.GetName((uint)sb.Capacity, out strCount, sb);
                                    listAppDomains.Items.Add(new ListViewItem(sb.ToString(0, (int)strCount - 1)));
                                }
                                finally
                                {
                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(appDomain);
                                }
                            }
                        }
                        finally
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(appDomainEnum);
                        }
                    }
                }
                finally
                {
                    Debugger.Wrappers.ResourceManager.ReleaseCOMObject(process.WrappedObject, process.GetType());
                }
            }
            catch
            { }

            var categories = PerformanceCounterCategory.GetCategories();
            List<string> names = new List<string>();

            foreach (var category in categories)
            {
                if (category.CategoryName.StartsWith(".NET CLR", StringComparison.OrdinalIgnoreCase))
                    names.Add(category.CategoryName);
            }

            names.Sort();
            comboCategories.Items.AddRange(names.ToArray());
            comboCategories.SelectedItem = comboCategories.Items[0];

            _initialized = true;
        }
コード例 #4
0
        public static bool IsDotNetProcess(int pid)
        {
            var publish = new Debugger.Core.Wrappers.CorPub.ICorPublish();
            Debugger.Core.Wrappers.CorPub.ICorPublishProcess process = null;

            try
            {
                process = publish.GetProcess(pid);

                if (process == null)
                    return false;

                return process.IsManaged;
            }
            finally
            {
                if (process != null)
                {
                    Debugger.Wrappers.ResourceManager.ReleaseCOMObject(process.WrappedObject, process.GetType());
                }
            }
        }