Lines Matching refs:volume

52 u64 ReadFile(const Volume& volume, const Partition& partition, const FileInfo* file_info,  in ReadFile()  argument
66 if (!volume.Read(file_info->GetOffset() + offset_in_file, read_length, buffer, partition)) in ReadFile()
72 u64 ReadFile(const Volume& volume, const Partition& partition, std::string_view path, u8* buffer, in ReadFile() argument
75 const FileSystem* file_system = volume.GetFileSystem(partition); in ReadFile()
79 return ReadFile(volume, partition, file_system->FindFileInfo(path).get(), buffer, max_buffer_size, in ReadFile()
83 bool ExportData(const Volume& volume, const Partition& partition, u64 offset, u64 size, in ExportData() argument
97 if (!volume.Read(offset, read_size, buffer.data(), partition)) in ExportData()
110 bool ExportFile(const Volume& volume, const Partition& partition, const FileInfo* file_info, in ExportFile() argument
116 return ExportData(volume, partition, file_info->GetOffset(), file_info->GetSize(), in ExportFile()
120 bool ExportFile(const Volume& volume, const Partition& partition, std::string_view path, in ExportFile() argument
123 const FileSystem* file_system = volume.GetFileSystem(partition); in ExportFile()
127 return ExportFile(volume, partition, file_system->FindFileInfo(path).get(), export_filename); in ExportFile()
130 void ExportDirectory(const Volume& volume, const Partition& partition, const FileInfo& directory, in ExportDirectory() argument
152 else if (!ExportFile(volume, partition, &file_info, export_path)) in ExportDirectory()
157 ExportDirectory(volume, partition, file_info, recursive, path, export_path, update_progress); in ExportDirectory()
162 bool ExportWiiUnencryptedHeader(const Volume& volume, const std::string& export_filename) in ExportWiiUnencryptedHeader() argument
164 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportWiiUnencryptedHeader()
167 return ExportData(volume, PARTITION_NONE, 0, 0x100, export_filename); in ExportWiiUnencryptedHeader()
170 bool ExportWiiRegionData(const Volume& volume, const std::string& export_filename) in ExportWiiRegionData() argument
172 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportWiiRegionData()
175 return ExportData(volume, PARTITION_NONE, 0x4E000, 0x20, export_filename); in ExportWiiRegionData()
178 bool ExportTicket(const Volume& volume, const Partition& partition, in ExportTicket() argument
181 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportTicket()
184 return ExportData(volume, PARTITION_NONE, partition.offset, 0x2a4, export_filename); in ExportTicket()
187 bool ExportTMD(const Volume& volume, const Partition& partition, const std::string& export_filename) in ExportTMD() argument
189 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportTMD()
192 const std::optional<u32> size = volume.ReadSwapped<u32>(partition.offset + 0x2a4, PARTITION_NONE); in ExportTMD()
194 volume.ReadSwappedAndShifted(partition.offset + 0x2a8, PARTITION_NONE); in ExportTMD()
198 return ExportData(volume, PARTITION_NONE, partition.offset + *offset, *size, export_filename); in ExportTMD()
201 bool ExportCertificateChain(const Volume& volume, const Partition& partition, in ExportCertificateChain() argument
204 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportCertificateChain()
207 const std::optional<u32> size = volume.ReadSwapped<u32>(partition.offset + 0x2ac, PARTITION_NONE); in ExportCertificateChain()
209 volume.ReadSwappedAndShifted(partition.offset + 0x2b0, PARTITION_NONE); in ExportCertificateChain()
213 return ExportData(volume, PARTITION_NONE, partition.offset + *offset, *size, export_filename); in ExportCertificateChain()
216 bool ExportH3Hashes(const Volume& volume, const Partition& partition, in ExportH3Hashes() argument
219 if (volume.GetVolumeType() != Platform::WiiDisc) in ExportH3Hashes()
223 volume.ReadSwappedAndShifted(partition.offset + 0x2b4, PARTITION_NONE); in ExportH3Hashes()
227 return ExportData(volume, PARTITION_NONE, partition.offset + *offset, 0x18000, export_filename); in ExportH3Hashes()
230 bool ExportHeader(const Volume& volume, const Partition& partition, in ExportHeader() argument
233 if (!IsDisc(volume.GetVolumeType())) in ExportHeader()
236 return ExportData(volume, partition, 0, 0x440, export_filename); in ExportHeader()
239 bool ExportBI2Data(const Volume& volume, const Partition& partition, in ExportBI2Data() argument
242 if (!IsDisc(volume.GetVolumeType())) in ExportBI2Data()
245 return ExportData(volume, partition, 0x440, 0x2000, export_filename); in ExportBI2Data()
248 std::optional<u64> GetApploaderSize(const Volume& volume, const Partition& partition) in GetApploaderSize() argument
251 const std::optional<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition); in GetApploaderSize()
252 const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(0x2440 + 0x18, partition); in GetApploaderSize()
259 bool ExportApploader(const Volume& volume, const Partition& partition, in ExportApploader() argument
262 if (!IsDisc(volume.GetVolumeType())) in ExportApploader()
265 const std::optional<u64> apploader_size = GetApploaderSize(volume, partition); in ExportApploader()
269 return ExportData(volume, partition, 0x2440, *apploader_size, export_filename); in ExportApploader()
272 std::optional<u64> GetBootDOLOffset(const Volume& volume, const Partition& partition) in GetBootDOLOffset() argument
274 const Platform volume_type = volume.GetVolumeType(); in GetBootDOLOffset()
278 std::optional<u64> dol_offset = volume.ReadSwappedAndShifted(0x420, partition); in GetBootDOLOffset()
287 std::optional<u32> GetBootDOLSize(const Volume& volume, const Partition& partition, u64 dol_offset) in GetBootDOLSize() argument
289 if (!IsDisc(volume.GetVolumeType())) in GetBootDOLSize()
297 const std::optional<u32> offset = volume.ReadSwapped<u32>(dol_offset + 0x00 + i * 4, partition); in GetBootDOLSize()
298 const std::optional<u32> size = volume.ReadSwapped<u32>(dol_offset + 0x90 + i * 4, partition); in GetBootDOLSize()
307 const std::optional<u32> offset = volume.ReadSwapped<u32>(dol_offset + 0x1c + i * 4, partition); in GetBootDOLSize()
308 const std::optional<u32> size = volume.ReadSwapped<u32>(dol_offset + 0xac + i * 4, partition); in GetBootDOLSize()
317 bool ExportDOL(const Volume& volume, const Partition& partition, const std::string& export_filename) in ExportDOL() argument
319 if (!IsDisc(volume.GetVolumeType())) in ExportDOL()
322 const std::optional<u64> dol_offset = GetBootDOLOffset(volume, partition); in ExportDOL()
325 const std::optional<u32> dol_size = GetBootDOLSize(volume, partition, *dol_offset); in ExportDOL()
329 return ExportData(volume, partition, *dol_offset, *dol_size, export_filename); in ExportDOL()
332 std::optional<u64> GetFSTOffset(const Volume& volume, const Partition& partition) in GetFSTOffset() argument
334 const Platform volume_type = volume.GetVolumeType(); in GetFSTOffset()
338 return volume.ReadSwappedAndShifted(0x424, partition); in GetFSTOffset()
341 std::optional<u64> GetFSTSize(const Volume& volume, const Partition& partition) in GetFSTSize() argument
343 const Platform volume_type = volume.GetVolumeType(); in GetFSTSize()
347 return volume.ReadSwappedAndShifted(0x428, partition); in GetFSTSize()
350 bool ExportFST(const Volume& volume, const Partition& partition, const std::string& export_filename) in ExportFST() argument
352 if (!IsDisc(volume.GetVolumeType())) in ExportFST()
355 const std::optional<u64> fst_offset = GetFSTOffset(volume, partition); in ExportFST()
356 const std::optional<u64> fst_size = GetFSTSize(volume, partition); in ExportFST()
360 return ExportData(volume, partition, *fst_offset, *fst_size, export_filename); in ExportFST()
363 bool ExportSystemData(const Volume& volume, const Partition& partition, in ExportSystemData() argument
369 success &= ExportHeader(volume, partition, export_folder + "/sys/boot.bin"); in ExportSystemData()
370 success &= ExportBI2Data(volume, partition, export_folder + "/sys/bi2.bin"); in ExportSystemData()
371 success &= ExportApploader(volume, partition, export_folder + "/sys/apploader.img"); in ExportSystemData()
372 success &= ExportDOL(volume, partition, export_folder + "/sys/main.dol"); in ExportSystemData()
373 success &= ExportFST(volume, partition, export_folder + "/sys/fst.bin"); in ExportSystemData()
375 if (volume.GetVolumeType() == Platform::WiiDisc) in ExportSystemData()
378 success &= ExportWiiUnencryptedHeader(volume, export_folder + "/disc/header.bin"); in ExportSystemData()
379 success &= ExportWiiRegionData(volume, export_folder + "/disc/region.bin"); in ExportSystemData()
381 success &= ExportTicket(volume, partition, export_folder + "/ticket.bin"); in ExportSystemData()
382 success &= ExportTMD(volume, partition, export_folder + "/tmd.bin"); in ExportSystemData()
383 success &= ExportCertificateChain(volume, partition, export_folder + "/cert.bin"); in ExportSystemData()
384 if (volume.IsEncryptedAndHashed()) in ExportSystemData()
385 success &= ExportH3Hashes(volume, partition, export_folder + "/h3.bin"); in ExportSystemData()