OleViewDotNet.COMEnumerateInterfaces.QueryInterface C# (CSharp) Method

QueryInterface() private method

private QueryInterface ( IntPtr punk, System.Guid iid, string>.Dictionary module_names, List list ) : void
punk System.IntPtr
iid System.Guid
module_names string>.Dictionary
list List
return void
        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);
                }
            }
        }