summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-08-11 03:49:19 +0200
committerLiam <byteslice@airmail.cc>2023-08-15 23:47:25 +0200
commit0398b34370f9a6d739e0101378770c7d592a4806 (patch)
tree9affd31d1ef4d41ccadb06eff1357ee228805b20 /src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp
parentvfs: expand support for NCA reading (diff)
downloadyuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar.gz
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar.bz2
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar.lz
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar.xz
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.tar.zst
yuzu-0398b34370f9a6d739e0101378770c7d592a4806.zip
Diffstat (limited to 'src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp')
-rw-r--r--src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp b/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp
index b1b5fb156..450135ae0 100644
--- a/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp
+++ b/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.cpp
@@ -508,12 +508,15 @@ Result NcaFileSystemDriver::CreateSparseStorageMetaStorage(VirtualFile* out,
offset + meta_offset, sparse_info.MakeAesCtrUpperIv(upper_iv),
AlignmentStorageRequirement::None));
- // Create meta storage.
- auto meta_storage = std::make_shared<OffsetVfsFile>(decrypted_storage, meta_size, 0);
- R_UNLESS(meta_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
+ // Create buffered storage.
+ std::vector<u8> meta_data(meta_size);
+ decrypted_storage->Read(meta_data.data(), meta_size, 0);
+
+ auto buffered_storage = std::make_shared<VectorVfsFile>(std::move(meta_data));
+ R_UNLESS(buffered_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
// Set the output.
- *out = std::move(meta_storage);
+ *out = std::move(buffered_storage);
R_SUCCEED();
}
@@ -817,13 +820,15 @@ Result NcaFileSystemDriver::CreateAesCtrExStorageMetaStorage(
auto meta_storage = std::make_shared<OffsetVfsFile>(decrypted_storage, meta_size, 0);
R_UNLESS(meta_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
- // Create an alignment-matching storage.
- using AlignedStorage = AlignmentMatchingStorage<NcaHeader::CtrBlockSize, 1>;
- auto aligned_storage = std::make_shared<AlignedStorage>(std::move(meta_storage));
- R_UNLESS(aligned_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
+ // Create buffered storage.
+ std::vector<u8> meta_data(meta_size);
+ meta_storage->Read(meta_data.data(), meta_size, 0);
+
+ auto buffered_storage = std::make_shared<VectorVfsFile>(std::move(meta_data));
+ R_UNLESS(buffered_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
// Set the output.
- *out = std::move(aligned_storage);
+ *out = std::move(buffered_storage);
R_SUCCEED();
}
@@ -937,8 +942,15 @@ Result NcaFileSystemDriver::CreateIndirectStorageMetaStorage(VirtualFile* out,
patch_info.indirect_offset);
R_UNLESS(meta_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
+ // Create buffered storage.
+ std::vector<u8> meta_data(patch_info.indirect_size);
+ meta_storage->Read(meta_data.data(), patch_info.indirect_size, 0);
+
+ auto buffered_storage = std::make_shared<VectorVfsFile>(std::move(meta_data));
+ R_UNLESS(buffered_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
+
// Set the output.
- *out = std::move(meta_storage);
+ *out = std::move(buffered_storage);
R_SUCCEED();
}
@@ -1090,7 +1102,6 @@ Result NcaFileSystemDriver::CreateSha256Storage(
// Define storage types.
using VerificationStorage = HierarchicalSha256Storage;
- using AlignedStorage = AlignmentMatchingStoragePooledBuffer<1>;
// Validate the hash data.
R_UNLESS(Common::IsPowerOfTwo(hash_data.hash_block_size),
@@ -1141,13 +1152,8 @@ Result NcaFileSystemDriver::CreateSha256Storage(
hash_data.hash_block_size,
buffer_hold_storage->GetBuffer(), hash_buffer_size));
- // Make the aligned storage.
- auto aligned_storage = std::make_shared<AlignedStorage>(std::move(verification_storage),
- hash_data.hash_block_size);
- R_UNLESS(aligned_storage != nullptr, ResultAllocationMemoryFailedAllocateShared);
-
// Set the output.
- *out = std::move(aligned_storage);
+ *out = std::move(verification_storage);
R_SUCCEED();
}