public static bool GetImageIsHost(string path) { using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { byte[] array = new BinaryReader(fileStream).ReadBytes((int)fileStream.Length); Dictionary <Sections, FwInfo.SectionDetails> sectionInfo = new DeviceFwInfo(new FileFwInfoSource(array)).GetSectionInfo(); CheckLocation isHostCheckLocation = ImageValidator.GetIsHostCheckLocation(); return(Convert.ToBoolean(array.Skip((int)(sectionInfo[isHostCheckLocation.Section].Offset + isHostCheckLocation.Offset)).Take((int)isHostCheckLocation.Length).ToArray()[0] & isHostCheckLocation.Mask)); } }
protected override IEnumerable <CheckLocation> GetCheckLocations(HwGeneration generation) { CheckLocation isHostCheckLocation = ImageValidator.GetIsHostCheckLocation(); isHostCheckLocation.ErrorCode = TbtStatus.SDK_IMAGE_FOR_DEVICE_ERROR; List <CheckLocation> list = new List <CheckLocation>(); list.Add(isHostCheckLocation); list.AddRange(GetHostCheckLocations(generation).Where(delegate(HostCheckLocation val) { if (val.Type != HwType._1Port) { return(val.Type == base.HwInfo.Type); } return(true); })); return(list); }
protected override IEnumerable <CheckLocation> GetCheckLocations(HwGeneration generation) { CheckLocation isHostCheckLocation = ImageValidator.GetIsHostCheckLocation(); isHostCheckLocation.ErrorCode = TbtStatus.SDK_IMAGE_FOR_HOST_ERROR; if ((uint)(generation - 3) <= 2u) { return(new CheckLocation[2] { isHostCheckLocation, new CheckLocation(292u, 1u, byte.MaxValue, Sections.ArcParams, TbtStatus.SDK_IMAGE_VALIDATION_ERROR, "X of N") }); } if (generation == HwGeneration.JHL7540_7440_7340) { return(new CheckLocation[1] { isHostCheckLocation }); } throw new TbtException(TbtStatus.SDK_UNKNOWN_CHIP); }