Begin SparseFs impl

This commit is contained in:
jakcron 2021-10-16 16:40:14 +08:00
parent 289470d2a8
commit 42de7f6bdc
2 changed files with 24 additions and 1 deletions

View file

@ -239,6 +239,21 @@ void nstool::NcaProcess::generatePartitionConfiguration()
throw tc::Exception(mModuleName, fmt::format("NCA FS Header [{:d}] Version({:d}): UNSUPPORTED", partition.header_index, fs_header.version.unwrap()));
}
// detect sparse
if (fs_header.sparse_info.generation.unwrap() != 0)
{
fmt::print("[IsSparse]\n");
fmt::print(" bucket:\n");
fmt::print(" offset: 0x{:x}\n", fs_header.sparse_info.bucket.offset.unwrap());
fmt::print(" size: 0x{:x}\n", fs_header.sparse_info.bucket.offset.unwrap());
fmt::print(" header:\n");
fmt::print(" st_magic: {:s}\n", ((tc::bn::string<4>*)&fs_header.sparse_info.bucket.header.st_magic)->str());
fmt::print(" version: 0x{:x}\n", fs_header.sparse_info.bucket.header.version.unwrap());
fmt::print(" entry_count: {:d}\n", fs_header.sparse_info.bucket.header.entry_count.unwrap());
fmt::print(" physical_offset: 0x{:x}\n", fs_header.sparse_info.physical_offset.unwrap());
fmt::print(" generation: 0x{:x}\n", fs_header.sparse_info.generation.unwrap());
}
// setup AES-CTR
nn::hac::ContentArchiveUtil::getNcaPartitionAesCtr(&fs_header, info.aes_ctr.data());

View file

@ -85,6 +85,11 @@ private:
tc::Optional<nn::hac::detail::aes128_key_t> aes_ctr;
} mContentKey;
struct SparseInfo
{
};
// raw partition data
struct sPartitionInfo
{
@ -106,6 +111,9 @@ private:
// crypto metadata
nn::hac::detail::aes_iv_t aes_ctr;
// sparse metadata
SparseInfo sparse_info;
};
std::array<sPartitionInfo, nn::hac::nca::kPartitionNum> mPartitions;