2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-05-21 13:19:15 -06:00
|
|
|
|
2020-04-10 07:53:14 -06:00
|
|
|
// DiscScrubber removes the pseudorandom padding data from discs
|
2009-05-21 13:19:15 -06:00
|
|
|
|
|
|
|
// Note: the technique is inspired by Wiiscrubber, but much simpler - intentionally :)
|
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-05-21 13:19:15 -06:00
|
|
|
|
2017-01-04 12:31:38 -07:00
|
|
|
#include <array>
|
2014-03-12 13:33:41 -06:00
|
|
|
#include <string>
|
2017-01-04 12:31:38 -07:00
|
|
|
#include <vector>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2009-05-21 13:19:15 -06:00
|
|
|
|
2014-02-20 17:47:53 -07:00
|
|
|
namespace File
|
|
|
|
{
|
|
|
|
class IOFile;
|
|
|
|
}
|
2009-05-21 13:19:15 -06:00
|
|
|
|
|
|
|
namespace DiscIO
|
|
|
|
{
|
2015-08-08 11:59:33 -06:00
|
|
|
class FileInfo;
|
2017-06-06 03:49:01 -06:00
|
|
|
class Volume;
|
2015-06-13 04:51:24 -06:00
|
|
|
struct Partition;
|
2017-01-04 12:31:38 -07:00
|
|
|
|
|
|
|
class DiscScrubber final
|
2009-05-21 13:19:15 -06:00
|
|
|
{
|
2017-01-04 12:31:38 -07:00
|
|
|
public:
|
|
|
|
DiscScrubber();
|
|
|
|
|
2023-08-19 09:14:35 -06:00
|
|
|
bool SetupScrub(const Volume& disc);
|
2020-04-04 12:56:20 -06:00
|
|
|
|
|
|
|
// Returns true if the specified 32 KiB block only contains unused data
|
2019-03-30 09:20:45 -06:00
|
|
|
bool CanBlockBeScrubbed(u64 offset) const;
|
2017-01-04 12:31:38 -07:00
|
|
|
|
2020-04-10 09:40:07 -06:00
|
|
|
static constexpr size_t CLUSTER_SIZE = 0x8000;
|
|
|
|
|
2017-01-04 12:31:38 -07:00
|
|
|
private:
|
|
|
|
void MarkAsUsed(u64 offset, u64 size);
|
|
|
|
void MarkAsUsedE(u64 partition_data_offset, u64 offset, u64 size);
|
2018-09-20 11:32:52 -06:00
|
|
|
u64 ToClusterOffset(u64 offset) const;
|
2023-08-19 09:14:35 -06:00
|
|
|
bool ReadFromVolume(const Volume& disc, u64 offset, u32& buffer, const Partition& partition);
|
|
|
|
bool ReadFromVolume(const Volume& disc, u64 offset, u64& buffer, const Partition& partition);
|
|
|
|
bool ParseDisc(const Volume& disc);
|
|
|
|
bool ParsePartitionData(const Volume& disc, const Partition& partition);
|
2015-08-08 11:59:33 -06:00
|
|
|
void ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory);
|
2017-01-04 12:31:38 -07:00
|
|
|
|
2017-01-04 13:39:27 -07:00
|
|
|
std::vector<u8> m_free_table;
|
|
|
|
u64 m_file_size = 0;
|
2023-08-19 09:14:35 -06:00
|
|
|
bool m_has_wii_hashes = false;
|
2017-01-04 13:39:27 -07:00
|
|
|
bool m_is_scrubbing = false;
|
2017-01-04 12:31:38 -07:00
|
|
|
};
|
2009-05-21 13:19:15 -06:00
|
|
|
|
|
|
|
} // namespace DiscIO
|