Example #1
0
		public static Characteristics GetCharacteristics(Characteristics characteristics, ModuleKind moduleKind) {
			if (moduleKind == ModuleKind.Dll || moduleKind == ModuleKind.NetModule)
				characteristics |= Characteristics.Dll;
			else
				characteristics &= ~Characteristics.Dll;
			return characteristics;
		}
Example #2
0
 public static AssemblyDef AddToNewAssemblyDef(ModuleDef module, ModuleKind moduleKind, out Characteristics characteristics)
 {
     var asmDef = module.UpdateRowId(new AssemblyDefUser(GetAssemblyName(module)));
     asmDef.Modules.Add(module);
     WriteNewModuleKind(module, moduleKind, out characteristics);
     return asmDef;
 }
	void Start () {
		c = GetComponent<Controller> ();
		sr = GetComponent<SpriteRenderer> ();
		sg = GameObject.Find("MapGenerator").GetComponent<SquareGenerator> ();
		velocity = new Vector3 ();
		direction = new Vector2 ();
		stats = new Characteristics ();
	}
Example #4
0
 public Effect(Characteristics target, float amount, EffectTypes type, int duration, DurationTypes durType)
 {
     Target = target;
     Amount = amount;
     Type = type;
     Duration = duration;
     DurType = durType;
 }
Example #5
0
	void Start () {
		stats = new Characteristics();
		sr = GetComponent<SpriteRenderer> ();
		sg = GameObject.Find ("MapGenerator").GetComponent<SquareGenerator>();
		controller = GetComponent<Controller> ();
		gravity = -(2 * stats.jumpHeight) / Mathf.Pow (stats.timeToJumpApex, 2);
		targetDirection = (int)UnityEngine.Random.Range(0, 1) == 0 ? 1 : -1;
		jumpVelocity = Mathf.Abs (gravity) * stats.timeToJumpApex;
	}
Example #6
0
		public static Characteristics GetCharacteristics(Characteristics characteristics, Machine machine) {
			if (machine == Machine.IA64 || machine == Machine.AMD64 || machine == Machine.ARM64) {
				characteristics &= ~Characteristics._32BitMachine;
				characteristics |= Characteristics.LargeAddressAware;
			}
			else
				characteristics |= Characteristics._32BitMachine;
			return characteristics;
		}
Example #7
0
 internal CoffHeader(ref PEBinaryReader reader)
 {
     Machine = (Machine)reader.ReadUInt16();
     NumberOfSections = reader.ReadInt16();
     TimeDateStamp = reader.ReadInt32();
     PointerToSymbolTable = reader.ReadInt32();
     NumberOfSymbols = reader.ReadInt32();
     SizeOfOptionalHeader = reader.ReadInt16();
     Characteristics = (Characteristics)reader.ReadUInt16();
 }
Example #8
0
        public Context(bool isMock = false)
        {
            Abilities = new Abilities();
            Actions = new Actions();
            Characteristics = new Characteristics();
            Models = new Models();
            Spells = new Spells();
            Triggers = new Triggers();
            Weapons = new Weapons();

            LoadData(isMock);
        }
Example #9
0
	void Start () 
	{
		stats = new Characteristics ();
		controller = GetComponent<Controller> ();
		animator = GetComponentInChildren<Animator> ();
		gravity = -(2 * stats.jumpHeight) / Mathf.Pow (stats.timeToJumpApex, 2);
		jumpVelocity = Mathf.Abs (gravity) * stats.timeToJumpApex;

		foreach (Transform child in transform)
		{
			childTransform = child;
		}
	}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="reader">PE file reader pointing to the start of this section</param>
		/// <param name="verify">Verify section</param>
		/// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
		public ImageFileHeader(IImageStream reader, bool verify) {
			SetStartOffset(reader);
			this.machine = (Machine)reader.ReadUInt16();
			this.numberOfSections = reader.ReadUInt16();
			this.timeDateStamp = reader.ReadUInt32();
			this.pointerToSymbolTable = reader.ReadUInt32();
			this.numberOfSymbols = reader.ReadUInt32();
			this.sizeOfOptionalHeader = reader.ReadUInt16();
			this.characteristics = (Characteristics)reader.ReadUInt16();
			SetEndoffset(reader);
			if (verify && this.sizeOfOptionalHeader == 0)
				throw new BadImageFormatException("Invalid SizeOfOptionalHeader");
		}
