Change NSP padding logic to follow nxdt and nsfw validation (#147)
This commit is contained in:
@@ -112,8 +112,16 @@ auto Nsp::Build(std::span<CollectionEntry> entries, s64& size) -> std::vector<u8
|
|||||||
string_offset += entries[i].name.length() + 1;
|
string_offset += entries[i].name.length() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// align table
|
// Add padding to the string table so that the header as a whole is well-aligned
|
||||||
string_table.resize((string_table.size() + 0x1F) & ~0x1F);
|
const auto nameless_header_size = sizeof(Pfs0Header) + (file_table.size() * sizeof(Pfs0FileTableEntry));
|
||||||
|
auto padded_string_table_size = ((nameless_header_size + string_table.size() + 0x1F) & ~0x1F) - nameless_header_size;
|
||||||
|
|
||||||
|
// Add manual padding if the full Partition FS header would already be properly aligned.
|
||||||
|
if (padded_string_table_size == string_table.size()) {
|
||||||
|
padded_string_table_size += 0x20;
|
||||||
|
}
|
||||||
|
|
||||||
|
string_table.resize(padded_string_table_size);
|
||||||
|
|
||||||
header.magic = PFS0_MAGIC;
|
header.magic = PFS0_MAGIC;
|
||||||
header.total_files = entries.size();
|
header.total_files = entries.size();
|
||||||
|
|||||||
Reference in New Issue
Block a user