コード例 #1
0
        /// <summary>
        /// Format the RPC server as text.
        /// </summary>
        /// <param name="remove_comments">True to remove comments from the output.</param>
        /// <returns>The formatted RPC server.</returns>
        public string FormatAsText(bool remove_comments)
        {
            INdrFormatter formatter = DefaultNdrFormatter.Create(remove_comments
                ? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None);
            StringBuilder builder = new StringBuilder();

            if (!remove_comments)
            {
                builder.AppendLine($"// DllOffset: 0x{Offset:X}");
                builder.AppendLine($"// DllPath {FilePath}");
            }

            if (ComplexTypes.Any())
            {
                if (!remove_comments)
                {
                    builder.AppendLine("// Complex Types: ");
                }
                foreach (var type in ComplexTypes)
                {
                    builder.AppendLine(formatter.FormatComplexType(type));
                }
            }

            builder.AppendLine().AppendLine(formatter.FormatRpcServerInterface(Server));

            return(builder.ToString());
        }
コード例 #2
0
        private INdrFormatter GetNdrFormatter(bool useDemangler)
        {
            DefaultNdrFormatterFlags flags     = cbProxyRenderStyle.SelectedIndex % 2 == 0 ? DefaultNdrFormatterFlags.None : DefaultNdrFormatterFlags.RemoveComments;
            Func <string, string>    demangler = useDemangler ? COMUtilities.DemangleWinRTName : (Func <string, string>)null;
            bool useNtApiFormatter             = this.cbProxyRenderStyle.SelectedIndex < 2;

            return(useNtApiFormatter ?
                   DefaultNdrFormatter.Create(m_iids_to_names, demangler, flags) :

                   // cpp style requested
                   CppNdrFormatter.Create(m_iids_to_names, demangler, flags)
                   );
        }
コード例 #3
0
        public string Format(IDictionary <Guid, string> iids_to_names)
        {
            INdrFormatter formatter = DefaultNdrFormatter.Create(iids_to_names);
            StringBuilder builder   = new StringBuilder();

            builder.AppendFormat("[Guid(\"{0}\")]", Iid).AppendLine();
            string base_name = iids_to_names.ContainsKey(BaseIid) ?
                               iids_to_names[BaseIid] : String.Format("/* Unknown IID {0} */ IUnknown", BaseIid);

            builder.AppendFormat("interface {0} : {1} {{", Name, base_name).AppendLine();
            foreach (NdrProcedureDefinition proc in Procs)
            {
                builder.AppendFormat("    {0}", formatter.FormatProcedure(proc)).AppendLine();
            }
            builder.AppendLine("}").AppendLine();
            return(builder.ToString());
        }
コード例 #4
0
        /// <summary>
        /// Format the RPC server as text.
        /// </summary>
        /// <param name="remove_comments">True to remove comments from the output.</param>
        /// <param name="cpp_format">Formating using C++ pseduo syntax.</param>
        /// <returns>The formatted RPC server.</returns>
        public string FormatAsText(bool remove_comments, bool cpp_format)
        {
            DefaultNdrFormatterFlags flags = remove_comments
                ? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None;
            INdrFormatter formatter = cpp_format ? CppNdrFormatter.Create(flags) : DefaultNdrFormatter.Create(flags);
            StringBuilder builder   = new StringBuilder();

            if (!remove_comments)
            {
                builder.AppendLine($"// DllOffset: 0x{Offset:X}");
                builder.AppendLine($"// DllPath {FilePath}");
                if (!string.IsNullOrWhiteSpace(ServiceName))
                {
                    builder.AppendLine($"// ServiceName: {ServiceName}");
                    builder.AppendLine($"// ServiceDisplayName: {ServiceDisplayName}");
                }

                if (EndpointCount > 0)
                {
                    builder.AppendLine($"// Endpoints: {EndpointCount}");
                    foreach (var ep in Endpoints)
                    {
                        builder.AppendLine($"// {ep.BindingString}");
                    }
                }
            }

            if (ComplexTypes.Any())
            {
                if (!remove_comments)
                {
                    builder.AppendLine("// Complex Types: ");
                }
                foreach (var type in ComplexTypes)
                {
                    builder.AppendLine(formatter.FormatComplexType(type));
                }
            }

            builder.AppendLine().AppendLine(formatter.FormatRpcServerInterface(Server));

            return(builder.ToString());
        }
コード例 #5
0
        private string GetTextFromTag(object tag)
        {
            Type type = tag as Type;
            COMProxyInstanceEntry   proxy = tag as COMProxyInstanceEntry;
            NdrComplexTypeReference str   = tag as NdrComplexTypeReference;

            if (type != null)
            {
                return(TypeToText(type));
            }
            else if (proxy != null)
            {
                return(proxy.Format(m_iids_to_names));
            }
            else if (str != null)
            {
                INdrFormatter formatter = DefaultNdrFormatter.Create(m_iids_to_names);
                return(formatter.FormatComplexType(str));
            }

            return(String.Empty);
        }
コード例 #6
0
        private string GetTextFromTag(object tag)
        {
            var type  = tag as Type;
            var proxy = tag as NdrComProxyDefinition;
            NdrComplexTypeReference str = tag as NdrComplexTypeReference;

            if (type != null)
            {
                return(COMUtilities.FormatComType(type));
            }
            else if (proxy != null)
            {
                INdrFormatter formatter = DefaultNdrFormatter.Create(m_iids_to_names, COMUtilities.DemangleWinRTName);
                return(formatter.FormatComProxy(proxy));
            }
            else if (str != null)
            {
                INdrFormatter formatter = DefaultNdrFormatter.Create(m_iids_to_names);
                return(formatter.FormatComplexType(str));
            }

            return(String.Empty);
        }