Writing · Ep. 7 · 0x0A90–0x0B18 · Reverse engineering
Writing a tiny unpacker for a mystery .pak format
Magic bytes, offset tables, and a weekend in a hex editor — the first step of the OreGairu English Patch.
Looking at the header
Every archive starts with the same four bytes, followed by a file count and the offset of a table of contents.
import struct
def read_header(data: bytes):
magic, count, toc = struct.unpack_from("<4sII", data, 0)
assert magic == b"PAK\0", "not a pak file"
return count, tocHow the pieces fit
Repacking
Repacking is the same walk in reverse. The only rule: keep each file aligned to 16 bytes, or the game refuses to load it. The cleaned-up version of this script became paktool.
Read the header
List every entry
Extract files
Repack with alignment
