private void SetupInterfaceEntry(COMInterfaceEntry entry) { textBoxInterfaceName.Text = entry.Name; textBoxIID.Text = GetGuidValue(entry.Iid); textBoxInterfaceBase.Text = GetStringValue(entry.Base); textBoxInterfaceProxy.Text = GetGuidValue(entry.ProxyClsid); txtMethods.Text = entry.NumMethods.ToString(); btnProxyProperties.Enabled = m_registry.Clsids.ContainsKey(entry.ProxyClsid); tabControlProperties.TabPages.Add(tabPageInterface); SetupTypeLibVersionEntry(m_registry.GetTypeLibVersionEntry(entry.TypeLib, entry.TypeLibVersion)); m_interface = entry; }
private Guid GetSelectedIID() { if (listViewInterfaces.SelectedItems.Count > 0) { COMInterfaceEntry ent = listViewInterfaces.SelectedItems[0].Tag as COMInterfaceEntry; if (ent != null) { return(ent.Iid); } } return(COMInterfaceEntry.IID_IUnknown); }
/// <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>(); foreach (COMInterfaceEntry.KnownInterfaces known_infs in Enum.GetValues(typeof(COMInterfaceEntry.KnownInterfaces))) { COMInterfaceEntry unk = COMInterfaceEntry.CreateKnownInterface(this, known_infs); 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(this, iid, regKey); interfaces.Add(iid, ent); } } } } } } } foreach (var pair in COMUtilities.RuntimeInterfaceMetadata) { if (!interfaces.ContainsKey(pair.Key)) { interfaces.Add(pair.Key, new COMInterfaceEntry(this, pair.Value)); } else { interfaces[pair.Key].RuntimeInterface = true; } } m_interfaces = new SortedDictionary <Guid, COMInterfaceEntry>(interfaces); }
private void LoadInterfaceList(IEnumerable <COMInterfaceInstance> entries, ListView view) { view.Items.Clear(); foreach (COMInterfaceInstance entry in entries) { COMInterfaceEntry int_entry = _registry.MapIidToInterface(entry.Iid); ListViewItem item = view.Items.Add(int_entry.Name); item.SubItems.Add(int_entry.NumMethods.ToString()); if (!String.IsNullOrWhiteSpace(entry.ModulePath)) { item.SubItems.Add(String.Format("{0}+0x{1:X}", entry.ModulePath, entry.VTableOffset)); } item.Tag = entry; } view.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); view.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }
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()); }
public static COMProxyInterfaceInstance GetFromIID(COMInterfaceEntry intf, ISymbolResolver resolver) { if (intf == null || !intf.HasProxy) { throw new ArgumentException($"Interface {intf.Name} doesn't have a registered proxy"); } COMCLSIDEntry clsid = intf.ProxyClassEntry; if (m_proxies.ContainsKey(intf.Iid)) { return(m_proxies[intf.Iid]); } else { var instance = new COMProxyInterfaceInstance(clsid, resolver, intf, clsid.Database); m_proxies[intf.Iid] = instance; return(instance); } }
/// <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>(); foreach (COMInterfaceEntry.KnownInterfaces known_infs in Enum.GetValues(typeof(COMInterfaceEntry.KnownInterfaces))) { COMInterfaceEntry unk = COMInterfaceEntry.CreateKnownInterface(known_infs); 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); } } } } } } } m_interfaces = new SortedDictionary <Guid, COMInterfaceEntry>(interfaces); }
public IntPtr CreateInstance(CLSCTX dwContext) { IntPtr pInterface = IntPtr.Zero; bool blValid = false; if (dwContext == CLSCTX.CLSCTX_ALL) { if (ServerType == COMServerType.InProcServer32) { dwContext = CLSCTX.CLSCTX_INPROC_SERVER; blValid = true; } else if (ServerType == COMServerType.LocalServer32) { dwContext = CLSCTX.CLSCTX_LOCAL_SERVER; blValid = true; } } else { blValid = true; } if (blValid) { Guid iid = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IUnknown).Iid; Guid clsid = Clsid; int iError = COMUtilities.CoCreateInstance(ref clsid, IntPtr.Zero, dwContext, ref iid, out pInterface); if (iError != 0) { Marshal.ThrowExceptionForHR(iError); } } return(pInterface); }
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_objName, m_pEntry); if ((frm != null) && !frm.IsDisposed) { Program.GetMainForm().HostControl(frm); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private COMProxyInterfaceInstance(COMCLSIDEntry clsid, ISymbolResolver resolver, COMInterfaceEntry intf, COMRegistry registry) { NdrParser parser = new NdrParser(resolver); Entry = parser.ReadFromComProxyFile(clsid.DefaultServer, clsid.Clsid, new Guid[] { intf.Iid }).FirstOrDefault(); ComplexTypes = parser.ComplexTypes; OriginalName = intf.Name; ClassEntry = clsid; m_registry = registry; }
public IntPtr CreateInstance(CLSCTX dwContext, string server) { IntPtr pInterface = IntPtr.Zero; if (dwContext == CLSCTX.ALL) { if (DefaultServerType == COMServerType.InProcServer32) { dwContext = CLSCTX.INPROC_SERVER; } else if (DefaultServerType == COMServerType.LocalServer32) { dwContext = CLSCTX.LOCAL_SERVER; } else if (DefaultServerType == COMServerType.InProcHandler32) { dwContext = CLSCTX.INPROC_HANDLER; } else { dwContext = CLSCTX.SERVER; } } Guid iid = COMInterfaceEntry.CreateKnownInterface(COMInterfaceEntry.KnownInterfaces.IUnknown).Iid; Guid clsid = Clsid; int hr = 0; if (server != null) { MULTI_QI[] qis = new MULTI_QI[1]; qis[0] = new MULTI_QI(iid); COSERVERINFO server_info = new COSERVERINFO(server); try { hr = COMUtilities.CoCreateInstanceEx(ref clsid, IntPtr.Zero, dwContext, server_info, 1, qis); if (hr == 0) { hr = qis[0].HResult(); if (hr == 0) { pInterface = qis[0].GetObjectPointer(); } } } finally { ((IDisposable)qis[0]).Dispose(); } } else { hr = COMUtilities.CoCreateInstance(ref clsid, IntPtr.Zero, dwContext, ref iid, out pInterface); } if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(pInterface); }
public void AddProxy(COMInterfaceEntry ent) { m_proxies.Add(ent); }