Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of stringTable padding #135

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions nsz/Fs/Hfs0.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ def getHeader(self):
stringTable = '\x00'.join(file['name'] for file in self.files)

headerSize = 0x10 + len(self.files) * 0x40 + len(stringTable)
remainder = 0x10 - headerSize % 0x10
headerSize += remainder

h = b''
h += b'HFS0'
h += len(self.files).to_bytes(4, byteorder='little')
h += (len(stringTable)+remainder).to_bytes(4, byteorder='little')
h += (len(stringTable)).to_bytes(4, byteorder='little')
h += b'\x00\x00\x00\x00'

stringOffset = 0
Expand All @@ -92,7 +90,6 @@ def getHeader(self):
stringOffset += len(f['name']) + 1

h += stringTable.encode()
h += remainder * b'\x00'

return h

Expand Down
4 changes: 1 addition & 3 deletions nsz/Fs/Nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ def generateHeader(self, files):
filesNb = len(files)
stringTable = '\x00'.join(os.path.basename(file) for file in files)
headerSize = 0x10 + (filesNb)*0x18 + len(stringTable)
remainder = 0x10 - headerSize%0x10
headerSize += remainder

fileSizes = [os.path.getsize(file) for file in files]
fileOffsets = [sum(fileSizes[:n]) for n in range(filesNb)]
Expand All @@ -419,7 +417,7 @@ def generateHeader(self, files):
header = b''
header += b'PFS0'
header += pk('<I', filesNb)
header += pk('<I', len(stringTable)+remainder)
header += pk('<I', len(stringTable))
header += b'\x00\x00\x00\x00'
for n in range(filesNb):
header += pk('<Q', fileOffsets[n])
Expand Down
5 changes: 1 addition & 4 deletions nsz/Fs/Pfs0.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ def getFirstFileOffset(self):
def getHeader(self):
stringTable = '\x00'.join(file['name'] for file in self.files)
headerSize = 0x10 + len(self.files) * 0x18 + len(stringTable)
remainder = 0x10 - headerSize % 0x10
headerSize += remainder

h = b''
h += b'PFS0'
h += len(self.files).to_bytes(4, byteorder='little')
h += (len(stringTable)+remainder).to_bytes(4, byteorder='little')
h += (len(stringTable)).to_bytes(4, byteorder='little')
h += b'\x00\x00\x00\x00'

stringOffset = 0
Expand All @@ -95,7 +93,6 @@ def getHeader(self):
stringOffset += len(f['name']) + 1

h += stringTable.encode()
h += remainder * b'\x00'

return h

Expand Down