Example #11
0
        /// <summary>
        /// Creates PE header builder.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="fileAlignment"/> is not power of 2 between 512 and 64K, or
        /// <paramref name="sectionAlignment"/> not power of 2 or it's less than <paramref name="fileAlignment"/>.
        /// </exception>
        public PEHeaderBuilder(
            Machine machine = 0,
            int sectionAlignment = 0x2000,
            int fileAlignment = 0x200,
            ulong imageBase = 0x00400000,
            byte majorLinkerVersion = 0x30, // (what is ref.emit using?)
            byte minorLinkerVersion = 0,
            ushort majorOperatingSystemVersion = 4,
            ushort minorOperatingSystemVersion = 0,
            ushort majorImageVersion = 0,
            ushort minorImageVersion = 0,
            ushort majorSubsystemVersion = 4,
            ushort minorSubsystemVersion = 0,
            Subsystem subsystem = Subsystem.WindowsCui,
            DllCharacteristics dllCharacteristics = DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware,
            Characteristics imageCharacteristics = Characteristics.Dll,
            ulong sizeOfStackReserve = 0x00100000,
            ulong sizeOfStackCommit = 0x1000,
            ulong sizeOfHeapReserve = 0x00100000,
            ulong sizeOfHeapCommit = 0x1000)
        {
            if (fileAlignment < 512 || fileAlignment > 64 * 1024 || BitArithmetic.CountBits(fileAlignment) != 1)
            {
                Throw.ArgumentOutOfRange(nameof(fileAlignment));
            }

            if (sectionAlignment < fileAlignment || BitArithmetic.CountBits(sectionAlignment) != 1)
            {
                Throw.ArgumentOutOfRange(nameof(sectionAlignment));
            }

            Machine = machine;
            SectionAlignment = sectionAlignment;
            FileAlignment = fileAlignment;
            ImageBase = imageBase;
            MajorLinkerVersion = majorLinkerVersion;
            MinorLinkerVersion = minorLinkerVersion;
            MajorOperatingSystemVersion = majorOperatingSystemVersion;
            MinorOperatingSystemVersion = minorOperatingSystemVersion;
            MajorImageVersion = majorImageVersion;
            MinorImageVersion = minorImageVersion;
            MajorSubsystemVersion = majorSubsystemVersion;
            MinorSubsystemVersion = minorSubsystemVersion;
            Subsystem = subsystem;
            DllCharacteristics = dllCharacteristics;
            ImageCharacteristics = imageCharacteristics;
            SizeOfStackReserve = sizeOfStackReserve;
            SizeOfStackCommit = sizeOfStackCommit;
            SizeOfHeapReserve = sizeOfHeapReserve;
            SizeOfHeapCommit = sizeOfHeapCommit;
        }
Example #12
0
		public ModuleOptions(ModuleDef module) {
			Mvid = module.Mvid;
			EncId = module.EncId;
			EncBaseId = module.EncBaseId;
			Name = module.Name;
			Kind = module.Kind;
			Characteristics = module.Characteristics;
			DllCharacteristics = module.DllCharacteristics;
			RuntimeVersion = module.RuntimeVersion;
			Machine = module.Machine;
			Cor20HeaderFlags = module.Cor20HeaderFlags;
			Cor20HeaderRuntimeVersion = module.Cor20HeaderRuntimeVersion;
			TablesHeaderVersion = module.TablesHeaderVersion;
			ManagedEntryPoint = module.ManagedEntryPoint;
			NativeEntryPoint = module.NativeEntryPoint;
			CustomAttributes.AddRange(module.CustomAttributes);
		}
 public CoffHeader(
     Machine machine,
     short numberOfSections,
     int timeDateStamp,
     int pointerToSymbolTable,
     int numberOfSymbols,
     short sizeOfOptionalHeader,
     Characteristics characteristics)
 {
     Machine = machine;
     NumberOfSections = numberOfSections;
     TimeDateStamp = timeDateStamp;
     PointerToSymbolTable = pointerToSymbolTable;
     NumberOfSymbols = numberOfSymbols;
     SizeOfOptionalHeader = sizeOfOptionalHeader;
     Characteristics = characteristics;
 }
Example #14
0
 public ManagedTextSection(
     Characteristics imageCharacteristics,
     Machine machine,
     int ilStreamSize,
     int metadataSize,
     int resourceDataSize,
     int strongNameSignatureSize,
     int debugDataSize,
     int mappedFieldDataSize)
 {
     MetadataSize = metadataSize;
     ResourceDataSize = resourceDataSize;
     ILStreamSize = ilStreamSize;
     MappedFieldDataSize = mappedFieldDataSize;
     StrongNameSignatureSize = strongNameSignatureSize;
     ImageCharacteristics = imageCharacteristics;
     Machine = machine;
     DebugDataSize = debugDataSize;
 }
Example #15
0
 public PEHeaderBuilder(
     Machine machine = 0,
     int sectionAlignment = 0x2000,
     int fileAlignment = 0x200,
     ulong imageBase = 0x00400000,
     byte majorLinkerVersion = 0x30, // (what is ref.emit using?)
     byte minorLinkerVersion = 0,
     ushort majorOperatingSystemVersion = 4,
     ushort minorOperatingSystemVersion = 0,
     ushort majorImageVersion = 0,
     ushort minorImageVersion = 0,
     ushort majorSubsystemVersion = 4,
     ushort minorSubsystemVersion = 0,
     Subsystem subsystem = Subsystem.WindowsCui,
     DllCharacteristics dllCharacteristics = DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware,
     Characteristics imageCharacteristics = Characteristics.Dll,
     ulong sizeOfStackReserve = 0x00100000,
     ulong sizeOfStackCommit = 0x1000,
     ulong sizeOfHeapReserve = 0x00100000,
     ulong sizeOfHeapCommit = 0x1000)
 {
     Machine = machine;
     SectionAlignment = sectionAlignment;
     FileAlignment = fileAlignment;
     ImageBase = imageBase;
     MajorLinkerVersion = majorLinkerVersion;
     MinorLinkerVersion = minorLinkerVersion;
     MajorOperatingSystemVersion = majorOperatingSystemVersion;
     MinorOperatingSystemVersion = minorOperatingSystemVersion;
     MajorImageVersion = majorImageVersion;
     MinorImageVersion = minorImageVersion;
     MajorSubsystemVersion = majorSubsystemVersion;
     MinorSubsystemVersion = minorSubsystemVersion;
     Subsystem = subsystem;
     DllCharacteristics = dllCharacteristics;
     ImageCharacteristics = imageCharacteristics;
     SizeOfStackReserve = sizeOfStackReserve;
     SizeOfStackCommit = sizeOfStackCommit;
     SizeOfHeapReserve = sizeOfHeapReserve;
     SizeOfHeapCommit = sizeOfHeapCommit;
 }
Example #16
0
 public ManagedTextSection(
     int metadataSize,
     int ilStreamSize,
     int mappedFieldDataSize,
     int resourceDataSize,
     int strongNameSignatureSize,
     Characteristics imageCharacteristics,
     Machine machine, 
     string pdbPathOpt,
     bool isDeterministic)
 {
     MetadataSize = metadataSize;
     ResourceDataSize = resourceDataSize;
     ILStreamSize = ilStreamSize;
     MappedFieldDataSize = mappedFieldDataSize;
     StrongNameSignatureSize = strongNameSignatureSize;
     ImageCharacteristics = imageCharacteristics;
     Machine = machine;
     PdbPathOpt = pdbPathOpt;
     IsDeterministic = isDeterministic;
 }
Example #17
0
        /// <summary>
        /// Fill in PE header information into a PEHeaderBuilder used by PEBuilder.
        /// </summary>
        /// <param name="relocsStripped">Relocs are not present in the PE executable</param>
        /// <param name="dllCharacteristics">Extra DLL characteristics to apply</param>
        /// <param name="subsystem">Targeting subsystem</param>
        /// <param name="target">Target architecture to set in the header</param>
        public static PEHeaderBuilder Create(Characteristics imageCharacteristics, DllCharacteristics dllCharacteristics, Subsystem subsystem, TargetDetails target)
        {
            bool is64BitTarget = target.PointerSize == sizeof(long);

            imageCharacteristics &= ~(Characteristics.Bit32Machine | Characteristics.LargeAddressAware);
            imageCharacteristics |= (is64BitTarget ? Characteristics.LargeAddressAware : Characteristics.Bit32Machine);

            ulong imageBase = PE32HeaderConstants.ImageBase;

            if (target.IsWindows && is64BitTarget && (imageBase <= uint.MaxValue))
            {
                // Base addresses below 4 GiB are reserved for WoW on x64 and disallowed on ARM64.
                // If the input assembly was compiled for anycpu, its base address is 32-bit and we need to fix it.
                imageBase = (imageCharacteristics & Characteristics.Dll) != 0 ? PE64HeaderConstants.DllImageBase : PE64HeaderConstants.ExeImageBase;
            }

            int fileAlignment = 0x200;

            if (!target.IsWindows && !is64BitTarget)
            {
                // To minimize wasted VA space on 32 bit systems align file to page bounaries (presumed to be 4K).
                fileAlignment = 0x1000;
            }

            int sectionAlignment = 0x1000;

            if (!target.IsWindows && is64BitTarget)
            {
                // On Linux, we must match the bottom 12 bits of section RVA's to their file offsets. For this reason
                // we need the same alignment for both.
                sectionAlignment = fileAlignment;
            }

            dllCharacteristics &= DllCharacteristics.AppContainer;

            // In Crossgen1, this is under a debug-specific condition 'if (0 == CLRConfig::GetConfigValue(CLRConfig::INTERNAL_NoASLRForNgen))'
            dllCharacteristics |= DllCharacteristics.DynamicBase;

            // Without NxCompatible the PE executable cannot execute on Windows ARM64
            dllCharacteristics |= DllCharacteristics.NxCompatible | DllCharacteristics.TerminalServerAware;

            if (is64BitTarget)
            {
                dllCharacteristics |= DllCharacteristics.HighEntropyVirtualAddressSpace;
            }
            else
            {
                dllCharacteristics |= DllCharacteristics.NoSeh;
            }

            return(new PEHeaderBuilder(
                       machine: target.MachineFromTarget(),
                       sectionAlignment: sectionAlignment,
                       fileAlignment: fileAlignment,
                       imageBase: imageBase,
                       majorLinkerVersion: PEHeaderConstants.MajorLinkerVersion,
                       minorLinkerVersion: PEHeaderConstants.MinorLinkerVersion,
                       majorOperatingSystemVersion: PEHeaderConstants.MajorOperatingSystemVersion,
                       minorOperatingSystemVersion: PEHeaderConstants.MinorOperatingSystemVersion,
                       majorImageVersion: PEHeaderConstants.MajorImageVersion,
                       minorImageVersion: PEHeaderConstants.MinorImageVersion,
                       majorSubsystemVersion: PEHeaderConstants.MajorSubsystemVersion,
                       minorSubsystemVersion: PEHeaderConstants.MinorSubsystemVersion,
                       subsystem: subsystem,
                       dllCharacteristics: dllCharacteristics,
                       imageCharacteristics: imageCharacteristics,
                       sizeOfStackReserve: (is64BitTarget ? PE64HeaderConstants.SizeOfStackReserve : PE32HeaderConstants.SizeOfStackReserve),
                       sizeOfStackCommit: (is64BitTarget ? PE64HeaderConstants.SizeOfStackCommit : PE32HeaderConstants.SizeOfStackCommit),
                       sizeOfHeapReserve: (is64BitTarget ? PE64HeaderConstants.SizeOfHeapReserve : PE32HeaderConstants.SizeOfHeapReserve),
                       sizeOfHeapCommit: (is64BitTarget ? PE64HeaderConstants.SizeOfHeapCommit : PE32HeaderConstants.SizeOfHeapCommit)));
        }
