Ejemplo n.º 1
0
 public NuGenFieldDefinition(NuGenIMetaDataImport2 import, NuGenTypeDefinition typeDefinition, string name, uint token, IntPtr signatureBlob, uint signatureBlobLength, uint flags, uint defaultValueType, IntPtr defaultValue, uint defaultValueLength)
 {
     BaseTypeDefinition = typeDefinition;
     Name                = name;
     Token               = token;
     SignatureBlob       = signatureBlob;
     SignatureBlobLength = signatureBlobLength;
     Flags               = (CorFieldAttr)flags;
     DefaultValueType    = (CorElementType)defaultValueType;
     DefaultValue        = defaultValue;
     DefaultValueLength  = defaultValueLength;
 }
Ejemplo n.º 2
0
        private void projectElements_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node != null && e.Node.Tag == null && e.Node.Nodes != null && e.Node.Nodes.Count >= 1)
            {
                NuGenTypeDefinition typeDefinition = e.Node.Nodes[0].Tag as NuGenTypeDefinition;

                if (typeDefinition != null)
                {
                    CreateTypeDefinitionSubnodes(typeDefinition, e.Node);
                    e.Node.Tag = true;
                }
            }
        }
Ejemplo n.º 3
0
        public void EnumerateTypeDefinitions(NuGenIMetaDataImport2 import, ModuleWrapper debuggedModule)
        {
            DebuggedModule = debuggedModule;
            IntPtr enumHandle = IntPtr.Zero;

            uint[] typeDefs = new uint[NuGenProject.DefaultArrayCount];
            uint   count    = 0;

            import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count);

            while (count > 0)
            {
                for (uint typeDefsIndex = 0; typeDefsIndex < count; typeDefsIndex++)
                {
                    uint token = typeDefs[typeDefsIndex];
                    uint typeNameLength;
                    uint typeDefFlags;
                    uint baseTypeToken;

                    import.GetTypeDefProps(token, NuGenProject.DefaultCharArray,
                                           Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken);

                    if (typeNameLength > NuGenProject.DefaultCharArray.Length)
                    {
                        NuGenProject.DefaultCharArray = new char[typeNameLength];

                        import.GetTypeDefProps(token, NuGenProject.DefaultCharArray,
                                               Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken);
                    }

                    NuGenTypeDefinition typeDefinition = new NuGenTypeDefinition(import, this, NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, typeNameLength), token, (CorTypeAttr)typeDefFlags, baseTypeToken);
                    TypeDefinitions[token]    = typeDefinition;
                    Assembly.AllTokens[token] = typeDefinition;
                }

                import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count);
            }

            import.CloseEnum(enumHandle);

            foreach (NuGenTypeDefinition typeDefinition in TypeDefinitions.Values)
            {
                if (typeDefinition.IsNestedType)
                {
                    typeDefinition.FindEnclosingType(import);
                }
            }

            DebuggedModule = null;
        }
Ejemplo n.º 4
0
        private void FindGetThreadNameMethod(uint threadTypeToken, ModuleWrapper module)
        {
            NuGenTypeDefinition threadType = NuGenHelperFunctions.FindObjectByToken(threadTypeToken, module) as NuGenTypeDefinition;

            if (threadType != null)
            {
                NuGenProperty nameProperty = threadType.FindPropertyByName("Name");

                if (nameProperty != null)
                {
                    GetThreadNameMethod = NuGenHelperFunctions.FindObjectByToken(nameProperty.GetterMethodToken, module) as NuGenMethodDefinition;
                }
            }

            HasSearchedForNameMethod = true;
        }
Ejemplo n.º 5
0
        private void ValueDisplayer_TypeInspected(NuGenValueDisplayer sender, NuGenTypeDefinition typeDefinition)
        {
            InvokeDisplayEvaluationState(string.Format("Type inspected: {0} (assembly name: {1})", typeDefinition.FullName, typeDefinition.ModuleScope.Assembly.FileName), 1);
            UpdateCancelEvaluation(sender);

            if (!IsTypeOfValueFound)
            {
                IsTypeOfValueFound = true;

                NuGenStringValueFormatter objectTypeValueFormatter = new NuGenStringValueFormatter(typeDefinition.FullName);
                objectTypeValueFormatter.FieldGroup = ValueFieldGroup.ObjectInformation;
                objectTypeValueFormatter.Name       = "Type of value";

                InvokeDisplayValueFormatter(objectTypeValueFormatter, sender.ParentNode);
            }
        }
Ejemplo n.º 6
0
        public NuGenProperty(NuGenIMetaDataImport2 import, uint token, NuGenTypeDefinition baseTypeDefinition, string name, uint flags, IntPtr signature, uint signatureLength, uint elementType, IntPtr defaultValue, uint defaultValueLength, uint setterMethodToken, uint getterMethodToken, uint[] otherMethods, uint otherMethodsCount)
        {
            Token = token;
            BaseTypeDefinition = baseTypeDefinition;
            Name               = name;
            Flags              = (CorPropertyAttr)flags;
            Signature          = signature;
            SignatureLength    = signatureLength;
            ElementType        = (CorElementType)elementType;
            DefaultValue       = defaultValue;
            DefaultValueLength = defaultValueLength;

            if (DefaultValueLength > 0)
            {
                throw new NotImplementedException("Default value is given for the property.");
            }

            SetterMethodToken = setterMethodToken;
            GetterMethodToken = getterMethodToken;
            OtherMethods      = otherMethods;
            OtherMethodsCount = otherMethodsCount;
        }
Ejemplo n.º 7
0
        private TreeNode CreateTypeDefinitionNode(Dictionary <string, TreeNode> namespaceNodes, TreeNode moduleScopeNode, NuGenTypeDefinition typeDefinition, bool createDefinitionNode)
        {
            TreeNode result = new TreeNode(NuGenHelperFunctions.TruncateText(typeDefinition.FullName));

            result.ImageIndex = 11;
            string typeNamespace = typeDefinition.Namespace;

            if (typeNamespace.Length == 0)
            {
                typeNamespace = NuGenConstants.DefaultNamespaceName;
            }

            if (namespaceNodes.ContainsKey(typeNamespace))
            {
                namespaceNodes[typeNamespace].Nodes.Add(result);
            }
            else
            {
                TreeNode namespaceNode = new TreeNode(typeNamespace);
                namespaceNode.ImageIndex = 8;
                moduleScopeNode.Nodes.Add(namespaceNode);
                namespaceNodes[typeNamespace] = namespaceNode;

                namespaceNode.Nodes.Add(result);
            }

            if (createDefinitionNode)
            {
                TreeNode classNode = new TreeNode("definition");
                classNode.ImageIndex = 2;
                classNode.Tag        = typeDefinition;
                result.Nodes.Add(classNode);
            }
            else
            {
                CreateTypeDefinitionSubnodes(typeDefinition, result);
                result.Tag = true;
            }

            return(result);
        }
Ejemplo n.º 8
0
        private static TreeNode SearchNodes(TreeNode parentNode, NuGenTokenBase tokenObject)
        {
            TreeNode result = null;

            if (parentNode != null)
            {
                switch (tokenObject.ItemType)
                {
                case SearchOptions.Assembly:
                    NuGenAssembly assembly = (NuGenAssembly)tokenObject;
                    parentNode.Expand();
                    result = FindNodeByName(parentNode.Nodes, assembly.FileName);
                    break;

                case SearchOptions.AssemblyReference:
                    NuGenAssemblyReference assemblyReference = (NuGenAssemblyReference)tokenObject;

                    result = SearchTokenNode(parentNode, assemblyReference.Assembly, " References", assemblyReference.Name);
                    break;

                case SearchOptions.FieldDefintion:
                    NuGenFieldDefinition fieldDefinition = (NuGenFieldDefinition)tokenObject;

                    result = SearchTokenNode(parentNode, fieldDefinition.BaseTypeDefinition, "Fields", fieldDefinition.Name);
                    break;

                case SearchOptions.File:
                    NuGenFile file = (NuGenFile)tokenObject;

                    result = SearchTokenNode(parentNode, file.Assembly, " Files", file.Name);
                    break;

                case SearchOptions.ManifestResource:
                    NuGenManifestResource manifestResource = (NuGenManifestResource)tokenObject;

                    result = SearchTokenNode(parentNode, manifestResource.Assembly, " Manifest Resources", manifestResource.Name);
                    break;

                case SearchOptions.MethodDefinition:
                    NuGenMethodDefinition methodDefinition = (NuGenMethodDefinition)tokenObject;

                    if (methodDefinition.OwnerProperty == null)
                    {
                        result = SearchTokenNode(parentNode, methodDefinition.BaseTypeDefinition, "Methods", methodDefinition.DisplayName);
                    }
                    else
                    {
                        result = SearchNodes(parentNode, methodDefinition.OwnerProperty);
                        result.Expand();
                        result = FindNodeByName(result.Nodes, methodDefinition.DisplayName);
                    }
                    break;

                case SearchOptions.ModuleReference:
                    NuGenModuleReference moduleReference = (NuGenModuleReference)tokenObject;

                    result = SearchTokenNode(parentNode, moduleReference.Assembly, " Module References", moduleReference.Name);
                    break;

                case SearchOptions.ModuleScope:
                    NuGenModuleScope moduleScope = (NuGenModuleScope)tokenObject;

                    result = SearchTokenNode(parentNode, moduleScope.Assembly, null, moduleScope.Name);
                    break;

                case SearchOptions.Property:
                    NuGenProperty property = (NuGenProperty)tokenObject;

                    result = SearchTokenNode(parentNode, property.BaseTypeDefinition, "Properties", property.Name);
                    break;

                case SearchOptions.TypeDefinition:
                    NuGenTypeDefinition typeDefinition = (NuGenTypeDefinition)tokenObject;
                    string typeNamespace = typeDefinition.Namespace;

                    if (typeNamespace.Length == 0)
                    {
                        typeNamespace = NuGenConstants.DefaultNamespaceName;
                    }

                    result = SearchTokenNode(parentNode, typeDefinition.ModuleScope, typeNamespace, typeDefinition.FullName);
                    break;
                }
            }

            return(result);
        }
		public NuGenMethodDefinition(NuGenIMetaDataImport2 import, NuGenTypeDefinition typeDefinition, string name, uint token, uint flags, IntPtr signaturePointer, uint signatureLength, uint rva, uint implementationFlags)
		{
			BaseTypeDefinition = typeDefinition;
			Name = name;
			Token = token;
			Flags = (CorMethodAttr)flags;
			SignaturePointer = signaturePointer;
			SignatureLength = signatureLength;
			Rva = rva;
			ImplementationFlags = (CorMethodImpl)implementationFlags;

			NuGenAssembly assembly = BaseTypeDefinition.ModuleScope.Assembly;

			NuGenHelperFunctions.GetMemberReferences(assembly, token);
			EnumParameters(import);
			GenericParameters = NuGenHelperFunctions.EnumGenericParameters(import, assembly, this);
			MethodSpecs = NuGenHelperFunctions.EnumMethodSpecs(import, assembly, this);
			
			if (assembly.ModuleScope.DebuggedModule != null)
			{
				FunctionWrapper debuggedFunction = assembly.ModuleScope.DebuggedModule.GetFunction(Token);

				try
				{
					LocalVarSigToken = debuggedFunction.GetLocalVarSigToken();

					if (LocalVarSigToken == DefaultSignatureValue)
					{
						LocalVarSigToken = 0;
					}

					MethodAddress = debuggedFunction.GetAddress();
				}
				catch (COMException comException)
				{
					//0x8013130a exception means that the method is native.
					if ((uint)comException.ErrorCode == 0x8013130a)
					{
						LocalVarSigToken = 0;
					}
				}
			}
		}
