예제 #1
0
        public string GetPEVerifyPath(PEVerifyVersion version)
        {
            var potentialPath = GetPotentialPEVerifyPath(version);

            if (potentialPath != null && File.Exists(potentialPath))
            {
                return(potentialPath);
            }

            return(null);
        }
예제 #2
0
 public override string GetLookupDiagnostics(PEVerifyVersion version)
 {
     if (version != PEVerifyVersion.DotNet2)
     {
         return(".NET SDK 2.0: n/a");
     }
     else
     {
         return(string.Format(".NET SDK 2.0: Registry: HKEY_LOCAL_MACHINE\\{0}\\{1}\\bin\\PEVerify.exe", SdkRegistryKey, SdkRegistryValue));
     }
 }
예제 #3
0
        public string GetVerifierPath(PEVerifyVersion version)
        {
            string verifierPath = _pathSource.GetPEVerifyPath(version);

            if (verifierPath == null)
            {
                var message = string.Format(
                    "PEVerify for version '{0}' could not be found. Locations searched:\r\n{1}",
                    version,
                    _pathSource.GetLookupDiagnostics(version));
                throw new PEVerifyException(message);
            }
            return(verifierPath);
        }
 public override string GetLookupDiagnostics(PEVerifyVersion version)
 {
     if (version != PEVerifyVersion.DotNet2)
     {
         return("Windows SDK 6: n/a");
     }
     else
     {
         return(string.Format(
                    "Windows SDK 6: Registry: HKEY_LOCAL_MACHINE\\{0}\\[CurrentVersion]\\{1}\\bin\\PEVerify.exe",
                    WindowsSdkRegistryKey,
                    WindowsSdkRegistryInstallationFolderValue));
     }
 }
예제 #5
0
        public override string GetLookupDiagnostics(PEVerifyVersion version)
        {
            switch (version)
            {
            case PEVerifyVersion.DotNet4:
                return(string.Format(
                           "Windows SDK 8.1A: Registry: HKEY_LOCAL_MACHINE\\{0}\\{1}\\PEVerify.exe",
                           WindowsSdkRegistryKey40,
                           WindowsSdkRegistryInstallationFolderValue));

            default:
                return("Windows SDK 8.1A: n/a");
            }
        }
예제 #6
0
        protected override string GetPotentialPEVerifyPath(PEVerifyVersion version)
        {
            if (version != PEVerifyVersion.DotNet2)
            {
                return(null);
            }

            return(Maybe
                   .ForValue(RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                   .Select(key => key.OpenSubKey(SdkRegistryKey, false))
                   .Select(key => key.GetValue(SdkRegistryValue) as string)
                   .Select(path => Path.Combine(path, "bin"))
                   .Select(path => Path.Combine(path, "PEVerify.exe"))
                   .ValueOrDefault());
        }
예제 #7
0
        public void VerifyPEFile(string modulePath, PEVerifyVersion version)
        {
            ArgumentUtility.CheckNotNullOrEmpty("modulePath", modulePath);

            var process = StartPEVerifyProcess(modulePath, version);

            string output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            if (process.ExitCode != 0)
            {
                throw new PEVerifyException(process.ExitCode, output);
            }
        }
예제 #8
0
        private Process StartPEVerifyProcess(string modulePath, PEVerifyVersion version)
        {
            string verifierPath = GetVerifierPath(version);

            var process = new Process();

            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName               = verifierPath;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.WorkingDirectory       = AppDomain.CurrentDomain.BaseDirectory;
            process.StartInfo.Arguments              = string.Format("/verbose \"{0}\"", modulePath);
            process.Start();
            return(process);
        }
예제 #9
0
        protected override string GetPotentialPEVerifyPath(PEVerifyVersion version)
        {
            switch (version)
            {
            case PEVerifyVersion.DotNet4:
                return(Maybe
                       .ForValue(RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                       .Select(key => key.OpenSubKey(WindowsSdkRegistryKey40, false))
                       .Select(key => key.GetValue(WindowsSdkRegistryInstallationFolderValue) as string)
                       .Select(path => Path.Combine(path, "PEVerify.exe"))
                       .ValueOrDefault());

            default:
                return(null);
            }
        }
예제 #10
0
        public void VerifyPEFile(Assembly assembly, PEVerifyVersion version)
        {
            ArgumentUtility.CheckNotNull("assembly", assembly);

            VerifyPEFile(assembly.ManifestModule.FullyQualifiedName, version);
        }
예제 #11
0
 public string GetLookupDiagnostics(PEVerifyVersion version)
 {
     return(string.Join(Environment.NewLine, _sources.Select(source => source.GetLookupDiagnostics(version))));
 }
예제 #12
0
 public string GetPEVerifyPath(PEVerifyVersion version)
 {
     return(_sources.Select(source => source.GetPEVerifyPath(version)).FirstOrDefault(path => path != null));
 }
예제 #13
0
 protected abstract string GetPotentialPEVerifyPath(PEVerifyVersion version);
예제 #14
0
 public abstract string GetLookupDiagnostics(PEVerifyVersion version);
예제 #15
0
 public string GetLookupDiagnostics(PEVerifyVersion version)
 {
     return("Path: " + _path);
 }
예제 #16
0
 public string GetPEVerifyPath(PEVerifyVersion version)
 {
     return(_path);
 }