Ejemplo n.º 1
0
 public void AddDependency(string name, FourPartVersion version, Architecture arch, string publicKeyToken, string language = "*", AssemblyType assemblyType = AssemblyType.win32, BindingRedirect bindingRedirect = null)
 {
     if (!(from dat in DependentAssemblyElements
         let assemblyIdentity = new AssemblyIdentity(dat)
         where
             assemblyIdentity.Name == name &&
                 assemblyIdentity.Version == version &&
                     assemblyIdentity.Architecture == arch &&
                         assemblyIdentity.PublicKeyToken == publicKeyToken &&
                             ((language == "*" && string.IsNullOrEmpty(assemblyIdentity.Language)) || assemblyIdentity.Language == language)
         select assemblyIdentity).Any()) {
         // add another.
         var dat = new XElement(DependencyTag, new XElement(DependentAssemblyTag));
         var identity = new AssemblyIdentity(dat.Elements().FirstOrDefault()) {
             AssemblyType = assemblyType,
             Name = name,
             Version = version,
             Architecture = arch,
             PublicKeyToken = publicKeyToken,
             Language = language,
             BindingRedirect = bindingRedirect
         };
         _parentElement.Add(dat);
     }
 }
Ejemplo n.º 2
0
        private static string GetCachedPath(string tool, FourPartVersion minimumToolVersion,Architecture architecture) {
            if( architecture == Architecture.Auto ) {
                return (from arch in Architecture.Architectures
                    let p = GetCachedPath(tool, minimumToolVersion, arch)
                    where p != null
                    select p)
                    .FirstOrDefault();
            }

            var view = RegistryView.CoAppUser[@"Tools#{0}/{1}/{2}".format(tool, minimumToolVersion,architecture)];

            var result = view.StringValue;

            // if we've remembered that we've not found something...
            if ("NOT-FOUND".Equals(result, StringComparison.CurrentCultureIgnoreCase)) {
                return result;
            }

            if (null != result && !File.Exists(result)) {
                view.StringValue = null;
                result = null;
            }

            return result;
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        internal override bool Analyze(DirectoryInfo baseDirectory, FileInfo file)
        {
            if (!base.Analyze(baseDirectory, file)) return false;
            if (!HasMagicBytes(file)) return false;

            Name = file.Name;
            Architecture = new Architecture(OS.Linux, Cpu.All);

            IELF elfData = null;
            try
            {
                if (ELFReader.TryLoad(file.FullName, out elfData))
                {
                    if (elfData.Class == Class.NotELF || elfData.Type != FileType.Executable) return false;

                    Architecture = new Architecture(OS.Linux, GetCpu(elfData));
                }
            }
            catch (NullReferenceException)
            {}
            finally
            {
                elfData?.Dispose();
            }

            return true;
        }
Ejemplo n.º 4
0
 public AggregateEventsData(string testName, Platform platform, Architecture architecture)
     : this()
 {
     m_testName = testName;
     m_platform = platform;
     m_arch = architecture;
 }
Ejemplo n.º 5
0
        public static IDisassembler Create(Architecture arch)
        {
            String plug = null;

            switch (arch)
            {
                case Architecture.PowerPC:
                    plug = "disasm\\PPCDisassembler.dll";
                    break;
                default:
                    break;
            }

            if (plug != null)
            {
                Assembly a = Assembly.LoadFrom(plug);
                Type[] types = a.GetTypes();
                foreach (Type type in types)
                {
                    if (type.GetInterface("IDisassembler") != null)
                        return Activator.CreateInstance(type) as IDisassembler;
                }
            }

            return null;
        }
Ejemplo n.º 6
0
 static SettingsUI()
 {
     Architecture[] architectureArray1 = new Architecture[3];
     architectureArray1[1] = Architecture.ARM64;
     architectureArray1[2] = Architecture.Universal;
     kArchitectureOrder = architectureArray1;
     kArchitectureDescriptions = new GUIContent[] { EditorGUIUtility.TextContent("ARMv7"), EditorGUIUtility.TextContent("ARM64"), EditorGUIUtility.TextContent("Universal") };
 }
 public PersonGenerateParam(GameScenario scenario, Architecture foundLocation, Person finder, bool inGame, PersonGeneratorType preferredType, bool isAI)
 {
     this.scenario = scenario;
     this.foundLocation = foundLocation;
     this.finder = finder;
     this.inGame = inGame;
     this.preferredType = preferredType;
     this.isAI = isAI;
 }
Ejemplo n.º 8
0
        public DataTargetImpl(IDataReader dataReader, IDebugClient client)
        {
            if (dataReader == null)
                throw new ArgumentNullException("dataReader");

            _dataReader = dataReader;
            _client = client;
            _architecture = _dataReader.GetArchitecture();
        }
Ejemplo n.º 9
0
        /// <inheritdoc/>
        internal override bool Analyze(DirectoryInfo baseDirectory, FileInfo file)
        {
            if (!base.Analyze(baseDirectory, file)) return false;
            if (!RelativePath.GetLeftPartAtLastOccurrence('/').EndsWith(@".app/Contents/MacOS")) return false;

            // TODO: Parse MacOS plist
            Name = file.Name.Substring(0, file.Name.Length - file.Extension.Length);
            Architecture = new Architecture(OS.MacOSX, Cpu.All);
            return true;
        }
Ejemplo n.º 10
0
        /// <inheritdoc/>
        internal override bool Analyze(DirectoryInfo baseDirectory, FileInfo file)
        {
            if (!base.Analyze(baseDirectory, file)) return false;
            if (!StringUtils.EqualsIgnoreCase(file.Extension, @".bat") && !StringUtils.EqualsIgnoreCase(file.Extension, @".cmd")) return false;

            Architecture = new Architecture(OS.Windows, Cpu.All);
            Name = file.Name.Substring(0, file.Name.Length - file.Extension.Length);
            NeedsTerminal = true;
            return true;
        }
Ejemplo n.º 11
0
        protected virtual bool Parse([NotNull] PEHeader peHeader)
        {
            #region Sanity checks
            if (peHeader == null) throw new ArgumentNullException(nameof(peHeader));
            #endregion

            Architecture = new Architecture(OS.Windows, GetCpu(peHeader.FileHeader.Machine));
            if (peHeader.Subsystem >= Subsystem.WindowsCui) NeedsTerminal = true;
            return peHeader.Is32BitHeader
                ? (peHeader.OptionalHeader32.CLRRuntimeHeader.VirtualAddress == 0)
                : (peHeader.OptionalHeader64.CLRRuntimeHeader.VirtualAddress == 0);
        }
Ejemplo n.º 12
0
        /// <inheritdoc/>
        internal override bool Analyze(DirectoryInfo baseDirectory, FileInfo file)
        {
            if (!base.Analyze(baseDirectory, file)) return false;

            string firstLine = file.ReadFirstLine(Encoding.ASCII);
            if (string.IsNullOrEmpty(firstLine) || !firstLine.StartsWith(@"#!")) return false;

            Architecture = new Architecture(OS.Posix, Cpu.All);
            Name = file.Name;
            NeedsTerminal = true;
            return true;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates a new exporter.
        /// </summary>
        /// <param name="selections">A list of <see cref="ImplementationSelection"/>s to check for referenced feeds.</param>
        /// <param name="architecture">The target architecture to use for bootstrap binaries.</param>
        /// <param name="destination">The path of the directory to export to.</param>
        public Exporter([NotNull] Selections selections, Architecture architecture, [NotNull] string destination)
        {
            #region Sanity checks
            if (selections == null) throw new ArgumentNullException(nameof(selections));
            if (string.IsNullOrEmpty(destination)) throw new ArgumentNullException(nameof(destination));
            #endregion

            _selections = selections;
            _architecture = architecture;
            _destination = destination;

            Directory.CreateDirectory(_destination);
        }
Ejemplo n.º 14
0
        public DataTargetImpl(IDataReader dataReader, IDebugClient client)
        {
            if (dataReader == null)
                throw new ArgumentNullException("dataReader");

            m_dataReader = dataReader;
            m_client = client;
            m_architecture = m_dataReader.GetArchitecture();

            var sympath = SymPath._NT_SYMBOL_PATH;
            if (string.IsNullOrEmpty(sympath))
                sympath = SymPath.MicrosoftSymbolServerPath;

            m_symPath = new SymPath(sympath);
        }
Ejemplo n.º 15
0
        public Test(int count, string filename)
        {
            tw = new StreamWriter(filename);
            this.count = count;
            siec = new Architecture(3);
            siec.inputCount = 2;
            put = new double[count, 2];
            wynik = new double[count];
            Random r = new Random(DateTime.Now.Second);

            for (int i = 0; i < count; i++)
            {
                put[i,0] = (double)(r.Next(100)) / 100.0;
                put[i, 1] = (double)(r.Next(100)) / 100.0;
                wynik[i] = (put[i, 0] + put[i, 1]) / 2.0;
            }
        }
Ejemplo n.º 16
0
    public static int Main (string[] args)
    {
	Architecture arch = new Architecture ();

	if (args.Length != 1) {
	    Console.Error.WriteLine ("This program takes exactly one argument.");
	    return 1;
	}

	try {
	    arch.SetFromString (args[0]);
	} catch (Exception e) {
	    Console.Error.WriteLine ("Exception parsing input string \"{0}\": {1}",
				     args[0], e);
	    return 1;
	}

	Console.WriteLine ("{0}", arch.ToString ());
	return 0;
    }
Ejemplo n.º 17
0
        /// <summary>
        ///     ctor
        /// </summary>
        public WebServerIisExpress(WebServerSettings settings, Dependencies dependencies)
        {
            if (TestEasyConfig.Instance.Client.Remote)
            {
                throw new NotSupportedException("For tests using remote browsers, IISExpress web server type is not supported, please use IIS.");
            }

            if (string.IsNullOrEmpty(settings.RootPhysicalPath) && !string.IsNullOrEmpty(settings.WebAppName))
            {
                settings.RootPhysicalPath = TestEasyHelpers.Tools.GetUniqueTempPath(settings.WebAppName);
            }

            _architecture = settings.Architecture;
            _fileSystem = dependencies.FileSystem;
            _environmentSystem = dependencies.EnvironmentSystem;
            _processRunner = dependencies.ProcessRunner;
            _serverManagerProvider = dependencies.ServerManagerProvider;

            _type = "IISExpress";
            _hostName = settings.HostName;
            _startupTimeout = settings.StartupTimeout;
            _rootPhysicalPath = string.IsNullOrEmpty(settings.RootPhysicalPath)
                ? Path.GetDirectoryName(_fileSystem.GetExecutingAssemblyDirectory())
                : settings.RootPhysicalPath;
            _httpPort = _environmentSystem.GetNextAvailablePort(0);
            _serverExecutablePath = LocateIisExpress(); // _version is initialized here
            _applicationHostConfigPath = CreateApplicationHostConfigFromTemplate();

            _configs = new Dictionary<string, string>
            {
                {
                    "applicationhost.config", _applicationHostConfigPath
                }
            };

            _iisExpressConfig = new IisExpressConfig(_applicationHostConfigPath, dependencies.FileSystem);
            
            InitializeApplicationHostConfig();

            Start();
        }
Ejemplo n.º 18
0
        public DHCPClient(Guid guid, string mac, SocketType type, IPEndPoint endpoint)
        {
            this.type = type;
            this.endp = endpoint;
            this.wdsclient = false;
            this.pollInterval = Convert.ToInt16(Settings.PollInterval);
            this.retrycount = Convert.ToInt16(Settings.RetryCount);

            this.actionDone = false;
            this.guid = guid;
            this.mac = mac;
            this.id = string.Format("{0}-{1}", this.guid, this.mac);
            this.adminMessage = "Client ID: {0}".F(this.id);
            this.nextAction = NextActionOptionValues.Approval;
            this.msgType = DHCPMsgType.Offer;
            this.arch = Architecture.Intelx86PC;
            this.bootfile = string.Empty;

            this.undi_major = 2;
            this.undi_minor = 1;
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Determines whether an <paramref name="implementation"/> architecture (the current instance) can run on a <paramref name="system"/> architecture.
 /// </summary>
 public static bool IsCompatible(this Architecture implementation, Architecture system)
 {
     return implementation.OS.IsCompatible(system.OS) && implementation.Cpu.IsCompatible(system.Cpu);
 }
Ejemplo n.º 20
0
 public NativeLibraryAttribute(string path)
 {
     Architecture = BlackBerry.ApplicationDescriptor.Architecture.ALL;
     Path = path;
 }
Ejemplo n.º 21
0
 private void person_OnSpySuccess(Person person, Architecture architecture)
 {
     person.Scenario.GameScreen.PersonSpySuccess(person, architecture);
 }
Ejemplo n.º 22
0
 private void person_OnCapturedByArchitecture(Person person, Architecture architecture)
 {
     person.Scenario.GameScreen.PersonCapturedByArchitecture(person, architecture);
 }
Ejemplo n.º 23
0
        private bool UpdatePlatform(XmlDocument document, XPathNavigator navigator, List <string> sources, IDictionary <string, Architecture> sourcePlatforms, Architecture defaultArchitecture, out Architecture chosenPlatform)
        {
            // Get platform from sources
            var inferedPlatform = inferHelper.AutoDetectArchitecture(sources, sourcePlatforms, defaultArchitecture);

            // Get platform from runsettings
            bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform);

            // Update platform if required. For commandline scenario update happens in ArgumentProcessor.
            if (updatePlatform)
            {
                InferRunSettingsHelper.UpdateTargetPlatform(document, inferedPlatform.ToString(), overwrite: true);
                chosenPlatform = inferedPlatform;
            }

            return(updatePlatform);
        }
Ejemplo n.º 24
0
 public static IEnumerable<_Disasm> Disassemble(byte[] data, IntPtr address, Architecture architecture)
 {
     return BeaEngine.Disassemble(data, (UIntPtr)address.ToInt64(), architecture);
 }
        public override bool Run(BuildConfiguration config, Architecture arch)
        {
            // Means we didn't find git.
            var toolsPath = WorkingDirectory + Path.DirectorySeparatorChar + "tools";
            string portableGitDownloadUri = string.Empty;
            string portableGitSha256 = string.Empty;

            portableGitDownloadUri = @"https://github.com/basil00/Divert/releases/download/v1.2.0-rc/WinDivert-1.2.0-rc-MSVC.zip";
            portableGitSha256 = @"7A194D5066C4093A370E3EA474371A4CF9976D28763C253D9DDF312BC2B33715";

            var portableGitZipName = "WinDivert.zip";

            var fullZipPath = toolsPath + Path.DirectorySeparatorChar + portableGitZipName;

            bool zipAlreadyExists = File.Exists(fullZipPath);

            if (zipAlreadyExists)
            {
                WriteLineToConsole("Discovered previous download. Verifying integrity.");

                // Just let it revert to false if hash doesn't match. The file
                // would simply be overwritten.
                zipAlreadyExists = VerifyFileHash(HashAlgorithmName.SHA256, fullZipPath, portableGitSha256);

                if (!zipAlreadyExists)
                {
                    WriteLineToConsole("Integrity check failed. Attempting clean download.");
                }
                else
                {
                    WriteLineToConsole("Integrity check passed. Using cached download.");
                }
            }

            if (!zipAlreadyExists)
            {
                var downloadTask = DownloadFile(portableGitDownloadUri, toolsPath, null, portableGitZipName);
                downloadTask.Wait();

                if (!VerifyFileHash(HashAlgorithmName.SHA256, fullZipPath, portableGitSha256))
                {
                    throw new Exception("Downloaded file does not match expected hash.");
                }
            }

            // Before decompressing again, let's see if we can find an already
            // decompressed perl.exe.
            var decompressedPath = WorkingDirectory + Path.DirectorySeparatorChar + "deps" + Path.DirectorySeparatorChar + "windivert" + Path.DirectorySeparatorChar + "msvc";

            string[] existingGitPaths = new string[0];

            if (Directory.Exists(decompressedPath))
            {
                existingGitPaths = Directory.GetFiles(decompressedPath, "WinDivert.dll", SearchOption.AllDirectories);

                if (existingGitPaths.Length > 0)
                {
                    return true;
                }
            }

            // If we reached here, then we need to decompress.
            DecompressArchive(fullZipPath, decompressedPath);

            // Collapse the top directory which contains version 
            // info and rename the 64 bit folder from amd64 to x64.
            var amd64Path = Directory.GetDirectories(decompressedPath, "amd64", SearchOption.AllDirectories);

            if(amd64Path.Length != 1)
            {
                WriteLineToConsole("Failed to find WinDivert 64 bit library in extracted package.");
                return false;
            }

            var parentDir = Directory.GetParent(amd64Path[0]);

            var allDirs = Directory.GetDirectories(parentDir.FullName, "*.*", SearchOption.TopDirectoryOnly);

            foreach(var dir in allDirs)
            {
                var dirInfo = new DirectoryInfo(dir);
                if(dirInfo.Name.Equals("amd64", StringComparison.OrdinalIgnoreCase))
                {
                    Directory.Move(dir, decompressedPath + Path.DirectorySeparatorChar + "x64");
                }
                else
                {
                    Directory.Move(dir, decompressedPath + Path.DirectorySeparatorChar + dirInfo.Name);
                }
            }

            // Delete the now empty, version specific folder.
            Directory.Delete(parentDir.FullName, true);

            existingGitPaths = Directory.GetFiles(decompressedPath, "WinDivert.dll", SearchOption.AllDirectories);

            if (existingGitPaths.Length == 0)
            {
                WriteLineToConsole("Failed to find WinDivert library in extracted package.");
                return false;
            }

            return true;
        
        }        
 private void architecture_Onfashengzainan(Architecture architecture, int zainanID)
 {
     architecture.Scenario.GameScreen.Architecturefashengzainan(architecture, zainanID);
 }
 private void architecture_OnFacilityCompleted(Architecture architecture, Facility facility)
 {
     architecture.Scenario.GameScreen.ArchitectureFacilityCompleted(architecture, facility);
 }
 private void architecture_OnBeginRecentlyAttacked(Architecture architecture)
 {
     architecture.Scenario.GameScreen.ArchitectureBeginRecentlyAttacked(architecture);
 }
 public override void ApplyEffectKind(Architecture a, Event e)
 {
     a.IncreaseTechnology(increment);
 }
Ejemplo n.º 30
0
 public override bool CheckConditionKind(Architecture architecture)
 {
     return(Session.Current.Scenario.DaySince >= val);
 }
Ejemplo n.º 31
0
 public override BitSet CreateImplicitArgumentRegisters()
 {
     return(Architecture.CreateRegisterBitset());
 }
Ejemplo n.º 32
0
 private void person_OnSearchFinished(Person person, Architecture architecture, SearchResultPack resultPack)
 {
     person.Scenario.GameScreen.PersonSearchFinished(person, architecture, resultPack);
 }
 public ExecutedFacetAnnotationForControlMethods(MethodInfo method, Architecture.Facets.Where where, IFacetHolder holder)
     : base(holder) {
     methodToWhere[method] = where;
 }
 private void architecture_OnPopulationEscape(Architecture a, int quantity)
 {
     a.Scenario.GameScreen.ArchitecturePopulationEscape(a, quantity);
 }
Ejemplo n.º 35
0
 private void person_OnInstigateSuccess(Person person, Architecture architecture, int down)
 {
     person.Scenario.GameScreen.PersonInstigateSuccess(person, architecture, down);
 }
 private void architecture_OnReleaseCaptiveAfterOccupied(Architecture architecture, PersonList persons)
 {
     architecture.Scenario.GameScreen.ArchitectureReleaseCaptiveAfterOccupied(architecture, persons);
 }
Ejemplo n.º 37
0
 private void person_OnBeKilled(Person person, Architecture location)
 {
     person.Scenario.GameScreen.PersonBeKilled(person, location);
 }
 private void architecture_OnRewardPersons(Architecture architecture, GameObjectList personlist)
 {
     architecture.Scenario.GameScreen.ArchitectureRewardPersons(architecture, personlist);
 }
Ejemplo n.º 39
0
 public void AddDependency(string name, FourPartVersion version, Architecture arch, string publicKeyToken, string language = "*", AssemblyType assemblyType = AssemblyType.win32, BindingRedirect redirect = null)
 {
     Modified = true;
     _dependentAssemblies.AddDependency(name, version, arch, publicKeyToken, language, assemblyType, redirect);
 }
Ejemplo n.º 40
0
 extern static bool CFBundleIsArchitectureLoadable(/*cpu_type_t => integer_t => int*/ Architecture architecture);
Ejemplo n.º 41
0
        public void RemoveDependency(string name, FourPartVersion version, Architecture arch, string publicKeyToken, string language = "*")
        {
            var deleteThis = (from dat in DependentAssemblyElements
                let assemblyIdentity = new AssemblyIdentity(dat)
                where
                    assemblyIdentity.Name == name &&
                        assemblyIdentity.Version == version &&
                            assemblyIdentity.Architecture == arch &&
                                assemblyIdentity.PublicKeyToken == publicKeyToken &&
                                    ((language == "*" && string.IsNullOrEmpty(assemblyIdentity.Language)) || assemblyIdentity.Language == language)
                select dat).FirstOrDefault();

            if (deleteThis != null) {
                deleteThis.Parent.Remove();
            }
        }
Ejemplo n.º 42
0
 public static bool IsArchitectureLoadable(Architecture architecture) => CFBundleIsArchitectureLoadable(architecture);
Ejemplo n.º 43
0
 public NativeLibraryAttribute(Architecture arch, string path)
 {
     Architecture = arch;
     Path = path;
 }
 public override void PurifyInfluenceKind(Architecture architecture)
 {
     architecture.RateIncrementOfMonthFood -= this.rate;
 }
Ejemplo n.º 45
0
        public Machine(Architecture architecture, Logger logger, Kernel kernel,
            int rows, int columns, int memory)
        {
            if (architecture != Architecture.EpiphanyIII &&
                architecture != Architecture.EpiphanyIV)
                throw new ArgumentException(
                    "Invalid Architecture value ({0}).".Interpolate(architecture),
                    "architecture");

            if (logger == null)
                throw new ArgumentNullException("logger");

            if (kernel == null)
                throw new ArgumentNullException("kernel");

            if (rows < MinRows || rows > MaxRows)
                throw new ArgumentOutOfRangeException("rows", rows,
                    "Row count is out of range.");

            if (columns < MinColumns || columns > MaxColumns)
                throw new ArgumentOutOfRangeException("columns", columns,
                    "Column count is out of range.");

            if (new CoreId(rows - 1, columns - 1).ToAddress() >= Memory.ExternalBaseAddress)
                throw new ArgumentException("The given row and column counts would result " +
                    "in a grid that overlaps external memory.");

            if (memory < Memory.MinMemorySize || memory > Memory.MaxMemorySize)
                throw new ArgumentOutOfRangeException("memory", memory,
                    "External memory size is out of range.");

            Architecture = architecture;
            Logger = logger;
            Kernel = kernel;
            Memory = new Memory(this, memory);
            Fetcher = new Fetcher(this);
            Rows = rows;
            Columns = columns;

            var cores = new List<Core>(rows * columns);
            var grid = new List<List<Core>>(rows);

            for (var i = 0; i < rows; i++)
            {
                var row = new List<Core>(columns);

                for (var j = 0; j < columns; j++)
                {
                    // A core can't have row 0 and column 0 since routing
                    // anything to it would be impossible; addresses with
                    // the upper 12 bits all zero are mapped to the local
                    // core memory.
                    if (i == 0 && j == 0)
                        break;

                    row.Add(new Core(this, new CoreId(i, j)));
                }

                cores.AddRange(row);

                // See comment above. We don't want a `null` entry in the
                // `Cores` list, so insert it here.
                if (i == 0)
                    row.Insert(0, null);

                grid.Add(row);
            }

            Cores = cores;
            Grid = grid;
            SleepDuration = TimeSpan.FromMilliseconds(50);
            IdleDuration = TimeSpan.FromMilliseconds(10);
        }
Ejemplo n.º 46
0
        public override bool Run(BuildConfiguration config, Architecture arch)
        {
            // Clear errors before trying.
            Errors.Clear();

            if (!SupportedArchitectures.HasFlag(arch))
            {
                Errors.Add(new Exception("Unsupported architecture specified for build task."));
                return(false);
            }

            if (!ConfigureDirectories())
            {
                Errors.Add(new Exception("Failed to configure arch specific directories for openSSL build."));
                return(false);
            }

            // We need to get the environment for a the MSVC compiler and
            // associated build tools.
            var installedMsvcVersions = MSVCCompilerTask.InstalledToolVersions;

            if (installedMsvcVersions.Count == 0)
            {
                Errors.Add(new Exception("Could not detect a compatible installation of MSVC."));
                return(false);
            }

            // Get a reversed list of tool versions and iterate over them, until we find
            // an installed version. This way we're always working with the latest
            // version available.
            var allVersions = Enum.GetValues(typeof(ToolVersions)).Cast <ToolVersions>().Reverse();

            ToolVersions versionToUse = ToolVersions.v11;

            foreach (var msvcVersion in allVersions)
            {
                if (installedMsvcVersions.ContainsKey(msvcVersion))
                {
                    versionToUse = msvcVersion;
                    WriteLineToConsole(string.Format("Discovered and using MSVC {0} for compilation.", versionToUse.ToString()));
                    break;
                }
            }

            // Build out the base path to the openSSL source directory.
            StringBuilder opensslBasePath = new StringBuilder(WorkingDirectory);

            opensslBasePath.Append(Path.DirectorySeparatorChar);
            opensslBasePath.Append("deps");
            opensslBasePath.Append(Path.DirectorySeparatorChar);
            opensslBasePath.Append("openssl");

            int numCompilationAttempts    = 0;
            int numSuccessfulCompilations = 0;

            // We're only going to iterate over arches. We're not going to build a debug
            // version of openSSL, just release versions for each arch.
            foreach (Architecture a in Enum.GetValues(typeof(Architecture)))
            {
                if (arch.HasFlag(a))
                {
                    ++numCompilationAttempts;

                    var finalBuildEnvironment = MSVCCompilerTask.GetEnvironmentForVersion(versionToUse, a);

                    // Add perl path if it doesn't already exist.
                    if (finalBuildEnvironment["PATH"].IndexOf(m_perlDir) == -1)
                    {
                        finalBuildEnvironment["PATH"] += (Path.PathSeparator + m_perlDir);
                    }

                    var configArgs = new List <string>();

                    configArgs.Add("no-idea");
                    configArgs.Add("no-mdc2");
                    configArgs.Add("no-rc5");
                    configArgs.Add("no-comp");

                    // XXX TODO - Remove this option when upgrading to openSSL 1.1.0
                    configArgs.Add("no-ssl2");

                    configArgs.Add("no-ssl3");
                    configArgs.Add("no-weak-ssl-ciphers");
                    configArgs.Add("threads");

                    // The working dir. This will either be the x86 or x64 openSSL source dir.
                    string workingDirectory = string.Empty;

                    // We need to include nasm regardless of rater arch because
                    // the openSSL configuration system will whine and quit if
                    // we don't. We should be guaranteed to have a PATH variable
                    // here unless something went horribly wrong.
                    finalBuildEnvironment["PATH"] += (Path.PathSeparator + m_nasmDir);

                    // XXX TODO - This needs to go away when we bump to OpenSSL 1.1.0
                    string whichAsmCall = string.Empty;

                    string openSslInstallDir = string.Empty;

                    switch (a)
                    {
                    case Architecture.x86:
                    {
                        // Build inside the x86 dir
                        workingDirectory = m_openSslx86Dir;

                        // Set x86 release build.
                        configArgs.Insert(0, "VC-WIN32");

                        whichAsmCall = "ms" + Path.DirectorySeparatorChar + "do_nasm.bat";

                        openSslInstallDir = opensslBasePath.ToString().ConvertToHostOsPath() +
                                            Path.DirectorySeparatorChar +
                                            "msvc" +
                                            Path.DirectorySeparatorChar +
                                            "Releasex86";
                    }
                    break;

                    case Architecture.x64:
                    {
                        // Build inside the x64 dir
                        workingDirectory = m_openSslx64Dir;

                        whichAsmCall = "ms" + Path.DirectorySeparatorChar + "do_win64a.bat";

                        // Set x64 release build.
                        configArgs.Insert(0, "VC-WIN64A");

                        openSslInstallDir = opensslBasePath.ToString().ConvertToHostOsPath() +
                                            Path.DirectorySeparatorChar +
                                            "msvc" +
                                            Path.DirectorySeparatorChar +
                                            "Releasex64";
                    }
                    break;

                    default:
                    {
                        WriteLineToConsole(string.Format("Dont have arch: {0}", a.ToString()));
                        continue;
                    }
                    }

                    // Setup prefix (output) path to deps/openssl/msvc/ReleaseX64
                    configArgs.Add(
                        string.Format(
                            "--prefix={0}",
                            openSslInstallDir)
                        );

                    // Setup config path to deps/openssl/msvc/ReleaseX86
                    configArgs.Add(
                        string.Format(
                            "--openssldir={0}",
                            openSslInstallDir)
                        );


                    WriteLineToConsole(string.Format("Configuring for arch: {0}", a.ToString()));

                    WriteLineToConsole(workingDirectory);

                    WriteLineToConsole(string.Format("Config Path: {0}", workingDirectory + Path.DirectorySeparatorChar + "Configure"));

                    // Push configure script to front of args.
                    configArgs.Insert(0, "Configure");

                    WriteLineToConsole(string.Join(" ", configArgs));

                    // Run the configuration process.
                    var perlExitCode = RunProcess(workingDirectory, m_perlDir + Path.DirectorySeparatorChar + "perl.exe", configArgs, Timeout.Infinite, finalBuildEnvironment);

                    // Now run the actual build process.

                    // Example of the call string expanded/populated:
                    // call "ms\do_nasm.bat" && nmake -f ms\ntdll.mak && nmake -f ms\ntdll.mak install

                    string callArgs = string.Format("/C \"{0}\" && {1} && {2}", whichAsmCall, "nmake -f ms" + Path.DirectorySeparatorChar + "ntdll.mak", "nmake -f ms" + Path.DirectorySeparatorChar + "ntdll.mak install");

                    // XXX TODO - This is way to do it when we jump up to OpenSSL 1.1.0
                    //string callArgs = string.Format("/C {0} && {1}", "nmake", "nmake install");

                    // Running cmd.exe with these batch commands will build openSSL.
                    var buildExitCode = RunProcess(workingDirectory, "cmd.exe", new List <string> {
                        callArgs
                    }, Timeout.Infinite, finalBuildEnvironment);

                    if (perlExitCode == 0 && buildExitCode == 0)
                    {
                        // Was a success. Move the output folder now.
                        var destBaseDir = opensslBasePath.ToString().ConvertToHostOsPath() +
                                          Path.DirectorySeparatorChar +
                                          "msvc" +
                                          Path.DirectorySeparatorChar;

                        var destReleaseDir = destBaseDir + string.Format("{0} {1}", BuildConfiguration.Release.ToString(), a.ToString());
                        var destDebugDir   = destBaseDir + string.Format("{0} {1}", BuildConfiguration.Debug.ToString(), a.ToString());

                        // If we don't delete old stuff, Directory.Move will fail.
                        if (Directory.Exists(destReleaseDir))
                        {
                            Directory.Delete(destReleaseDir, true);
                        }

                        // Move aka rename the directory to have a space.
                        try
                        {
                            Directory.Move(openSslInstallDir, destReleaseDir);
                        }
                        catch
                        {
                            // Sometimes getting access denied. Perhaps parts of the build
                            // process are still hanging. Try and give them a few seconds
                            // to wrap up, then try again.
                            Thread.Sleep(3000);

                            Directory.Move(openSslInstallDir, destReleaseDir);
                        }

                        // Simply copy the release folder for arch to a debug folder.
                        CopyDirectory(destReleaseDir, destDebugDir, true);

                        ++numSuccessfulCompilations;
                    }
                }
            }

            var wasSuccess = numCompilationAttempts > 0 && numCompilationAttempts == numSuccessfulCompilations;

            return(wasSuccess);
        }
Ejemplo n.º 47
0
 private void person_OnSpyFailed(Person person, Architecture architecture)
 {
     person.Scenario.GameScreen.PersonSpyFailed(person, architecture);
 }
Ejemplo n.º 48
0
 public override bool CheckConditionKind(Architecture a)
 {
     return(a.Mayor != null);
 }
Ejemplo n.º 49
0
 private void te_OnApplyEvent(Event te, Architecture a)
 {
     te.Scenario.GameScreen.ApplyEvent(te, a);
 }
Ejemplo n.º 50
0
 public override double AIFacilityValue(Architecture a)
 {
     return(this.increment);
 }
 public override void AddMethodExecutedWhere(MethodInfo method, Architecture.Facets.Where where) {
     methodToWhere[method] = where;
 }
Ejemplo n.º 52
0
 internal void SetArchitecture(Architecture architecture)
 {
     this.CreatingArchitecture = architecture;
 }
Ejemplo n.º 53
0
 private void person_OnLeave(Person person, Architecture location)
 {
     person.Scenario.GameScreen.PersonLeave(person, location);
 }
Ejemplo n.º 54
0
        public static IEnumerable <FileInfo> NativePluginInterceptor(FileInfo from, FileInfo to,
                                                                     DirectoryInfo nativePluginFolder, bool isFlat, Architecture preferredArchitecture)
        {
            if (to.FullName.StartsWith(nativePluginFolder.FullName))
            {
                var relevantBit = to.FullName.Substring(nativePluginFolder.FullName.Length + 1);
                // Goes into the plugin folder!
                bool isFileFlat = !relevantBit.StartsWith("x86");
                if (isFlat && !isFileFlat)
                {
                    // Flatten structure
                    bool is64Bit = relevantBit.StartsWith("x86_64");
                    if (!is64Bit && preferredArchitecture == Architecture.x86)
                    {
                        // 32 bit
                        yield return(new FileInfo(Path.Combine(nativePluginFolder.FullName,
                                                               relevantBit.Substring("x86".Length + 1))));
                    }
                    else if (is64Bit && (preferredArchitecture == Architecture.x64 ||
                                         preferredArchitecture == Architecture.Unknown))
                    {
                        // 64 bit
                        yield return(new FileInfo(Path.Combine(nativePluginFolder.FullName,
                                                               relevantBit.Substring("x86_64".Length + 1))));
                    }
                }
                else if (!isFlat && isFileFlat)
                {
                    // Deepen structure
                    yield return(new FileInfo(Path.Combine(Path.Combine(nativePluginFolder.FullName, "x86"),
                                                           relevantBit)));

                    yield return(new FileInfo(Path.Combine(Path.Combine(nativePluginFolder.FullName, "x86_64"),
                                                           relevantBit)));
                }
                else
                {
                    yield return(to);
                }
            }
            else
            {
                yield return(to);
            }
        }
Ejemplo n.º 55
0
 private void person_OnDeath(Person person, Architecture location)
 {
     location.Scenario.GameScreen.PersonDeath(person, location);
 }
 public override void PurifyInfluenceKind(Architecture architecture)
 {
     architecture.RateIncrementOfPopulationDevelop -= this.rate;
 }
Ejemplo n.º 57
0
        public static IEnumerable<_Disasm> Disassemble(byte[] data, UIntPtr address, Architecture architecture)
        {
            GCHandle h = GCHandle.Alloc(data, GCHandleType.Pinned);
            UInt64 EndCodeSection = (UInt64)h.AddrOfPinnedObject().ToInt64() + (ulong)data.Length;

            _Disasm d = new _Disasm();
            d.InstructionPointer = (UIntPtr)h.AddrOfPinnedObject().ToInt64();
            d.VirtualAddr = address.ToUInt64();
            d.Architecture = architecture;
            bool error = false;
            while (!error)
            {
                d.SecurityBlock = (uint)(EndCodeSection - d.InstructionPointer.ToUInt64());

                d.Length = BeaEngine.Disassemble(ref d);
                if (d.Length == BeaEngine.OutOfBlock)
                {
                    Console.WriteLine("disasm engine is not allowed to read more memory.");
                    error = true;
                }
                else if (d.Length == BeaEngine.UnknownOpcode)
                {
                    _Disasm yieldedInst = d;
                    d.InstructionPointer = d.InstructionPointer + 1;
                    d.VirtualAddr = d.VirtualAddr + 1;
                    yield return yieldedInst;
                }
                else
                {
                    _Disasm yieldedInst = d;
                    d.InstructionPointer = d.InstructionPointer + d.Length;
                    d.VirtualAddr = d.VirtualAddr + (ulong)d.Length;
                    if (d.InstructionPointer.ToUInt64() >= EndCodeSection)
                    {
                        error = true;
                    }

                    yield return yieldedInst;
                }
            }

            yield break;
        }
Ejemplo n.º 58
0
 void person_OnJailBreakFailed(Person source, Architecture destination)
 {
     source.Scenario.GameScreen.PersonJailBreakFailed(source, destination);
 }
Ejemplo n.º 59
0
 public override bool CheckConditionKind(Architecture architecture)
 {
     return(Session.Current.Scenario.Troops.Count >= val);
 }
 public override double AIFacilityValue(Architecture a)
 {
     return((1 - Math.Pow((double)a.Food / a.FoodCeiling, 0.5) + (a.IsFoodEnough ? 0 : 0.5) + (a.IsFoodAbundant ? 0 : 0.5) + (a.IsFoodIncomeEnough ? 0 : 1000))
            * (a.ExpectedFood * this.rate / 20000.0));
 }