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

Why is hfs0 header size modified? #77

Closed
ghost opened this issue Jul 12, 2020 · 1 comment
Closed

Why is hfs0 header size modified? #77

ghost opened this issue Jul 12, 2020 · 1 comment
Assignees
Labels
bug Something isn't working file format Issues with the NSZ file format
Milestone

Comments

@ghost
Copy link

ghost commented Jul 12, 2020

Hello. I was looking through the code and trying to get an understanding of how it all works. I'm having trouble understanding the purpose of modifying the hfs0 header size.

nsz/nsz/Fs/Xci.py

Lines 82 to 84 in 30577fe

def setHfs0Size(self, sz):
self.seek(0x138)
self.writeInt64(sz)

This function is called every time an XciStream is close, and hence every XCZ made with nsz will result in the header size modified. What is the reason behind this? Am I missing something?

@nicoboss nicoboss added bug Something isn't working file format Issues with the NSZ file format labels Jul 30, 2020
@nicoboss nicoboss self-assigned this Jul 30, 2020
@nicoboss nicoboss added this to the v3.2.0 milestone Jul 30, 2020
@nicoboss nicoboss pinned this issue Sep 6, 2020
@nicoboss
Copy link
Owner

nicoboss commented Sep 6, 2020

Thanks a lot for pointing that out. I have no idea why we changed the HFS0 header size. This code originates from NUT which was developed quite early when parts of the HFS0 file format were still unknown so probably it was thought this indicates the whole file size instead of the HFS0 header size. I removed it in the latest NSZ v4.0 release as there seems to be absolutely no reason for this to be required and as a lossless compression format XCZ should never modify values inside the file irreversible. The only reason this was never noticed was because unlike the NCA files there were no easily accessible checksum to verify the headers integrity and changing the header size had no impact on real hardware.

@nicoboss nicoboss unpinned this issue Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working file format Issues with the NSZ file format
Projects
None yet
Development

No branches or pull requests

1 participant