예제 #1
0
 public void Write(PakFileStructure archive)
 {
     Write(archive.Signature);
     Write(archive.Version);
     Write(archive.DataSize);
     Write(archive.FileTreeSize);
     Write(archive.Hash);
 }
        public PakFileStructure ReadPakInfo()
        {
            var pakFile = new PakFileStructure();

            pakFile.Signature    = ReadInt32();
            pakFile.Version      = ReadInt32();
            pakFile.DataSize     = ReadInt64();
            pakFile.FileTreeSize = ReadInt64();
            pakFile.Hash         = ReadBytes(20);

            return(pakFile);
        }
예제 #3
0
        public void LoadPakFileStructure(PakBinaryReader reader, int version, string aesKey)
        {
            var startOffset = version >= 8 ? -204 : -44;

            reader.BaseStream.Seek(startOffset, SeekOrigin.End);
            Archive = reader.ReadPakInfo();

            reader.BaseStream.Seek(Archive.DataSize, SeekOrigin.Begin);

            var readerToUse = reader;

            if (aesKey != null)
            {
                var soapHex = SoapHexBinary.Parse(aesKey);

                var fileTree          = reader.ReadBytes((int)Archive.FileTreeSize);
                var decryptedFileTree = AesHandler.DecryptAes(fileTree, soapHex.Value);

                var memoryStream = new MemoryStream(decryptedFileTree);
                var memoryReader = new PakBinaryReader(memoryStream);

                readerToUse = memoryReader;
            }

            Archive.Directory = readerToUse.ReadPakDirectory();

            for (int i = 0; i < Archive.Directory.NumberOfEntries; i++)
            {
                var currentEntry = readerToUse.ReadDirectoryLevelPakEntry();
                Archive.Directory.Entries.Add(currentEntry);

                if (i > 0)
                {
                    var previousEntry = Archive.Directory.Entries[i - 1];
                    var realEntrySize = currentEntry.Offset - previousEntry.Offset;
                    previousEntry.Padded     = currentEntry.Offset % 2048 == 0;
                    previousEntry.NextOffset = currentEntry.Offset;
                    previousEntry.RealSize   = realEntrySize;
                }
            }

            if (aesKey != null)
            {
                readerToUse.Close();
            }

            var compressionTypes     = Archive.Directory.Entries.Select(entry => entry.CompressionType).Distinct();
            var encryptionTyoes      = Archive.Directory.Entries.Select(entry => entry.EncryptionType).Distinct();
            var paddedUncompressed   = Archive.Directory.Entries.Where(entry => entry.CompressionType == 0 && entry.Padded).OrderBy(entry => entry.UncompressedSize);
            var unpaddedUncompressed = Archive.Directory.Entries.Where(entry => entry.CompressionType == 0 && entry.Padded == false).OrderBy(entry => entry.UncompressedSize);
        }
예제 #4
0
 public void CreateNewPakFile(string mountPoint, List <PakEntry> entries, int version)
 {
     Archive = new PakFileStructure
     {
         Signature = 1517228769,
         Version   = version,
         Directory = new PakDirectory
         {
             Name            = mountPoint,
             Entries         = entries,
             NumberOfEntries = entries.Count
         }
     };
 }