Beispiel #1
0
        bool DetectMethodProxyObfuscation()
        {
            const int MIN_FOUND_PROXIES = 10;

            int foundProxies = 0, checkedMethods = 0;

            foreach (var type in module.GetTypes())
            {
                foreach (var method in type.Methods)
                {
                    if (foundProxies >= MIN_FOUND_PROXIES)
                    {
                        goto done;
                    }
                    if (!method.IsStatic || method.Body == null)
                    {
                        continue;
                    }
                    if (checkedMethods++ >= 1000)
                    {
                        goto done;
                    }
                    if (!DsMethodCallInliner.CanInline(method))
                    {
                        continue;
                    }
                    foundProxies++;
                }
            }
done:
            return(foundProxies >= MIN_FOUND_PROXIES);
        }
Beispiel #2
0
        public static List <MethodDef> Find(ModuleDefMD module, IEnumerable <MethodDef> notInlinedMethods)
        {
            var notInlinedMethodsDict = new Dictionary <MethodDef, bool>();

            foreach (var method in notInlinedMethods)
            {
                notInlinedMethodsDict[method] = true;
            }

            var inlinedMethods = new List <MethodDef>();

            foreach (var type in module.GetTypes())
            {
                foreach (var method in type.Methods)
                {
                    if (!notInlinedMethodsDict.ContainsKey(method) && DsMethodCallInliner.CanInline(method))
                    {
                        inlinedMethods.Add(method);
                    }
                }
            }

            return(inlinedMethods);
        }