Splatoon .pack File

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Larsenv
Posts: 137
Joined: Thu Jun 04, 2015 11:20 pm

Splatoon .pack File

Post by Larsenv »

aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Splatoon .pack File

Post by aluigi »

http://aluigi.org/bms/splatoon_sarc.bms

Read the header of the script for some technical information.
einstein95
Posts: 64
Joined: Tue Sep 08, 2015 11:27 am

Re: Splatoon .pack File

Post by einstein95 »

Reworked the script somewhat to work with any SARC from a 3DS game, also works with SARC archives from other Wii U games. Feel free to take credit for this one.

Code: Select all

# Nintendo SARC
#   the script automatically extracts all the extracted SARC archives
#   but will be created a backup copy of the archive in the destination folder
#   for technical reasons related to opening the TEMPORARY_FILE and reopening the old one

math RECURSIVE_SARC_EXTRACTION = 1

comtype yaz0

if RECURSIVE_SARC_EXTRACTION != 0
    print "Press 'a' if asked to overwrite TEMPORARY_FILE"
    get SIZE asize
    get MYFILE_NAME filename
    log MYFILE_NAME OFFSET SIZE  # long story...
endif

set NAME string ""
set PATH string ""
callfunction SARC_EXTRACT 1

if RECURSIVE_SARC_EXTRACTION != 0
    print "You can delete the file %MYFILE_NAME% in the output folder"
endif

startfunction SARC_EXTRACT
    string PATH + NAME
    string PATH + /

    getdstring SIGN 4
    if SIGN == "SARC"
        get HEAD_SIZE short
        get END short
        if END == 0xFFFE
            endian big
        else
            endian little
        endif
        get PACK_SIZE long
        get BASE_OFF long
        get UNK long
        idstring "SFAT"
        get DUMMY short
        get FILES short
        get DUMMY long
        for i = 0 < FILES
            get DUMMY long
            get NAME_OFF long
            math NAME_OFF & 0x00FFFFFF
            get OFFSET long
            get SIZE long
            math SIZE - OFFSET
            math OFFSET + BASE_OFF
            math NAME_OFF * 4
            putarray 0 i OFFSET
            putarray 1 i SIZE
            putarray 2 i NAME_OFF
        next i
        idstring "SFNT"
        get DUMMY short
        get DUMMY short
        savepos NAMES_OFF
        for i = 0 < FILES
            getarray OFFSET   0 i
            getarray SIZE     1 i
            getarray NAME_OFF 2 i

            math NAME_OFF + NAMES_OFF
            goto NAME_OFF
            get NAME string
            string FNAME p "%s%s" PATH NAME

            goto OFFSET
            getdstring SIGN 4
            if SIGN == "Yaz0"
                math ZSIZE = SIZE
                math ZSIZE - 0x10
                get SIZE long
                get FLAGS long
                get ZERO long
                savepos OFFSET

                if RECURSIVE_SARC_EXTRACTION != 0
                    clog TEMPORARY_FILE OFFSET ZSIZE SIZE

                    string NAME - 4
                    get MYFILE_NAME filename
                    open "." TEMPORARY_FILE
                    callfunction SARC_EXTRACT
                    open "." MYFILE_NAME
                else
                    clog NAME OFFSET ZSIZE SIZE
                endif

            else
                log FNAME OFFSET SIZE
            endif
        next i
    else
        get SIZE asize
        log FNAME OFFSET SIZE
    endif
endfunction
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Splatoon .pack File

Post by aluigi »

Cool thanks.
I have updated the script with some modifications that should make it compatible with all the versions.
Larsenv
Posts: 137
Joined: Thu Jun 04, 2015 11:20 pm

Re: Splatoon .pack File

Post by Larsenv »

Please make this script use Yaz0 if it's detected as Yaz0.

Not all SARCs use Yaz0.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Splatoon .pack File

Post by aluigi »

That's what it does.
It checks if the file starts with the magic "Yaz0" and uses the yaz0 compression on it.
Have you encountered any specific problem?