Exemple #1
0
		void SearchResourceElementTreeNode(LoadedAssembly module, ResourceTreeNode resTreeNode, ResourceElementTreeNode resElNode) {
			var res = filter.GetFilterResult(resElNode);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			if (res.IsMatch) {
				bool m = IsMatch(resElNode.Name, resElNode);
				if (!m) {
					var builtin = resElNode.ResourceElement.ResourceData as BuiltInResourceData;
					if (builtin != null) {
						var val = builtin.Data;
						if (builtin.Code == ResourceTypeCode.TimeSpan)
							val = ((TimeSpan)val).Ticks;
						m = IsMatch(val as string, val);
					}
				}
				if (!m)
					m = IsMatch(resElNode.GetStringContents(), null);
				if (m) {
					onMatch(new SearchResult {
						Language = language,
						Object = resElNode,
						NameObject = resElNode,
						TypeImageInfo = GetImage(resElNode.IconName),
						LocationObject = resTreeNode,
						LocationImageInfo = GetImage(resTreeNode.IconName),
						LoadedAssembly = module,
					});
				}
			}
		}
 public Edge(ResourceTreeNode source, ResourceTreeNode target, EdgeType edgeType)
 {
     this.edgeType = edgeType;
     this.source   = source;
     this.target   = target;
     path          = null;
 }
Exemple #3
0
		void SearchResourceTreeNodes(LoadedAssembly module, ResourceTreeNode resTreeNode) {
			var res = filter.GetFilterResult(resTreeNode);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			if (res.IsMatch && (IsMatch(resTreeNode.Name, resTreeNode) || IsMatch(resTreeNode.GetStringContents(), null))) {
				onMatch(new SearchResult {
					Language = language,
					Object = resTreeNode,
					NameObject = resTreeNode,
					TypeImageInfo = GetImage(resTreeNode.IconName),
					LocationObject = module.ModuleDefinition,
					LocationImageInfo = GetImage("AssemblyModule"),
					LoadedAssembly = module,
				});
			}

			res = filter.GetFilterResult((ResourceElementTreeNode)null);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			var resNodes = new List<ResourceElementTreeNode>();
			App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
				resTreeNode.EnsureChildrenFiltered();
				resNodes.AddRange(resTreeNode.Children.Cast<ResourceElementTreeNode>());
			}));

			foreach (var resElNode in resNodes)
				SearchResourceElementTreeNode(module, resTreeNode, resElNode);
		}
 public override TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     if (showPublicApi() && !ResourceTreeNode.IsPublicAPIInternal(node.Resource))
     {
         return(new TreeViewNodeFilterResult(FilterResult.Hidden, false));
     }
     return(base.GetFilterResult(node));
 }
 public override string GetStringContents()
 {
     if (resElem.ResourceData.Code == ResourceTypeCode.ByteArray || resElem.ResourceData.Code == ResourceTypeCode.Stream)
     {
         var data = (byte[])((BuiltInResourceData)resElem.ResourceData).Data;
         return(ResourceTreeNode.GetStringContents(new MemoryStream(data)));
     }
     return(null);
 }
        public override void Search(PEFile module, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var resourcesNode = new ResourceListTreeNode(module);

            foreach (Resource resource in module.Resources)
            {
                Search(module, resource, resourcesNode, ResourceTreeNode.Create(resource), cancellationToken);
            }
        }
