Esempio n. 1
0
        /// <summary>
        /// Sends the ServiceID to CAM to start decryption.
        /// </summary>
        /// <param name="serviceId">Service ID</param>
        /// <returns>true if successful or no CI available</returns>
        public bool SendServiceIdToCam(Int32 serviceId)
        {
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(true);
            }

            KSMETHOD KsProperty = new KSMETHOD(KSPROPERTYSET_DD_COMMON_INTERFACE,
                                               (Int32)KSPROPERTY_DD_COMMON_INTERFACE.KSPROPERTY_DD_DECRYPT_PROGRAM,
                                               KSPROPERTY_TYPE_SET);
            Int32 paramSize  = Marshal.SizeOf(sizeof(Int32));
            Int32 dwReturned = 0;
            // Initialize unmanged memory to hold the struct.
            IntPtr pSid = Marshal.AllocHGlobal(paramSize);

            Marshal.WriteInt32(pSid, serviceId);
            try
            {
                Int32 hr = pControl.KsProperty(ref KsProperty, Marshal.SizeOf(KsProperty),
                                               pSid, paramSize,
                                               ref dwReturned);
                Log.Log.Debug(
                    FormatMessage(String.Format("--> Setting service id {0} for decrypting returned {1}", serviceId, hr)));
                return(hr == 0);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pSid);
            }
        }
Esempio n. 2
0
        private bool GetMenuTitle(out DD_CAM_MENU_TITLE MenuTitle)
        {
            MenuTitle = new DD_CAM_MENU_TITLE();

            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            KSMETHOD KsProperty = new KSMETHOD(KSPROPERTYSET_DD_COMMON_INTERFACE,
                                               (Int32)KSPROPERTY_DD_COMMON_INTERFACE.KSPROPERTY_DD_CAM_MENU_TITLE,
                                               KSPROPERTY_TYPE_GET);
            Int32 ulMenuSize = Marshal.SizeOf(MenuTitle);
            Int32 dwReturned = 0;
            // Initialize unmanged memory to hold the struct.
            IntPtr pTitle = Marshal.AllocHGlobal(Marshal.SizeOf(MenuTitle));

            try
            {
                Int32 hr = pControl.KsProperty(ref KsProperty, Marshal.SizeOf(KsProperty),
                                               pTitle, ulMenuSize,
                                               ref dwReturned
                                               );

                if (hr != 0 || dwReturned != ulMenuSize)
                {
                    return(false);
                }

                MenuTitle = (DD_CAM_MENU_TITLE)Marshal.PtrToStructure(pTitle, typeof(DD_CAM_MENU_TITLE));
                return(true);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pTitle);
            }
        }