Пример #1
0
        public bool Repair(Virus virus)
        {
            try
            {
                KCompress.KCompressExtractor extr = new KCompress.KCompressExtractor(virus.Location);
                extr.ExtractArchive(AVEngine.TempDir + @"QA\A\");

                virus.Scanner.Repair(new Virus(virus.Name, AVEngine.TempDir + @"QA\A\" + virus.FileName, FileFormat.GetFileFormat(virus.FileName)));

                File.Copy(virus.Location, Application.StartupPath + @"\Quarantine\ARCHIVEBACKUP\" + Path.GetFileName(virus.Location) + ".BACKUP");
                KCompress.KCompressCompressor comp = new KCompress.KCompressCompressor();
                comp.IncludeEmptyDirectories = true;
                comp.FastCompression         = true;
                comp.CompressionLevel        = KCompress.CompressionLevel.High;
                comp.CompressionMethod       = KCompress.CompressionMethod.Default;
                comp.CompressionMode         = KCompress.CompressionMode.Create;
                comp.CompressDirectory(AVEngine.TempDir + @"QA\A\", virus.Location);
                Directory.Delete(AVEngine.TempDir + @"QA\A\", true);
                return(true);
            }
            catch
            {
            }
            finally
            {
            }
            return(false);
        }
Пример #2
0
        private void CommonInit(IInArchive archive, int filesCount, KCompressExtractor extractor)
        {
            _archive    = archive;
            _filesCount = filesCount;
            _fakeStream = new FakeOutStreamWrapper();
            _fakeStream.BytesWritten += IntEventArgsHandler;
            _extractor = extractor;
#if !WINCE
            GC.AddMemoryPressure(MEMORY_PRESSURE);
#endif
        }
Пример #3
0
 private void Init(IInArchive archive, string directory, int filesCount, bool directoryStructure,
                   List <uint> actualIndexes, KCompressExtractor extractor)
 {
     CommonInit(archive, filesCount, extractor);
     _directory          = directory;
     _actualIndexes      = actualIndexes;
     _directoryStructure = directoryStructure;
     if (!directory.EndsWith("" + Path.DirectorySeparatorChar, StringComparison.CurrentCulture))
     {
         _directory += Path.DirectorySeparatorChar;
     }
 }
Пример #4
0
        private static bool ExtractionBenchmark(string archiveFileName, Stream outStream,
                                                ref LibraryFeature?features, LibraryFeature testedFeature)
        {
            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                GetResourceString(archiveFileName));

            try
            {
                using (var extr = new KCompressExtractor(stream))
                {
                    extr.ExtractFile(0, outStream);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            features |= testedFeature;
            return(true);
        }
Пример #5
0
        private void ReadChunk()
        {
            long size;

            byte[] properties;
            try
            {
                properties = KCompressExtractor.GetLzmaProperties(_input, out size);
            }
            catch (LzmaException)
            {
                _error = true;
                return;
            }
            if (!_firstChunkRead)
            {
                _commonProperties = properties;
            }
            if (_commonProperties[0] != properties[0] ||
                _commonProperties[1] != properties[1] ||
                _commonProperties[2] != properties[2] ||
                _commonProperties[3] != properties[3] ||
                _commonProperties[4] != properties[4])
            {
                _error = true;
                return;
            }
            if (_buffer.Capacity < (int)size)
            {
                _buffer.Capacity = (int)size;
            }
            _buffer.SetLength(size);
            _decoder.SetDecoderProperties(properties);
            _buffer.Position = 0;
            _decoder.Code(
                _input, _buffer, 0, size, null);
            _buffer.Position = 0;
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the ArchiveExtractCallback class
 /// </summary>
 /// <param name="archive">IInArchive interface for the archive</param>
 /// <param name="directory">Directory where files are to be unpacked to</param>
 /// <param name="filesCount">The archive files count</param>
 /// <param name="password">Password for the archive</param>
 /// <param name="extractor">The owner of the callback</param>
 /// <param name="actualIndexes">The list of actual indexes (solid archives support)</param>
 /// <param name="directoryStructure">The value indicating whether to preserve directory structure of extracted files.</param>
 public ArchiveExtractCallback(IInArchive archive, string directory, int filesCount, bool directoryStructure,
                               List <uint> actualIndexes, string password, KCompressExtractor extractor)
     : base(password)
 {
     Init(archive, directory, filesCount, directoryStructure, actualIndexes, extractor);
 }
Пример #7
0
 private void Init(IInArchive archive, Stream stream, int filesCount, uint fileIndex, KCompressExtractor extractor)
 {
     CommonInit(archive, filesCount, extractor);
     _fileStream = new OutStreamWrapper(stream, false);
     _fileStream.BytesWritten += IntEventArgsHandler;
     _fileIndex = fileIndex;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the ArchiveExtractCallback class
 /// </summary>
 /// <param name="archive">IInArchive interface for the archive</param>
 /// <param name="stream">The stream where files are to be unpacked to</param>
 /// <param name="filesCount">The archive files count</param>
 /// <param name="fileIndex">The file index for the stream</param>
 /// <param name="password">Password for the archive</param>
 /// <param name="extractor">The owner of the callback</param>
 public ArchiveExtractCallback(IInArchive archive, Stream stream, int filesCount, uint fileIndex, string password,
                               KCompressExtractor extractor)
     : base(password)
 {
     Init(archive, stream, filesCount, fileIndex, extractor);
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the ArchiveExtractCallback class
 /// </summary>
 /// <param name="archive">IInArchive interface for the archive</param>
 /// <param name="stream">The stream where files are to be unpacked to</param>
 /// <param name="filesCount">The archive files count</param>
 /// <param name="fileIndex">The file index for the stream</param>
 /// <param name="extractor">The owner of the callback</param>
 public ArchiveExtractCallback(IInArchive archive, Stream stream, int filesCount, uint fileIndex,
                               KCompressExtractor extractor)
 {
     Init(archive, stream, filesCount, fileIndex, extractor);
 }