Ejemplo n.º 10
0
		public void LoadAssemblyFromMetadataInterfaces(ModuleWrapper debuggedModule)
		{
			string assemblyPath = (IsInMemory ? Name : FullPath);
			NuGenUIHandler.Instance.ResetProgressBar();

			if (IsInMemory)
			{
				NuGenUIHandler.Instance.SetProgressBarMaximum(15);
				DebuggedProcess = debuggedModule.GetProcess();
			}
			else
			{
				NuGenUIHandler.Instance.SetProgressBarMaximum(16);
				NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Reading header...", true);
				ReadHeader();
				NuGenUIHandler.Instance.StepProgressBar(1);
			}

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Opening assembly references...", true);
			OpenAssemblyRefs();
			NuGenUIHandler.Instance.StepProgressBar(1);

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading user strings...", true);
			GetUserStrings();
			NuGenUIHandler.Instance.StepProgressBar(1);

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading manifest resources...", true);
			GetManifestResources();
			NuGenUIHandler.Instance.StepProgressBar(1);

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading files...", true);
			GetFiles();
			NuGenUIHandler.Instance.StepProgressBar(1);

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading module references...", true);
			GetModuleReferences();
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading type references...", true);
			GetTypeReferences();
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading global type's references...", true);
			NuGenHelperFunctions.GetMemberReferences(this, 0);
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading type specifications...", true);
			GetTypeSpecs();
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading standalone signatures...", true);
			GetSignatures();
			NuGenUIHandler.Instance.StepProgressBar(1);

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading module scope...", true);
			ModuleScope = new NuGenModuleScope(Import, this);
			ModuleScope.EnumerateTypeDefinitions(Import, debuggedModule);
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading global type...", true);
			GlobalType = new NuGenTypeDefinition(Import, ModuleScope, 0);
			NuGenUIHandler.Instance.StepProgressBar(1);
			AllTokens[0] = GlobalType;

			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Associating properties with methods...", true);
			AssociatePropertiesWithMethods();
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Reading assembly properties...", true);

			DisplayInTree = false;
			try
			{
				ReadProperties();
				DisplayInTree = true;
			}
			catch (COMException comException)
			{
				unchecked
				{
					if (comException.ErrorCode != (int)0x80131130)
					{
						throw;
					}
				}
			}

			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading resolving resolution scopes...", true);
			ResolveResolutionScopes();
			NuGenUIHandler.Instance.StepProgressBar(1);
			NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Searching for entry method...", true);
			SearchEntryPoint();
			NuGenUIHandler.Instance.StepProgressBar(1);
		}
Ejemplo n.º 11
0
 public NuGenInterfaceImplementation(NuGenIMetaDataImport2 import, uint token, NuGenTypeDefinition typeDefinition, uint interfaceToken)
 {
     Token          = token;
     TypeDefinition = typeDefinition;
     InterfaceToken = interfaceToken;
 }
Ejemplo n.º 12
0
        private static void CreateTypeDefinitionSubnodes(NuGenTypeDefinition typeDefinition, TreeNode typeDefinitionNode)
        {
            NuGenAssembly assembly = typeDefinition.ModuleScope.Assembly;

            typeDefinition.LazyInitialize(assembly.AllTokens);
            Dictionary <uint, NuGenMethodDefinition> methodDefinitions = null;

            if (typeDefinition.MethodDefinitions != null)
            {
                methodDefinitions = new Dictionary <uint, NuGenMethodDefinition>(typeDefinition.MethodDefinitions);
            }

            if (typeDefinition.FieldDefinitions != null)
            {
                TreeNode fieldsNode = new TreeNode("Fields");
                fieldsNode.ImageIndex = 9;
                typeDefinitionNode.Nodes.Add(fieldsNode);

                foreach (NuGenFieldDefinition field in typeDefinition.FieldDefinitions.Values)
                {
                    field.LazyInitialize(assembly.AllTokens);
                    TreeNode fieldNode = new TreeNode(NuGenHelperFunctions.TruncateText(field.Name));
                    fieldNode.Tag        = field;
                    fieldNode.ImageIndex = 10;
                    fieldsNode.Nodes.Add(fieldNode);
                }
            }

            if (typeDefinition.Properties != null)
            {
                TreeNode propertiesNode = new TreeNode("Properties");
                propertiesNode.ImageIndex = 9;
                typeDefinitionNode.Nodes.Add(propertiesNode);

                foreach (NuGenProperty property in typeDefinition.Properties.Values)
                {
                    property.LazyInitialize(assembly.AllTokens);
                    TreeNode propertyNode = new TreeNode(NuGenHelperFunctions.TruncateText(property.Name));
                    propertyNode.ImageIndex = 11;
                    propertiesNode.Nodes.Add(propertyNode);

                    TreeNode definitionNode = new TreeNode(" definition");
                    definitionNode.Tag        = property;
                    definitionNode.ImageIndex = 2;
                    propertyNode.Nodes.Add(definitionNode);

                    if (methodDefinitions != null)
                    {
                        if (methodDefinitions.ContainsKey(property.GetterMethodToken))
                        {
                            NuGenMethodDefinition getterMethod = methodDefinitions[property.GetterMethodToken];
                            getterMethod.LazyInitialize(assembly.AllTokens);

                            TreeNode getterNode = new TreeNode(NuGenHelperFunctions.TruncateText(getterMethod.DisplayName));
                            getterNode.ImageIndex = 10;
                            getterNode.Tag        = getterMethod;
                            propertyNode.Nodes.Add(getterNode);

                            methodDefinitions.Remove(property.GetterMethodToken);
                        }

                        if (methodDefinitions.ContainsKey(property.SetterMethodToken))
                        {
                            NuGenMethodDefinition setterMethod = methodDefinitions[property.SetterMethodToken];
                            setterMethod.LazyInitialize(assembly.AllTokens);

                            TreeNode setterNode = new TreeNode(NuGenHelperFunctions.TruncateText(setterMethod.DisplayName));
                            setterNode.ImageIndex = 10;
                            setterNode.Tag        = setterMethod;
                            propertyNode.Nodes.Add(setterNode);

                            methodDefinitions.Remove(property.SetterMethodToken);
                        }

                        for (int index = 0; index < property.OtherMethodsCount; index++)
                        {
                            uint token = property.OtherMethods[index];

                            if (methodDefinitions.ContainsKey(token))
                            {
                                NuGenMethodDefinition otherMethod = methodDefinitions[token];
                                otherMethod.LazyInitialize(assembly.AllTokens);

                                TreeNode otherNode = new TreeNode(NuGenHelperFunctions.TruncateText(otherMethod.DisplayName));
                                otherNode.ImageIndex = 10;
                                otherNode.Tag        = otherMethod;
                                propertyNode.Nodes.Add(otherNode);

                                methodDefinitions.Remove(token);
                            }
                        }
                    }
                }
            }

            if (methodDefinitions != null && methodDefinitions.Count > 0)
            {
                TreeNode methodsNode = new TreeNode("Methods");
                methodsNode.ImageIndex = 9;
                typeDefinitionNode.Nodes.Add(methodsNode);

                foreach (NuGenMethodDefinition method in methodDefinitions.Values)
                {
                    method.LazyInitialize(assembly.AllTokens);
                    TreeNode methodNode = new TreeNode(NuGenHelperFunctions.TruncateText(method.DisplayName));
                    methodNode.ImageIndex = 12;
                    methodNode.Tag        = method;
                    methodsNode.Nodes.Add(methodNode);
                }
            }
        }
