DiscScrubber.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // DiscScrubber removes the pseudorandom padding data from discs
  4. // Note: the technique is inspired by Wiiscrubber, but much simpler - intentionally :)
  5. #pragma once
  6. #include <array>
  7. #include <string>
  8. #include <vector>
  9. #include "Common/CommonTypes.h"
  10. namespace File
  11. {
  12. class IOFile;
  13. }
  14. namespace DiscIO
  15. {
  16. class FileInfo;
  17. class Volume;
  18. struct Partition;
  19. class DiscScrubber final
  20. {
  21. public:
  22. DiscScrubber();
  23. bool SetupScrub(const Volume& disc);
  24. // Returns true if the specified 32 KiB block only contains unused data
  25. bool CanBlockBeScrubbed(u64 offset) const;
  26. static constexpr size_t CLUSTER_SIZE = 0x8000;
  27. private:
  28. void MarkAsUsed(u64 offset, u64 size);
  29. void MarkAsUsedE(u64 partition_data_offset, u64 offset, u64 size);
  30. u64 ToClusterOffset(u64 offset) const;
  31. bool ReadFromVolume(const Volume& disc, u64 offset, u32& buffer, const Partition& partition);
  32. bool ReadFromVolume(const Volume& disc, u64 offset, u64& buffer, const Partition& partition);
  33. bool ParseDisc(const Volume& disc);
  34. bool ParsePartitionData(const Volume& disc, const Partition& partition);
  35. void ParseFileSystemData(u64 partition_data_offset, const FileInfo& directory);
  36. std::vector<u8> m_free_table;
  37. u64 m_file_size = 0;
  38. bool m_has_wii_hashes = false;
  39. bool m_is_scrubbing = false;
  40. };
  41. } // namespace DiscIO