示例#1
0
        private static void DumpTypes(ClrHeap heap, ulong obj, string type)
        {
            var resultItem = new ServiceDescriptionEntry((int)heap.Runtime.DataTarget.ProcessId);

            // Get ServiceEndpoint[]
            List <ulong> endpointObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, obj, HIERARCHY_ServiceDescription_To_ServiceEndpoints, 0, TYPE_ServiceEndpointArray);

            foreach (var endpointObj in endpointObjs)
            {
                var epEntry = new ServiceEndpointEntry();

                // Get Contract
                ulong contractObj = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_ContractType, 0);

                if (contractObj == 0)
                {
                    continue;
                }

                string contractTypeName = heap.GetObjectType(contractObj).GetRuntimeType(contractObj).Name;
                epEntry.Contract = contractTypeName;

                // Get IContractBehavior[]
                List <ulong> contractBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_ContractBehaviors, 0, TYPE_ContractBehaviorArray);

                foreach (var contractBehaviorObj in contractBehaviorObjs)
                {
                    ClrType itemType = heap.GetObjectType(contractBehaviorObj);
                    epEntry.ContractBehaviors.Add(itemType.Name);
                }

                // Get OperationDescription[]
                List <ulong> operationDescObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_OperationDescriptions, 0, TYPE_OperationDescriptionArray);

                foreach (var operationDescObj in operationDescObjs)
                {
                    ulong  opNameObj = ClrMdHelper.GetLastObjectInHierarchy(heap, operationDescObj, HIERARCHY_OperationDescription_To_Name, 0);
                    string opName    = ClrMdHelper.GetObjectAs <string>(heap, opNameObj, FIELD_XmlName);
                    var    odEntry   = new OperationDescriptionEntry();
                    odEntry.OperationName = opName;

                    // Get IOperationBehavior[]
                    List <ulong> operationBehavObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, operationDescObj, HIERARCHY_OperationDescription_To_OperationBehaviors, 0, TYPE_OperationBehaviorArray);

                    foreach (var operationBehavObj in operationBehavObjs)
                    {
                        ClrType itemType = heap.GetObjectType(operationBehavObj);
                        odEntry.OperationBehaviors.Add(itemType.Name);
                    }

                    epEntry.ContractOperations.Add(odEntry);
                }

                // Get CallbackContract
                ulong cbcontractObj = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_CallbackContractType, 0);

                if (cbcontractObj != 0)
                {
                    string cbcontractTypeName = heap.GetObjectType(cbcontractObj).GetRuntimeType(cbcontractObj).Name;
                    epEntry.CallbackContract = cbcontractTypeName;
                }

                // Get EndpointAddress URI
                ulong  uriObj = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_Uri, 0);
                string uri    = ClrMdHelper.GetObjectAs <string>(heap, uriObj, FIELD_UriName);
                epEntry.Uri = uri;

                // Read binding security information.
                ulong   bindingObj  = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, new [] { "binding" }, 0);
                ClrType bindingType = heap.GetObjectType(bindingObj);

                if (bindingType == null)
                {
                    epEntry.BindingSecurity = new UnknownBindingSecurity();
                }
                else if (bindingType.Name.EndsWith("NetTcpBinding"))
                {
                    ulong securityObj = ClrMdHelper.GetLastObjectInHierarchy(heap, bindingObj, new[] { "security" }, 0);

                    NetTcpBindingSecurity netTcpBindingSecurity = new NetTcpBindingSecurity();
                    netTcpBindingSecurity.SecurityMode = ClrMdHelper.GetObjectAs <SecurityMode>(heap, securityObj, FIELD_NetTcpBindingSecurityMode);

                    ulong tcpTransportSecurityObj = ClrMdHelper.GetLastObjectInHierarchy(heap, securityObj, HIERARCHY_NetTcpBindingSecurity_To_TcpTransportSecurity, 0);
                    netTcpBindingSecurity.ClientCredentialType = (TcpClientCredentialType)ClrMdHelper.GetObjectAs <int>(heap, tcpTransportSecurityObj, FIELD_NetTcpBindingClientCredentialType);

                    epEntry.BindingSecurity = netTcpBindingSecurity;
                }
                else if (bindingType.Name.EndsWith("NetNamedPipeBinding"))
                {
                    ulong securityObj = ClrMdHelper.GetLastObjectInHierarchy(heap, bindingObj, new[] { "security" }, 0);

                    NetNamedPipeBindingSecurity netNamedPipeSecurity = new NetNamedPipeBindingSecurity();
                    netNamedPipeSecurity.SecurityMode = ClrMdHelper.GetObjectAs <NetNamedPipeSecurityMode>(heap, securityObj, FIELD_NetTcpBindingSecurityMode);

                    epEntry.BindingSecurity = netNamedPipeSecurity;
                }
                else
                {
                    epEntry.BindingSecurity = new UnknownBindingSecurity(bindingType.Name);
                }

                // Get IEndpointBehavior[]
                List <ulong> endpBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_EndpointBehaviors, 0, TYPE_EndpointBehaviorArray);

                foreach (var endpBehaviorObj in endpBehaviorObjs)
                {
                    ClrType itemType = heap.GetObjectType(endpBehaviorObj);
                    epEntry.EndpointBehaviors.Add(itemType.Name);
                }

                resultItem.ServiceEndpoints.Add(epEntry);
            }

            // Get IServiceBehavior[]
            List <ulong> svcBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, obj, HIERARCHY_ServiceDescription_To_ServiceBehaviors, 0, TYPE_ServiceBehaviorArray);

            foreach (var svcBehaviorObj in svcBehaviorObjs)
            {
                ClrType svcBehaviorType = heap.GetObjectType(svcBehaviorObj);
                resultItem.ServiceBehaviors.Add(svcBehaviorType.Name);
            }

            RESULTS.Add(resultItem);
        }