Ejemplo n.º 13
0
		private void ValueDisplayer_TypeInspected(NuGenValueDisplayer sender, NuGenTypeDefinition typeDefinition)
		{
			InvokeDisplayEvaluationState(string.Format("Type inspected: {0} (assembly name: {1})", typeDefinition.FullName, typeDefinition.ModuleScope.Assembly.FileName), 1);
			UpdateCancelEvaluation(sender);

			if (!IsTypeOfValueFound)
			{
				IsTypeOfValueFound = true;

				NuGenStringValueFormatter objectTypeValueFormatter = new NuGenStringValueFormatter(typeDefinition.FullName);
				objectTypeValueFormatter.FieldGroup = ValueFieldGroup.ObjectInformation;
				objectTypeValueFormatter.Name = "Type of value";

				InvokeDisplayValueFormatter(objectTypeValueFormatter, sender.ParentNode);
			}
		}
Ejemplo n.º 14
0
		public NuGenProperty(NuGenIMetaDataImport2 import, uint token, NuGenTypeDefinition baseTypeDefinition, string name, uint flags, IntPtr signature, uint signatureLength, uint elementType, IntPtr defaultValue, uint defaultValueLength, uint setterMethodToken, uint getterMethodToken, uint[] otherMethods, uint otherMethodsCount)
		{
			Token = token;
			BaseTypeDefinition = baseTypeDefinition;
			Name = name;
			Flags = (CorPropertyAttr)flags;
			Signature = signature;
			SignatureLength = signatureLength;
			ElementType = (CorElementType)elementType;
			DefaultValue = defaultValue;
			DefaultValueLength = defaultValueLength;

			if (DefaultValueLength > 0)
			{
				throw new NotImplementedException("Default value is given for the property.");
			}

			SetterMethodToken = setterMethodToken;
			GetterMethodToken = getterMethodToken;
			OtherMethods = otherMethods;
			OtherMethodsCount = otherMethodsCount;
		}
		public NuGenInterfaceImplementation(NuGenIMetaDataImport2 import, uint token, NuGenTypeDefinition typeDefinition, uint interfaceToken)
		{
			Token = token;
			TypeDefinition = typeDefinition;
			InterfaceToken = interfaceToken;
		}