Exemple #7
0
        protected override void ProcessResource(ResourceTree aResourceTree)
        {
            System.Action <XElement, ResourceTreeNode> ReadChildren = null;
            var excludedGroups = new NodeGroup[] {
                NodeGroup.ExtensionPackages, NodeGroup.GameInformation, NodeGroup.GlobalGameSettings, NodeGroup.Invalid
            };

            ReadChildren = (aBranch, aParent) => {
                foreach (var element in aBranch.Elements())
                {
                    if (element.Name == "Node")
                    {
                        aParent.Add(new ResourceTreeNode()
                        {
                            Name  = element.Attribute("Name").Value,
                            ID    = int.Parse(element.Attribute("ID").Value),
                            Type  = NodeTypes.Child,
                            Group = aParent.Group
                        });
                    }
                    else if (element.Name == "Group")
                    {
                        var node = new ResourceTreeNode()
                        {
                            Name  = element.Attribute("Name").Value,
                            Type  = NodeTypes.Group,
                            Group = aParent.Group
                        };

                        ReadChildren(element, node);
                        aParent.Add(node);
                    }
                }
            };

            var document = LoadXml(Filenames.Tree + ".xml");

            if (document != null)
            {
                OnCategoryProcessing(ResourceTypes.ResourceTree);

                foreach (var node in aResourceTree)
                {
                    if (!excludedGroups.Contains(node.Group))
                    {
                        ReadChildren(document.Element(node.Group.ToString()), node);
                    }
                }

                OnCategoryProcessed(ResourceTypes.ResourceTree);
            }
        }
        // Attach a new node as child of the current node.
        public ResourceTreeNode Add(ResourceTreeNode node, bool buyable)
        {
            node.Parent    = this;
            node.Resources = this.Resources
                             .Concat(node.Resources)
                             .GroupBy(o => o.Key)
                             .ToDictionary(o => o.Key, o => o.Sum(v => v.Value));
            node.BuyableResources = this.BuyableResources
                                    .Concat(node.BuyableResources)
                                    .GroupBy(o => o.Key)
                                    .ToDictionary(o => o.Key, o => o.Sum(v => v.Value));
            this.Children.Add(node);

            return(node);
        }
Exemple #9
0
        public override TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
        {
            var  visibleFlags = VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement;
            bool isMatch      = (flags & VisibleMembersFlags.Resource) != 0;

            if ((flags & visibleFlags) == 0)
            {
                return(new TreeViewNodeFilterResult(FilterResult.Hidden, isMatch));
            }
            if (isMatch)
            {
                return(new TreeViewNodeFilterResult(FilterResult.Match, isMatch));
            }
            return(new TreeViewNodeFilterResult(FilterResult.Recurse, isMatch));
        }
        public override bool View(DecompilerTextView textView)
        {
            if (resElem.ResourceData.Code == ResourceTypeCode.String)
            {
                var output = new AvalonEditTextOutput();
                output.Write((string)((BuiltInResourceData)resElem.ResourceData).Data, TextTokenType.Text);
                textView.ShowNode(output, this, null);
                return(true);
            }
            if (resElem.ResourceData.Code == ResourceTypeCode.ByteArray || resElem.ResourceData.Code == ResourceTypeCode.Stream)
            {
                var data = (byte[])((BuiltInResourceData)resElem.ResourceData).Data;
                return(ResourceTreeNode.View(this, textView, new MemoryStream(data), Name));
            }

            return(base.View(textView));
        }
 public override TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     if (showPublicApi() && !ResourceTreeNode.IsPublicAPIInternal(node.Resource))
         return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
     return base.GetFilterResult(node);
 }
Exemple #12
0
 public virtual TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     return(filter.GetFilterResult(node));
 }
Exemple #13
0
 protected sealed override void Write(ITextOutput output, Language language)
 {
     ResourceTreeNode.WriteFileName(output, resElem.Name);
 }
Exemple #14
0
 public ITreeNode Create(Resource resource)
 {
     return(ResourceTreeNode.Create(resource));
 }
