-
Notifications
You must be signed in to change notification settings - Fork 68
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
[ctrtool] support more prototype CXIs #154
Conversation
Hi Wack0, good find. Happy to bring in this change, but can we make the logic clearer? e.g. from this: bool is_proto_exhdr_size = mHeader.header.format_version.unwrap() == ntd::n3ds::NcchCommonHeader::FormatVersion_CXI_PROTOTYPE && mHeader.header.exhdr_size.unwrap() == (sizeof(ntd::n3ds::ExtendedHeader) + sizeof(ntd::n3ds::AccessDescriptor));
if (mHeader.header.exhdr_size.unwrap() != 0 && mHeader.header.exhdr_size.unwrap() != sizeof(ntd::n3ds::ExtendedHeader) && !is_proto_exhdr_size)
{
throw tc::InvalidOperationException(mModuleLabel, fmt::format("NcchHeader has invalid ExHeader size. (0x{:02x})", mHeader.header.exhdr_size.unwrap()));
} to this: // validate exheader size
size_t expected_exhdr_size = sizeof(ntd::n3ds::ExtendedHeader); // default for modern CXI is 0x400 (sizeof(ntd::n3ds::ExtendedHeader))
if (mHeader.header.format_version.unwrap() == ntd::n3ds::NcchCommonHeader::FormatVersion_CXI_PROTOTYPE)
{
expected_exhdr_size = sizeof(ntd::n3ds::ExtendedHeader) + sizeof(ntd::n3ds::AccessDescriptor); // for some 0.10.x prototype CXI this is 0x800 (sizeof(ntd::n3ds::ExtendedHeader) + sizeof(ntd::n3ds::AccessDescriptor))
}
if (mHeader.header.exhdr_size.unwrap() != 0 && mHeader.header.exhdr_size.unwrap() != expected_exhdr_size)
{
throw tc::InvalidOperationException(mModuleLabel, fmt::format("NcchHeader has invalid ExHeader size. (0x{:02x})", mHeader.header.exhdr_size.unwrap()));
} What do you think? |
There may be some later CXIs that use v1 format version but with exheader size 0x400, so the proposed change may not be correct. |
Are there any further changes that need to be made? I'd like to see to it that this gets merged as soon as humanly possible. There will be users who need this feature in a matter of days. |
I can confirm that at some point (SDK 0.10.1 or 0.10.2), exheader size changed to 0x400 with the NCCH format version still being v1. Therefore the proposed change is indeed not correct. |
@Wack0 thanks for confirming. Then can you just add a comment above I'd be happy to merge it and release it after that. |
7fc7e8d
to
50b34ac
Compare
SDK 0.10-era CXIs specify the full exheader size of 0x800 in the NCCH header, so allow that.
SDK 0.10-era CXIs specify the full exheader size of 0x800 in the NCCH header, so allow that.