Example #18
0
 public void GivenThetestObjects(Characteristics characteristics, Dictionary <string, TestObject> testObjects)
 => GivenThetestObjects(null, characteristics, testObjects);
Example #19
0
		public static void WriteNewModuleKind(ModuleDef module, ModuleKind moduleKind, out Characteristics characteristics) {
			module.Kind = moduleKind;
			characteristics = module.Characteristics;
			module.Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(module.Characteristics, moduleKind);
		}
Example #20
0
 void Awake()
 {
     if (_instance == null) _instance = this;
     else { DestroyImmediate(this); return; }
 }
Example #21
0
 protected override int Efficiency()
 {
     return(Characteristics.CalculateEfficiency(LeaderCharacteristics, JobsEn.Shaman, 0.1, 0.1, 0.7, 0.1));
 }
 public const ushort DefaultFileAlignment64Bit = 0x00000200; //both 32 and 64 bit binaries used this value in the native stack.
 
 internal ModulePropertiesForSerialization(
     Guid persistentIdentifier,
     ushort fileAlignment,
     string targetRuntimeVersion,
     Machine machine,
     bool prefer32Bit,
     bool trackDebugData,
     ulong baseAddress,
     ulong sizeOfHeapReserve,
     ulong sizeOfHeapCommit,
     ulong sizeOfStackReserve,
     ulong sizeOfStackCommit,
     bool enableHighEntropyVA,
     bool strongNameSigned,
     bool configureToExecuteInAppContainer,
     Characteristics imageCharacteristics,
     Subsystem subsystem,
     ushort majorSubsystemVersion,
     ushort minorSubsystemVersion,
     byte linkerMajorVersion,
     byte linkerMinorVersion)
 {
     this.PersistentIdentifier = persistentIdentifier;
     this.FileAlignment = fileAlignment;
     this.TargetRuntimeVersion = targetRuntimeVersion;
     this.Machine = machine;
     this.Prefers32Bit = prefer32Bit;
     this.TrackDebugData = trackDebugData;
     this.BaseAddress = baseAddress;
     this.SizeOfHeapReserve = sizeOfHeapReserve;
     this.SizeOfHeapCommit = sizeOfHeapCommit;
     this.SizeOfStackReserve = sizeOfStackReserve;
     this.SizeOfStackCommit = sizeOfStackCommit;
     this.StrongNameSigned = strongNameSigned;
     this.LinkerMajorVersion = linkerMajorVersion;
     this.LinkerMinorVersion = linkerMinorVersion;
     this.MajorSubsystemVersion = majorSubsystemVersion;
     this.MinorSubsystemVersion = minorSubsystemVersion;
     this.ImageCharacteristics = imageCharacteristics;
     this.Subsystem = subsystem;
     this.DllCharacteristics = GetDllCharacteristics(enableHighEntropyVA, configureToExecuteInAppContainer);
 }
        internal ModulePropertiesForSerialization(
            Guid persistentIdentifier,
            CorFlags corFlags,
            int fileAlignment,
            int sectionAlignment,
            string targetRuntimeVersion,
            Machine machine,
            ulong baseAddress,
            ulong sizeOfHeapReserve,
            ulong sizeOfHeapCommit,
            ulong sizeOfStackReserve,
            ulong sizeOfStackCommit,
            DllCharacteristics dllCharacteristics,
            Characteristics imageCharacteristics,
            Subsystem subsystem,
            ushort majorSubsystemVersion,
            ushort minorSubsystemVersion,
            byte linkerMajorVersion,
            byte linkerMinorVersion)
        {
            this.PersistentIdentifier = persistentIdentifier;
            this.FileAlignment = fileAlignment;
            this.SectionAlignment = sectionAlignment;
            this.TargetRuntimeVersion = targetRuntimeVersion;
            this.Machine = machine;
            this.BaseAddress = baseAddress;
            this.SizeOfHeapReserve = sizeOfHeapReserve;
            this.SizeOfHeapCommit = sizeOfHeapCommit;
            this.SizeOfStackReserve = sizeOfStackReserve;
            this.SizeOfStackCommit = sizeOfStackCommit;
            this.LinkerMajorVersion = linkerMajorVersion;
            this.LinkerMinorVersion = linkerMinorVersion;
            this.MajorSubsystemVersion = majorSubsystemVersion;
            this.MinorSubsystemVersion = minorSubsystemVersion;
            this.ImageCharacteristics = imageCharacteristics;
            this.Subsystem = subsystem;

            this.DllCharacteristics = dllCharacteristics;
            this.CorFlags = corFlags;
        }
