[NCSD/NCCH] More NCSD parsing

This commit is contained in:
wheremyfoodat 2022-10-02 03:26:24 +03:00
parent 6b6cc7ca2f
commit 71cc187f93
3 changed files with 75 additions and 10 deletions

View file

@ -42,9 +42,13 @@ std::optional<NCSD> Memory::loadNCSD(const std::filesystem::path& path) {
for (int i = 0; i < 8; i++) {
auto& partition = ncsd.partitions[i];
NCCH& ncch = partition.ncch;
partition.offset = u64(partitionData[i * 2]) * NCSD::mediaUnit;
partition.length = u64(partitionData[i * 2 + 1]) * NCSD::mediaUnit;
ncch.partitionIndex = i;
ncch.fileOffset = partition.offset;
if (partition.length != 0) { // Initialize the NCCH of each partition
ncsd.file.seek(partition.offset);
@ -57,7 +61,7 @@ std::optional<NCSD> Memory::loadNCSD(const std::filesystem::path& path) {
return std::nullopt;
}
if (!partition.ncch.loadFromHeader(ncchHeader)) {
if (!ncch.loadFromHeader(ncchHeader, ncsd.file)) {
printf("Invalid NCCH partition\n");
return std::nullopt;
}