Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:SARC archive

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

Nintendo's archive of the Wii U and Switch generation (.sarc, .pack, .bfarc, often Yaz0-compressed as .szs): header SARC, an SFAT table of files sorted by a 32-bit name hash, an SFNT name table and the file data; either endianness, given by a byte order mark.

Overview

SARC is the sead library archive (oead's code notes that it mirrors what sead::SharcArchiveRes::prepareArchive_ does). Wii U games are big endian, Switch games little endian; the byte order mark tells which. Files are looked up by a hash of their path, so the name table is optional. Layout from zeldamods/oead (GPL-2.0-or-later) src/sarc.cpp.

Layout

Offset Field
0x00 SARC
0x04 u16 header size (0x14)
0x06 u16 byte order mark 0xFEFF (reads as 0xFFFE when the file is little endian and read as big endian)
0x08 u32 file size
0x0C u32 data offset (start of the file data)
0x10 u16 version (0x0100), u16 reserved
0x14 SFAT, u16 header size (0x0C), u16 file count (the reader rejects counts of 0x4000 or more), u32 hash multiplier (0x65 by default)
0x20 file entries, 16 bytes each
after SFNT, u16 header size (8), u16 reserved, then the NUL-terminated names, each padded to 4 bytes

Entry: u32 name hash; u32 name field (nonzero when the file has a name: low 24 bits are the name offset in the SFNT string area in units of 4 bytes, oead writes 1 in the upper byte); u32 data begin and u32 data end, both relative to the data offset. The file data must not start before the end of the name table.

Name hash

hash = 0; for each character c of the path: hash = hash * multiplier + c (32-bit wrap). Entries are stored sorted by hash so a reader can binary-search. Unverified: paths use / and have no leading slash.

Checked: zeldamods/oead src/sarc.cpp @ 5fb74e1128 HashName(multiplier, name) is exactly this loop over a signed char (u32 hash = 0; hash = hash * multiplier + c), with the multiplier read from the SFAT header (hash_multiplier), and the writer sorts files by this hash. The slash and leading-slash convention is not stated there and stays Unverified.

Writing and alignment

oead aligns file data per extension when it writes an archive (for example .gtx 0x2000, .sharc/.sharcb 0x1000, .baglmf 0x80, .bffnt 0x2000 big endian or 0x1000 little endian) and 0x2000 for nested archives. Unverified: a rebuilt archive that ignores these alignments can crash the game.

Identification

Plain: SARC at offset 0. Compressed: Format:Yaz0 whose decompressed data starts with SARC (typical extensions .szs and the BotW-style sb* names such as .sbfres, see Format:BFRES).

Related

Format:BYML, Format:BFRES, Format:Yaz0, Format:RARC archive (the GameCube predecessor), Format:U8 archive, Platform:Nintendo Switch.

Code & repositories

  • https://github.com/zeldamods/oead @ 5fb74e1128468380b47da23a5690891c8af4ab72 · license: GPL-2.0-or-later (declared by the contributor for the files used; GitHub reports GPL-2.0 for the repository)
    Library and Python module for Nintendo formats: SARC, BYML, AAMP, Yaz0 (zlib-based encoder), FSTM/FSTP/FWAV audio header readers; src/sarc.cpp and src/byml.cpp define the binary layouts
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-02