psforever / PSPack

A tool to work with PlanetSide 1's pack file format.
Other
3 stars 3 forks source link

Repacking support #3

Open pschord opened 8 years ago

pschord commented 8 years ago

We want to be able to REPACK game files after editing them.

The general idea is there is a .PAK file that has a bunch of assets with in it. In order to repack, there needs to be a way to gather up all unpacked files, recompress them, and rebuild the index in the beginning of the PAK.

shaql2 commented 8 years ago

For repacking, we need to Reverse Engineer the format a bit further:

In pack_index_entry, as far as I've seen, unk1 and unk3 are always 0, it should be safe to assume that while repacking; unk4 is simply the decompressed size; unk5 may be some crc32 or other checksum - note that it's 0x00000000 in case of an empty file.

In the PACK's header, the third unknown uint32 is the number of files packed (could be useful for simplifying decompressing too?); the first one is always 0x02 (possibly version, knowing SOE), the second is decompressed index size. So the whole PACK header is as follows: "PACK", 0x02, compressed index size, decompressed index size, numFiles, unk3, unk4

pschord commented 8 years ago

Steps to repack:

  1. Select directory to pack
  2. Get list of all files
  3. Compress all files (either in memory or back to disk)
  4. Build pack index from files
  5. Compress pack index
  6. Write pack header off of the above information
  7. Finalize file from provided filename