Ejemplo n.º 16
0
		private static void CreateTypeDefinitionSubnodes(NuGenTypeDefinition typeDefinition, TreeNode typeDefinitionNode)
		{
			NuGenAssembly assembly = typeDefinition.ModuleScope.Assembly;
			typeDefinition.LazyInitialize(assembly.AllTokens);
			Dictionary<uint, NuGenMethodDefinition> methodDefinitions = null;

			if (typeDefinition.MethodDefinitions != null)
			{
				methodDefinitions = new Dictionary<uint, NuGenMethodDefinition>(typeDefinition.MethodDefinitions);
			}

			if (typeDefinition.FieldDefinitions != null)
			{
				TreeNode fieldsNode = new TreeNode("Fields");
                fieldsNode.ImageIndex = 9;
				typeDefinitionNode.Nodes.Add(fieldsNode);

				foreach (NuGenFieldDefinition field in typeDefinition.FieldDefinitions.Values)
				{
					field.LazyInitialize(assembly.AllTokens);
					TreeNode fieldNode = new TreeNode(NuGenHelperFunctions.TruncateText(field.Name));
					fieldNode.Tag = field;
                    fieldNode.ImageIndex = 10;
					fieldsNode.Nodes.Add(fieldNode);
				}
			}

			if (typeDefinition.Properties != null)
			{
				TreeNode propertiesNode = new TreeNode("Properties");
                propertiesNode.ImageIndex = 9;
				typeDefinitionNode.Nodes.Add(propertiesNode);

				foreach (NuGenProperty property in typeDefinition.Properties.Values)
				{
					property.LazyInitialize(assembly.AllTokens);
					TreeNode propertyNode = new TreeNode(NuGenHelperFunctions.TruncateText(property.Name));
                    propertyNode.ImageIndex = 11;
					propertiesNode.Nodes.Add(propertyNode);                                            

					TreeNode definitionNode = new TreeNode(" definition");
					definitionNode.Tag = property;
                    definitionNode.ImageIndex = 2;
					propertyNode.Nodes.Add(definitionNode);

					if (methodDefinitions != null)
					{
						if (methodDefinitions.ContainsKey(property.GetterMethodToken))
						{
							NuGenMethodDefinition getterMethod = methodDefinitions[property.GetterMethodToken];
							getterMethod.LazyInitialize(assembly.AllTokens);

							TreeNode getterNode = new TreeNode(NuGenHelperFunctions.TruncateText(getterMethod.DisplayName));
                            getterNode.ImageIndex = 10;
							getterNode.Tag = getterMethod;
							propertyNode.Nodes.Add(getterNode);

							methodDefinitions.Remove(property.GetterMethodToken);
						}

						if (methodDefinitions.ContainsKey(property.SetterMethodToken))
						{
							NuGenMethodDefinition setterMethod = methodDefinitions[property.SetterMethodToken];
							setterMethod.LazyInitialize(assembly.AllTokens);

							TreeNode setterNode = new TreeNode(NuGenHelperFunctions.TruncateText(setterMethod.DisplayName));
                            setterNode.ImageIndex = 10;
							setterNode.Tag = setterMethod;
							propertyNode.Nodes.Add(setterNode);

							methodDefinitions.Remove(property.SetterMethodToken);
						}

						for (int index = 0; index < property.OtherMethodsCount; index++)
						{
							uint token = property.OtherMethods[index];

							if (methodDefinitions.ContainsKey(token))
							{
								NuGenMethodDefinition otherMethod = methodDefinitions[token];
								otherMethod.LazyInitialize(assembly.AllTokens);

								TreeNode otherNode = new TreeNode(NuGenHelperFunctions.TruncateText(otherMethod.DisplayName));
                                otherNode.ImageIndex = 10;
								otherNode.Tag = otherMethod;
								propertyNode.Nodes.Add(otherNode);

								methodDefinitions.Remove(token);
							}
						}
					}
				}
			}

			if (methodDefinitions != null && methodDefinitions.Count > 0)
			{
				TreeNode methodsNode = new TreeNode("Methods");
                methodsNode.ImageIndex = 9;
				typeDefinitionNode.Nodes.Add(methodsNode);

				foreach (NuGenMethodDefinition method in methodDefinitions.Values)
				{
					method.LazyInitialize(assembly.AllTokens);
					TreeNode methodNode = new TreeNode(NuGenHelperFunctions.TruncateText(method.DisplayName));
                    methodNode.ImageIndex = 12;
					methodNode.Tag = method;
					methodsNode.Nodes.Add(methodNode);
				}
			}
		}
