Files
dolphin/Source/Core/DiscIO/DiscScrubber.h
T

82 lines
2.0 KiB
C++
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-18 01:08:10 +02:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
2014-11-13 21:28:27 -05:00
// DiscScrubber removes the garbage data from discs (currently Wii only) which
// is on the disc due to encryption
2014-11-13 21:28:27 -05:00
// It could be adapted to GameCube discs, but the gain is most likely negligible,
// and having 1:1 backups of discs is always nice when they are reasonably sized
// Note: the technique is inspired by Wiiscrubber, but much simpler - intentionally :)
#pragma once
2017-01-04 14:31:38 -05:00
#include <array>
#include <memory>
2014-03-12 15:33:41 -04:00
#include <string>
2017-01-04 14:31:38 -05:00
#include <vector>
2014-02-17 05:18:15 -05:00
#include "Common/CommonTypes.h"
namespace File
{
class IOFile;
}
namespace DiscIO
{
2015-08-08 19:59:33 +02:00
class FileInfo;
class Volume;
struct Partition;
2017-01-04 14:31:38 -05:00
class DiscScrubber final
{
public:
DiscScrubber();
~DiscScrubber();
bool SetupScrub(const std::string& filename, int block_size);
size_t GetNextBlock(File::IOFile& in, u8* buffer);
private:
struct PartitionHeader final
2017-01-04 14:31:38 -05:00
{
u8* ticket[0x2a4];
u32 tmd_size;
u64 tmd_offset;
u32 cert_chain_size;
u64 cert_chain_offset;
2017-01-04 14:31:38 -05:00
// H3Size is always 0x18000
u64 h3_offset;
u64 data_offset;
u64 data_size;
2017-01-04 14:31:38 -05:00
// TMD would be here
u64 dol_offset;
u64 dol_size;
u64 fst_offset;
u64 fst_size;
u32 apploader_size;
u32 apploader_trailer_size;
2017-01-04 14:31:38 -05:00
};
void MarkAsUsed(u64 offset, u64 size);
void MarkAsUsedE(u64 partition_data_offset, u64 offset, u64 size);
2018-09-20 19:32:52 +02:00
u64 ToClusterOffset(u64 offset) const;
bool ReadFromVolume(u64 offset, u32& buffer, const Partition& partition);
bool ReadFromVolume(u64 offset, u64& buffer, const Partition& partition);
2017-01-04 14:31:38 -05:00
bool ParseDisc();
bool ParsePartitionData(const Partition& partition, PartitionHeader* header);
2015-08-08 19:59:33 +02:00
void ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory);
2017-01-04 14:31:38 -05:00
std::string m_filename;
std::unique_ptr<Volume> m_disc;
2017-01-04 14:31:38 -05:00
std::vector<u8> m_free_table;
u64 m_file_size = 0;
u64 m_block_count = 0;
u32 m_block_size = 0;
bool m_is_scrubbing = false;
2017-01-04 14:31:38 -05:00
};
} // namespace DiscIO