Example #1
0
        protected virtual SoftwareInfo DoGetSoftware(IEnumerable <IProductBinarySoftwareDetector> detectors, byte[] prefix, byte[] inBuffer, IProgress <double> progress, CancellationToken token)
        {
            var processorCount = Environment.ProcessorCount;
            var count          = MaxThreads > 0 && MaxThreads < processorCount
                ? MaxThreads : processorCount;

            var offsets = GetOffsets();

            var watch = new Stopwatch();

            watch.Start();

            var workers = new BinarySoftwareDetectorWorker[count];

            for (var i = 0; i < count; i++)
            {
                workers[i] = new BinarySoftwareDetectorWorker(detectors, BinaryDecoder, prefix, inBuffer,
                                                              i * offsets.Length / count, (i + 1) * offsets.Length / count, offsets);
            }

            var progressState = new ProgressState(offsets.Length, progress);
            var software      = GetSoftware(workers, offsets.Length, progressState, token);

            watch.Stop();
            Logger.LogDebug("Detecting software completed in {0}", watch.Elapsed);

            progressState.Reset();

            return(software);
        }
Example #2
0
        private SoftwareInfo DoGetSoftware(IEnumerable <IProductBinarySoftwareDetector> detectors, byte[] prefix, byte[] inBuffer, SoftwareEncodingInfo encoding, CancellationToken token)
        {
            var worker = new BinarySoftwareDetectorWorker(detectors, BinaryDecoder, prefix, inBuffer, encoding);

            return(worker.GetSoftware(new ProgressState(), token));
        }