Exemple #1
0
        public SoftwareInfo GetSoftware(string basePath, string categoryName, IProgress <double> progress, CancellationToken token)
        {
            if (!CategoryName.Equals(categoryName, StringComparison.Ordinal))
            {
                return(null);
            }

            var fileName     = BootProvider.GetFileName(CategoryName);
            var diskbootPath = Path.Combine(basePath, fileName);

            Logger.LogTrace("Detecting software from {0}", diskbootPath);

            if (!File.Exists(diskbootPath))
            {
                Logger.LogTrace("{0} not found", diskbootPath);
                return(null);
            }

            var inBuffer = File.ReadAllBytes(diskbootPath);
            var software = GetSoftware(inBuffer, progress, token);

            if (software != null)
            {
                if (software.Product.Created == null)
                {
                    software.Product.Created = File.GetCreationTimeUtc(diskbootPath);
                }
            }
            return(software);
        }
Exemple #2
0
        private DateTime GetCreationTime(CardInfo cardInfo)
        {
            var rootPath     = cardInfo.GetRootPath();
            var fileName     = BootProvider.GetFileName(CategoryName);
            var diskbootPath = Path.Combine(rootPath, fileName);

            return(File.GetCreationTimeUtc(diskbootPath));
        }
        public override SoftwareInfo GetSoftware(byte[] inBuffer, IProgress <double> progress, CancellationToken token)
        {
            var fileName  = BootProvider.GetFileName(CategoryName);
            var hash      = HashProvider.GetHash(inBuffer, fileName, HashName);
            var hashStr   = hash.Values[fileName.ToLowerInvariant()];
            var hashBytes = GetHashBytes(hashStr);

            Hash2Software.TryGetValue(hashBytes, out SoftwareInfo software);
            return(software);
        }
Exemple #4
0
        private SoftwareInfo GetSoftware(IEnumerable <IProductBinarySoftwareDetector> detectors, byte[] inBuffer, SoftwareEncodingInfo encoding,
                                         IProgress <double> progress = null, CancellationToken token = default(CancellationToken))
        {
            var prefix = BootProvider.GetPrefix(CategoryName);

            if (encoding == null)
            {
                return(GetSoftware(detectors, prefix, inBuffer, progress, token));
            }
            return(DoGetSoftware(detectors, prefix, inBuffer, encoding, token));
        }
Exemple #5
0
        public virtual SoftwareInfo GetSoftware(byte[] inBuffer, IProgress <double> progress, CancellationToken token)
        {
            var detectors = GetDetectors();
            var prefix    = BootProvider.GetPrefix(CategoryName);
            var software  = GetSoftware(detectors, prefix, inBuffer, progress, token);

            if (software != null)
            {
                var fileName = BootProvider.GetFileName(CategoryName);
                software.Hash = HashProvider.GetHash(inBuffer, fileName, HashName);
            }
            return(software);
        }
Exemple #6
0
        public virtual bool UpdateSoftware(SoftwareInfo software, byte[] inBuffer)
        {
            if (!CategoryName.Equals(software.Category.Name, StringComparison.Ordinal))
            {
                return(false);
            }

            var detectors = GetDetectors(software.Product);
            var encoding  = GetEncoding(software.Product, software.Camera, software.Encoding);

            var fileName = BootProvider.GetFileName(CategoryName);

            software.Hash = HashProvider.GetHash(inBuffer, fileName, HashName);

            var software2 = GetSoftware(detectors, inBuffer, encoding);

            if (software2 != null)
            {
                if (software2.Product.Created != null)
                {
                    software.Product.Created = software2.Product.Created;
                }
                if (software2.Build.Changeset != null)
                {
                    software.Build.Changeset = software2.Build.Changeset;
                }
                if (software2.Build.Creator != null)
                {
                    software.Build.Creator = software2.Build.Creator;
                }
                if (software2.Compiler != null)
                {
                    software.Compiler = software2.Compiler;
                }
                if (software.Encoding == null)
                {
                    software.Encoding = software2.Encoding;
                }
                return(true);
            }

            return(false);
        }
Exemple #7
0
        private bool UpdateSoftware(ref SoftwareInfo software, string destPath, IProgress <double> progress, CancellationToken token)
        {
            var category     = software.Category;
            var readSoftware = MetadataSoftwareDetector.GetSoftware(destPath, category, progress, token);

            if (readSoftware != null)
            {
                software = readSoftware;
                return(false);
            }

            software.Encoding = SoftwareViewModel.SelectedItem?.Info.Encoding;

            var fileName = BootProvider.GetFileName(category.Name);
            var filePath = Path.Combine(destPath, fileName);
            var buffer   = File.ReadAllBytes(filePath);

            BinarySoftwareDetector.UpdateSoftware(software, buffer);

            Logger.LogObject(LogLevel.Information, "Updated to {0}", software);

            return(true);
        }
Exemple #8
0
 private BootData GetBoot(uint modelId, string productName)
 {
     return(BootProvider.GetBoot(modelId, productName));
 }