Exemple #1
0
        private void method_0(Dictionary <string, AssemblyTuple> nameToAssemblyTuples)
        {
            Dictionary <AssemblyDefinition, BfAssembly> dictionary = new Dictionary <AssemblyDefinition, BfAssembly>();

            foreach (AssemblyTuple assemblyTuple in nameToAssemblyTuples.Values)
            {
                AssemblyTuple assemblyTuple;
                if (!dictionary.ContainsKey(assemblyTuple.Assembly))
                {
                    BfAssembly bfAssembly = new BfAssembly(this, assemblyTuple.Assembly, assemblyTuple.IsCoreAssembly, assemblyTuple.Directory);
                    dictionary.Add(assemblyTuple.Assembly, bfAssembly);
                    foreach (ModuleDefinition moduleDefinition in assemblyTuple.Assembly.Modules)
                    {
                        if (!this.dictionary_1.ContainsKey(moduleDefinition.Name))
                        {
                            this.dictionary_1.Add(moduleDefinition.Name, bfAssembly);
                        }
                        if (assemblyTuple.IsCoreAssembly)
                        {
                            foreach (TypeDefinition typeDefinition_ in moduleDefinition.Types)
                            {
                                this.method_12(typeDefinition_, bfAssembly);
                            }
                        }
                    }
                }
            }
            foreach (string current in nameToAssemblyTuples.Keys)
            {
                AssemblyTuple      assemblyTuple = nameToAssemblyTuples[current];
                AssemblyDefinition assembly      = assemblyTuple.Assembly;
                this.dictionary_0.Add(current, dictionary[assembly]);
            }
        }
		internal static Dictionary<string, AssemblyTuple> smethod_1(IEnumerable<AssemblyFileInfo> coreAssemblyFiles)
		{
			Dictionary<string, AssemblyTuple> dictionary = new Dictionary<string, AssemblyTuple>();
			DefaultAssemblyResolver defaultAssemblyResolver = new DefaultAssemblyResolver();
			foreach (string current in BfCache.list_0)
			{
				if (Directory.Exists(current))
				{
					defaultAssemblyResolver.AddSearchDirectory(current);
				}
			}
			foreach (AssemblyFileInfo current2 in coreAssemblyFiles)
			{
				if (current2.Name == "Search Directory")
				{
					defaultAssemblyResolver.AddSearchDirectory(current2.Path);
				}
				else
				{
					string directoryName = Path.GetDirectoryName(current2.Path);
					defaultAssemblyResolver.AddSearchDirectory(directoryName);
				}
			}
			foreach (AssemblyFileInfo current2 in coreAssemblyFiles)
			{
				if (!(current2.Name == "Search Directory"))
				{
					AssemblyDefinition assembly;
					try
					{
						assembly = AssemblyFactory.GetAssembly(current2.Path);
					}
					catch (ImageFormatException)
					{
						throw new NitriqException("NotManagedAssembly", "The assembly \"" + current2.Name + "\" is not a managed assembly");
					}
					if (!dictionary.ContainsKey(assembly.Name.FullName))
					{
						AssemblyTuple assemblyTuple = new AssemblyTuple(assembly);
						assemblyTuple.IsCoreAssembly = true;
						assemblyTuple.Directory = Path.GetDirectoryName(current2.Path);
						dictionary.Add(assembly.Name.FullName, assemblyTuple);
					}
				}
			}
			List<AssemblyTuple> list = new List<AssemblyTuple>(dictionary.Values);
			foreach (AssemblyTuple current3 in list)
			{
				foreach (ModuleDefinition moduleDefinition in current3.Assembly.Modules)
				{
					foreach (AssemblyNameReference assemblyNameReference in moduleDefinition.AssemblyReferences)
					{
						AssemblyDefinition assemblyDefinition;
						try
						{
							assemblyDefinition = defaultAssemblyResolver.Resolve(assemblyNameReference);
						}
						catch (FileNotFoundException)
						{
							throw new NitriqException("CantResolve", "Nitriq couldn't resolve the below assembly, consider adding a search directory where this assembly can be found \r\n\r\n" + assemblyNameReference.FullName);
						}
						string fullName = assemblyNameReference.FullName;
						string fullName2 = assemblyDefinition.Name.FullName;
						if (fullName2 == fullName)
						{
							if (!dictionary.ContainsKey(fullName))
							{
								dictionary.Add(fullName, new AssemblyTuple(assemblyDefinition)
								{
									Directory = "",
									IsCoreAssembly = false
								});
							}
						}
						else if (dictionary.ContainsKey(fullName) || dictionary.ContainsKey(fullName2))
						{
							if (!dictionary.ContainsKey(fullName))
							{
								dictionary.Add(fullName, dictionary[fullName2]);
							}
							if (!dictionary.ContainsKey(fullName2))
							{
								dictionary.Add(fullName2, dictionary[fullName]);
							}
						}
						else
						{
							AssemblyTuple assemblyTuple2 = new AssemblyTuple(assemblyDefinition);
							assemblyTuple2.Directory = "";
							assemblyTuple2.IsCoreAssembly = false;
							dictionary.Add(fullName, assemblyTuple2);
							dictionary.Add(fullName2, assemblyTuple2);
						}
					}
				}
			}
			return dictionary;
		}
