Esempio n. 1
0
        public static XmlDocument GetDocument(this MemoryMappedFile m2dFile, IPackFileHeader header)
        {
            XmlDocument document = new XmlDocument();

            document.Load(new MemoryStream(CryptoManager.DecryptData(header, m2dFile)));
            return(document);
        }
Esempio n. 2
0
        public static byte[] DecryptData(IPackFileHeader pHeader, MemoryMappedFile data)
        {
            if (pHeader.CompressedFileSize > 0 && pHeader.EncodedFileSize > 0 && pHeader.FileSize > 0)
            {
                using MemoryMappedViewStream buffer =
                          data.CreateViewStream((long)pHeader.Offset, pHeader.EncodedFileSize);
                byte[] src = new byte[pHeader.EncodedFileSize];

                if (buffer.Read(src, 0, (int)pHeader.EncodedFileSize) == pHeader.EncodedFileSize)
                {
                    return(Decrypt(pHeader.Version, pHeader.EncodedFileSize,
                                   (uint)pHeader.CompressedFileSize, pHeader.BufferFlag, src));
                }
            }

            throw new Exception("ERROR decrypting data file segment: the size of the block is invalid.");
        }
Esempio n. 3
0
 public static XmlReader GetReader(this MemoryMappedFile m2dFile, IPackFileHeader header)
 {
     return(XmlReader.Create(new MemoryStream(CryptoManager.DecryptData(header, m2dFile))));
 }