示例#2
0
        private static void DumpTypes(ClrHeap heap, ulong obj, string type)
        {
            var resultItem = new ServiceDescriptionEntry((int)heap.Runtime.DataTarget.ProcessId);

            // Get ServiceEndpoint[]
            List <ulong> endpointObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, obj, HIERARCHY_ServiceDescription_To_ServiceEndpoints, 0, TYPE_ServiceEndpointArray);

            foreach (var endpointObj in endpointObjs)
            {
                var epEntry = new ServiceEndpointEntry();

                // Get Contract
                ulong  contractObj      = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_ContractType, 0);
                string contractTypeName = heap.GetObjectType(contractObj).GetRuntimeType(contractObj).Name;
                epEntry.Contract = contractTypeName;

                // Get IContractBehavior[]
                List <ulong> contractBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_ContractBehaviors, 0, TYPE_ContractBehaviorArray);

                foreach (var contractBehaviorObj in contractBehaviorObjs)
                {
                    ClrType itemType = heap.GetObjectType(contractBehaviorObj);
                    epEntry.ContractBehaviors.Add(itemType.Name);
                }

                // Get OperationDescription[]
                List <ulong> operationDescObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_OperationDescriptions, 0, TYPE_OperationDescriptionArray);

                foreach (var operationDescObj in operationDescObjs)
                {
                    ulong  opNameObj = ClrMdHelper.GetLastObjectInHierarchy(heap, operationDescObj, HIERARCHY_OperationDescription_To_Name, 0);
                    string opName    = ClrMdHelper.GetObjectAs <string>(heap, opNameObj, FIELD_XmlName);
                    var    odEntry   = new OperationDescriptionEntry();
                    odEntry.OperationName = opName;

                    // Get IOperationBehavior[]
                    List <ulong> operationBehavObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, operationDescObj, HIERARCHY_OperationDescription_To_OperationBehaviors, 0, TYPE_OperationBehaviorArray);

                    foreach (var operationBehavObj in operationBehavObjs)
                    {
                        ClrType itemType = heap.GetObjectType(operationBehavObj);
                        odEntry.OperationBehaviors.Add(itemType.Name);
                    }

                    epEntry.ContractOperations.Add(odEntry);
                }

                // Get CallbackContract
                ulong cbcontractObj = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_CallbackContractType, 0);

                if (cbcontractObj != 0)
                {
                    string cbcontractTypeName = heap.GetObjectType(cbcontractObj).GetRuntimeType(cbcontractObj).Name;
                    epEntry.CallbackContract = cbcontractTypeName;
                }

                // Get EndpointAddress URI
                ulong  uriObj = ClrMdHelper.GetLastObjectInHierarchy(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_Uri, 0);
                string uri    = ClrMdHelper.GetObjectAs <string>(heap, uriObj, FIELD_UriName);
                epEntry.Uri = uri;

                // Get IEndpointBehavior[]
                List <ulong> endpBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, endpointObj, HIERARCHY_ServiceEndpoint_To_EndpointBehaviors, 0, TYPE_EndpointBehaviorArray);

                foreach (var endpBehaviorObj in endpBehaviorObjs)
                {
                    ClrType itemType = heap.GetObjectType(endpBehaviorObj);
                    epEntry.EndpointBehaviors.Add(itemType.Name);
                }

                resultItem.ServiceEndpoints.Add(epEntry);
            }

            // Get IServiceBehavior[]
            List <ulong> svcBehaviorObjs = ClrMdHelper.GetLastObjectInHierarchyAsArray(heap, obj, HIERARCHY_ServiceDescription_To_ServiceBehaviors, 0, TYPE_ServiceBehaviorArray);

            foreach (var svcBehaviorObj in svcBehaviorObjs)
            {
                ClrType svcBehaviorType = heap.GetObjectType(svcBehaviorObj);
                resultItem.ServiceBehaviors.Add(svcBehaviorType.Name);
            }

            RESULTS.Add(resultItem);
        }