public static ObjectEntry Add(string name, object instance, COMInterfaceEntry[] interfaces)
        {
            ObjectEntry ret = new ObjectEntry(name, instance, interfaces);
            m_objects.Add(ret);

            return ret;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="objName">Descriptive name of the object</param>
 /// <param name="pObject">Managed wrapper to the object</param>
 /// <param name="properties">List of textual properties to display</param>
 /// <param name="interfaces">List of available interfaces</param>
 public ObjectInformation(string objName, Object pObject, Dictionary<string, string> properties, COMInterfaceEntry[] interfaces)
 {
     ObjectCache.Add(objName, pObject, interfaces);
     m_pObject = pObject;
     m_properties = properties;
     m_interfaces = interfaces;
     m_objName = objName;
     InitializeComponent();
 }
        public ObjectEntry(string name, object instance, COMInterfaceEntry[] interfaces)
        {
            Name = name;
            Instance = instance;
            Id = Guid.NewGuid();

            Interfaces = new KeyValuePair<Guid,string>[interfaces.Length];
            int pos = 0;
            foreach (COMInterfaceEntry ent in interfaces)
            {
                Interfaces[pos++] = new KeyValuePair<Guid, string>(ent.Iid, ent.Name);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="objName">Descriptive name of the object</param>
        /// <param name="pObject">Managed wrapper to the object</param>
        /// <param name="properties">List of textual properties to display</param>
        /// <param name="interfaces">List of available interfaces</param>
        public ObjectInformation(string objName, Object pObject, Dictionary<string, string> properties, COMInterfaceEntry[] interfaces)
        {
            m_pEntry = ObjectCache.Add(objName, pObject, interfaces);
            m_pObject = pObject;
            m_properties = properties;
            m_interfaces = interfaces;
            m_objName = objName;
            InitializeComponent();

            LoadProperties();
            LoadInterfaces();
            Text = m_objName;
            listViewInterfaces.ListViewItemSorter = new ListItemComparer(0);
        }
示例#5
0
        private void listViewInterfaces_DoubleClick(object sender, EventArgs e)
        {
            if (listViewInterfaces.SelectedItems.Count > 0)
            {
                COMInterfaceEntry ent = (COMInterfaceEntry)listViewInterfaces.SelectedItems[0].Tag;
                InterfaceViewers.ITypeViewerFactory factory = InterfaceViewers.InterfaceViewers.GetInterfaceViewer(ent.Iid);

                try
                {
                    if (factory != null)
                    {
                        Control frm = factory.CreateInstance(m_registry, m_entry, m_objName, m_pEntry);
                        if ((frm != null) && !frm.IsDisposed)
                        {
                            EntryPoint.GetMainForm(m_registry).HostControl(frm);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private TreeNode CreateInterfaceNameNode(COMInterfaceEntry ent, COMInterfaceInstance instance)
        {
            TreeNode nodeRet = new TreeNode(ent.Name, InterfaceIcon, InterfaceIcon);
            nodeRet.ToolTipText = BuildInterfaceToolTip(ent, instance);
            nodeRet.Tag = ent;

            return nodeRet;
        }
        private TreeNode CreateInterfaceNode(COMInterfaceEntry ent)
        {
            TreeNode nodeRet = new TreeNode(String.Format("{0} - {1}", ent.Iid.ToString(), ent.Name), InterfaceIcon, InterfaceIcon);
            nodeRet.ToolTipText = BuildInterfaceToolTip(ent, null);
            nodeRet.Tag = ent;

            return nodeRet;
        }
        private string BuildInterfaceToolTip(COMInterfaceEntry ent, COMInterfaceInstance instance)
        {            
            StringBuilder builder = new StringBuilder();

            AppendFormatLine(builder, "Name: {0}", ent.Name);
            AppendFormatLine(builder, "IID: {0}", ent.Iid.ToString("B"));
            if (ent.ProxyClsid != Guid.Empty)
            {
                AppendFormatLine(builder, "ProxyCLSID: {0}", ent.ProxyClsid.ToString("B"));
            }
            if (instance != null && instance.ModulePath != null)
            {
                AppendFormatLine(builder, "VTable Address: {0}+0x{1:X}", instance.ModulePath, instance.VTableOffset);
            }

            return builder.ToString();
        }
示例#9
0
        /// <summary>
        /// Load interface list from registry
        /// </summary>
        /// <param name="rootKey">Root key of registry</param>
        private void LoadInterfaces(RegistryKey rootKey)
        {
            Dictionary<Guid, COMInterfaceEntry> interfaces = new Dictionary<Guid, COMInterfaceEntry>();
            COMInterfaceEntry unk = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IUnknown);
            interfaces.Add(unk.Iid, unk);
            unk = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IMarshal);
            interfaces.Add(unk.Iid, unk);
            RegistryKey iidKey = rootKey.OpenSubKey("Interface");
            if (iidKey != null)
            {
                string[] subkeys = iidKey.GetSubKeyNames();
                foreach (string key in subkeys)
                {
                    try
                    {
                        Guid iid = new Guid(key);

                        if (!interfaces.ContainsKey(iid))
                        {
                            RegistryKey regKey = iidKey.OpenSubKey(key);
                            if (regKey != null)
                            {
                                COMInterfaceEntry ent = new COMInterfaceEntry(iid, regKey);
                                interfaces.Add(iid, ent);
                                if (ent.ProxyClsid != Guid.Empty)
                                {
                                    if (m_clsids.ContainsKey(ent.ProxyClsid))
                                    {
                                        m_clsids[ent.ProxyClsid].AddProxy(ent);
                                    }
                                }
                            }
                        }
                    }
                    catch (FormatException e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.ToString());
                    }
                }
            }

            int pos = 0;
            m_interfacebyname = new COMInterfaceEntry[interfaces.Count];
            foreach (COMInterfaceEntry ent in interfaces.Values)
            {
                m_interfacebyname[pos++] = ent;
            }
            Array.Sort(m_interfacebyname);

            m_interfaces = new SortedDictionary<Guid, COMInterfaceEntry>(interfaces);
        }
示例#10
0
        /// <summary>
        /// Get list of supported Interface IIDs (that we know about)
        /// NOTE: This will load the object itself to check what is supported, it _might_ crash the app
        /// The returned array is cached so subsequent calls to this function return without calling into COM
        /// </summary>
        /// <param name="ent">The entry to get the interfaces for</param>
        /// <param name="bRefresh">Force the supported interface list to refresh</param>
        /// <returns>An array of supported interfaces</returns>
        public COMInterfaceEntry[] GetSupportedInterfaces(COMCLSIDEntry ent, bool bRefresh)
        {
            COMInterfaceEntry[] retList = null;

            if (ent != null)
            {
                if (m_supportediids.ContainsKey(ent.Clsid))
                {
                    retList = m_supportediids[ent.Clsid];
                }
                else
                {
                    Guid[] guids = EnumerateInterfaces.GetInterfaces(ent);
                    List<COMInterfaceEntry> ents = new List<COMInterfaceEntry>();

                    foreach (Guid g in guids)
                    {
                        if (m_interfaces.ContainsKey(g))
                        {
                            ents.Add(m_interfaces[g]);
                        }
                    }

                    ents.Sort();
                    retList = ents.ToArray();
                    m_supportediids[ent.Clsid] = retList;
                }
            }
            else
            {
                retList = new COMInterfaceEntry[0];
            }

            return retList;
        }
示例#11
0
 public static BaseComWrapper Wrap(object obj, COMInterfaceEntry intf)
 {
     return(Wrap(obj, COMUtilities.GetInterfaceType(intf)));
 }
示例#12
0
        /// <summary>
        /// Load interface list from registry
        /// </summary>
        /// <param name="rootKey">Root key of registry</param>
        private void LoadInterfaces(RegistryKey rootKey)
        {
            Dictionary<Guid, COMInterfaceEntry> interfaces = new Dictionary<Guid, COMInterfaceEntry>();
            COMInterfaceEntry unk = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IUnknown);
            interfaces.Add(unk.Iid, unk);
            unk = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IMarshal);
            interfaces.Add(unk.Iid, unk);
            using (RegistryKey iidKey = rootKey.OpenSubKey("Interface"))
            {
                if (iidKey != null)
                {
                    string[] subkeys = iidKey.GetSubKeyNames();
                    foreach (string key in subkeys)
                    {
                        Guid iid;

                        if (Guid.TryParse(key, out iid))
                        {
                            if (!interfaces.ContainsKey(iid))
                            {
                                using (RegistryKey regKey = iidKey.OpenSubKey(key))
                                {
                                    if (regKey != null)
                                    {
                                        COMInterfaceEntry ent = new COMInterfaceEntry(iid, regKey);
                                        interfaces.Add(iid, ent);
                                        if (ent.ProxyClsid != Guid.Empty)
                                        {
                                            if (m_clsids.ContainsKey(ent.ProxyClsid))
                                            {
                                                m_clsids[ent.ProxyClsid].AddProxy(ent);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
            }

            int pos = 0;
            m_interfacebyname = new COMInterfaceEntry[interfaces.Count];
            foreach (COMInterfaceEntry ent in interfaces.Values)
            {
                m_interfacebyname[pos++] = ent;
            }
            Array.Sort(m_interfacebyname);

            m_interfaces = new SortedDictionary<Guid, COMInterfaceEntry>(interfaces);
        }
示例#13
0
 public static void Add(string name, object instance, COMInterfaceEntry[] interfaces)
 {
     m_objects.Add(instance, new ObjectEntry(name, instance, interfaces));
 }
        private string BuildInterfaceToolTip(COMInterfaceEntry ent)
        {
            string strRet;

            strRet = String.Format("Name: {0}\n", ent.Name);
            strRet += String.Format("IID: {0}\n", ent.Iid.ToString("B"));
            if (ent.ProxyClsid != Guid.Empty)
            {
                strRet += String.Format("ProxyCLSID: {0}\n", ent.ProxyClsid.ToString("B"));
            }

            return strRet;
        }