SARC

SARC

SARC File Format #

.sarc files are similar to the ARC format with a slightly different structure.

File Format #

SARC Header #

OffsetSizeDescription
0x000x04Magic Bytes “SARC”
0x040x02Header Length
0x060x02Byte-order marker (0xFEFF = big, 0xFFFE = little)
0x080x04File Length
0x0C0x04Data Offset (absolute)
0x100x04Unknown (always 0x00000100)

SFAT Header #

OffsetSizeDescription
0x000x04Magic bytes “SFAT”
0x040x02Header Length
0x060x02Node Count
0x080x04Filename Hash Multiplier (usually 0x65)

SFAT Node #

OffsetSizeDescription
0x000x04Name Hash
0x040x04SFNT Filename Offset (relative to SFNT data section)
0x080x04File Data Start (relative to SARC data start)
0x0C0x04File Data End (relative to SARC data end)

Node hashing function #

The node hash is calculated via:

Python:

def calc_hash(name, hash_multiplier):
    result = 0
    
    for c in name:
        result = ord(c) + (result * hash_multiplier)
        # ensure the result is a 32-bit value
        result &= 0xFFFFFFFF
    
    return result

C:

uint32_t calc_hash(char *name, int hash_multiplier) {
    uint32_t result = 0;
    
    for(int i = 0; i < strlen(name); i++) {
        result = name[i] + (result * hash_multiplier)
    }
    
    return result;
}

SFNT Header #

OffsetSizeDescription
0x000x04Magic bytes “SFNT”
0x040x02Header Length
0x060x02Unknown (padding?)

SFNT Data #

SFNT data immediately follows the SFNT header and consists of NULL-terminated ASCII strings.

File Data #

File data begins after SFNT with 0x100 (256) byte alignment with all subsequent files aligned to 0x80 bytes.

File Sort Order #

Files are sorted by their hash in the SFAT table, games require this sorting as they use a binary search algorithm 🔗 1.

Tools #

🔗 2 - SARC Extractor/Creator with TAR-like command line flags. Can decompress a .zlib SARC file (4-byte size header + ZLIB data).

Category:File formats