Ejemplo n.º 17
0
		private TreeNode CreateTypeDefinitionNode(Dictionary<string, TreeNode> namespaceNodes, TreeNode moduleScopeNode, NuGenTypeDefinition typeDefinition, bool createDefinitionNode)
		{
			TreeNode result = new TreeNode(NuGenHelperFunctions.TruncateText(typeDefinition.FullName));
            result.ImageIndex = 11;
			string typeNamespace = typeDefinition.Namespace;

			if (typeNamespace.Length == 0)
			{
				typeNamespace = NuGenConstants.DefaultNamespaceName;
			}

			if (namespaceNodes.ContainsKey(typeNamespace))
			{
				namespaceNodes[typeNamespace].Nodes.Add(result);
			}
			else
			{
				TreeNode namespaceNode = new TreeNode(typeNamespace);
                namespaceNode.ImageIndex = 8;
				moduleScopeNode.Nodes.Add(namespaceNode);
				namespaceNodes[typeNamespace] = namespaceNode;

				namespaceNode.Nodes.Add(result);
			}

			if (createDefinitionNode)
			{
				TreeNode classNode = new TreeNode("definition");
                classNode.ImageIndex = 2;
				classNode.Tag = typeDefinition;
				result.Nodes.Add(classNode);
			}
			else
			{
				CreateTypeDefinitionSubnodes(typeDefinition, result);
				result.Tag = true;
			}

			return result;
		}
Ejemplo n.º 18
0
		public NuGenFieldDefinition(NuGenIMetaDataImport2 import, NuGenTypeDefinition typeDefinition, string name, uint token, IntPtr signatureBlob, uint signatureBlobLength, uint flags, uint defaultValueType, IntPtr defaultValue, uint defaultValueLength)
		{
			BaseTypeDefinition = typeDefinition;
			Name = name;
			Token = token;
			SignatureBlob = signatureBlob;
			SignatureBlobLength = signatureBlobLength;
			Flags = (CorFieldAttr)flags;
			DefaultValueType = (CorElementType)defaultValueType;
			DefaultValue = defaultValue;
			DefaultValueLength = defaultValueLength;
		}
Ejemplo n.º 19
0
		public void EnumerateTypeDefinitions(NuGenIMetaDataImport2 import, ModuleWrapper debuggedModule)
		{
			DebuggedModule = debuggedModule;
			IntPtr enumHandle = IntPtr.Zero;
			uint[] typeDefs = new uint[NuGenProject.DefaultArrayCount];
			uint count = 0;
			import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count);

			while (count > 0)
			{
				for (uint typeDefsIndex = 0; typeDefsIndex < count; typeDefsIndex++)
				{
					uint token = typeDefs[typeDefsIndex];
					uint typeNameLength;
					uint typeDefFlags;
					uint baseTypeToken;

					import.GetTypeDefProps(token, NuGenProject.DefaultCharArray,
Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken);

					if (typeNameLength > NuGenProject.DefaultCharArray.Length)
					{
						NuGenProject.DefaultCharArray = new char[typeNameLength];

						import.GetTypeDefProps(token, NuGenProject.DefaultCharArray,
Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken);
					}

					NuGenTypeDefinition typeDefinition = new NuGenTypeDefinition(import, this, NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, typeNameLength), token, (CorTypeAttr)typeDefFlags, baseTypeToken);
					TypeDefinitions[token] = typeDefinition;
					Assembly.AllTokens[token] = typeDefinition;
				}

				import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count);
			}

			import.CloseEnum(enumHandle);

			foreach (NuGenTypeDefinition typeDefinition in TypeDefinitions.Values)
			{
				if (typeDefinition.IsNestedType)
				{
					typeDefinition.FindEnclosingType(import);
				}
			}

			DebuggedModule = null;
		}