예제 #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);
        }
예제 #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));
        }
예제 #3
0
        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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }