Skip to content

Instantly share code, notes, and snippets.

@hillexed
Created January 10, 2017 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hillexed/274a77b5cfb84705de23368f05c0e629 to your computer and use it in GitHub Desktop.
Save hillexed/274a77b5cfb84705de23368f05c0e629 to your computer and use it in GitHub Desktop.
alyt_extract_sarc.py
"""ALYT Splitter
* by hillexed
* Splits an ALYT into the Sarc file contained within and the ALYT header
* Given a file 00.ALYT this creates 00.ALYT.SARC and 00.ALYT.HEADER"""
version = 1.1
import sys
def getUnsignedBytes(bytestring, offset, numBytes=4):
return int.from_bytes(bytestring[offset:offset+numBytes],byteorder='little')
def main():
if(len(sys.argv) != 2):
print("Usage: %s <alyt file>\n" % sys.argv[0])
return 1
with open(sys.argv[1],'rb') as fp:
fileBuf = fp.read()
fileSize = len(fileBuf)
if(fileBuf[0:4] != b'ALYT'):
return 1
"""
ltblOff = getUnsignedBytes(fileBuf,0x8,4)
lmtlOff = getUnsignedBytes(fileBuf,0x10,4)
lfnlOff = getUnsignedBytes(fileBuf,0x18,4)
ltblSize = getUnsignedBytes(fileBuf,0xC,4)
lmtlSize = getUnsignedBytes(fileBuf,0x14,4)
lfnlSize = getUnsignedBytes(fileBuf,0x1C,4)
symbolTbl = getUnsignedBytes(fileBuf,0x20,4)
numOfEntries = getUnsignedBytes(fileBuf,symbolTbl,4)"""
sarcHeaderIndex = fileBuf.index(b"SARC")
ALYTHeader = fileBuf[:sarcHeaderIndex]
clippedFile = fileBuf[sarcHeaderIndex:]
with open(sys.argv[1] + '.SARC','wb') as fp:
fp.write(clippedFile)
with open(sys.argv[1] + '.ALYT.HEADER','wb') as fp:
fp.write(clippedFile)
return 0
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment