private static string FormatArchitecture(ProcessorArchitecture arch) { switch (arch) { case ProcessorArchitecture.Amd64: return "x64"; case ProcessorArchitecture.X86: return "x86"; default: return "Unknown"; } }
/// <summary> /// <para>Constructs a new interpreter configuration based on the /// provided values.</para> /// <para>No validation is performed on the parameters.</para> /// <para>If winPath is null or empty, /// <see cref="WindowsInterpreterPath"/> will be set to path.</para> /// <para>If libraryPath is null or empty and prefixPath is a valid /// file system path, <see cref="LibraryPath"/> will be set to /// prefixPath plus "Lib".</para> /// </summary> public InterpreterConfiguration( string prefixPath, string path, string winPath, string libraryPath, string pathVar, ProcessorArchitecture arch, Version version, InterpreterUIMode uiMode ) { _prefixPath = prefixPath; _interpreterPath = path; _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath; _libraryPath = libraryPath; if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath)) { try { _libraryPath = Path.Combine(_prefixPath, "Lib"); } catch (ArgumentException) { } } _pathEnvironmentVariable = pathVar; _architecture = arch; _version = version; Debug.Assert(string.IsNullOrEmpty(_interpreterPath) || !string.IsNullOrEmpty(_prefixPath), "Anyone providing an interpreter should also specify the prefix path"); _uiMode = uiMode; }
public CPythonInterpreterConfiguration(string pythonPath, string pythonwPath, string pathEnvVar, ProcessorArchitecture arch, Version version) { _pythonPath = pythonPath; _pythonwPath = pythonwPath; _arch = arch; _version = version; _pathEnvVar = pathEnvVar; }
public CPythonInterpreterFactory( Version version, string newId, string description, string prefixPath, string pythonPath, string pythonwPath, string libPath, string pathEnvVar, ProcessorArchitecture arch, bool watchForNewModules) : base(new InterpreterConfiguration( newId, description, prefixPath, pythonPath, pythonwPath, libPath, pathEnvVar, arch, version, InterpreterUIMode.SupportsDatabase), watchForNewModules) { }
/// <summary> /// <para>Constructs a new interpreter configuration based on the /// provided values.</para> /// <para>No validation is performed on the parameters.</para> /// <para>If winPath is null or empty, /// <see cref="WindowsInterpreterPath"/> will be set to path.</para> /// <para>If libraryPath is null or empty and prefixPath is a valid /// file system path, <see cref="LibraryPath"/> will be set to /// prefixPath plus "Lib".</para> /// </summary> public InterpreterConfiguration( string id, string description, string prefixPath = null, string path = null, string winPath = "", string libraryPath = "", string pathVar = "", ProcessorArchitecture arch = ProcessorArchitecture.None, Version version = null, InterpreterUIMode uiMode = InterpreterUIMode.Normal, string descriptionSuffix = "" ) { _id = id; _description = description; _prefixPath = prefixPath; _interpreterPath = path; _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath; _libraryPath = libraryPath; if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath)) { try { _libraryPath = Path.Combine(_prefixPath, "Lib"); } catch (ArgumentException) { } } _pathEnvironmentVariable = pathVar; _architecture = arch; _version = version; _uiMode = uiMode; _descriptionSuffix = descriptionSuffix; }
private static string GetFrameworkPath( string subfolder, ProcessorArchitecture architecture, string windowsFolder, bool is64BitOperatingSystem) { Guard.AgainstNullArgument("windowsFolder", windowsFolder); switch (architecture) { case ProcessorArchitecture.None: case ProcessorArchitecture.MSIL: return is64BitOperatingSystem ? Path.Combine(windowsFolder, "Microsoft.NET", "Framework64", subfolder, "MSBuild.exe") : Path.Combine(windowsFolder, "Microsoft.NET", "Framework", subfolder, "MSBuild.exe"); case ProcessorArchitecture.X86: return Path.Combine(windowsFolder, "Microsoft.NET", "Framework", subfolder, "MSBuild.exe"); case ProcessorArchitecture.Amd64: return Path.Combine(windowsFolder, "Microsoft.NET", "Framework64", subfolder, "MSBuild.exe"); default: var message = string.Format( CultureInfo.InvariantCulture, "MSBuild processor architecture '{0}' is not supported.", architecture.ToString()); throw new NotSupportedException(message); } }
public ClientInformation() { m_operatingSys = OperatingSystem.Win; m_architecture = ProcessorArchitecture.x86; Locale = ClientLocale.English; TimeZone = 0x258; IPAddress = new XmlIPAddress(System.Net.IPAddress.Loopback); }
public CJInterpreterConfiguration(string jPath, string jvPath, string pathEnvVar, ProcessorArchitecture arch, Version version) { _jPath = jPath; _jvPath = jvPath; _arch = arch; _version = version; _pathEnvVar = pathEnvVar; }
public CJInterpreterFactory(Version version, Guid id, string description, string jPath, string jvPath, string pathEnvVar, ProcessorArchitecture arch) { if (version == default(Version)) { version = new Version(6, 0, 2); } _description = description; _id = id; _config = new CJInterpreterConfiguration(jPath, jvPath, pathEnvVar, arch, version); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPluginFramework.Diagnostics.DiagResult"/> /// class with the result values. /// </summary> /// <param name="exists"> /// Set true if the plugin assembly exists. /// </param> /// <param name="valid"> /// Set true if the plugin is valid (compatible with this framework). /// </param> /// <param name="isAssm"> /// The inspected file is a Mono/.NET assembly. /// </param> /// <param name="reasonInvalid"> /// The reason the plugin is not valid. /// </param> /// <param name="ver"> /// The plugin version. /// </param> /// <param name="pa"> /// The plugin processor architecture. /// </param> public DiagResult(Boolean exists, Boolean valid, Boolean isAssm, String reasonInvalid, Version ver, ProcessorArchitecture pa) { this._exists = exists; this._isValid = valid; this._isAssembly = isAssm; this._reasonNotValid = reasonInvalid; this._assemblyVersion = ver; this._arch = pa; }
protected Resolver(string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion, ProcessorArchitecture targetedProcessorArchitecture, bool compareProcessorArchitecture) { this.searchPathElement = searchPathElement; this.getAssemblyName = getAssemblyName; this.fileExists = fileExists; this.getRuntimeVersion = getRuntimeVersion; this.targetedRuntimeVersion = targetedRuntimeVesion; this.targetProcessorArchitecture = targetedProcessorArchitecture; this.compareProcessorArchitecture = compareProcessorArchitecture; }
/// <summary> /// <para>Constructs a new interpreter configuration based on the /// provided values.</para> /// <para>No validation is performed on the parameters.</para> /// <para>If winPath is null or empty, /// <see cref="WindowsInterpreterPath"/> will be set to path.</para> /// <para>If libraryPath is null or empty and prefixPath is a valid /// file system path, <see cref="LibraryPath"/> will be set to /// prefixPath plus "Lib".</para> /// </summary> public InterpreterConfiguration( string prefixPath, string path, string winPath, string libraryPath, string pathVar, ProcessorArchitecture arch, Version version ) : this(prefixPath, path, winPath, libraryPath, pathVar, arch, version, InterpreterUIMode.Normal) { }
private static VCCompiler FindVC(string version, ProcessorArchitecture arch) { string vcDir = null, vsDir = null; using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var key1 = baseKey.OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7")) using (var key2 = baseKey.OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7")) { if (key1 != null) { vcDir = key1.GetValue(version) as string; } if (key2 != null) { vsDir = key2.GetValue(version) as string; } } if (string.IsNullOrEmpty(vcDir)) { using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32)) using (var key = baseKey.OpenSubKey("SOFTWARE\\Microsoft\\DevDiv\\VCForPython\\" + version)) { if (key != null) { vcDir = key.GetValue("InstallDir") as string; } } } if (string.IsNullOrEmpty(vcDir)) { using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) using (var key = baseKey.OpenSubKey("SOFTWARE\\Microsoft\\DevDiv\\VCForPython\\" + version)) { if (key != null) { vcDir = key.GetValue("InstallDir") as string; } } } if (string.IsNullOrEmpty(vcDir)) { return null; } string bin = Path.Combine(vcDir, "bin"), bins = bin; if (arch == ProcessorArchitecture.Amd64) { bin = Path.Combine(bin, "x86_amd64"); bins = bin + ";" + bins; } if (!string.IsNullOrEmpty(vsDir)) { bins += ";" + vsDir; } string include = Path.Combine(vcDir, "include"); string lib = Path.Combine(vcDir, "lib"); if (arch == ProcessorArchitecture.Amd64) { lib = Path.Combine(lib, "amd64"); } AddWindowsSdk(version, arch, ref include, ref lib); return new VCCompiler(bin, bins, include, lib); }
internal static string GetLocation(AssemblyNameExtension strongName, ProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, bool fullFusionName, Microsoft.Build.Shared.FileExists fileExists, GetPathFromFusionName getPathFromFusionName, GetGacEnumerator getGacEnumerator, bool specificVersion) { string str = null; if (((strongName.GetPublicKeyToken() == null) || (strongName.GetPublicKeyToken().Length == 0)) && (strongName.FullName.IndexOf("PublicKeyToken", StringComparison.OrdinalIgnoreCase) != -1)) { return str; } getPathFromFusionName = getPathFromFusionName ?? pathFromFusionName; getGacEnumerator = getGacEnumerator ?? gacEnumerator; if (!strongName.HasProcessorArchitectureInFusionName) { if ((targetProcessorArchitecture != ProcessorArchitecture.MSIL) && (targetProcessorArchitecture != ProcessorArchitecture.None)) { string str2 = ResolveAssemblyReference.ProcessorArchitectureToString(targetProcessorArchitecture); if (fullFusionName) { str = CheckForFullFusionNameInGac(strongName, str2, getPathFromFusionName); } else { str = GetLocationImpl(strongName, str2, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if ((str != null) && (str.Length > 0)) { return str; } } if (fullFusionName) { str = CheckForFullFusionNameInGac(strongName, "MSIL", getPathFromFusionName); } else { str = GetLocationImpl(strongName, "MSIL", getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if ((str != null) && (str.Length > 0)) { return str; } } if (fullFusionName) { str = CheckForFullFusionNameInGac(strongName, null, getPathFromFusionName); } else { str = GetLocationImpl(strongName, null, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if ((str != null) && (str.Length > 0)) { return str; } return null; }
private void RegisterInterpreters(HashSet<string> registeredPaths, RegistryKey python, ProcessorArchitecture? arch) { foreach (var key in python.GetSubKeyNames()) { Version version; if (Version.TryParse(key, out version)) { if (version.Major == 2 && version.Minor <= 4) { // 2.4 and below not supported. continue; } var installPath = python.OpenSubKey(key + "\\InstallPath"); if (installPath != null) { var basePathObj = installPath.GetValue(""); if (basePathObj == null) { // http://pytools.codeplex.com/discussions/301384 // messed up install, we don't know where it lives, we can't use it. continue; } string basePath = basePathObj.ToString(); if (basePath.IndexOfAny(Path.GetInvalidPathChars()) != -1) { // Invalid path in registry continue; } if (!registeredPaths.Add(basePath)) { // registered in both HCKU and HKLM continue; } var actualArch = arch; if (!actualArch.HasValue) { actualArch = NativeMethods.GetBinaryType(Path.Combine(basePath, "python.exe")); } var id = _cpyInterpreterGuid; var description = "Python"; if (actualArch == ProcessorArchitecture.Amd64) { id = _cpy64InterpreterGuid; description = "Python 64-bit"; } _interpreters.Add( new CPythonInterpreterFactory( version, id, description, Path.Combine(basePath, "python.exe"), Path.Combine(basePath, "pythonw.exe"), "PYTHONPATH", actualArch ?? ProcessorArchitecture.None ) ); } } } }
private static InterpreterConfiguration GetConfiguration(ProcessorArchitecture arch) { var prefixPath = IronPythonResolver.GetPythonInstallDir(); return new InterpreterConfiguration( prefixPath, Path.Combine(prefixPath, arch == ProcessorArchitecture.Amd64 ? "ipy64.exe" : "ipy.exe"), Path.Combine(prefixPath, arch == ProcessorArchitecture.Amd64 ? "ipyw64.exe" : "ipyw.exe"), Path.Combine(prefixPath, "Lib"), "IRONPYTHONPATH", arch, new Version(2, 7)); }
public UpdateChecker( Version applicationVersion, ProcessorArchitecture processorArchitecture, string variant, IUpdateNotificationClient updateNotificationClient) { this.applicationVersion = applicationVersion; this.processorArchitecture = processorArchitecture; this.variant = variant; this.updateNotificationClient = updateNotificationClient; }
/// <summary> /// Format a ProcessorArchitecture as it would be expected in a user agent of a browser. /// </summary> /// <returns>String containing the format processor architecture.</returns> private static string FormatForUserAgent(ProcessorArchitecture architecture) { switch (architecture) { case ProcessorArchitecture.AMD64: return "x64"; case ProcessorArchitecture.ARM: return "ARM"; default: return ""; } }
/// <summary> /// Initializes a new instance of <see cref="Dependency"/>. /// </summary> /// <param name="name">The assembly name.</param> /// <param name="verson">The asembly version.</param> /// <param name="culture">The assembly culture.</param> /// <param name="architecture">The compatible architecture of the assembly.</param> public Dependency(string name, Version version, CultureInfo culture, ProcessorArchitecture architecture) { // Input validation Ensure.That(name, "name").IsNotNullOrWhiteSpace(); Ensure.That(version, "version").IsNotNull(); Ensure.That(culture, "culture").IsNotNull(); // Initializes this.Name = name; this.Version = version; this.Culture = culture; this.Architecture = architecture; }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary<string, string> envVars) { var arch = NativeMethods.GetBinaryType(exe); if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } dir = PathUtils.TrimEndSeparator(dir); if (string.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll", typeof(ProfiledProcess).Assembly)); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = string.Join(" ", ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, "proflaun.py")), ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, dll)), ProcessOutput.QuoteSingleArgument(dir), _args ); processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
public override void Check() { var architectures = new Dictionary<string, ProcessorArchitecture>(); var architecture = Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture; var exes = AppHelper.GetFiles(".", "*.exe"); // Exclude x360ce files. exes = exes.Where(x => !x.ToLower().Contains("x360ce")).ToArray(); // If single executable was found then... if (exes.Length == 1 && CheckFile) { CheckFile = false; // Update current settings file. MainForm.Current.Invoke((Action)delegate () { MainForm.Current.GameSettingsPanel.ProcessExecutable(exes[0]); }); } foreach (var exe in exes) { var pa = Engine.Win32.PEReader.GetProcessorArchitecture(exe); architectures.Add(exe, pa); } var fi = new FileInfo(Application.ExecutablePath); // Select all architectures of executables. var archs = architectures.Select(x => x.Value).ToArray(); var x86Count = archs.Count(x => x == ProcessorArchitecture.X86); var x64Count = archs.Count(x => x == ProcessorArchitecture.Amd64); // If executables are 32-bit, but this program is 64-bit then... if (x86Count > 0 && x64Count == 0 && architecture == ProcessorArchitecture.Amd64) { Description = "This folder contains 32-bit game. You should use 32-bit X360CE Application:\r\n" + "http://www.x360ce.com/Files/x360ce.zip"; _architecture = ProcessorArchitecture.X86; FixName = "Download"; Severity = IssueSeverity.Moderate; return; } // If executables are 64-bit, but this program is 32-bit then... if (x64Count > 0 && x86Count == 0 && architecture == ProcessorArchitecture.X86) { Description = "This folder contains 64-bit game. You should use 64-bit X360CE Application:\r\n" + "http://www.x360ce.com/Files/x360ce_x64.zip"; _architecture = ProcessorArchitecture.Amd64; FixName = "Download"; Severity = IssueSeverity.Moderate; return; } Severity = IssueSeverity.None; }
internal static InterpreterConfiguration GetConfiguration(ProcessorArchitecture arch) { var prefixPath = IronPythonResolver.GetPythonInstallDir(); return new InterpreterConfiguration( GetInterpreterId(arch), "IronPython", prefixPath, Path.Combine(prefixPath, arch == ProcessorArchitecture.Amd64 ? "ipy64.exe" : "ipy.exe"), Path.Combine(prefixPath, arch == ProcessorArchitecture.Amd64 ? "ipyw64.exe" : "ipyw.exe"), Path.Combine(prefixPath, "Lib"), "IRONPYTHONPATH", arch, new Version(2, 7), InterpreterUIMode.SupportsDatabase); }
public ProfiledProcess(string exe, string interpreterArgs, string script, string scriptArgs, string dir, Dictionary<string, string> envVars, ProcessorArchitecture arch, string launchUrl, int? port, bool startBrowser, bool justMyCode) { if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } if (String.IsNullOrEmpty(dir)) { // run from where the script is by default (the UI enforces this) Debug.Assert(Path.IsPathRooted(script)); dir = Path.GetDirectoryName(script); } _exe = exe; _args = interpreterArgs; _dir = dir; _arch = arch; _launchUrl = launchUrl; _port = port; _startBrowser = startBrowser; _justMyCode = justMyCode; var processInfo = new ProcessStartInfo(_exe); processInfo.WorkingDirectory = dir; processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; if (_startBrowser && _port == null) { _port = GetFreePort(); } if (_port != null) { if (envVars == null) { envVars = new Dictionary<string, string>(); } envVars["PORT"] = port.ToString(); } if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } processInfo.Arguments = String.Format("{1} --prof \"{0}\" {2}", script, interpreterArgs, scriptArgs); _process = new Process(); _process.StartInfo = processInfo; }
public static void DeterminesFrameworkFolderPerArchitecture( ProcessorArchitecture architecture, bool is64BitOperatingSystem, bool expect64Bit) { // arrange var root = "root"; var msbuild = new Derived { MSBuildVersion = "net45", MSBuildArchitecture = architecture }; var expectedFilename = expect64Bit ? Path.Combine(root, "Microsoft.NET", "Framework64", "v4.0.30319", "MSBuild.exe") : Path.Combine(root, "Microsoft.NET", "Framework", "v4.0.30319", "MSBuild.exe"); // act var startInfo = msbuild.GetStartInfoFramework(root, is64BitOperatingSystem); // assert startInfo.FileName.Should().Be(expectedFilename); }
public IJInterpreterFactory CreateConfigurableInterpreterFactory(Guid id, string path, string vocPath, string pathEnvVar, string description, ProcessorArchitecture archValue, Version ver) { var fact = _defaultCreator.CreateInterpreterFactory( new Dictionary<InterpreterFactoryOptions, object>() { { InterpreterFactoryOptions.Version, ver }, { InterpreterFactoryOptions.Guid, id }, { InterpreterFactoryOptions.Description, description }, { InterpreterFactoryOptions.JPath, path }, { InterpreterFactoryOptions.JVocabularyPath, vocPath }, { InterpreterFactoryOptions.PathEnvVar, pathEnvVar }, { InterpreterFactoryOptions.ProcessorArchitecture, archValue } } ); return new ConfigurableJInterpreterFactory(fact); }
public static string GetXInputResoureceName(ProcessorArchitecture architecture = ProcessorArchitecture.None) { var assembly = Assembly.GetEntryAssembly(); if (architecture == ProcessorArchitecture.None) { architecture = assembly.GetName().ProcessorArchitecture; } // There must be an easier way to check embedded non managed DLL version. var paString = ""; if (architecture == ProcessorArchitecture.Amd64) paString = "_x64"; if (architecture == ProcessorArchitecture.X86) paString = "_x86"; var name = string.Format("xinput{0}.dll", paString); var names = assembly.GetManifestResourceNames(); var resourceName = names.FirstOrDefault(x => x.EndsWith(name)); return resourceName; }
private static bool IsCompatible(ProcessorArchitecture pa) { if ((pa == ProcessorArchitecture.X86) && (IntPtr.Size == 8)) { return false; } if ((pa == ProcessorArchitecture.IA64) && (IntPtr.Size == 4)) { return false; } if ((pa == ProcessorArchitecture.Amd64) && (IntPtr.Size == 4)) { return false; } return true; }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary<string, string> envVars, ProcessorArchitecture arch) { if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } if (String.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll")); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = "\"" + Path.Combine(pythonInstallDir, "proflaun.py") + "\" " + "\"" + Path.Combine(pythonInstallDir, dll) + "\" " + "\"" + dir + "\" " + _args; processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
public static NCoverTool GetInstance(NCoverVersion version, ProcessorArchitecture architecture) { switch (version) { case NCoverVersion.V1: return new NCoverV1Tool(architecture); case NCoverVersion.V2: return new NCoverV2Tool(architecture); case NCoverVersion.V3: return new NCoverV3Tool(architecture); default: throw new NotSupportedException("Unrecognized NCover version."); } }
/// <summary> /// Gets a registry value taking into account the bitness of the platform /// and the requested processor architecture affinity. /// </summary> /// <remarks> /// If <paramref name="architecture" /> requests a 32bit architecture, then only /// the 32bit registry is searched. Likewise if it requests a 64bit architecture, /// then only the 64bit registry is searched. Otherwise searches the 64bit /// registry first then falls back on the 32bit registry. /// </remarks> /// <param name="architecture">The processor architecture affinity.</param> /// <param name="hive">The registry hive.</param> /// <param name="keyName">The key name.</param> /// <param name="valueName">The value name, or null to read the key's value.</param> /// <param name="defaultValue">The default value to return.</param> /// <returns>The value, or null if the key does not exist.</returns> /// <seealso cref="Registry.GetValue(string, string, object)"/> public static object GetValueWithBitness(ProcessorArchitecture architecture, RegistryHive hive, string keyName, string valueName, string defaultValue) { if (keyName == null) throw new ArgumentNullException("keyName"); object value = defaultValue; TryActionOnOpenSubKeyWithBitness(architecture, hive, keyName, key => { object maybeValue = key.GetValue(valueName, Sentinel); if (maybeValue == Sentinel) return false; value = maybeValue; return true; }); return value; }
private static ProcessorArchitecture GetProcessorArchitectureImpl(EndianBinaryReader reader) { ProcessorArchitecture architecture = ProcessorArchitecture.Unknown; ushort dosSignature = reader.ReadUInt16(); if (dosSignature == IMAGE_DOS_SIGNATURE) { reader.Position = NTSignatureOffsetLocation; uint ntSignatureOffset = reader.ReadUInt32(); reader.Position = ntSignatureOffset; uint ntSignature = reader.ReadUInt32(); if (ntSignature == IMAGE_NT_SIGNATURE) { ushort machine = reader.ReadUInt16(); switch (machine) { case IMAGE_FILE_MACHINE_I386: architecture = ProcessorArchitecture.X86; break; case IMAGE_FILE_MACHINE_AMD64: architecture = ProcessorArchitecture.X64; break; case IMAGE_FILE_MACHINE_ARM: architecture = ProcessorArchitecture.Arm; break; case IMAGE_FILE_MACHINE_ARM64: architecture = ProcessorArchitecture.Arm64; break; } } } return(architecture); }
public IdentityBuilder( string assemblyName, ProcessorArchitecture architecture, int majorVersion, int minorVersion, int buildVersion, int revisionVersion, CultureInfoType cultureType = CultureInfoType.CurrentCulture, AssemblyHashAlgorithm hashAlgorithm = AssemblyHashAlgorithm.MD5) : this( CreateAssemblyName(assemblyName), CreateVersion( majorVersion, minorVersion, buildVersion, revisionVersion), architecture, cultureType, hashAlgorithm) { }
private string GetArchitectureName(ProcessorArchitecture type) { switch (type) { case ProcessorArchitecture.MSIL: return("Any CPU"); case ProcessorArchitecture.X86: return("x86"); case ProcessorArchitecture.Amd64: return("x64"); case ProcessorArchitecture.IA64: case ProcessorArchitecture.Arm: case ProcessorArchitecture.None: default: return(string.Empty); } }
/// <summary> /// Initializes a new instance of the <see cref="QueryFilter"/> class. /// </summary> /// <param name="fileName">The file name of the plug-in.</param> /// <param name="platform">The processor architecture that the plug-in was built for.</param> /// <exception cref="System.PlatformNotSupportedException">The processor architecture specified by <paramref name="platform"/> is not supported.</exception> public QueryFilter(string fileName, ProcessorArchitecture platform) { this.fileName = fileName; switch (platform) { case ProcessorArchitecture.X86: platformEntryPoint = PIPropertyID.PIWin32X86CodeProperty; break; case ProcessorArchitecture.X64: platformEntryPoint = PIPropertyID.PIWin64X86CodeProperty; break; case ProcessorArchitecture.Unknown: default: throw new PlatformNotSupportedException($"No platform entry point was defined for { nameof(ProcessorArchitecture) }.{ platform }."); } plugins = new List <PluginData>(); runWith32BitShim = platform == ProcessorArchitecture.X86 && ProcessInformation.Architecture != ProcessorArchitecture.X86; }
private void Load() { var image = _module.Image; if (image.GetAssemblyCount() == 0) { throw new AssemblyLoadException(string.Format(SR.AssemblyLoadError, _module.Location)); } AssemblyRow row; image.GetAssembly(1, out row); _name = image.GetString(row.Name); _culture = image.GetString(row.Locale); _processorArchitecture = (ProcessorArchitecture)((int)(row.Flags & AssemblyFlags.PA_Mask) >> (int)AssemblyFlags.PA_Shift); _version = new Version(row.MajorVersion, row.MinorVersion, row.BuildNumber, row.RevisionNumber); _publicKey = image.GetBlob(row.PublicKey); _hashAlgorithm = row.HashAlgId; _framework = GetFramework(); }
/// <summary> /// Implementation of ICorDebugDataTarget.GetPlatform /// </summary> /// <param name="type">platform that the process in this dump was executing on</param> public CorDebugPlatform GetPlatform() { // Infer platform based off CPU architecture // At the moment we only support windows. ProcessorArchitecture p = this.m_reader.ProcessorArchitecture; switch (p) { case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_INTEL: return(CorDebugPlatform.CORDB_PLATFORM_WINDOWS_X86); case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_IA64: return(CorDebugPlatform.CORDB_PLATFORM_WINDOWS_IA64); case ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64: return(CorDebugPlatform.CORDB_PLATFORM_WINDOWS_AMD64); } throw new InvalidOperationException("Unrecognized target architecture " + p); }
/// <summary> /// Gets the processor architecture that the module was built for. /// </summary> /// <param name="fileName">The file name to check.</param> /// <returns>The processor architecture of the module.</returns> internal static ProcessorArchitecture GetProcessorArchitecture(string fileName) { ProcessorArchitecture architecture = ProcessorArchitecture.Unknown; FileStream stream = null; try { stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); using (EndianBinaryReader reader = new EndianBinaryReader(stream, Endianess.Little)) { stream = null; architecture = GetProcessorArchitectureImpl(reader); } } catch (ArgumentException) { } catch (IOException) { } catch (NotSupportedException) { } catch (SecurityException) { } catch (UnauthorizedAccessException) { } finally { stream?.Dispose(); } return(architecture); }
/// <summary> /// Generates a new context object for the current platform. This does NOT account for Wow mode processes. /// This method should be primarily used for dump debugging. /// </summary> /// <param name="architecture">The architecture for which to create the context</param> /// <returns>Newly allocated platform specific context.</returns> /// <exception cref="InvalidOperationException">Throws if running on an unsupported platform</exception> static public INativeContext GenerateContext(ProcessorArchitecture architecture) { if (architecture == ProcessorArchitecture.PROCESSOR_ARCHITECTURE_INTEL) { // We know that we need an x86 context return(new X86Context()); } else if (architecture == ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64) { // We know that we need an amd64 context return(new AMD64Context()); } else if (architecture == ProcessorArchitecture.PROCESSOR_ARCHITECTURE_IA64) { // We know that we need an ia64 context return(new IA64Context()); } else { throw new ApplicationException("Error: This architecture is not supported"); } }
public static Version GetEmbeddedDllVersion(ProcessorArchitecture architecture) { lock (EmbededVersionsLock) { if (_embededVersions == null) { _embededVersions = new Dictionary <ProcessorArchitecture, Version>(); ProcessorArchitecture[] archs = { ProcessorArchitecture.X86, ProcessorArchitecture.Amd64, ProcessorArchitecture.MSIL }; foreach (var a in archs) { string tempPath = Path.GetTempPath(); FileStream sw = null; var tempFile = Path.Combine(Path.GetTempPath(), "xinput_" + a.ToString() + ".tmp.dll"); sw = new FileStream(tempFile, FileMode.Create, FileAccess.Write); var buffer = new byte[1024]; var assembly = Assembly.GetEntryAssembly(); var resourceName = GetXInputResoureceName(architecture); var sr = assembly.GetManifestResourceStream(resourceName); while (true) { var count = sr.Read(buffer, 0, buffer.Length); if (count == 0) { break; } sw.Write(buffer, 0, count); } sr.Close(); sw.Close(); var vi = FileVersionInfo.GetVersionInfo(tempFile); var v = new Version(vi.FileMajorPart, vi.FileMinorPart, vi.FileBuildPart, vi.FilePrivatePart); File.Delete(tempFile); _embededVersions.Add(a, v); } } } return(_embededVersions[architecture]); }
/// <summary> /// Gets a registry value taking into account the bitness of the platform /// and the requested processor architecture affinity. /// </summary> /// <remarks> /// If <paramref name="architecture" /> requests a 32bit architecture, then only /// the 32bit registry is searched. Likewise if it requests a 64bit architecture, /// then only the 64bit registry is searched. Otherwise searches the 64bit /// registry first then falls back on the 32bit registry. /// </remarks> /// <param name="architecture">The processor architecture affinity.</param> /// <param name="hive">The registry hive.</param> /// <param name="keyName">The key name.</param> /// <param name="valueName">The value name, or null to read the key's value.</param> /// <param name="defaultValue">The default value to return.</param> /// <returns>The value, or null if the key does not exist.</returns> /// <seealso cref="Registry.GetValue(string, string, object)"/> public static object GetValueWithBitness(ProcessorArchitecture architecture, RegistryHive hive, string keyName, string valueName, string defaultValue) { if (keyName == null) { throw new ArgumentNullException("keyName"); } object value = defaultValue; TryActionOnOpenSubKeyWithBitness(architecture, hive, keyName, key => { object maybeValue = key.GetValue(valueName, Sentinel); if (maybeValue == Sentinel) { return(false); } value = maybeValue; return(true); }); return(value); }
public NotFoundInterpreterFactory( string id, Version version, string description = null, string prefixPath = null, ProcessorArchitecture architecture = ProcessorArchitecture.None, string descriptionSuffix = null ) { Configuration = new InterpreterConfiguration( id, string.IsNullOrEmpty(description) ? "Unknown Python" : description, prefixPath, null, null, null, null, architecture, version, InterpreterUIMode.CannotBeDefault | InterpreterUIMode.CannotBeConfigured, "(unavailable)" ); }
public Result( string fullName, Flavor flavor, ProcessorArchitecture targetPlatform, string targetFramework, string errorMsg ) { this.FullName = fullName; this.Flavor = flavor; this.TargetPlatform = targetPlatform; this.TargetFramework = targetFramework; if (errorMsg == null) { this.HasError = false; } else { this.HasError = true; this.ErrorMessage = errorMsg; } }
static PlatformConfiguration() { #if WINDOWS_UWP IsMac = false; IsLinux = false; IsUnix = false; IsWindows = true; var arch = Package.Current.Id.Architecture; const ProcessorArchitecture arm64 = (ProcessorArchitecture)12; IsArm = arch == ProcessorArchitecture.Arm || arch == arm64; #else IsMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); IsUnix = IsMac || IsLinux; IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); var arch = RuntimeInformation.ProcessArchitecture; IsArm = arch == Architecture.Arm || arch == Architecture.Arm64; #endif Is64Bit = IntPtr.Size == 8; }
private static string GetProcessorArchitectureName(ProcessorArchitecture architecture) { switch (architecture) { case ProcessorArchitecture.None: return(null); case ProcessorArchitecture.MSIL: return("msil"); case ProcessorArchitecture.X86: return("x86"); case ProcessorArchitecture.IA64: return("ia64"); case ProcessorArchitecture.Amd64: return("amd64"); default: throw new ArgumentOutOfRangeException("architecture"); } }
private void WriteAsmIDElement(Stream s, Assembly assembly, int offset) { AssemblyName name = assembly.GetName(); string str = name.Version.ToString(); string str2 = name.Name; byte[] publicKeyToken = name.GetPublicKeyToken(); string str3 = name.CultureInfo.ToString(); ProcessorArchitecture processorArchitecture = name.ProcessorArchitecture; this.WriteUTFChars(s, "<assemblyIdentity" + Environment.NewLine, offset); this.WriteUTFChars(s, " name=\"" + str2 + "\"" + Environment.NewLine, offset); this.WriteUTFChars(s, " version=\"" + str + "\"", offset); if ((publicKeyToken != null) && (publicKeyToken.Length != 0)) { this.WriteUTFChars(s, Environment.NewLine); this.WriteUTFChars(s, " publicKeyToken=\"", offset); this.WriteUTFChars(s, publicKeyToken); this.WriteUTFChars(s, "\""); } if (processorArchitecture != ProcessorArchitecture.None) { this.WriteUTFChars(s, Environment.NewLine); this.WriteUTFChars(s, " processorArchitecture=\"", offset); this.WriteUTFChars(s, processorArchitecture.ToString()); this.WriteUTFChars(s, "\""); } if (str3 == "") { this.WriteUTFChars(s, " />" + Environment.NewLine); } else { this.WriteUTFChars(s, Environment.NewLine); this.WriteUTFChars(s, " language=\"" + str3 + "\" />" + Environment.NewLine, offset); } }
public ProfiledProcess(string exe, string args, string dir, ProcessorArchitecture arch) { if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } if (String.IsNullOrEmpty(dir)) { dir = "."; } _exe = exe; _args = args; _dir = dir; _arch = arch; var processInfo = new ProcessStartInfo(_exe); processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; string pythonInstallDir = GetPythonToolsInstallPath(); string dll = _arch == ProcessorArchitecture.Amd64 ? "x64\\vspyprof.dll" : "vspyprof.dll"; processInfo.Arguments = "\"" + Path.Combine(pythonInstallDir, "proflaun.py") + "\" " + "\"" + Path.Combine(pythonInstallDir, dll) + "\" " + "\"" + dir + "\" " + _args; _process = new Process(); _process.StartInfo = processInfo; }
public bool CreateFile(string resourceName, string destinationFileName, ProcessorArchitecture oldArchitecture, ProcessorArchitecture newArchitecture) { if (destinationFileName == null) { destinationFileName = resourceName; } DialogResult answer; var form = new MessageBoxForm(); form.StartPosition = FormStartPosition.CenterParent; var oldDesc = EngineHelper.GetProcessorArchitectureDescription(oldArchitecture); var newDesc = EngineHelper.GetProcessorArchitectureDescription(newArchitecture); var fileName = new FileInfo(destinationFileName).Name; answer = form.ShowForm( string.Format("You are running {2} application but {0} on the disk was built for {1} architecture.\r\n\r\nDo you want to replace {0} file with {2} version?", fileName, oldDesc, newDesc), "Processor architecture mismatch.", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (answer == DialogResult.Yes) { return(AppHelper.WriteFile(resourceName, destinationFileName)); } return(true); }
public void SetProcessorArchitecture_InvalidArchitecture_TakesLowerThreeBitsIfLessThanOrEqualToMax(ProcessorArchitecture invalidArchitecture) { foreach (ProcessorArchitecture validArchitecture in ValidProcessorArchitectureValues()) { var assemblyName = new AssemblyName(); assemblyName.ProcessorArchitecture = validArchitecture; assemblyName.ProcessorArchitecture = invalidArchitecture; ProcessorArchitecture maskedInvalidArchitecture = (ProcessorArchitecture)(((int)invalidArchitecture) & 0x7); ProcessorArchitecture expectedResult = maskedInvalidArchitecture > CurrentMaxValue ? validArchitecture : maskedInvalidArchitecture; Assert.Equal(expectedResult, assemblyName.ProcessorArchitecture); } }
public void GetFullNameAndToString_AreEquivalentAndDoNotPreserveArchitecture(string name, ProcessorArchitecture expected) { _ = expected; string originalFullName = "Test, Culture=en-US, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=" + name; string expectedSerializedFullName = "Test, Culture=en-US, PublicKeyToken=b77a5c561934e089"; var assemblyName = new AssemblyName(originalFullName); Assert.Equal(expectedSerializedFullName, assemblyName.FullName); Assert.Equal(expectedSerializedFullName, assemblyName.ToString()); }
public static string GetXInputResoureceName(ProcessorArchitecture architecture = ProcessorArchitecture.None) { return(GetResourcePath("xinput.dll")); }
private static void DumpGCHeap(string qualifiers, string inputArg, string outputFile, TextWriter log, ProcessorArchitecture arch) { var directory = arch == ProcessorArchitecture.X86 ? "x86" : "amd64"; var heapDumpExe = Path.Combine(SupportFiles.SupportFileDir, Path.Combine(directory, "HeapDump.exe")); var options = new CommandOptions().AddNoThrow().AddTimeout(CommandOptions.Infinite); if (log != null) { options.AddOutputStream(log); } // TODO breaking abstraction to know about StackWindow. options.AddEnvironmentVariable("_NT_SYMBOL_PATH", App.SymbolPath); log.WriteLine("set _NT_SYMBOL_PATH={0}", App.SymbolPath); var commandLine = string.Format("\"{0}\" {1} \"{2}\" \"{3}\"", heapDumpExe, qualifiers, inputArg, outputFile); log.WriteLine("Exec: {0}", commandLine); PerfViewLogger.Log.TriggerHeapSnapshot(outputFile, inputArg, qualifiers); var cmd = Command.Run(commandLine, options); if (cmd.ExitCode == 3) { throw new ApplicationException("Unable to open the process dump. PerfView only supports converting Windows process dumps. Please confirm that this is a Windows process dump."); } else if (cmd.ExitCode != 0) { throw new ApplicationException("HeapDump failed with exit code " + cmd.ExitCode); } if (log != null) { log.WriteLine("Completed Heap Dump for {0} to {1}", inputArg, outputFile); } }
public LocateAssemblyResult(ProcessorArchitecture processorArchitecture) { this.Success = false; this.SwitchContext = true; this.SwitchToArchitecture = processorArchitecture; }
public static LocateAssemblyResult Locate(string assemblyName, bool isBeforeBuild, params SearchLocation[] locations) { foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.IsDynamic)) { if (assembly.Location.Equals(assemblyName, StringComparison.CurrentCultureIgnoreCase) || assembly.GetName().Name.Equals(assemblyName, StringComparison.CurrentCultureIgnoreCase)) { return(new LocateAssemblyResult(assembly)); } } Assembly entryAssembly = Assembly.GetEntryAssembly(); ProcessorArchitecture entryArchitecture = entryAssembly.GetName().ProcessorArchitecture; try { ProcessorArchitecture assemblyArchitecture = AssemblyName.GetAssemblyName(assemblyName).ProcessorArchitecture; bool isCompatible64 = (entryArchitecture == ProcessorArchitecture.Amd64 || entryArchitecture == ProcessorArchitecture.MSIL) && (assemblyArchitecture == ProcessorArchitecture.Amd64 || assemblyArchitecture == ProcessorArchitecture.MSIL); bool isCompatible86 = entryArchitecture == ProcessorArchitecture.X86 && assemblyArchitecture == ProcessorArchitecture.X86; if (!isCompatible64 && !isCompatible86) { return(new LocateAssemblyResult(assemblyArchitecture)); } } catch (FileNotFoundException) { if (isBeforeBuild) { return(new LocateAssemblyResult()); } throw; } try { SwitchableFramework? assemblyFramework = null; string[] frameworkFiles = FileSystem.GetFiles(RuntimeEnvironment.GetRuntimeDirectory(), "*.dll"); IEnumerable <string> loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.IsDynamic).Select(x => x.Location); PathAssemblyResolver resolver = new PathAssemblyResolver(loadedAssemblies.Concat(frameworkFiles)); MetadataLoadContext metadataLoadContext = new MetadataLoadContext(resolver); using (metadataLoadContext) { Assembly assemblyData = metadataLoadContext.LoadFromAssemblyPath(assemblyName); IList <CustomAttributeData> customAttributeData = assemblyData.GetCustomAttributesData(); foreach (CustomAttributeData attributeData in customAttributeData) { try { assemblyFramework = assemblyFramework ?? attributeData.ConstructorArguments.Select(x => x.Value as string) .Where(x => x != null) .Select(TryParseFrameworkName) .FirstOrDefault()? .GetSwitchableFramework(); } catch { // Some unnecessary attributes can not be read by a assembly with the wrong framework version, so ignore them } } assemblyFramework = assemblyFramework ?? SwitchableFramework.None; } SwitchableFramework entryFramework = entryAssembly.GetSwitchableFramework(); if (entryFramework != assemblyFramework && assemblyFramework != SwitchableFramework.None) { return(new LocateAssemblyResult(assemblyFramework.Value)); } } catch (TypeLoadException exception) { Logger.Warning($"Could not check framework compatibility, because {exception.TypeName} could not be loaded\n{exception.Message}"); } catch (FileNotFoundException exception) { Logger.Warning($"Could not check framework compatibility, because an assembly could not be found\n{exception.Message}"); } catch (Exception exception) { Logger.Warning($"Could not check framework compatibility, because an error occurred\n{exception.Message}"); } NugetAssemblyLocator locator = NugetPackageDependencyLoader.CreateLocator(); locator.Locations.InsertRange(0, locations); Version defaultVersion = typeof(CoreModule).Assembly.GetName().Version; return(new LocateAssemblyResult(locator.Locate(assemblyName, defaultVersion))); }
internal static AssemblyNameFlags CombineAssemblyNameFlags(AssemblyNameFlags flags, AssemblyContentType contentType, ProcessorArchitecture processorArchitecture) { return((AssemblyNameFlags)(((int)flags) | (((int)contentType) << 9) | ((int)processorArchitecture << 4))); }
/// <summary> /// Given a strong name, find its path in the GAC. /// </summary> /// <param name="strongName">The strong name.</param> /// <param name="targetProcessorArchitecture">Like x86 or IA64\AMD64.</param> /// <param name="getRuntimeVersion">Delegate to get the runtime version from a file path</param> /// <param name="targetedRuntimeVersion">What version of the runtime are we targeting</param> /// <param name="fullFusionName">Are we guranteed to have a full fusion name. This really can only happen if we have already resolved the assembly</param> /// <returns>The path to the assembly. Empty if none exists.</returns> internal static string GetLocation ( IBuildEngine4 buildEngine, AssemblyNameExtension strongName, ProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, bool fullFusionName, FileExists fileExists, GetPathFromFusionName getPathFromFusionName, GetGacEnumerator getGacEnumerator, bool specificVersion ) { ConcurrentDictionary <AssemblyNameExtension, string> fusionNameToResolvedPath = null; bool useGacRarCache = Environment.GetEnvironmentVariable("MSBUILDDISABLEGACRARCACHE") == null; if (buildEngine != null && useGacRarCache) { string key = "44d78b60-3bbe-48fe-9493-04119ebf515f" + "|" + targetProcessorArchitecture.ToString() + "|" + targetedRuntimeVersion.ToString() + "|" + fullFusionName.ToString() + "|" + specificVersion.ToString(); fusionNameToResolvedPath = buildEngine.GetRegisteredTaskObject(key, RegisteredTaskObjectLifetime.Build) as ConcurrentDictionary <AssemblyNameExtension, string>; if (fusionNameToResolvedPath == null) { fusionNameToResolvedPath = new ConcurrentDictionary <AssemblyNameExtension, string>(AssemblyNameComparer.GenericComparer); buildEngine.RegisterTaskObject(key, fusionNameToResolvedPath, RegisteredTaskObjectLifetime.Build, true /* dispose early ok*/); } else { if (fusionNameToResolvedPath.ContainsKey(strongName)) { string fusionName = null; fusionNameToResolvedPath.TryGetValue(strongName, out fusionName); return(fusionName); } } } // Optimize out the case where the public key token is null, if it is null it is not a strongly named assembly and CANNOT be in the gac. // also passing it would cause the gac enumeration method to throw an exception indicating the assembly is not a strongnamed assembly. string location = null; // If the publickeyToken is null and the publickeytoken is in the fusion name then this means we are passing in a null or empty PublicKeyToken and then this cannot possibly be in the gac. if ((strongName.GetPublicKeyToken() == null || strongName.GetPublicKeyToken().Length == 0) && strongName.FullName.IndexOf("PublicKeyToken", StringComparison.OrdinalIgnoreCase) != -1) { if (fusionNameToResolvedPath != null) { fusionNameToResolvedPath.TryAdd(strongName, location); } return(location); } // A delegate was not passed in to use the default one getPathFromFusionName = getPathFromFusionName ?? pathFromFusionName; // A delegate was not passed in to use the default one getGacEnumerator = getGacEnumerator ?? gacEnumerator; // If we have no processor architecture set then we can tryout a number of processor architectures. if (!strongName.HasProcessorArchitectureInFusionName) { if (targetProcessorArchitecture != ProcessorArchitecture.MSIL && targetProcessorArchitecture != ProcessorArchitecture.None) { string processorArchitecture = ResolveAssemblyReference.ProcessorArchitectureToString(targetProcessorArchitecture); // Try processor specific first. if (fullFusionName) { location = CheckForFullFusionNameInGac(strongName, processorArchitecture, getPathFromFusionName); } else { location = GetLocationImpl(strongName, processorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if (location != null && location.Length > 0) { if (fusionNameToResolvedPath != null) { fusionNameToResolvedPath.TryAdd(strongName, location); } return(location); } } // Next, try MSIL if (fullFusionName) { location = CheckForFullFusionNameInGac(strongName, "MSIL", getPathFromFusionName); } else { location = GetLocationImpl(strongName, "MSIL", getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if (location != null && location.Length > 0) { if (fusionNameToResolvedPath != null) { fusionNameToResolvedPath.TryAdd(strongName, location); } return(location); } } // Next, try no processor architecure if (fullFusionName) { location = CheckForFullFusionNameInGac(strongName, null, getPathFromFusionName); } else { location = GetLocationImpl(strongName, null, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion); } if (location != null && location.Length > 0) { if (fusionNameToResolvedPath != null) { fusionNameToResolvedPath.TryAdd(strongName, location); } return(location); } if (fusionNameToResolvedPath != null) { fusionNameToResolvedPath.TryAdd(strongName, null); } return(null); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ProcessorArchitecture.Expression != null) { targetCommand.AddParameter("ProcessorArchitecture", ProcessorArchitecture.Get(context)); } if (SessionType.Expression != null) { targetCommand.AddParameter("SessionType", SessionType.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (AssemblyName.Expression != null) { targetCommand.AddParameter("AssemblyName", AssemblyName.Get(context)); } if (ApplicationBase.Expression != null) { targetCommand.AddParameter("ApplicationBase", ApplicationBase.Get(context)); } if (ConfigurationTypeName.Expression != null) { targetCommand.AddParameter("ConfigurationTypeName", ConfigurationTypeName.Get(context)); } if (RunAsCredential.Expression != null) { targetCommand.AddParameter("RunAsCredential", RunAsCredential.Get(context)); } if (ThreadApartmentState.Expression != null) { targetCommand.AddParameter("ThreadApartmentState", ThreadApartmentState.Get(context)); } if (ThreadOptions.Expression != null) { targetCommand.AddParameter("ThreadOptions", ThreadOptions.Get(context)); } if (AccessMode.Expression != null) { targetCommand.AddParameter("AccessMode", AccessMode.Get(context)); } if (UseSharedProcess.Expression != null) { targetCommand.AddParameter("UseSharedProcess", UseSharedProcess.Get(context)); } if (StartupScript.Expression != null) { targetCommand.AddParameter("StartupScript", StartupScript.Get(context)); } if (MaximumReceivedDataSizePerCommandMB.Expression != null) { targetCommand.AddParameter("MaximumReceivedDataSizePerCommandMB", MaximumReceivedDataSizePerCommandMB.Get(context)); } if (MaximumReceivedObjectSizeMB.Expression != null) { targetCommand.AddParameter("MaximumReceivedObjectSizeMB", MaximumReceivedObjectSizeMB.Get(context)); } if (SecurityDescriptorSddl.Expression != null) { targetCommand.AddParameter("SecurityDescriptorSddl", SecurityDescriptorSddl.Get(context)); } if (ShowSecurityDescriptorUI.Expression != null) { targetCommand.AddParameter("ShowSecurityDescriptorUI", ShowSecurityDescriptorUI.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (NoServiceRestart.Expression != null) { targetCommand.AddParameter("NoServiceRestart", NoServiceRestart.Get(context)); } if (PSVersion.Expression != null) { targetCommand.AddParameter("PSVersion", PSVersion.Get(context)); } if (SessionTypeOption.Expression != null) { targetCommand.AddParameter("SessionTypeOption", SessionTypeOption.Get(context)); } if (TransportOption.Expression != null) { targetCommand.AddParameter("TransportOption", TransportOption.Get(context)); } if (ModulesToImport.Expression != null) { targetCommand.AddParameter("ModulesToImport", ModulesToImport.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public IronPythonInterpreterFactory(ProcessorArchitecture arch = ProcessorArchitecture.X86) : base( GetConfiguration(arch), true) { }
internal static extern IntPtr DriverPackageOpen( string driverPackageFilename, ProcessorArchitecture processorArchitecture, string localeName, DriverPackageOpenFlags flags, IntPtr resolveContext);
private static string GetInterpreterId(ProcessorArchitecture arch) { return(arch == ProcessorArchitecture.Amd64 ? "IronPython|2.7 64-bit" : "IronPython|2.7 32-bit"); }
public Package(String filePath, String version, String publisher, String name, PackageType packageType, ProcessorArchitecture processorArchitecture) { _filePath = filePath; _version = version; _publisher = publisher; _packageType = packageType; _name = name; _processorArchitecture = processorArchitecture; }