예제 #1
0
        /// <summary>
        /// Search the missing DLL
        /// </summary>
        /// <param name="ignoreapppath">If true, the current dir will be ignored</param>
        /// <returns>The names of missing DLL</returns>
        public List <string> FindMissingDll(bool ignoreapppath = false)
        {
            if (localPE == null)
            {
                throw new InvalidOperationException();
            }
            List <string>      result    = new List <string>();
            List <PeImportDll> peImports = GetImportDllList();

            Environment.SpecialFolder WindowsSystemFolder = (localPE.IsWow64Dll()) ?
                                                            Environment.SpecialFolder.SystemX86 :
                                                            Environment.SpecialFolder.System;
            string User32Filepath = Path.Combine(Environment.GetFolderPath(WindowsSystemFolder), "user32.dll");

            foreach (PeImportDll dllImp in peImports)
            {
                Tuple <ModuleSearchStrategy, PE> ResolvedModule = BinaryCache.ResolveModule(localPE, dllImp.Name, SxsEntriesCache);
                ModuleSearchStrategy             strategy       = ResolvedModule.Item1;
                if (strategy == ModuleSearchStrategy.NOT_FOUND)
                {
                    result.Add(dllImp.Name);
                }
                if (ignoreapppath && (strategy == ModuleSearchStrategy.ApplicationDirectory))
                {
                    result.Add(dllImp.Name);
                }
            }
            return(result);
        }
예제 #2
0
        static string FindPeFromPath(string ModuleName, List <string> CandidateFolders, bool Wow64Dll = false)
        {
            string PeFilePath = null;

            foreach (String CandidatePath in CandidateFolders)
            {
                PeFilePath = Path.Combine(CandidatePath, ModuleName);
                PE TestPe = BinaryCache.LoadPe(PeFilePath);

                if ((TestPe != null) && (TestPe.LoadSuccessful) && (TestPe.IsWow64Dll() == Wow64Dll))
                {
                    return(PeFilePath);
                }
            }

            return(null);
        }