예제 #1
0
        static int EnumInterfaces(Queue <string> args, bool runtime_class)
        {
            using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, args.Dequeue()))
            {
                using (StreamWriter writer = new StreamWriter(client))
                {
                    Guid   clsid             = Guid.Empty;
                    CLSCTX clsctx            = 0;
                    bool   sta               = false;
                    string activatable_class = string.Empty;
                    if (runtime_class)
                    {
                        activatable_class = args.Dequeue();
                    }
                    else
                    {
                        if (!Guid.TryParse(args.Dequeue(), out clsid))
                        {
                            return(1);
                        }
                    }

                    sta = args.Dequeue() == "s";
                    if (!Enum.TryParse(args.Dequeue(), true, out clsctx))
                    {
                        return(1);
                    }

                    int timeout = 10000;
                    if (args.Count > 0)
                    {
                        if (!int.TryParse(args.Dequeue(), out timeout) || timeout < 0)
                        {
                            return(1);
                        }
                    }

                    COMEnumerateInterfaces intf = new COMEnumerateInterfaces(clsid, clsctx, activatable_class, sta, timeout);
                    if (intf.Exception != null)
                    {
                        writer.WriteLine("ERROR:{0:X08}", intf.Exception.NativeErrorCode);
                        return(1);
                    }
                    else
                    {
                        foreach (COMInterfaceInstance entry in intf.Interfaces)
                        {
                            writer.WriteLine("{0}", entry);
                        }
                        foreach (COMInterfaceInstance entry in intf.FactoryInterfaces)
                        {
                            writer.WriteLine("*{0}", entry);
                        }
                        return(0);
                    }
                }
            }
        }
예제 #2
0
 private async Task <COMEnumerateInterfaces> GetSupportedInterfacesInternal()
 {
     try
     {
         return(await COMEnumerateInterfaces.GetInterfacesOOP(this, m_registry));
     }
     catch (Win32Exception)
     {
         throw;
     }
 }
예제 #3
0
        /// <summary>
        /// Get list of supported Interface IIDs (that we know about)
        /// NOTE: This will load the object itself to check what is supported, it _might_ crash the app
        /// The returned array is cached so subsequent calls to this function return without calling into COM
        /// </summary>
        /// <param name="refresh">Force the supported interface list to refresh</param>
        /// <returns>Returns true if supported interfaces were refreshed.</returns>
        /// <exception cref="Win32Exception">Thrown on error.</exception>
        public async Task <bool> LoadSupportedInterfacesAsync(bool refresh)
        {
            if (refresh || m_interfaces == null)
            {
                COMEnumerateInterfaces enum_int = await GetSupportedInterfacesInternal();

                m_interfaces         = new List <COMInterfaceInstance>(enum_int.Interfaces);
                m_factory_interfaces = new List <COMInterfaceInstance>(enum_int.FactoryInterfaces);
                return(true);
            }
            return(false);
        }
예제 #4
0
        public async Task <bool> LoadSupportedInterfacesAsync(bool refresh, NtToken token)
        {
            if (refresh || !InterfacesLoaded)
            {
                COMEnumerateInterfaces enum_int = await GetSupportedInterfacesInternal(token);

                m_interfaces         = new List <COMInterfaceInstance>(enum_int.Interfaces);
                m_factory_interfaces = new List <COMInterfaceInstance>(enum_int.FactoryInterfaces);
                InterfacesLoaded     = true;
                return(true);
            }
            return(false);
        }
예제 #5
0
        static int EnumInterfaces(List <string> args)
        {
            using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, args[0]))
            {
                using (StreamWriter writer = new StreamWriter(client))
                {
                    Guid clsid;
                    if (!Guid.TryParse(args[1], out clsid))
                    {
                        return(1);
                    }

                    bool sta = args[2] == "s";

                    CLSCTX clsctx;
                    if (!Enum.TryParse(args[3], true, out clsctx))
                    {
                        return(1);
                    }

                    int timeout = 10000;
                    if (args.Count > 4)
                    {
                        if (!int.TryParse(args[4], out timeout) || timeout < 0)
                        {
                            return(1);
                        }
                    }

                    COMEnumerateInterfaces intf = new COMEnumerateInterfaces(clsid, clsctx, sta, timeout);
                    if (intf.Exception != null)
                    {
                        writer.WriteLine("ERROR:{0:X08}", intf.Exception.NativeErrorCode);
                        return(1);
                    }
                    else
                    {
                        foreach (COMInterfaceInstance entry in intf.Interfaces)
                        {
                            writer.WriteLine("{0}", entry);
                        }
                        foreach (COMInterfaceInstance entry in intf.FactoryInterfaces)
                        {
                            writer.WriteLine("*{0}", entry);
                        }
                        return(0);
                    }
                }
            }
        }
예제 #6
0
 private async Task <COMEnumerateInterfaces> GetSupportedInterfacesInternal(NtToken token)
 {
     try
     {
         return(await COMEnumerateInterfaces.GetInterfacesOOP(this, Database, token));
     }
     catch (Win32Exception)
     {
         throw;
     }
     catch (AggregateException agg)
     {
         throw agg.InnerException;
     }
 }
예제 #7
0
        /// <summary>
        /// Get list of supported Interface IIDs (that we know about)
        /// NOTE: This will load the object itself to check what is supported, it _might_ crash the app
        /// The returned array is cached so subsequent calls to this function return without calling into COM
        /// </summary>
        /// <param name="refresh">Force the supported interface list to refresh</param>
        /// <returns>Returns true if supported interfaces were refreshed.</returns>
        /// <exception cref="Win32Exception">Thrown on error.</exception>
        public async Task <bool> LoadSupportedInterfacesAsync(bool refresh)
        {
            if (Clsid == Guid.Empty)
            {
                return(false);
            }

            if (refresh || !m_loaded_interfaces)
            {
                COMEnumerateInterfaces enum_int = await GetSupportedInterfacesInternal();

                m_interfaces         = new List <COMInterfaceInstance>(enum_int.Interfaces);
                m_factory_interfaces = new List <COMInterfaceInstance>(enum_int.FactoryInterfaces);
                m_loaded_interfaces  = true;
                return(true);
            }
            return(false);
        }
예제 #8
0
        static int EnumInterfaces(List<string> args)
        {
            using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(PipeDirection.Out, args[0]))
            {
                using (StreamWriter writer = new StreamWriter(client))
                {
                    Guid clsid;
                    if (!Guid.TryParse(args[1], out clsid))
                    {
                        return 1;
                    }

                    bool sta = args[2] == "s";

                    CLSCTX clsctx;
                    if (!Enum.TryParse(args[3], true, out clsctx))
                    {
                        return 1;
                    }

                    int timeout = 10000;
                    if (args.Count > 4)
                    {
                        if (!int.TryParse(args[4], out timeout) || timeout < 0)
                        {
                            return 1;
                        }
                    }

                    COMEnumerateInterfaces intf = new COMEnumerateInterfaces(clsid, clsctx, sta, timeout);
                    if (intf.Exception != null)
                    {
                        writer.WriteLine("ERROR:{0:X08}", intf.Exception.NativeErrorCode);
                        return 1;
                    }
                    else
                    {
                        foreach (COMInterfaceInstance entry in intf.Interfaces)
                        {
                            writer.WriteLine("{0}", entry);
                        }
                        foreach (COMInterfaceInstance entry in intf.FactoryInterfaces)
                        {
                            writer.WriteLine("*{0}", entry);
                        }
                        return 0;
                    }
                }
            }
        }