Beispiel #1
0
        private ExploreTreeNode CreateExploreTreeNode(Triple triple, string searchType, ExploreTreeNode exploreTreeNode)
        {
            var childExploreTreeNode = new ExploreTreeNode()
            {
                FullSignature = string.Format("{0}:{1}", searchType, triple.From.InstructionKey)
            };

            exploreTreeNode.AddChild(childExploreTreeNode);

            return(childExploreTreeNode);
        }
Beispiel #2
0
        private void ContinueDownFullTree(MethodGraph methodGraph, MethodNode parentMethodNode, MethodObject parentMethod, int depth, ExploreTreeNode callTreeNode)
        {
            foreach (var calledMethod in parentMethod.MethodsCalled)
            {
                CheckForResourceCall(methodGraph, calledMethod, parentMethod, parentMethodNode);
                var calledMethodSignature = SignatureKeyService.GetFullMethodSignature(calledMethod.MethodCalled);
                var treeNode = new ExploreTreeNode()
                {
                    FullSignature = calledMethodSignature
                };
                callTreeNode.AddChild(treeNode);

                bool   isGenericAndIndexed = false;
                string genericSignature    = null;
                var    methodIsIndexed     = _methodIndexer.HasMethod(calledMethodSignature);
                if (!methodIsIndexed)
                {
                    genericSignature = SignatureKeyService.GetGenericMethodSignature(calledMethod.MethodCalled);
                    if (!string.IsNullOrEmpty(genericSignature))
                    {
                        isGenericAndIndexed = _methodIndexer.HasMethod(genericSignature);
                    }
                }

                if (methodIsIndexed || isGenericAndIndexed)
                {
                    List <MethodObject> matchingMethodNodes = null;
                    if (methodIsIndexed)
                    {
                        matchingMethodNodes = _methodIndexer.GetMethods(calledMethodSignature);
                    }
                    else if (isGenericAndIndexed)
                    {
                        matchingMethodNodes = _methodIndexer.GetMethods(genericSignature);
                    }

                    foreach (var calledMethodNode in matchingMethodNodes)
                    {
                        var cachedRootNode = GetCachedRootNode(calledMethodNode.GetMethodDefinition());

                        if (cachedRootNode != null) // this is a call to an already analyzed method, we copy over the calls and resource accesses already calculated for this node
                        {
                            cachedRootNode.CopyCallsToNode(parentMethodNode);
                        }
                        else // this is not a call to a previously analyzed method, so we continue down the call tree
                        {
                            PublicInnerAssemblyWalk(methodGraph, parentMethodNode, calledMethodNode, depth + 1, treeNode);
                        }
                    }
                }
            }
        }