Changes

Jump to navigation Jump to search
1,053 bytes added ,  00:37, 30 July 2019
m
→‎Header versions 6+: Updated a comment
Line 20: Line 20:  
  {
 
  {
 
     uint128 headerMD5;
 
     uint128 headerMD5;
     uint32 metaDataOffset;
+
     uint32 gbxHeadersStart; // offset to metadata section
     uint32 dataOffset;
+
     uint32 dataStart;
 
     if version >= 2:
 
     if version >= 2:
 
     {
 
     {
         uint32 metaDataUncompressedSize;
+
         uint32 gbxHeadersSize;
         uint32 metaDataCompressedSize;
+
         uint32 gbxHeadersComprSize;
 
     }
 
     }
 
     if version >= 3:
 
     if version >= 3:
Line 85: Line 85:  
  {
 
  {
 
     uint256 ContentsChecksum;    // Checksum Sha256 of the pack contents starting at next byte
 
     uint256 ContentsChecksum;    // Checksum Sha256 of the pack contents starting at next byte
     uint32 DecryptFlags;       // 0x1 = IsHeaderPrivate, 0x2 = IsCrypted(?), 0x4 = IsDataPrivate, 0x8 = IsImpostor
+
     struct SHeaderFlagsUncrypt
 +
    {
 +
        uint32 IsHeaderPrivate    : 1;
 +
        uint32 UseDefaultHeaderKey : 1;
 +
        uint32 IsDataPrivate       : 1;
 +
        uint32 IsImpostor         : 1;
 +
        uint32 __Unused__          : 28;
 +
    };
 
     if (version >= 15)
 
     if (version >= 15)
 
         uint32 HeaderMaxSize;    // 0x4000 = Small (16 KB), 0x100000 = Big (1 MB), 0x1000000 = Huge (16 MB)
 
         uint32 HeaderMaxSize;    // 0x4000 = Small (16 KB), 0x100000 = Big (1 MB), 0x1000000 = Huge (16 MB)
 
     if (version >= 7)
 
     if (version >= 7)
 
     {
 
     {
         SAuthorInfo AuthorInfo; // uint32 version = 0, string login, string nick, string zone, string extra
+
         struct SAuthorInfo
 +
        {
 +
            uint32 Version;
 +
            string Login;
 +
            string Nick;
 +
            string Zone;
 +
            string ExtraInfo;
 +
        };
 
         if (version < 9)
 
         if (version < 9)
 
         {
 
         {
Line 106: Line 120:  
             if (version >= 13)
 
             if (version >= 13)
 
                 string DownloadUrl;
 
                 string DownloadUrl;
             uint64 CreationDate;
+
             uint64 CreationDate; // Win32 FILETIME structure
 
             string Comment;
 
             string Comment;
 
             if (version >= 12)
 
             if (version >= 12)
Line 113: Line 127:  
                 string TitleID;
 
                 string TitleID;
 
             }
 
             }
             string UsageSubDir; // to known the kind of pack it is
+
             string UsageSubDir; // to known the kind of pack it is
             string CreationBuildInfo;
+
             string CreationBuildInfo;
 
             uint128 unused;
 
             uint128 unused;
 
             if (version >= 10)
 
             if (version >= 10)
Line 133: Line 147:  
         }
 
         }
 
     }
 
     }
     Blowfish encrypted:   // Unencrypted, if DecryptFlags & 0x3 == 0
+
     Blowfish encrypted: // Unencrypted if neither SHeaderFlagsUncrypt.IsHeaderPrivate nor SHeaderFlagsUncrypt.UseDefaultHeaderKey are set
 
     {
 
     {
 
         uint128 Checksum;
 
         uint128 Checksum;
         uint32 GbxHeadersStart;
+
         uint32 GbxHeadersStart; // Offset to the metadata section
 
         if version < 15:
 
         if version < 15:
            uint32 DataStart;
+
            uint32 DataStart;     // If version >= 15: DataStart = HeaderMaxSize
 
         if version >= 2:
 
         if version >= 2:
 
         {
 
         {
            uint32 GbxHeadersSize;
+
            uint32 GbxHeadersSize;
            uint32 GbxHeadersComprSize;
+
            uint32 GbxHeadersComprSize;
 
         }
 
         }
 
         if version >= 14:
 
         if version >= 14:
            uint128 unused;
+
            uint128 unused;
 
         if version >= 16:
 
         if version >= 16:
            uint32 FileSize;
+
            uint32 FileSize;
 
         if version >= 3:
 
         if version >= 3:
            uint128 unused;
+
            uint128 unused;
 
         if version == 6:
 
         if version == 6:
            SAuthorInfo;
+
            SAuthorInfo;
 
         uint32 Flags;
 
         uint32 Flags;
 
         uint32 NumFolders;
 
         uint32 NumFolders;
 
         FolderDesc Folders[NumFolders]
 
         FolderDesc Folders[NumFolders]
 
         {
 
         {
            int32 FolderIndexParent;
+
            int32 FolderIndexParent;
            string FolderName;
+
            string FolderName;
 
         }
 
         }
 
         uint32 NumFiles;
 
         uint32 NumFiles;
 
         FileDesc Files[NumFiles]
 
         FileDesc Files[NumFiles]
 
         {
 
         {
            int32 FolderIndex;
+
            int32 FolderIndex;
            string FileName;
+
            string FileName;
            uint32 unknown;
+
            uint32 unknown;
            uint32 UncompressedSize;
+
            uint32 UncompressedSize;
            uint32 CompressedSize;
+
            uint32 CompressedSize;
            uint32 Offset;
+
            uint32 Offset;
            uint32 [[Class IDs|classID]];
+
            uint32 [[Class IDs|classID]];
            if version >= 17:
+
            if version >= 17:
              uint32 Size;
+
                uint32 Size;
            if version >= 14:
+
            if version >= 14:
              uint128 Checksum;
+
                uint128 Checksum;
            uint64 Flags;
+
            struct SFileDescFlags
 +
            {
 +
                uint32 IsHashed          : 1;
 +
                uint32 PublishFid        : 1;
 +
                uint32 Compression      : 4;
 +
                uint32 IsSeekable        : 1;
 +
                uint32 _Unknown_        : 1;
 +
                uint32 __Unused1__      : 24;
 +
                uint32 DontUseDummyWrite : 1;
 +
                uint32 OpaqueUserData    : 16;
 +
                uint32 PublicFile        : 1;
 +
                uint32 ForceNoCrypt      : 1;
 +
                uint32 __Unused2__      : 13;
 +
            };
 
         }
 
         }
 
     }
 
     }
Line 179: Line 206:     
===Data===
 
===Data===
The content of each file starts at Header.dataOffset + FileDesc.offset in the .pak file. First, an 8-byte plaintext IV is read. Then, FileDesc.compressedSize bytes are read and decrypted using Blowfish in CBC mode, using the same key that was used to decrypt the header. If FileDesc.flags & 0x7C is not zero, the file is compressed and should be decompressed using zlib deflate after decryption (it will end up at FileDesc.uncompressedSize bytes).
+
The content of each file starts at Header.dataStart + FileDesc.offset in the .pak file. From version 15, the data block starts at HeaderMaxSize. First, an 8-byte plaintext IV is read. Then, FileDesc.compressedSize bytes are read and decrypted using Blowfish in CBC mode, using the same key that was used to decrypt the header. If FileDesc.flags & 0x7C is not zero, the file is compressed and should be decompressed using zlib deflate after decryption (it will end up at FileDesc.uncompressedSize bytes).
    
The type of the file can be found from the extension in the name, or, if this is not available (many file names are actually just hashes), from the [[Class IDs|class ID]].
 
The type of the file can be found from the extension in the name, or, if this is not available (many file names are actually just hashes), from the [[Class IDs|class ID]].

Navigation menu