Ejemplo n.º 1
0
        public void ResolveDependencies()
        {
            if (DependenciesResolved)
            {
                return;
            }


            foreach (PeImportDll DllImport in Imports)
            {
                string ModuleFilepath = null;
                ModuleSearchStrategy Strategy;


                // Find Dll in "paths"
                Tuple <ModuleSearchStrategy, PE> ResolvedModule = Root.ResolveModule(DllImport.Name);
                Strategy = ResolvedModule.Item1;

                if (Strategy != ModuleSearchStrategy.NOT_FOUND)
                {
                    ModuleFilepath = ResolvedModule.Item2?.Filepath;
                }



                bool             IsAlreadyCached = Root.isModuleCached(DllImport.Name, ModuleFilepath);
                PeDependencyItem DependencyItem  = Root.GetModuleItem(DllImport.Name, ModuleFilepath, Strategy, RecursionLevel + 1);

                // do not add twice the same imported module
                if (ResolvedImports.Find(ri => ri.ModuleName == DllImport.Name) == null)
                {
                    ResolvedImports.Add(DependencyItem);
                }

                // Do not process twice a dependency. It will be displayed only once
                if (!IsAlreadyCached)
                {
                    Debug.WriteLine("[{0:d}] [{1:s}] Adding dep {2:s}", RecursionLevel, ModuleName, ModuleFilepath);
                    Dependencies.Add(DependencyItem);
                }
            }

            DependenciesResolved = true;
            if ((Root.MaxRecursion > 0) && ((RecursionLevel + 1) >= Root.MaxRecursion))
            {
                return;
            }


            // Recursively resolve dependencies
            foreach (var Dep in Dependencies)
            {
                Dep.LoadPe();
                Dep.ResolveDependencies();
            }
        }
Ejemplo n.º 2
0
        public void ResolveDependencies()
        {
            if (DependenciesResolved)
            {
                return;
            }

            Dependencies = new List <PeDependencyItem>();

            foreach (PeImportDll DllImport in Imports)
            {
                string ModuleFilepath = null;
                ModuleSearchStrategy Strategy;


                // Find Dll in "paths"
                Tuple <ModuleSearchStrategy, PE> ResolvedModule = Root.ResolveModule(DllImport.Name);
                Strategy = ResolvedModule.Item1;

                if (Strategy != ModuleSearchStrategy.NOT_FOUND)
                {
                    ModuleFilepath = ResolvedModule.Item2.Filepath;
                }


                Debug.WriteLine("[{0:d}] [{1:s}] Adding dep {2:s}", RecursionLevel, ModuleName, ModuleFilepath);
                PeDependencyItem DependencyItem = Root.GetModuleItem(DllImport.Name, ModuleFilepath, Strategy, RecursionLevel + 1);
                Dependencies.Add(DependencyItem);
            }

            DependenciesResolved = true;


            // Recursively resolve dependencies
            foreach (var Dep in Dependencies)
            {
                Dep.ResolveDependencies();
            }
        }