Exemple #15
0
        void CreateUI(ITextOutput output, object o, bool includeNamespace)
        {
            var ns = o as NamespaceSearchResult;

            if (ns != null)
            {
                NamespaceTreeNode.Write(output, ns.Namespace);
                return;
            }

            var td = o as TypeDef;

            if (td != null)
            {
                Debug.Assert(Language != null);
                Language.TypeToString(output, td, includeNamespace);
                return;
            }

            var md = o as MethodDef;

            if (md != null)
            {
                output.Write(IdentifierEscaper.Escape(md.Name), TextTokenHelper.GetTextTokenType(md));
                return;
            }

            var fd = o as FieldDef;

            if (fd != null)
            {
                output.Write(IdentifierEscaper.Escape(fd.Name), TextTokenHelper.GetTextTokenType(fd));
                return;
            }

            var pd = o as PropertyDef;

            if (pd != null)
            {
                output.Write(IdentifierEscaper.Escape(pd.Name), TextTokenHelper.GetTextTokenType(pd));
                return;
            }

            var ed = o as EventDef;

            if (ed != null)
            {
                output.Write(IdentifierEscaper.Escape(ed.Name), TextTokenHelper.GetTextTokenType(ed));
                return;
            }

            var asm = o as AssemblyDef;

            if (asm != null)
            {
                Write(output, asm);
                return;
            }

            var mod = o as ModuleDef;

            if (mod != null)
            {
                output.Write(mod.FullName, TextTokenType.Module);
                return;
            }

            var asmRef = o as AssemblyRef;

            if (asmRef != null)
            {
                Write(output, asmRef);
                return;
            }

            var modRef = o as ModuleRef;

            if (modRef != null)
            {
                output.Write(modRef.FullName, TextTokenType.Module);
                return;
            }

            // non-.NET file
            var loadedAsm = o as LoadedAssembly;

            if (loadedAsm != null)
            {
                output.Write(loadedAsm.ShortName, TextTokenType.Text);
                return;
            }

            var resNode = o as ResourceTreeNode;

            if (resNode != null)
            {
                ResourceTreeNode.WriteFileName(output, resNode.Name);
                return;
            }

            var resElNode = o as ResourceElementTreeNode;

            if (resElNode != null)
            {
                ResourceTreeNode.WriteFileName(output, resElNode.Name);
                return;
            }

            var s = o as string;

            if (s != null)
            {
                output.Write(s, TextTokenType.Text);
                return;
            }

            Debug.Assert(s == null);
        }
 public virtual TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     return(new TreeViewNodeFilterResult(FilterResult.Hidden, false));
 }
 public virtual TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     return new TreeViewNodeFilterResult();
 }
 public override TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     var visibleFlags = VisibleMembersFlags.ResourceElement;
     bool isMatch = (flags & VisibleMembersFlags.Resource) != 0;
     if ((flags & visibleFlags) == 0)
         return new TreeViewNodeFilterResult(FilterResult.Hidden, isMatch);
     if (isMatch)
         return new TreeViewNodeFilterResult(FilterResult.Match, isMatch);
     return new TreeViewNodeFilterResult(FilterResult.Recurse, isMatch);
 }
    public override void Load(TextAsset file)
    {
        Dictionary <string, ResourceTreeNode> dictionary = new Dictionary <string, ResourceTreeNode>();

        using (XmlReader xmlReader = XmlReader.Create(new StringReader(file.text)))
        {
            while (xmlReader.ReadToFollowing("node"))
            {
                xmlReader.MoveToFirstAttribute();
                string value = xmlReader.Value;
                float  nodeX = 0f;
                float  nodeY = 0f;
                float  num   = 40f;
                float  num2  = 20f;
                if (xmlReader.ReadToFollowing("Geometry"))
                {
                    xmlReader.MoveToAttribute("x");
                    nodeX = float.Parse(xmlReader.Value);
                    xmlReader.MoveToAttribute("y");
                    nodeY = 0f - float.Parse(xmlReader.Value);
                    xmlReader.MoveToAttribute("width");
                    num = float.Parse(xmlReader.Value);
                    xmlReader.MoveToAttribute("height");
                    num2 = float.Parse(xmlReader.Value);
                }
                Debug.Assert(num != 0f && num2 != 0f, "Error parsing GRAPHML");
                if (xmlReader.ReadToFollowing("NodeLabel"))
                {
                    string text = xmlReader.ReadString();
                    T      val  = new T();
                    val.Id            = text;
                    val.Name          = text;
                    val.nodeX         = nodeX;
                    val.nodeY         = nodeY;
                    val.width         = num;
                    val.height        = num2;
                    dictionary[value] = val;
                    resources.Add(val);
                }
            }
        }
        XmlDocument xmlDocument = new XmlDocument();

        xmlDocument.LoadXml(file.text);
        XmlNodeList xmlNodeList = xmlDocument.DocumentElement.SelectNodes("/graphml/graph/edge");
        IEnumerator enumerator  = xmlNodeList.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                XmlNode          xmlNode = (XmlNode)enumerator.Current;
                ResourceTreeNode value2  = null;
                dictionary.TryGetValue(xmlNode.Attributes["source"].Value, out value2);
                ResourceTreeNode value3 = null;
                dictionary.TryGetValue(xmlNode.Attributes["target"].Value, out value3);
                if (value2 != null && value3 != null)
                {
                    value2.references.Add(value3);
                    ResourceTreeNode.Edge edge = null;
                    XmlNode     xmlNode2       = null;
                    IEnumerator enumerator2    = xmlNode.ChildNodes.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            XmlNode xmlNode3 = (XmlNode)enumerator2.Current;
                            if (xmlNode3.HasChildNodes)
                            {
                                xmlNode2 = xmlNode3.FirstChild;
                                break;
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable;
                        if ((disposable = (enumerator2 as IDisposable)) != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    string name = xmlNode2.Name;
                    ResourceTreeNode.Edge.EdgeType edgeType = (ResourceTreeNode.Edge.EdgeType)Enum.Parse(typeof(ResourceTreeNode.Edge.EdgeType), name);
                    edge = new ResourceTreeNode.Edge(value2, value3, edgeType);
                    IEnumerator enumerator3 = xmlNode2.ChildNodes.GetEnumerator();
                    try
                    {
                        while (enumerator3.MoveNext())
                        {
                            XmlNode xmlNode4 = (XmlNode)enumerator3.Current;
                            if (!(xmlNode4.Name != "Path"))
                            {
                                edge.sourceOffset = new Vector2f(float.Parse(xmlNode4.Attributes["sx"].Value), 0f - float.Parse(xmlNode4.Attributes["sy"].Value));
                                edge.targetOffset = new Vector2f(float.Parse(xmlNode4.Attributes["tx"].Value), 0f - float.Parse(xmlNode4.Attributes["ty"].Value));
                                IEnumerator enumerator4 = xmlNode4.ChildNodes.GetEnumerator();
                                try
                                {
                                    while (enumerator4.MoveNext())
                                    {
                                        XmlNode  xmlNode5 = (XmlNode)enumerator4.Current;
                                        Vector2f point    = new Vector2f(float.Parse(xmlNode5.Attributes["x"].Value), 0f - float.Parse(xmlNode5.Attributes["y"].Value));
                                        edge.AddToPath(point);
                                    }
                                }
                                finally
                                {
                                    IDisposable disposable2;
                                    if ((disposable2 = (enumerator4 as IDisposable)) != null)
                                    {
                                        disposable2.Dispose();
                                    }
                                }
                                break;
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable3;
                        if ((disposable3 = (enumerator3 as IDisposable)) != null)
                        {
                            disposable3.Dispose();
                        }
                    }
                    value2.edges.Add(edge);
                }
            }
        }
        finally
        {
            IDisposable disposable4;
            if ((disposable4 = (enumerator as IDisposable)) != null)
            {
                disposable4.Dispose();
            }
        }
    }
 public virtual TreeViewNodeFilterResult GetFilterResult(ResourceTreeNode node)
 {
     return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
 }