Ejemplo n.º 1
0
        public static bool IsManaged(int processId)        //TODO: Why isn't this method used by AttachToProcessWindow?
        {
            var corPublish             = new CorpubPublishClass();
            ICorPublishProcess process = corPublish.GetProcess((uint)processId);

            if (process != null)
            {
                return(process.IsManaged() != 0);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool IsManaged(int processId)
        {
            corPublish = new CorpubPublishClass();
            CorDbg.Interop.TrackedComObjects.Track(corPublish);

            ICorPublishProcess process = corPublish.GetProcess((uint)processId);

            if (process != null)
            {
                return(process.IsManaged() != 0);
            }
            return(false);
        }
Ejemplo n.º 3
0
        void EnumAppDomainsShown(object sender, EventArgs e)
        {
            ICorPublish publish = (ICorPublish) new CorpubPublish();

            if (publish != null)
            {
                ICorPublishProcess ppProcess = null;
                try
                {
                    publish.GetProcess((uint)procid, out ppProcess);
                }
                catch
                {
                }

                if (ppProcess != null)
                {
                    bool IsManaged = false;
                    ppProcess.IsManaged(out IsManaged);
                    if (IsManaged)
                    {
// Enumerate the domains within the process.
                        ICorPublishAppDomainEnum ppEnum = null;
                        ppProcess.EnumAppDomains(out ppEnum);

                        ICorPublishAppDomain pappDomain; // ICorPublishAppDomain
                        uint aFetched = 0;
                        while (ppEnum.Next(1, out pappDomain, out aFetched) == 0 && aFetched > 0)
                        {
                            StringBuilder szName = null;
                            try
                            {
                                uint pcchName = 0;
                                pappDomain.GetName(0, out pcchName, null);
                                szName = new StringBuilder((int)pcchName);
                                pappDomain.GetName((uint)szName.Capacity, out pcchName, szName);
                            }
                            catch
                            {
                            }

                            string appdomainname = szName.ToString();
                            uint   appdomainid   = 0;
                            pappDomain.GetID(out appdomainid);

                            ListViewItem appdomaintoadd = new ListViewItem(new string[] { appdomainid.ToString(), appdomainname });
                            lvdomains.Items.Add(appdomaintoadd);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Selected process is not a managed .NET process!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Failed to open slected process \r\n" +
                                    "maybe is not a .NET process!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }