Difference between revisions of "ZiPatch File Structure"

From FFXIV Classic Wiki
Jump to: navigation, search
Line 4: Line 4:
 
<pre>91 5A 49 50 41 54 43 48 0D 0A 1A 0A            ‘ZIPATCH....</pre>
 
<pre>91 5A 49 50 41 54 43 48 0D 0A 1A 0A            ‘ZIPATCH....</pre>
  
The ZiPatch File Header is followed immediately by ''n'' blocks, which carry specific instructions. Each block has the following structure:
+
The ZiPatch File Header is followed immediately by ''n'' blocks, which each carry specific instructions.
  
 
<pre>
 
<pre>
Line 17: Line 17:
 
</pre>
 
</pre>
  
byte type[data[0..3]]
+
The block type identifier is indicated by the slice of data[0..3]. Analysis of ffxivupdater.exe indicates the following block types as valid:
"FHDR" (File Header)
 
"APLY"
 
"APFS"
 
"ETRY" (Entry File)
 
"ADIR" (Add Directory)
 
"DELD" (Delete Directory)
 
  
>>FHDR
+
<pre>
byte version[4]
+
FHDR // File Header; observed
byte result[4]
+
APLY // Unknown; observed
uint numEtry (Little Endian)
+
APFS // Unknown; not observed
uint numAply (Little Endian)
+
ETRY // Entry File; observed
uint numDeld (Little Endian)
+
ADIR // Add Directory; observed
 +
DELD // Delete Directory; observed
 +
</pre>
 +
 
 +
The File Header block is a summary of the changes that will take place as a result of applying the ZiPatch.
 +
 
 +
[StructLayout(LayoutKind.Sequential, Pack=4, Size=20)]
 +
struct FileHeader
 +
{
 +
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
 +
    byte[] _version;        // version format is unknown, but may be major/minor. Analysis of ffxivupdater.exe indicates the string FileHeaderV2
 +
 
 +
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
 +
    byte[] _result;          // DIFF or HIST observed
 +
 
 +
    int _numEntryFile;      // Little Endian
 +
    int _numAddDirectory;    // Little Endian
 +
    int _numDeleteDirectory; // Little Endian
 +
}
 +
</pre>
  
 
>>ADIR
 
>>ADIR

Revision as of 18:54, 5 June 2019

All ZiPatch files for FINAL FANTASY XIV share the same overall structure. This format was later expanded in 2012 for DRAGON QUEST X and FINAL FANTASY XIV: A Realm Reborn, which are more similar in their DAT structure. Many of the block types found in this version were deprecated, but still remain in the executable for A Realm Reborn.

ZiPatch File Header

91 5A 49 50 41 54 43 48 0D 0A 1A 0A            ‘ZIPATCH....

The ZiPatch File Header is followed immediately by n blocks, which each carry specific instructions.

[StructLayout(LayoutKind.Sequential, Pack=4)]
struct Block
{
    int dataSize; // Little Endian
    byte[] data;  // data.Length is dataSize + 4 (inclusive of block type identifier)
    [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
    byte[] crc;   // crc is a standard CRC32 checksum (RFC 1952) of data
}

The block type identifier is indicated by the slice of data[0..3]. Analysis of ffxivupdater.exe indicates the following block types as valid:

FHDR // File Header; observed
APLY // Unknown; observed
APFS // Unknown; not observed
ETRY // Entry File; observed
ADIR // Add Directory; observed
DELD // Delete Directory; observed

The File Header block is a summary of the changes that will take place as a result of applying the ZiPatch.

[StructLayout(LayoutKind.Sequential, Pack=4, Size=20)] struct FileHeader {

   [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
   byte[] _version;         // version format is unknown, but may be major/minor. Analysis of ffxivupdater.exe indicates the string FileHeaderV2
   [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
   byte[] _result;          // DIFF or HIST observed
   int _numEntryFile;       // Little Endian
   int _numAddDirectory;    // Little Endian
   int _numDeleteDirectory; // Little Endian

} </pre>

>>ADIR uint pathSize (Little Endian) byte path[pathSize]

>>DELD uint pathSize (Little Endian) byte path[pathSize]