Example #24
0
 static KnownCharacteristics()
 {
     //ToDo do we need a lock here?
     LookupTable = Characteristics.ToDictionary(c => c.Id, c => c);
 }
Example #25
0
 public override void GoToWork(TribeResources tribeResources)
 {
     efficiency = Efficiency();
     tribeResources.AddResource(new Stone(efficiency));
     Characteristics.JobsLevelUpdate(JobsEn.Collector, ref _daysOnJob);
 }
Example #26
0
 /// <summary>
 /// Calculates the battle power of a <see cref="FarmHeroes.Data.Models.HeroModels.Hero"/>.
 /// </summary>
 /// <param name="characteristics">
 /// The <see cref="FarmHeroes.Data.Models.HeroModels.Characteristics"/> of a <see cref="FarmHeroes.Data.Models.HeroModels.Hero"/>.
 /// </param>
 /// <returns>
 /// The total battle power of a <see cref="FarmHeroes.Data.Models.HeroModels.Hero"/>.
 /// </returns>
 public static int CalculateBattlePower(Characteristics characteristics) =>
 (int)(characteristics.Attack * AttackBattlePowerModifier) +
 (int)(characteristics.Defense * DefenseBattlePowerModifier) +
 (int)(characteristics.Mastery * MasteryBattlePowerModifier) +
 (int)(characteristics.Dexterity * DexterityBattlePowerModifier);
        public override void Analyze(BinaryAnalyzerContext context)
        {
            PEBinary           target             = context.PEBinary();
            PEHeader           peHeader           = target.PE.PEHeaders.PEHeader;
            DllCharacteristics dllCharacteristics = peHeader.DllCharacteristics;

            CoffHeader      coffHeader      = target.PE.PEHeaders.CoffHeader;
            Characteristics characteristics = coffHeader.Characteristics;

            bool highEntropyVA = ((int)dllCharacteristics & 0x0020 /*IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA*/) == 0x0020;

            //  /LARGEADDRESSAWARE is necessary for HIGH_ENTROPY_VA to have effect
            bool largeAddressAware = (characteristics & Characteristics.LargeAddressAware /*IMAGE_FILE_LARGE_ADDRESS_AWARE*/) == Characteristics.LargeAddressAware;

            if (!highEntropyVA && !largeAddressAware)
            {
                // '{0}' does not declare itself as high entropy ASLR compatible. High entropy allows
                // Address Space Layout Randomization to be more effective in mitigating memory
                // corruption vulnerabilities. To resolve this issue, configure your tool chain to
                // mark the program high entropy compatible; e.g. by supplying /HIGHENTROPYVA as well
                // as /LARGEADDRESSAWARE to the C or C++ linker command line.
                context.Logger.Log(this,
                                   RuleUtilities.BuildResult(FailureLevel.Error, context, null,
                                                             nameof(RuleResources.BA2015_Error_NeitherHighEntropyVANorLargeAddressAware),
                                                             context.TargetUri.GetFileName()));
                return;
            }

            if (!highEntropyVA)
            {
                // '{0}' does not declare itself as high entropy ASLR compatible. High entropy allows
                // Address Space Layout Randomization to be more effective in mitigating memory
                // corruption vulnerabilities. To resolve this issue, configure your tool chain to
                // mark the program high entropy compatible; e.g. by supplying /HIGHENTROPYVA to the
                // C or C++ linker command line. (This image was determined to have been properly
                // compiled as /LARGEADDRESSAWARE.)
                context.Logger.Log(this,
                                   RuleUtilities.BuildResult(FailureLevel.Error, context, null,
                                                             nameof(RuleResources.BA2015_Error_NoHighEntropyVA),
                                                             context.TargetUri.GetFileName()));
                return;
            }

            if (!largeAddressAware)
            {
                // '{0}' does not declare itself as high entropy ASLR compatible. High entropy allows
                // Address Space Layout Randomization to be more effective in mitigating memory
                // corruption vulnerabilities. To resolve this issue, configure your tool chain to
                // mark the program high entropy compatible by supplying /LARGEADDRESSAWARE to the C
                // or C++ linker command line. (This image was determined to have been properly
                // compiled as /HIGHENTROPYVA.)
                context.Logger.Log(this,
                                   RuleUtilities.BuildResult(FailureLevel.Error, context, null,
                                                             nameof(RuleResources.BA2015_Error_NoLargeAddressAware),
                                                             context.TargetUri.GetFileName()));
                return;
            }

            //'{0}' is high entropy ASLR compatible.
            context.Logger.Log(this,
                               RuleUtilities.BuildResult(ResultKind.Pass, context, null,
                                                         nameof(RuleResources.BA2015_Pass),
                                                         context.TargetUri.GetFileName()));
        }
Example #28
0
 public void GivenTheStores(Characteristics characteristics, Dictionary <string, Store> stores)
 => GivenTheStores(null, characteristics, stores);
Example #29
0
 public void GivenTheUsers(Characteristics characteristics, Dictionary <string, User> users)
 => GivenTheUsers(null, characteristics, users);
Example #30
0
		bool? GetFlagValue(Characteristics flag) {
			return Characteristics == null ? (bool?)null : (Characteristics.Value & flag) != 0;
		}