Exemple #3
0
        internal static Dictionary <string, AssemblyTuple> smethod_1(IEnumerable <AssemblyFileInfo> coreAssemblyFiles)
        {
            Dictionary <string, AssemblyTuple> dictionary = new Dictionary <string, AssemblyTuple>();
            DefaultAssemblyResolver            defaultAssemblyResolver = new DefaultAssemblyResolver();

            foreach (string current in BfCache.list_0)
            {
                if (Directory.Exists(current))
                {
                    defaultAssemblyResolver.AddSearchDirectory(current);
                }
            }
            foreach (AssemblyFileInfo current2 in coreAssemblyFiles)
            {
                if (current2.Name == "Search Directory")
                {
                    defaultAssemblyResolver.AddSearchDirectory(current2.Path);
                }
                else
                {
                    string directoryName = Path.GetDirectoryName(current2.Path);
                    defaultAssemblyResolver.AddSearchDirectory(directoryName);
                }
            }
            foreach (AssemblyFileInfo current2 in coreAssemblyFiles)
            {
                if (!(current2.Name == "Search Directory"))
                {
                    AssemblyDefinition assembly;
                    try
                    {
                        assembly = AssemblyFactory.GetAssembly(current2.Path);
                    }
                    catch (ImageFormatException)
                    {
                        throw new NitriqException("NotManagedAssembly", "The assembly \"" + current2.Name + "\" is not a managed assembly");
                    }
                    if (!dictionary.ContainsKey(assembly.Name.FullName))
                    {
                        AssemblyTuple assemblyTuple = new AssemblyTuple(assembly);
                        assemblyTuple.IsCoreAssembly = true;
                        assemblyTuple.Directory      = Path.GetDirectoryName(current2.Path);
                        dictionary.Add(assembly.Name.FullName, assemblyTuple);
                    }
                }
            }
            List <AssemblyTuple> list = new List <AssemblyTuple>(dictionary.Values);

            foreach (AssemblyTuple current3 in list)
            {
                foreach (ModuleDefinition moduleDefinition in current3.Assembly.Modules)
                {
                    foreach (AssemblyNameReference assemblyNameReference in moduleDefinition.AssemblyReferences)
                    {
                        AssemblyDefinition assemblyDefinition;
                        try
                        {
                            assemblyDefinition = defaultAssemblyResolver.Resolve(assemblyNameReference);
                        }
                        catch (FileNotFoundException)
                        {
                            throw new NitriqException("CantResolve", "Nitriq couldn't resolve the below assembly, consider adding a search directory where this assembly can be found \r\n\r\n" + assemblyNameReference.FullName);
                        }
                        string fullName  = assemblyNameReference.FullName;
                        string fullName2 = assemblyDefinition.Name.FullName;
                        if (fullName2 == fullName)
                        {
                            if (!dictionary.ContainsKey(fullName))
                            {
                                dictionary.Add(fullName, new AssemblyTuple(assemblyDefinition)
                                {
                                    Directory      = "",
                                    IsCoreAssembly = false
                                });
                            }
                        }
                        else if (dictionary.ContainsKey(fullName) || dictionary.ContainsKey(fullName2))
                        {
                            if (!dictionary.ContainsKey(fullName))
                            {
                                dictionary.Add(fullName, dictionary[fullName2]);
                            }
                            if (!dictionary.ContainsKey(fullName2))
                            {
                                dictionary.Add(fullName2, dictionary[fullName]);
                            }
                        }
                        else
                        {
                            AssemblyTuple assemblyTuple2 = new AssemblyTuple(assemblyDefinition);
                            assemblyTuple2.Directory      = "";
                            assemblyTuple2.IsCoreAssembly = false;
                            dictionary.Add(fullName, assemblyTuple2);
                            dictionary.Add(fullName2, assemblyTuple2);
                        }
                    }
                }
            }
            return(dictionary);
        }