Exemple #1
0
        public void ScanMethodBody(string app, MethodDefinition methd, ICollection filters)
        {
            if (methd.Body == null)
            {
                return;
            }

            Collectors.OnMethodBody(methd.Body);

            foreach (Mono.Cecil.Cil.Instruction i in methd.Body.Instructions)
            {
                if (CodeProperties.IsMethodCall(i))
                {
                    //if (i.Operand is Mono.Cecil.CallSite || i.Operand is Mono.Cecil.FieldReference)
                    //    continue;

                    MethodReference rf       = (MethodReference)i.Operand;
                    string          typeName = CodeProperties.GetClassName(rf.DeclaringType);
                    string          methName = CodeProperties.GetMethodNameWithParameters(((MethodReference)i.Operand));

                    if (filters.Count > 0)
                    {
                        if (IsIncluded(filters, typeName))
                        {
                            ProcessMethod(methd, rf, typeName, methName);
                        }
                    }
                    else
                    {
                        ProcessMethod(methd, rf, typeName, methName);
                    }
                }
            }
        }
Exemple #2
0
        private void CountRankedUsage(MethodDefinition callingContext, MethodResult mr)
        {
            if (m_dtCodeRank != null)
            {
                string contextTypeName = CodeProperties.GetClassName(callingContext.DeclaringType);
                string contextMethName = CodeProperties.GetMethodNameWithParameters(callingContext);

                mr.MethodRankedFrequency += Rank(m_app, contextTypeName, contextMethName);
            }
        }
Exemple #3
0
        private void ProcessMethod(MethodDefinition methd, MethodReference rf, string typeName, string methName)
        {
            bool isSystem   = CodeProperties.IsSystem(rf);
            bool isExternal = CodeProperties.IsExternalCall(rf);

            Collectors.OnMethodCall(methd, rf, typeName, methName, isSystem, isExternal);
            if (isSystem)
            {
                Collectors.OnSystemMethodCall(methd, rf, typeName, methName);
            }
        }
Exemple #4
0
        // Add edges to virtual methods or after the fact?
        public override void OnMethodCall(MethodDefinition callingContext, MethodReference methodCall,
                                          string callTypeName, string callMethodName, bool isSystem, bool isExternal)
        {
            // Don't include system calls.
            if (isSystem)
            {
                return;
            }

            string contextTypeName = CodeProperties.GetClassName(callingContext.DeclaringType);
            string contextMethName = CodeProperties.GetMethodNameWithParameters(callingContext);

            m_graph.Add(contextTypeName, contextMethName, callTypeName, callMethodName);
        }
        private ArrayList GetSystemCallSequences(MethodBody body)
        {
            ArrayList list = new ArrayList();
            string    last = "";

            foreach (Instruction i in body.Instructions)
            {
                if (CodeProperties.IsMethodCall(i))
                {
                    MethodReference rf = (MethodReference)i.Operand;
                    if (CodeProperties.IsSystem(rf))
                    {
                        string full = CodeProperties.GetFullName(rf);

                        if (/*last != full &&*/ !Stop(full))
                        {
                            list.Add(full);
                        }
                        //last = full;
                    }
                }
            }
            return(list);
        }