public static bool AddGraphToRot(object graph, out int cookie)
        {
            bool flag;

            cookie = 0;
            int errorCode = 0;
            UCOMIRunningObjectTable pprot = null;
            UCOMIMoniker            ppmk  = null;

            try
            {
                errorCode = GetRunningObjectTable(0, out pprot);
                if (errorCode < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode);
                }
                int    currentProcessId  = GetCurrentProcessId();
                IntPtr iUnknownForObject = Marshal.GetIUnknownForObject(graph);
                int    num3 = (int)iUnknownForObject;
                Marshal.Release(iUnknownForObject);
                string item = string.Format("FilterGraph {0} pid {1}", num3.ToString("x8"), currentProcessId.ToString("x8"));
                errorCode = CreateItemMoniker("!", item, out ppmk);
                if (errorCode < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode);
                }
                pprot.Register(1, graph, ppmk, out cookie);
                flag = true;
            }
            catch (Exception)
            {
                flag = false;
            }
            finally
            {
                if (ppmk != null)
                {
                    Marshal.ReleaseComObject(ppmk);
                }
                ppmk = null;
                if (pprot != null)
                {
                    Marshal.ReleaseComObject(pprot);
                }
                pprot = null;
            }
            return(flag);
        }
Exemple #2
0
        public static bool AddGraphToRot(object graph, out int cookie)
        {
            cookie = 0;
            int hr = 0;
            UCOMIRunningObjectTable rot = null;
            UCOMIMoniker            mk  = null;

            try {
                hr = GetRunningObjectTable(0, out rot);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                int    id    = GetCurrentProcessId();
                IntPtr iuPtr = Marshal.GetIUnknownForObject(graph);
                int    iuInt = (int)iuPtr;
                Marshal.Release(iuPtr);
                string item = string.Format("FilterGraph {0} pid {1}", iuInt.ToString("x8"), id.ToString("x8"));
                hr = CreateItemMoniker("!", item, out mk);
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                rot.Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, graph, mk, out cookie);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                if (mk != null)
                {
                    Marshal.ReleaseComObject(mk);
                }
                mk = null;
                if (rot != null)
                {
                    Marshal.ReleaseComObject(rot);
                }
                rot = null;
            }
        }
Exemple #3
0
        // Token: 0x060002F9 RID: 761 RVA: 0x00012D6C File Offset: 0x00010F6C
        public static bool AddGraphToRot(object graph, ref int cookie)
        {
            cookie = 0;
            UCOMIRunningObjectTable ucomirunningObjectTable = null;
            UCOMIMoniker            ucomimoniker            = null;
            bool result;

            try
            {
                int    num = DsROT.GetRunningObjectTable(0, ref ucomirunningObjectTable);
                int    currentProcessId  = DsROT.GetCurrentProcessId();
                IntPtr iunknownForObject = Marshal.GetIUnknownForObject(RuntimeHelpers.GetObjectValue(graph));
                int    num2 = (int)iunknownForObject;
                Marshal.Release(iunknownForObject);
                string item = string.Format("FilterGraph {0} pid {1}", num2.ToString("x8"), currentProcessId.ToString("x8"));
                num = DsROT.CreateItemMoniker("!", item, ref ucomimoniker);
                ucomirunningObjectTable.Register(1, RuntimeHelpers.GetObjectValue(graph), ucomimoniker, out cookie);
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            finally
            {
                if (ucomimoniker != null)
                {
                    Marshal.ReleaseComObject(ucomimoniker);
                }
                ucomimoniker = null;
                if (ucomirunningObjectTable != null)
                {
                    Marshal.ReleaseComObject(ucomirunningObjectTable);
                }
                ucomirunningObjectTable = null;
            }
            return(result);
        }