Example #31
0
        /// <summary>
        /// Gets all the characteristics of this service
        /// </summary>
        public async Task <bool> GetAllCharacteristics()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("ObservableGattDeviceService::getAllCharacteristics: ");
            sb.Append(Name);

            try
            {
                CancellationTokenSource tokenSource = new CancellationTokenSource(5000);
                var t = Task.Run(() => Service.GetCharacteristicsAsync(Windows.Devices.Bluetooth.BluetoothCacheMode.Uncached), tokenSource.Token);

                GattCharacteristicsResult result = null;
                result = await t.Result;

                if (result.Status == GattCommunicationStatus.Success)
                {
                    sb.Append(" - getAllCharacteristics found ");
                    sb.Append(result.Characteristics.Count());
                    sb.Append(" characteristics");
                    Debug.WriteLine(sb);
                    foreach (GattCharacteristic gattchar in result.Characteristics)
                    {
                        Characteristics.Add(new ObservableGattCharacteristics(gattchar, this));
                    }
                    return(true);
                }
                else if (result.Status == GattCommunicationStatus.Unreachable)
                {
                    sb.Append(" - getAllCharacteristics failed with Unreachable");
                    Debug.WriteLine(sb.ToString());
                }
                else if (result.Status == GattCommunicationStatus.ProtocolError)
                {
                    sb.Append(" - getAllCharacteristics failed with Unreachable");
                    Debug.WriteLine(sb.ToString());
                }
            }
            catch (AggregateException ae)
            {
                foreach (var ex in ae.InnerExceptions)
                {
                    if (ex is TaskCanceledException)
                    {
                        Debug.WriteLine("Getting characteristics took too long.");
                        Name += " - Timed out getting some characteristics";
                        break;
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                // Bug 9145823:GetCharacteristicsAsync throw System.UnauthorizedAccessException when querying GenericAccess Service Characteristics
                Name += " - Unauthorized Access";
            }
            catch (Exception ex)
            {
                Debug.WriteLine("getAllCharacteristics: Exception - {0}" + ex.Message);
            }
            return(false);
        }
Example #32
0
		void SetFlagValue(Characteristics flag, bool? value) {
			if (Characteristics == null)
				Characteristics = 0;
			if (value ?? false)
				Characteristics |= flag;
			else
				Characteristics &= ~flag;
		}
Example #33
0
        public static AssemblyDef AddToNewAssemblyDef(ModuleDef module, ModuleKind moduleKind, out Characteristics characteristics)
        {
            var asmDef = module.UpdateRowId(new AssemblyDefUser(GetAssemblyName(module)));

            asmDef.Modules.Add(module);
            WriteNewModuleKind(module, moduleKind, out characteristics);
            return(asmDef);
        }
Example #34
0
        public async Task CharacterCard_Should_BeProperlyExportedAndImported()
        {
            var investigatorData = new InvestigatorData
            {
                Name       = "Elisabeth Grimaldi",
                Player     = "Lao",
                Occupation = new Occupation
                {
                    Name = "Badacz"
                },
                Age              = 26,
                Gender           = Gender.Female,
                PlaceOfResidence = "Paryż",
                PlaceOfBirth     = "Londyn"
            };
            var characteristics = new Characteristics
            {
                Strength     = 45,
                Constitution = 70,
                Size         = 71,
                Dexterity    = 45,
                Appearance   = 60,
                Intelligence = 55,
                Power        = 55,
                Education    = 65,
                HitPoints    = 14,
                Luck         = 55,
                MagicPoints  = 11
            };
            var weapons = new System.Collections.ObjectModel.ObservableCollection <Weapon>
            {
                new Weapon
                {
                    Name            = "Średni nóż",
                    Damage          = "1D4 + 2 + MO",
                    NumberOfAttacks = "1"
                }
            };
            var history = new InvestigatorHistory
            {
                CharacterDescription = "Śliczna" +
                                       "Nieśmiała" +
                                       "Elegancka",
                IdeologyAndBeliefs = "Polityka - liberalizm",
                ImportantPeople    = "Nauczyciel medycyny - Emmet Harding" +
                                     "ubóstwiam tą osobę za jej niesamowitą inteligencję",
                ImportantPlaces = "Wieża Eiffela",
                PersonalThings  = "Okrągła, walcowata tuba bez otworu znaleziona pod wejściem do windy wieży Eiffela",
                Qualities       = "Lojalność",
                InjuriesScars   = "10cm blizna na prawej łopatce"
            };
            var belongings = new Belongings
            {
                Equipment = new System.Collections.Generic.List <string>
                {
                    "Książki historyczne",
                    "Średni nóż"
                },
                ExpenditureLevel = 10,
                Cash             = 60,
                Possesions       = new System.Collections.Generic.Dictionary <string, int>
                {
                    { "mieszkanie w Paryżu", 1500 }
                }
            };
            var relations = new System.Collections.ObjectModel.ObservableCollection <Relations>
            {
                new Relations
                {
                    Investigator = "Hudson Caffey",
                    Player       = "Jasiu",
                    Relation     = "kolega, poznany przez Howarda Barnhama"
                },
                new Relations
                {
                    Investigator = "Mortimer Caffey",
                    Player       = "Gerard",
                    Relation     = "kolega, poznany przez Howarda Barnhama"
                },
                new Relations
                {
                    Investigator = "Howard Barnham",
                    Player       = "Bartek",
                    Relation     = "Poznany 5 lat temu na bankiecie, dobry przyjaciel"
                }
            };
            var sut = CharacterCard.Create(investigatorData, characteristics, new System.Collections.ObjectModel.ObservableCollection <Skill>(), weapons, history, belongings, relations);
            await sut.InitializeAsync();

            await sut.ExportAsync("CharacterCard.json");

            var newSut = new CharacterCard();
            await newSut.ImportAsync("CharacterCard.json");

            var compareLogic = new CompareLogic();
            var result       = compareLogic.Compare(sut, newSut);

            Assert.IsTrue(result.AreEqual);
        }
Example #35
0
 public static void WriteNewModuleKind(ModuleDef module, ModuleKind moduleKind, out Characteristics characteristics)
 {
     module.Kind            = moduleKind;
     characteristics        = module.Characteristics;
     module.Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(module.Characteristics, moduleKind);
 }
Example #36
0
 bool GetFlagValue(Characteristics flag)
 {
     return (Characteristics & flag) != 0;
 }
Example #37
0
		bool GetFlagValue(Characteristics flag) => (Characteristics & flag) != 0;
Example #38
0
 public override void GoToWork(TribeResources tribeResources)
 {
     efficiency = Efficiency();
     tribeResources.AddResource(new Medicines(efficiency));
     Characteristics.JobsLevelUpdate(JobsEn.Shaman, ref _daysOnJob);
 }
Example #39
0
		ImageReference GetImageReference(Characteristics ch) {
			bool isExe = (ch & Characteristics.Dll) == 0;
			return new ImageReference(GetType().Assembly, isExe ? "AssemblyExe" : "Assembly");
		}
Example #40
0
 protected override int Efficiency()
 {
     return(Characteristics.CalculateEfficiency(LeaderCharacteristics, JobsEn.Warrior, 0.5, 0.2, 0.1, 0.2));
 }
Example #41
0
 public override void GoToWork(TribeResources tribeResources)
 {
     efficiency = Efficiency();
     tribeResources.AddResource(new TribalStrength(efficiency));
     Characteristics.JobsLevelUpdate(JobsEn.Warrior, ref _daysOnJob);
 }
Example #42
0
		public void Read (BinaryReader reader) 
		{
			machine = (MachineId) reader.ReadUInt16 ();
			sections = reader.ReadInt16 ();
			tdStampRaw = reader.ReadUInt32 ();
			symTabPtr = reader.ReadUInt32 ();
			numSymbols = reader.ReadUInt32 ();
			optHeaderSize = reader.ReadInt16 ();
			characteristics = (Characteristics) reader.ReadUInt16 ();	
		}
Example #43
0
 public void GivenTheDealers(Characteristics characteristics, Dictionary <string, Dealer> dealers)
 => GivenTheDealers(null, characteristics, dealers);
Example #44
0
		void SetFlagValue(Characteristics flag, bool value) {
			if (value)
				Characteristics |= flag;
			else
				Characteristics &= ~flag;
		}
	public void TakeContactHit (Characteristics other) {
		if (armor <= other.contactDamage && (lastHitTime + recoverTime) < Time.time) {
			TakeDamage (other.contactDamage - armor);
		}
	}
Example #46
0
        public PEBuilder(
            Machine machine,
            int sectionAlignment, 
            int fileAlignment, 
            ulong imageBase,
            byte majorLinkerVersion,
            byte minorLinkerVersion,
            ushort majorOperatingSystemVersion,
            ushort minorOperatingSystemVersion,
            ushort majorImageVersion,
            ushort minorImageVersion,
            ushort majorSubsystemVersion,
            ushort minorSubsystemVersion,
            Subsystem subsystem,
            DllCharacteristics dllCharacteristics,
            Characteristics imageCharacteristics,
            ulong sizeOfStackReserve,
            ulong sizeOfStackCommit,
            ulong sizeOfHeapReserve,
            ulong sizeOfHeapCommit,
            Func<BlobBuilder, ContentId> deterministicIdProvider = null)
        {
            Machine = machine;
            SectionAlignment = sectionAlignment;
            FileAlignment = fileAlignment;
            ImageBase = imageBase;
            MajorLinkerVersion = majorLinkerVersion;
            MinorLinkerVersion = minorLinkerVersion;
            MajorOperatingSystemVersion = majorOperatingSystemVersion;
            MinorOperatingSystemVersion = minorOperatingSystemVersion;
            MajorImageVersion = majorImageVersion;
            MinorImageVersion = minorImageVersion;
            MajorSubsystemVersion = majorSubsystemVersion;
            MinorSubsystemVersion = minorSubsystemVersion;
            Subsystem = subsystem;
            DllCharacteristics = dllCharacteristics;
            ImageCharacteristics = imageCharacteristics;
            SizeOfStackReserve = sizeOfStackReserve;
            SizeOfStackCommit = sizeOfStackCommit;
            SizeOfHeapReserve = sizeOfHeapReserve;
            SizeOfHeapCommit = sizeOfHeapCommit;
            IsDeterministic = deterministicIdProvider != null;
            IdProvider = deterministicIdProvider ?? GetCurrentTimeBasedIdProvider();

            _sections = new List<Section>();
        }
Example #47
0
 bool?GetFlagValue(Characteristics flag) => Characteristics == null ? (bool?)null : (Characteristics.Value & flag) != 0;
Example #48
0
		ImageReference GetImageReference(Characteristics ch) {
			bool isExe = (ch & Characteristics.Dll) == 0;
			return isExe ? DsImages.AssemblyExe : DsImages.Assembly;
		}
        private void AddEntryes()
        {
            #region ValueType
            ValueType valueIntType    = new ValueType("int");
            ValueType valueStringType = new ValueType("string");
            ValueType valueFloatType  = new ValueType("float");
            ValueType valueBoolType   = new ValueType("bool");
            ValueTypes.Add(valueIntType);
            ValueTypes.Add(valueStringType);
            ValueTypes.Add(valueFloatType);
            ValueTypes.Add(valueBoolType);
            SaveChanges();
            #endregion

            #region DeviceType
            DeviceType deviceLaptopType = new DeviceType("Ноутбук", Properties.Resources.Laptop);
            DeviceTypes.Add(deviceLaptopType);
            SaveChanges();
            #endregion

            #region Devices
            Device device1 = new Device(deviceLaptopType.ID, "Samsung NC10");
            Device device2 = new Device(deviceLaptopType.ID, "ASUS K50IN");
            Devices.Add(device1);
            Devices.Add(device2);
            SaveChanges();
            #endregion

            #region CharacteristicType
            CharacteristicType characteristicType_Webcam       = new CharacteristicType(deviceLaptopType.ID, "Веб-камера", valueBoolType.ID);
            CharacteristicType characteristicType_VideoCard    = new CharacteristicType(deviceLaptopType.ID, "Видеокарта", valueStringType.ID);
            CharacteristicType characteristicType_WorkingHours = new CharacteristicType(deviceLaptopType.ID, "Время работы", valueIntType.ID);
            CharacteristicType characteristicType_Screen       = new CharacteristicType(deviceLaptopType.ID, "Диагональ экрана", valueFloatType.ID);
            CharacteristicType characteristicType_Storage      = new CharacteristicType(deviceLaptopType.ID, "Накопитель", valueIntType.ID);
            CharacteristicType characteristicType_RAM          = new CharacteristicType(deviceLaptopType.ID, "Оперативная память", valueIntType.ID);
            CharacteristicType characteristicType_CPU          = new CharacteristicType(deviceLaptopType.ID, "Процессор", valueStringType.ID);
            CharacteristicTypes.Add(characteristicType_Webcam);
            CharacteristicTypes.Add(characteristicType_VideoCard);
            CharacteristicTypes.Add(characteristicType_WorkingHours);
            CharacteristicTypes.Add(characteristicType_Screen);
            CharacteristicTypes.Add(characteristicType_Storage);
            CharacteristicTypes.Add(characteristicType_RAM);
            CharacteristicTypes.Add(characteristicType_CPU);
            SaveChanges();
            #endregion

            #region Characteristics
            //1 Samsung NC10
            Characteristic char1_Webcam       = new Characteristic(device1.ID, characteristicType_Webcam.ID, "true");
            Characteristic char1_VideoCard    = new Characteristic(device1.ID, characteristicType_VideoCard.ID, "Intel GMA 952 (встроенная)");
            Characteristic char1_WorkingHours = new Characteristic(device1.ID, characteristicType_WorkingHours.ID, "6");
            Characteristic char1_Screen       = new Characteristic(device1.ID, characteristicType_Screen.ID, "10,20");
            Characteristic char1_Storage      = new Characteristic(device1.ID, characteristicType_Storage.ID, "80");
            Characteristic char1_RAM          = new Characteristic(device1.ID, characteristicType_RAM.ID, "1");
            Characteristic char1_CPU          = new Characteristic(device1.ID, characteristicType_CPU.ID, "Intel 945GSE");
            Characteristics.Add(char1_Webcam);
            Characteristics.Add(char1_VideoCard);
            Characteristics.Add(char1_WorkingHours);
            Characteristics.Add(char1_Screen);
            Characteristics.Add(char1_Storage);
            Characteristics.Add(char1_RAM);
            Characteristics.Add(char1_CPU);
            //2 ASUS K50IN
            Characteristic char2_Webcam       = new Characteristic(device2.ID, characteristicType_Webcam.ID, "true");
            Characteristic char2_VideoCard    = new Characteristic(device2.ID, characteristicType_VideoCard.ID, "NVIDIA GeForce G 102M (дискретная)");
            Characteristic char2_WorkingHours = new Characteristic(device2.ID, characteristicType_WorkingHours.ID, "6");
            Characteristic char2_Screen       = new Characteristic(device2.ID, characteristicType_Screen.ID, "15,6");
            Characteristic char2_Storage      = new Characteristic(device2.ID, characteristicType_Storage.ID, "250");
            Characteristic char2_RAM          = new Characteristic(device2.ID, characteristicType_RAM.ID, "2");
            Characteristics.Add(char2_Webcam);
            Characteristics.Add(char2_VideoCard);
            Characteristics.Add(char2_WorkingHours);
            Characteristics.Add(char2_Screen);
            Characteristics.Add(char2_Storage);
            Characteristics.Add(char2_RAM);
            SaveChanges();
            #endregion
        }