private static string GetSecurityStatusForInternal(MethodDefinition methodDefinition)
        {
            if (_moonlightDefinitionFinder == null)
            {
                var securityroot = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.Parent.Parent.FullName;
                var dir          = securityroot + "/MoonlightAssemblies";
                var assemblies   = new List <AssemblyDefinition>();
                foreach (var file in Directory.GetFiles(dir, "*.dll"))
                {
                    assemblies.Add(AssemblyFactory.GetAssembly(file));
                }

                _moonlightDefinitionFinder = new CecilDefinitionFinder(assemblies);
            }

            var moonlightmethod = _moonlightDefinitionFinder.FindMethod(methodDefinition.ToString());

            if (moonlightmethod == null)
            {
                if (_moonlightDefinitionFinder.FindType(methodDefinition.DeclaringType.ToString()) == null)
                {
                    return("NotFound (Type also not found)");
                }
                return("NotFound (Type does exist: " + GetSecurityStatusFor(methodDefinition.DeclaringType.Resolve()) + ")");
            }
            string result = FindSecurityAttribute(moonlightmethod.CustomAttributes);

            if (result != null)
            {
                return(result);
            }

            return(GetSecurityStatusFor(moonlightmethod.DeclaringType));
        }
Esempio n. 2
0
 public Injector(AssemblyDefinition assembly)
 {
     _assembly = assembly;
     _cecilDefinitionFinder = new CecilDefinitionFinder(_assembly);
     OutputDirectory = Path.GetDirectoryName(assembly.MainModule.Image.FileInformation.FullName);
 }
        private static string GetSecurityStatusForInternal(MethodDefinition methodDefinition)
        {
            if (_moonlightDefinitionFinder == null)
            {
                var securityroot = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.Parent.Parent.FullName;
                var dir = securityroot + "/MoonlightAssemblies";
                var assemblies = new List<AssemblyDefinition>();
                foreach(var file in Directory.GetFiles(dir,"*.dll"))
                {
                    assemblies.Add(AssemblyFactory.GetAssembly(file));
                }

                _moonlightDefinitionFinder = new CecilDefinitionFinder(assemblies);
            }

            var moonlightmethod = _moonlightDefinitionFinder.FindMethod(methodDefinition.ToString());
            if (moonlightmethod == null)
            {
                if (_moonlightDefinitionFinder.FindType(methodDefinition.DeclaringType.ToString()) == null)
                    return "NotFound (Type also not found)";
                return "NotFound (Type does exist: " + GetSecurityStatusFor(methodDefinition.DeclaringType.Resolve())+")";
            }
            string result = FindSecurityAttribute(moonlightmethod.CustomAttributes);
            if (result!=null) return result;

            return GetSecurityStatusFor(moonlightmethod.DeclaringType);
        }
Esempio n. 4
0
 public Injector(AssemblyDefinition assembly)
 {
     _assembly = assembly;
     _cecilDefinitionFinder = new CecilDefinitionFinder(_assembly);
     OutputDirectory        = Path.GetDirectoryName(assembly.MainModule.Image.FileInformation.FullName);
 }