private void QueryInterface(IntPtr punk, Guid iid, Dictionary <IntPtr, string> module_names, HashSet <COMInterfaceInstance> list)
        {
            if (punk != IntPtr.Zero)
            {
                IntPtr ppout;
                if (Marshal.QueryInterface(punk, ref iid, out ppout) == 0)
                {
                    IntPtr vtable = Marshal.ReadIntPtr(ppout, 0);
                    COMInterfaceInstance intf;

                    using (SafeLibraryHandle module = COMUtilities.SafeGetModuleHandle(vtable))
                    {
                        if (_clsctx == CLSCTX.INPROC_SERVER && module != null)
                        {
                            if (!module_names.ContainsKey(module.DangerousGetHandle()))
                            {
                                module_names[module.DangerousGetHandle()] = module.GetModuleFileName();
                            }
                            intf = new COMInterfaceInstance(iid,
                                                            module_names[module.DangerousGetHandle()],
                                                            vtable.ToInt64() - module.DangerousGetHandle().ToInt64());
                        }
                        else
                        {
                            intf = new COMInterfaceInstance(iid);
                        }
                    }


                    list.Add(intf);
                    Marshal.Release(ppout);
                }
            }
        }
        private void QueryInterface(IntPtr punk, Guid iid, Dictionary <IntPtr, string> module_names, List <COMInterfaceInstance> list)
        {
            if (punk != IntPtr.Zero)
            {
                IntPtr ppout;
                if (Marshal.QueryInterface(punk, ref iid, out ppout) == 0)
                {
                    IntPtr vtable = Marshal.ReadIntPtr(ppout, 0);
                    IntPtr module;
                    COMInterfaceInstance intf;

                    if (_clsctx == CLSCTX.CLSCTX_INPROC_SERVER && GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, vtable, out module))
                    {
                        if (!module_names.ContainsKey(module))
                        {
                            module_names[module] = GetModuleFileName(module);
                        }
                        intf = new COMInterfaceInstance(iid, module_names[module], vtable.ToInt64() - module.ToInt64());
                    }
                    else
                    {
                        intf = new COMInterfaceInstance(iid);
                    }


                    list.Add(intf);
                    Marshal.Release(ppout);
                }
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
 public static COMProxyInterfaceInstance GetFromIID(COMInterfaceInstance intf, ISymbolResolver resolver)
 {
     return(GetFromIID(intf.InterfaceEntry, resolver));
 }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        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();
        }
        private void QueryInterface(IntPtr punk, Guid iid, Dictionary<IntPtr, string> module_names, List<COMInterfaceInstance> list)
        {
            if (punk != IntPtr.Zero)
            {
                IntPtr ppout;
                if (Marshal.QueryInterface(punk, ref iid, out ppout) == 0)
                {
                    IntPtr vtable = Marshal.ReadIntPtr(ppout, 0);
                    IntPtr module;
                    COMInterfaceInstance intf;

                    if (_clsctx == CLSCTX.CLSCTX_INPROC_SERVER && GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, vtable, out module))
                    {
                        if (!module_names.ContainsKey(module))
                        {
                            module_names[module] = GetModuleFileName(module);
                        }
                        intf = new COMInterfaceInstance(iid, module_names[module], vtable.ToInt64() - module.ToInt64());
                    }
                    else
                    {
                        intf = new COMInterfaceInstance(iid);
                    }


                    list.Add(intf);
                    Marshal.Release(ppout);
                }
            }
        }