mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
DiscIO: Remove C/I/S prefixes from class names
These prefixes were inconsistent with the rest of Dolphin.
I'm also renaming VolumeWiiCrypted to VolumeWii because of 1113b13
.
This commit is contained in:
@ -173,7 +173,7 @@ u32 SectorReader::ReadChunk(u8* buffer, u64 chunk_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename)
|
||||
std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename)
|
||||
{
|
||||
if (cdio_is_cdrom(filename))
|
||||
return DriveReader::Create(filename);
|
||||
|
@ -36,10 +36,10 @@ enum class BlobType
|
||||
TGC
|
||||
};
|
||||
|
||||
class IBlobReader
|
||||
class BlobReader
|
||||
{
|
||||
public:
|
||||
virtual ~IBlobReader() {}
|
||||
virtual ~BlobReader() {}
|
||||
virtual BlobType GetBlobType() const = 0;
|
||||
virtual u64 GetRawSize() const = 0;
|
||||
virtual u64 GetDataSize() const = 0;
|
||||
@ -56,13 +56,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
IBlobReader() {}
|
||||
BlobReader() {}
|
||||
};
|
||||
|
||||
// Provides caching and byte-operation-to-block-operations facilities.
|
||||
// Used for compressed blob and direct drive reading.
|
||||
// NOTE: GetDataSize() is expected to be evenly divisible by the sector size.
|
||||
class SectorReader : public IBlobReader
|
||||
class SectorReader : public BlobReader
|
||||
{
|
||||
public:
|
||||
virtual ~SectorReader() = 0;
|
||||
@ -147,8 +147,8 @@ private:
|
||||
std::array<Cache, CACHE_LINES> m_cache;
|
||||
};
|
||||
|
||||
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
|
||||
std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename);
|
||||
// Factory function - examines the path to choose the right type of BlobReader, and returns one.
|
||||
std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename);
|
||||
|
||||
typedef bool (*CompressCB)(const std::string& text, float percent, void* arg);
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct CISOHeader
|
||||
u8 map[CISO_MAP_SIZE];
|
||||
};
|
||||
|
||||
class CISOFileReader : public IBlobReader
|
||||
class CISOFileReader : public BlobReader
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<CISOFileReader> Create(File::IOFile file);
|
||||
|
@ -16,7 +16,7 @@ set(SRCS
|
||||
VolumeDirectory.cpp
|
||||
VolumeGC.cpp
|
||||
VolumeWad.cpp
|
||||
VolumeWiiCrypted.cpp
|
||||
VolumeWii.cpp
|
||||
WiiWad.cpp
|
||||
)
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
<ClCompile Include="VolumeDirectory.cpp" />
|
||||
<ClCompile Include="VolumeGC.cpp" />
|
||||
<ClCompile Include="VolumeWad.cpp" />
|
||||
<ClCompile Include="VolumeWiiCrypted.cpp" />
|
||||
<ClCompile Include="VolumeWii.cpp" />
|
||||
<ClCompile Include="WbfsBlob.cpp" />
|
||||
<ClCompile Include="WiiWad.cpp" />
|
||||
</ItemGroup>
|
||||
@ -73,7 +73,7 @@
|
||||
<ClInclude Include="VolumeDirectory.h" />
|
||||
<ClInclude Include="VolumeGC.h" />
|
||||
<ClInclude Include="VolumeWad.h" />
|
||||
<ClInclude Include="VolumeWiiCrypted.h" />
|
||||
<ClInclude Include="VolumeWii.h" />
|
||||
<ClInclude Include="WbfsBlob.h" />
|
||||
<ClInclude Include="WiiWad.h" />
|
||||
</ItemGroup>
|
||||
|
@ -63,10 +63,10 @@
|
||||
<ClCompile Include="VolumeWad.cpp">
|
||||
<Filter>Volume</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VolumeWiiCrypted.cpp">
|
||||
<ClCompile Include="Enums.cpp">
|
||||
<Filter>Volume</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Enums.cpp">
|
||||
<ClCompile Include="VolumeWii.cpp">
|
||||
<Filter>Volume</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Volume.cpp">
|
||||
@ -125,7 +125,7 @@
|
||||
<ClInclude Include="VolumeWad.h">
|
||||
<Filter>Volume</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VolumeWiiCrypted.h">
|
||||
<ClInclude Include="VolumeWii.h">
|
||||
<Filter>Volume</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Enums.h">
|
||||
|
@ -179,7 +179,7 @@ bool DiscScrubber::ParseDisc()
|
||||
// Operations dealing with encrypted space are done here
|
||||
bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeader* header)
|
||||
{
|
||||
std::unique_ptr<IFileSystem> filesystem(CreateFileSystem(m_disc.get(), partition));
|
||||
std::unique_ptr<FileSystem> filesystem(CreateFileSystem(m_disc.get(), partition));
|
||||
if (!filesystem)
|
||||
{
|
||||
ERROR_LOG(DISCIO, "Failed to read file system for the partition at 0x%" PRIx64,
|
||||
@ -219,7 +219,7 @@ bool DiscScrubber::ParsePartitionData(const Partition& partition, PartitionHeade
|
||||
MarkAsUsedE(partition_data_offset, header->fst_offset, header->fst_size);
|
||||
|
||||
// Go through the filesystem and mark entries as used
|
||||
for (const SFileInfo& file : filesystem->GetFileList())
|
||||
for (const FileInfo& file : filesystem->GetFileList())
|
||||
{
|
||||
DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str());
|
||||
if ((file.m_NameOffset & 0x1000000) == 0)
|
||||
|
@ -25,7 +25,7 @@ class IOFile;
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IVolume;
|
||||
class Volume;
|
||||
struct Partition;
|
||||
|
||||
class DiscScrubber final
|
||||
@ -66,7 +66,7 @@ private:
|
||||
bool ParsePartitionData(const Partition& partition, PartitionHeader* header);
|
||||
|
||||
std::string m_filename;
|
||||
std::unique_ptr<IVolume> m_disc;
|
||||
std::unique_ptr<Volume> m_disc;
|
||||
|
||||
std::vector<u8> m_free_table;
|
||||
u64 m_file_size = 0;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class PlainFileReader : public IBlobReader
|
||||
class PlainFileReader : public BlobReader
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<PlainFileReader> Create(File::IOFile file);
|
||||
|
@ -22,23 +22,23 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CFileSystemGCWii::CFileSystemGCWii(const IVolume* _rVolume, const Partition& partition)
|
||||
: IFileSystem(_rVolume, partition), m_Initialized(false), m_Valid(false), m_offset_shift(0)
|
||||
FileSystemGCWii::FileSystemGCWii(const Volume* _rVolume, const Partition& partition)
|
||||
: FileSystem(_rVolume, partition), m_Initialized(false), m_Valid(false), m_offset_shift(0)
|
||||
{
|
||||
m_Valid = DetectFileSystem();
|
||||
}
|
||||
|
||||
CFileSystemGCWii::~CFileSystemGCWii()
|
||||
FileSystemGCWii::~FileSystemGCWii()
|
||||
{
|
||||
m_FileInfoVector.clear();
|
||||
}
|
||||
|
||||
u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
||||
u64 FileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo != nullptr && !pFileInfo->IsDirectory())
|
||||
return pFileInfo->m_FileSize;
|
||||
@ -46,7 +46,7 @@ u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string CFileSystemGCWii::GetFileName(u64 _Address)
|
||||
std::string FileSystemGCWii::GetFileName(u64 _Address)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
@ -62,13 +62,13 @@ std::string CFileSystemGCWii::GetFileName(u64 _Address)
|
||||
return "";
|
||||
}
|
||||
|
||||
u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
u64 _OffsetInFile)
|
||||
u64 FileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
u64 _OffsetInFile)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
if (pFileInfo == nullptr)
|
||||
return 0;
|
||||
|
||||
@ -77,22 +77,21 @@ u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64
|
||||
|
||||
u64 read_length = std::min(_MaxBufferSize, pFileInfo->m_FileSize - _OffsetInFile);
|
||||
|
||||
DEBUG_LOG(DISCIO, "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64
|
||||
" Size: %" PRIx64,
|
||||
read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset,
|
||||
pFileInfo->m_FileSize);
|
||||
DEBUG_LOG(
|
||||
DISCIO,
|
||||
"Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64 " Size: %" PRIx64,
|
||||
read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset, pFileInfo->m_FileSize);
|
||||
|
||||
m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_partition);
|
||||
return read_length;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath,
|
||||
const std::string& _rExportFilename)
|
||||
bool FileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (!pFileInfo)
|
||||
return false;
|
||||
@ -127,7 +126,7 @@ bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath,
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
||||
bool FileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
||||
{
|
||||
std::optional<u32> apploader_size = m_rVolume->ReadSwapped<u32>(0x2440 + 0x14, m_partition);
|
||||
const std::optional<u32> trailer_size = m_rVolume->ReadSwapped<u32>(0x2440 + 0x18, m_partition);
|
||||
@ -153,13 +152,13 @@ bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<u64> CFileSystemGCWii::GetBootDOLOffset() const
|
||||
std::optional<u64> FileSystemGCWii::GetBootDOLOffset() const
|
||||
{
|
||||
std::optional<u32> offset = m_rVolume->ReadSwapped<u32>(0x420, m_partition);
|
||||
return offset ? static_cast<u64>(*offset) << 2 : std::optional<u64>();
|
||||
}
|
||||
|
||||
std::optional<u32> CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
std::optional<u32> FileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
{
|
||||
u32 dol_size = 0;
|
||||
|
||||
@ -179,9 +178,9 @@ std::optional<u32> CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
for (u8 i = 0; i < 11; i++)
|
||||
{
|
||||
const std::optional<u32> offset =
|
||||
m_rVolume->ReadSwapped<u32>(dol_offset + 0x1c + i * 4, m_partition);
|
||||
m_rVolume->ReadSwapped<u32>(dol_offset + 0x1c + i * 4, m_partition);
|
||||
const std::optional<u32> size =
|
||||
m_rVolume->ReadSwapped<u32>(dol_offset + 0xac + i * 4, m_partition);
|
||||
m_rVolume->ReadSwapped<u32>(dol_offset + 0xac + i * 4, m_partition);
|
||||
if (!offset || !size)
|
||||
return {};
|
||||
dol_size = std::max(*offset + *size, dol_size);
|
||||
@ -190,7 +189,7 @@ std::optional<u32> CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
return dol_size;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
||||
bool FileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
||||
{
|
||||
std::optional<u64> dol_offset = GetBootDOLOffset();
|
||||
if (!dol_offset)
|
||||
@ -215,7 +214,7 @@ bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CFileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
||||
std::string FileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
||||
{
|
||||
std::string data(255, 0x00);
|
||||
m_rVolume->Read(_Offset, data.size(), (u8*)&data[0], m_partition);
|
||||
@ -226,7 +225,7 @@ std::string CFileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
||||
return SHIFTJISToUTF8(data);
|
||||
}
|
||||
|
||||
const std::vector<SFileInfo>& CFileSystemGCWii::GetFileList()
|
||||
const std::vector<FileInfo>& FileSystemGCWii::GetFileList()
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
@ -234,7 +233,7 @@ const std::vector<SFileInfo>& CFileSystemGCWii::GetFileList()
|
||||
return m_FileInfoVector;
|
||||
}
|
||||
|
||||
const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
const FileInfo* FileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
@ -248,7 +247,7 @@ const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::DetectFileSystem()
|
||||
bool FileSystemGCWii::DetectFileSystem()
|
||||
{
|
||||
if (m_rVolume->ReadSwapped<u32>(0x18, m_partition) == u32(0x5D1C9EA3))
|
||||
{
|
||||
@ -264,7 +263,7 @@ bool CFileSystemGCWii::DetectFileSystem()
|
||||
return false;
|
||||
}
|
||||
|
||||
void CFileSystemGCWii::InitFileSystem()
|
||||
void FileSystemGCWii::InitFileSystem()
|
||||
{
|
||||
m_Initialized = true;
|
||||
|
||||
@ -280,8 +279,7 @@ void CFileSystemGCWii::InitFileSystem()
|
||||
const std::optional<u32> root_size = m_rVolume->ReadSwapped<u32>(FSTOffset + 0x8, m_partition);
|
||||
if (!root_name_offset || !root_offset || !root_size)
|
||||
return;
|
||||
SFileInfo root = {*root_name_offset, static_cast<u64>(*root_offset) << m_offset_shift,
|
||||
*root_size};
|
||||
FileInfo root = {*root_name_offset, static_cast<u64>(*root_offset) << m_offset_shift, *root_size};
|
||||
|
||||
if (!root.IsDirectory())
|
||||
return;
|
||||
@ -318,14 +316,14 @@ void CFileSystemGCWii::InitFileSystem()
|
||||
BuildFilenames(1, m_FileInfoVector.size(), "", NameTableOffset);
|
||||
}
|
||||
|
||||
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex,
|
||||
const std::string& _szDirectory, u64 _NameTableOffset)
|
||||
size_t FileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex,
|
||||
const std::string& _szDirectory, u64 _NameTableOffset)
|
||||
{
|
||||
size_t CurrentIndex = _FirstIndex;
|
||||
|
||||
while (CurrentIndex < _LastIndex)
|
||||
{
|
||||
SFileInfo& rFileInfo = m_FileInfoVector[CurrentIndex];
|
||||
FileInfo& rFileInfo = m_FileInfoVector[CurrentIndex];
|
||||
u64 const uOffset = _NameTableOffset + (rFileInfo.m_NameOffset & 0xFFFFFF);
|
||||
std::string const offset_str{GetStringFromOffset(uOffset)};
|
||||
bool const is_dir = rFileInfo.IsDirectory();
|
||||
|
@ -14,18 +14,18 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IVolume;
|
||||
class Volume;
|
||||
struct Partition;
|
||||
|
||||
class CFileSystemGCWii : public IFileSystem
|
||||
class FileSystemGCWii : public FileSystem
|
||||
{
|
||||
public:
|
||||
CFileSystemGCWii(const IVolume* _rVolume, const Partition& partition);
|
||||
virtual ~CFileSystemGCWii();
|
||||
FileSystemGCWii(const Volume* _rVolume, const Partition& partition);
|
||||
virtual ~FileSystemGCWii();
|
||||
|
||||
bool IsValid() const override { return m_Valid; }
|
||||
u64 GetFileSize(const std::string& _rFullPath) override;
|
||||
const std::vector<SFileInfo>& GetFileList() override;
|
||||
const std::vector<FileInfo>& GetFileList() override;
|
||||
std::string GetFileName(u64 _Address) override;
|
||||
u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
u64 _OffsetInFile) override;
|
||||
@ -39,10 +39,10 @@ private:
|
||||
bool m_Initialized;
|
||||
bool m_Valid;
|
||||
u32 m_offset_shift;
|
||||
std::vector<SFileInfo> m_FileInfoVector;
|
||||
std::vector<FileInfo> m_FileInfoVector;
|
||||
|
||||
std::string GetStringFromOffset(u64 _Offset) const;
|
||||
const SFileInfo* FindFileInfo(const std::string& _rFullPath);
|
||||
const FileInfo* FindFileInfo(const std::string& _rFullPath);
|
||||
bool DetectFileSystem();
|
||||
void InitFileSystem();
|
||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex,
|
||||
|
@ -9,21 +9,21 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
IFileSystem::IFileSystem(const IVolume* _rVolume, const Partition& partition)
|
||||
FileSystem::FileSystem(const Volume* _rVolume, const Partition& partition)
|
||||
: m_rVolume(_rVolume), m_partition(partition)
|
||||
{
|
||||
}
|
||||
|
||||
IFileSystem::~IFileSystem()
|
||||
FileSystem::~FileSystem()
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<IFileSystem> CreateFileSystem(const IVolume* volume, const Partition& partition)
|
||||
std::unique_ptr<FileSystem> CreateFileSystem(const Volume* volume, const Partition& partition)
|
||||
{
|
||||
if (!volume)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<IFileSystem> filesystem = std::make_unique<CFileSystemGCWii>(volume, partition);
|
||||
std::unique_ptr<FileSystem> filesystem = std::make_unique<FileSystemGCWii>(volume, partition);
|
||||
|
||||
if (!filesystem)
|
||||
return nullptr;
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace DiscIO
|
||||
{
|
||||
// file info of an FST entry
|
||||
struct SFileInfo
|
||||
struct FileInfo
|
||||
{
|
||||
u64 m_NameOffset = 0u;
|
||||
u64 m_Offset = 0u;
|
||||
@ -23,23 +23,23 @@ struct SFileInfo
|
||||
std::string m_FullPath;
|
||||
|
||||
bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0; }
|
||||
SFileInfo(u64 name_offset, u64 offset, u64 filesize)
|
||||
FileInfo(u64 name_offset, u64 offset, u64 filesize)
|
||||
: m_NameOffset(name_offset), m_Offset(offset), m_FileSize(filesize)
|
||||
{
|
||||
}
|
||||
|
||||
SFileInfo(SFileInfo const&) = default;
|
||||
SFileInfo() = default;
|
||||
FileInfo(FileInfo const&) = default;
|
||||
FileInfo() = default;
|
||||
};
|
||||
|
||||
class IFileSystem
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
IFileSystem(const IVolume* _rVolume, const Partition& partition);
|
||||
FileSystem(const Volume* _rVolume, const Partition& partition);
|
||||
|
||||
virtual ~IFileSystem();
|
||||
virtual ~FileSystem();
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual const std::vector<SFileInfo>& GetFileList() = 0;
|
||||
virtual const std::vector<FileInfo>& GetFileList() = 0;
|
||||
virtual u64 GetFileSize(const std::string& _rFullPath) = 0;
|
||||
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
u64 _OffsetInFile = 0) = 0;
|
||||
@ -52,10 +52,10 @@ public:
|
||||
|
||||
virtual const Partition GetPartition() const { return m_partition; }
|
||||
protected:
|
||||
const IVolume* const m_rVolume;
|
||||
const Volume* const m_rVolume;
|
||||
const Partition m_partition;
|
||||
};
|
||||
|
||||
std::unique_ptr<IFileSystem> CreateFileSystem(const IVolume* volume, const Partition& partition);
|
||||
std::unique_ptr<FileSystem> CreateFileSystem(const Volume* volume, const Partition& partition);
|
||||
|
||||
} // namespace
|
||||
|
@ -32,26 +32,26 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CNANDContentData::~CNANDContentData() = default;
|
||||
NANDContentData::~NANDContentData() = default;
|
||||
|
||||
CNANDContentDataFile::CNANDContentDataFile(const std::string& filename) : m_filename{filename}
|
||||
NANDContentDataFile::NANDContentDataFile(const std::string& filename) : m_filename{filename}
|
||||
{
|
||||
}
|
||||
|
||||
CNANDContentDataFile::~CNANDContentDataFile() = default;
|
||||
NANDContentDataFile::~NANDContentDataFile() = default;
|
||||
|
||||
void CNANDContentDataFile::EnsureOpen()
|
||||
void NANDContentDataFile::EnsureOpen()
|
||||
{
|
||||
if (!m_file)
|
||||
m_file = std::make_unique<File::IOFile>(m_filename, "rb");
|
||||
else if (!m_file->IsOpen())
|
||||
m_file->Open(m_filename, "rb");
|
||||
}
|
||||
void CNANDContentDataFile::Open()
|
||||
void NANDContentDataFile::Open()
|
||||
{
|
||||
EnsureOpen();
|
||||
}
|
||||
std::vector<u8> CNANDContentDataFile::Get()
|
||||
std::vector<u8> NANDContentDataFile::Get()
|
||||
{
|
||||
EnsureOpen();
|
||||
|
||||
@ -68,7 +68,7 @@ std::vector<u8> CNANDContentDataFile::Get()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CNANDContentDataFile::GetRange(u32 start, u32 size, u8* buffer)
|
||||
bool NANDContentDataFile::GetRange(u32 start, u32 size, u8* buffer)
|
||||
{
|
||||
EnsureOpen();
|
||||
if (!m_file->IsGood())
|
||||
@ -79,13 +79,13 @@ bool CNANDContentDataFile::GetRange(u32 start, u32 size, u8* buffer)
|
||||
|
||||
return m_file->ReadBytes(buffer, static_cast<size_t>(size));
|
||||
}
|
||||
void CNANDContentDataFile::Close()
|
||||
void NANDContentDataFile::Close()
|
||||
{
|
||||
if (m_file && m_file->IsOpen())
|
||||
m_file->Close();
|
||||
}
|
||||
|
||||
bool CNANDContentDataBuffer::GetRange(u32 start, u32 size, u8* buffer)
|
||||
bool NANDContentDataBuffer::GetRange(u32 start, u32 size, u8* buffer)
|
||||
{
|
||||
if (start + size > m_buffer.size())
|
||||
return false;
|
||||
@ -94,22 +94,22 @@ bool CNANDContentDataBuffer::GetRange(u32 start, u32 size, u8* buffer)
|
||||
return true;
|
||||
}
|
||||
|
||||
CNANDContentLoader::CNANDContentLoader(const std::string& content_name, Common::FromWhichRoot from)
|
||||
NANDContentLoader::NANDContentLoader(const std::string& content_name, Common::FromWhichRoot from)
|
||||
: m_root(from)
|
||||
{
|
||||
m_Valid = Initialize(content_name);
|
||||
}
|
||||
|
||||
CNANDContentLoader::~CNANDContentLoader()
|
||||
NANDContentLoader::~NANDContentLoader()
|
||||
{
|
||||
}
|
||||
|
||||
bool CNANDContentLoader::IsValid() const
|
||||
bool NANDContentLoader::IsValid() const
|
||||
{
|
||||
return m_Valid;
|
||||
}
|
||||
|
||||
const SNANDContent* CNANDContentLoader::GetContentByID(u32 id) const
|
||||
const NANDContent* NANDContentLoader::GetContentByID(u32 id) const
|
||||
{
|
||||
const auto iterator = std::find_if(m_Content.begin(), m_Content.end(), [id](const auto& content) {
|
||||
return content.m_metadata.id == id;
|
||||
@ -117,7 +117,7 @@ const SNANDContent* CNANDContentLoader::GetContentByID(u32 id) const
|
||||
return iterator != m_Content.end() ? &*iterator : nullptr;
|
||||
}
|
||||
|
||||
const SNANDContent* CNANDContentLoader::GetContentByIndex(int index) const
|
||||
const NANDContent* NANDContentLoader::GetContentByIndex(int index) const
|
||||
{
|
||||
for (auto& Content : m_Content)
|
||||
{
|
||||
@ -129,7 +129,7 @@ const SNANDContent* CNANDContentLoader::GetContentByIndex(int index) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CNANDContentLoader::Initialize(const std::string& name)
|
||||
bool NANDContentLoader::Initialize(const std::string& name)
|
||||
{
|
||||
if (name.empty())
|
||||
return false;
|
||||
@ -173,7 +173,7 @@ bool CNANDContentLoader::Initialize(const std::string& name)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& data_app)
|
||||
void NANDContentLoader::InitializeContentEntries(const std::vector<u8>& data_app)
|
||||
{
|
||||
if (!m_ticket.IsValid())
|
||||
{
|
||||
@ -201,7 +201,7 @@ void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& data_ap
|
||||
|
||||
u32 rounded_size = Common::AlignUp(static_cast<u32>(content.size), 0x40);
|
||||
|
||||
m_Content[i].m_Data = std::make_unique<CNANDContentDataBuffer>(Common::AES::Decrypt(
|
||||
m_Content[i].m_Data = std::make_unique<NANDContentDataBuffer>(Common::AES::Decrypt(
|
||||
title_key.data(), iv.data(), &data_app[data_app_offset], rounded_size));
|
||||
data_app_offset += rounded_size;
|
||||
}
|
||||
@ -213,37 +213,36 @@ void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& data_ap
|
||||
else
|
||||
filename = StringFromFormat("%s/%08x.app", m_Path.c_str(), content.id);
|
||||
|
||||
m_Content[i].m_Data = std::make_unique<CNANDContentDataFile>(filename);
|
||||
m_Content[i].m_Data = std::make_unique<NANDContentDataFile>(filename);
|
||||
}
|
||||
|
||||
m_Content[i].m_metadata = std::move(content);
|
||||
}
|
||||
}
|
||||
|
||||
CNANDContentManager::~CNANDContentManager()
|
||||
NANDContentManager::~NANDContentManager()
|
||||
{
|
||||
}
|
||||
|
||||
const CNANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& content_path,
|
||||
Common::FromWhichRoot from)
|
||||
const NANDContentLoader& NANDContentManager::GetNANDLoader(const std::string& content_path,
|
||||
Common::FromWhichRoot from)
|
||||
{
|
||||
auto it = m_map.find(content_path);
|
||||
if (it != m_map.end())
|
||||
return *it->second;
|
||||
return *m_map
|
||||
.emplace_hint(it, std::make_pair(content_path, std::make_unique<CNANDContentLoader>(
|
||||
.emplace_hint(it, std::make_pair(content_path, std::make_unique<NANDContentLoader>(
|
||||
content_path, from)))
|
||||
->second;
|
||||
}
|
||||
|
||||
const CNANDContentLoader& CNANDContentManager::GetNANDLoader(u64 title_id,
|
||||
Common::FromWhichRoot from)
|
||||
const NANDContentLoader& NANDContentManager::GetNANDLoader(u64 title_id, Common::FromWhichRoot from)
|
||||
{
|
||||
std::string path = Common::GetTitleContentPath(title_id, from);
|
||||
return GetNANDLoader(path, from);
|
||||
}
|
||||
|
||||
void CNANDContentManager::ClearCache()
|
||||
void NANDContentManager::ClearCache()
|
||||
{
|
||||
m_map.clear();
|
||||
}
|
||||
|
@ -26,21 +26,21 @@ enum class Region;
|
||||
// TODO: move some of these to Core/IOS/ES.
|
||||
IOS::ES::TicketReader FindSignedTicket(u64 title_id);
|
||||
|
||||
class CNANDContentData
|
||||
class NANDContentData
|
||||
{
|
||||
public:
|
||||
virtual ~CNANDContentData() = 0;
|
||||
virtual ~NANDContentData() = 0;
|
||||
virtual void Open() {}
|
||||
virtual std::vector<u8> Get() = 0;
|
||||
virtual bool GetRange(u32 start, u32 size, u8* buffer) = 0;
|
||||
virtual void Close() {}
|
||||
};
|
||||
|
||||
class CNANDContentDataFile final : public CNANDContentData
|
||||
class NANDContentDataFile final : public NANDContentData
|
||||
{
|
||||
public:
|
||||
explicit CNANDContentDataFile(const std::string& filename);
|
||||
~CNANDContentDataFile();
|
||||
explicit NANDContentDataFile(const std::string& filename);
|
||||
~NANDContentDataFile();
|
||||
|
||||
void Open() override;
|
||||
std::vector<u8> Get() override;
|
||||
@ -53,10 +53,11 @@ private:
|
||||
const std::string m_filename;
|
||||
std::unique_ptr<File::IOFile> m_file;
|
||||
};
|
||||
class CNANDContentDataBuffer final : public CNANDContentData
|
||||
|
||||
class NANDContentDataBuffer final : public NANDContentData
|
||||
{
|
||||
public:
|
||||
explicit CNANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer) {}
|
||||
explicit NANDContentDataBuffer(const std::vector<u8>& buffer) : m_buffer(buffer) {}
|
||||
std::vector<u8> Get() override { return m_buffer; }
|
||||
bool GetRange(u32 start, u32 size, u8* buffer) override;
|
||||
|
||||
@ -64,25 +65,25 @@ private:
|
||||
const std::vector<u8> m_buffer;
|
||||
};
|
||||
|
||||
struct SNANDContent
|
||||
struct NANDContent
|
||||
{
|
||||
IOS::ES::Content m_metadata;
|
||||
std::unique_ptr<CNANDContentData> m_Data;
|
||||
std::unique_ptr<NANDContentData> m_Data;
|
||||
};
|
||||
|
||||
// Instances of this class must be created by CNANDContentManager
|
||||
class CNANDContentLoader final
|
||||
// Instances of this class must be created by NANDContentManager
|
||||
class NANDContentLoader final
|
||||
{
|
||||
public:
|
||||
explicit CNANDContentLoader(const std::string& content_name, Common::FromWhichRoot from);
|
||||
~CNANDContentLoader();
|
||||
explicit NANDContentLoader(const std::string& content_name, Common::FromWhichRoot from);
|
||||
~NANDContentLoader();
|
||||
|
||||
bool IsValid() const;
|
||||
const SNANDContent* GetContentByID(u32 id) const;
|
||||
const SNANDContent* GetContentByIndex(int index) const;
|
||||
const NANDContent* GetContentByID(u32 id) const;
|
||||
const NANDContent* GetContentByIndex(int index) const;
|
||||
const IOS::ES::TMDReader& GetTMD() const { return m_tmd; }
|
||||
const IOS::ES::TicketReader& GetTicket() const { return m_ticket; }
|
||||
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
|
||||
const std::vector<NANDContent>& GetContent() const { return m_Content; }
|
||||
private:
|
||||
bool Initialize(const std::string& name);
|
||||
void InitializeContentEntries(const std::vector<u8>& data_app);
|
||||
@ -94,33 +95,33 @@ private:
|
||||
IOS::ES::TMDReader m_tmd;
|
||||
IOS::ES::TicketReader m_ticket;
|
||||
|
||||
std::vector<SNANDContent> m_Content;
|
||||
std::vector<NANDContent> m_Content;
|
||||
};
|
||||
|
||||
// we open the NAND Content files too often... let's cache them
|
||||
class CNANDContentManager
|
||||
class NANDContentManager
|
||||
{
|
||||
public:
|
||||
static CNANDContentManager& Access()
|
||||
static NANDContentManager& Access()
|
||||
{
|
||||
static CNANDContentManager instance;
|
||||
static NANDContentManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
const CNANDContentLoader&
|
||||
const NANDContentLoader&
|
||||
GetNANDLoader(const std::string& content_path,
|
||||
Common::FromWhichRoot from = Common::FROM_CONFIGURED_ROOT);
|
||||
const CNANDContentLoader&
|
||||
const NANDContentLoader&
|
||||
GetNANDLoader(u64 title_id, Common::FromWhichRoot from = Common::FROM_CONFIGURED_ROOT);
|
||||
void ClearCache();
|
||||
|
||||
private:
|
||||
CNANDContentManager() {}
|
||||
~CNANDContentManager();
|
||||
NANDContentManager() {}
|
||||
~NANDContentManager();
|
||||
|
||||
CNANDContentManager(CNANDContentManager const&) = delete;
|
||||
void operator=(CNANDContentManager const&) = delete;
|
||||
NANDContentManager(NANDContentManager const&) = delete;
|
||||
void operator=(NANDContentManager const&) = delete;
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<CNANDContentLoader>> m_map;
|
||||
std::unordered_map<std::string, std::unique_ptr<NANDContentLoader>> m_map;
|
||||
};
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void NANDImporter::ImportNANDBin(const std::string& path_to_bin,
|
||||
ExtractCertificates(nand_root);
|
||||
|
||||
// We have to clear the cache so the new NAND takes effect
|
||||
DiscIO::CNANDContentManager::Access().ClearCache();
|
||||
DiscIO::NANDContentManager::Access().ClearCache();
|
||||
}
|
||||
|
||||
bool NANDImporter::ReadNANDBin(const std::string& path_to_bin)
|
||||
|
@ -37,7 +37,7 @@ struct TGCHeader
|
||||
u32 unknown_important_2;
|
||||
};
|
||||
|
||||
class TGCFileReader final : public IBlobReader
|
||||
class TGCFileReader final : public BlobReader
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TGCFileReader> Create(File::IOFile file);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "DiscIO/VolumeDirectory.h"
|
||||
#include "DiscIO/VolumeGC.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
#include "DiscIO/VolumeWiiCrypted.h"
|
||||
#include "DiscIO/VolumeWii.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
@ -33,10 +33,10 @@ static const unsigned int WII_BANNER_HEIGHT = 64;
|
||||
static const unsigned int WII_BANNER_SIZE = WII_BANNER_WIDTH * WII_BANNER_HEIGHT * 2;
|
||||
static const unsigned int WII_BANNER_OFFSET = 0xA0;
|
||||
|
||||
const IOS::ES::TicketReader IVolume::INVALID_TICKET{};
|
||||
const IOS::ES::TMDReader IVolume::INVALID_TMD{};
|
||||
const IOS::ES::TicketReader Volume::INVALID_TICKET{};
|
||||
const IOS::ES::TMDReader Volume::INVALID_TMD{};
|
||||
|
||||
std::vector<u32> IVolume::GetWiiBanner(int* width, int* height, u64 title_id)
|
||||
std::vector<u32> Volume::GetWiiBanner(int* width, int* height, u64 title_id)
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
@ -66,7 +66,7 @@ std::vector<u32> IVolume::GetWiiBanner(int* width, int* height, u64 title_id)
|
||||
return image_buffer;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> IVolume::ReadWiiNames(const std::vector<u8>& data)
|
||||
std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<u8>& data)
|
||||
{
|
||||
std::map<Language, std::string> names;
|
||||
for (size_t i = 0; i < NUMBER_OF_LANGUAGES; ++i)
|
||||
@ -87,38 +87,38 @@ std::map<Language, std::string> IVolume::ReadWiiNames(const std::vector<u8>& dat
|
||||
return names;
|
||||
}
|
||||
|
||||
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename)
|
||||
std::unique_ptr<Volume> CreateVolumeFromFilename(const std::string& filename)
|
||||
{
|
||||
std::unique_ptr<IBlobReader> reader(CreateBlobReader(filename));
|
||||
std::unique_ptr<BlobReader> reader(CreateBlobReader(filename));
|
||||
if (reader == nullptr)
|
||||
return nullptr;
|
||||
|
||||
// Check for Wii
|
||||
const std::optional<u32> wii_magic = reader->ReadSwapped<u32>(0x18);
|
||||
if (wii_magic == u32(0x5D1C9EA3))
|
||||
return std::make_unique<CVolumeWiiCrypted>(std::move(reader));
|
||||
return std::make_unique<VolumeWii>(std::move(reader));
|
||||
|
||||
// Check for WAD
|
||||
// 0x206962 for boot2 wads
|
||||
const std::optional<u32> wad_magic = reader->ReadSwapped<u32>(0x02);
|
||||
if (wad_magic == u32(0x00204973) || wad_magic == u32(0x00206962))
|
||||
return std::make_unique<CVolumeWAD>(std::move(reader));
|
||||
return std::make_unique<VolumeWAD>(std::move(reader));
|
||||
|
||||
// Check for GC
|
||||
const std::optional<u32> gc_magic = reader->ReadSwapped<u32>(0x1C);
|
||||
if (gc_magic == u32(0xC2339F3D))
|
||||
return std::make_unique<CVolumeGC>(std::move(reader));
|
||||
return std::make_unique<VolumeGC>(std::move(reader));
|
||||
|
||||
// No known magic words found
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader,
|
||||
const std::string& dol)
|
||||
std::unique_ptr<Volume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader,
|
||||
const std::string& dol)
|
||||
{
|
||||
if (CVolumeDirectory::IsValidDirectory(directory))
|
||||
return std::make_unique<CVolumeDirectory>(directory, is_wii, apploader, dol);
|
||||
if (VolumeDirectory::IsValidDirectory(directory))
|
||||
return std::make_unique<VolumeDirectory>(directory, is_wii, apploader, dol);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -37,11 +37,11 @@ struct Partition final
|
||||
|
||||
const Partition PARTITION_NONE(std::numeric_limits<u64>::max() - 1);
|
||||
|
||||
class IVolume
|
||||
class Volume
|
||||
{
|
||||
public:
|
||||
IVolume() {}
|
||||
virtual ~IVolume() {}
|
||||
Volume() {}
|
||||
virtual ~Volume() {}
|
||||
virtual bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const = 0;
|
||||
template <typename T>
|
||||
std::optional<T> ReadSwapped(u64 offset, const Partition& partition) const
|
||||
@ -117,9 +117,9 @@ protected:
|
||||
static const IOS::ES::TMDReader INVALID_TMD;
|
||||
};
|
||||
|
||||
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename);
|
||||
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader = "",
|
||||
const std::string& dol = "");
|
||||
std::unique_ptr<Volume> CreateVolumeFromFilename(const std::string& filename);
|
||||
std::unique_ptr<Volume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader = "",
|
||||
const std::string& dol = "");
|
||||
|
||||
} // namespace
|
||||
|
@ -30,11 +30,11 @@ static u32 ComputeNameSize(const File::FSTEntry& parent_entry);
|
||||
static std::string ASCIIToUppercase(std::string str);
|
||||
static void ConvertUTF8NamesToSHIFTJIS(File::FSTEntry& parent_entry);
|
||||
|
||||
const size_t CVolumeDirectory::MAX_NAME_LENGTH;
|
||||
const size_t CVolumeDirectory::MAX_ID_LENGTH;
|
||||
const size_t VolumeDirectory::MAX_NAME_LENGTH;
|
||||
const size_t VolumeDirectory::MAX_ID_LENGTH;
|
||||
|
||||
CVolumeDirectory::CVolumeDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader, const std::string& dol)
|
||||
VolumeDirectory::VolumeDirectory(const std::string& directory, bool is_wii,
|
||||
const std::string& apploader, const std::string& dol)
|
||||
: m_data_start_address(-1), m_disk_header(DISKHEADERINFO_ADDRESS),
|
||||
m_disk_header_info(std::make_unique<SDiskHeaderInfo>()), m_fst_address(0), m_dol_address(0)
|
||||
{
|
||||
@ -56,16 +56,16 @@ CVolumeDirectory::CVolumeDirectory(const std::string& directory, bool is_wii,
|
||||
BuildFST();
|
||||
}
|
||||
|
||||
CVolumeDirectory::~CVolumeDirectory()
|
||||
VolumeDirectory::~VolumeDirectory()
|
||||
{
|
||||
}
|
||||
|
||||
bool CVolumeDirectory::IsValidDirectory(const std::string& directory)
|
||||
bool VolumeDirectory::IsValidDirectory(const std::string& directory)
|
||||
{
|
||||
return File::IsDirectory(ExtractDirectoryName(directory));
|
||||
}
|
||||
|
||||
bool CVolumeDirectory::Read(u64 offset, u64 length, u8* buffer, const Partition& partition) const
|
||||
bool VolumeDirectory::Read(u64 offset, u64 length, u8* buffer, const Partition& partition) const
|
||||
{
|
||||
bool decrypt = partition != PARTITION_NONE;
|
||||
|
||||
@ -160,27 +160,27 @@ bool CVolumeDirectory::Read(u64 offset, u64 length, u8* buffer, const Partition&
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<Partition> CVolumeDirectory::GetPartitions() const
|
||||
std::vector<Partition> VolumeDirectory::GetPartitions() const
|
||||
{
|
||||
return m_is_wii ? std::vector<Partition>{GetGamePartition()} : std::vector<Partition>();
|
||||
}
|
||||
|
||||
Partition CVolumeDirectory::GetGamePartition() const
|
||||
Partition VolumeDirectory::GetGamePartition() const
|
||||
{
|
||||
return m_is_wii ? Partition(0x50000) : PARTITION_NONE;
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::GetGameID(const Partition& partition) const
|
||||
std::string VolumeDirectory::GetGameID(const Partition& partition) const
|
||||
{
|
||||
return std::string(m_disk_header.begin(), m_disk_header.begin() + MAX_ID_LENGTH);
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetGameID(const std::string& id)
|
||||
void VolumeDirectory::SetGameID(const std::string& id)
|
||||
{
|
||||
memcpy(m_disk_header.data(), id.c_str(), std::min(id.length(), MAX_ID_LENGTH));
|
||||
}
|
||||
|
||||
Region CVolumeDirectory::GetRegion() const
|
||||
Region VolumeDirectory::GetRegion() const
|
||||
{
|
||||
if (m_is_wii)
|
||||
return RegionSwitchWii(m_disk_header[3]);
|
||||
@ -188,18 +188,18 @@ Region CVolumeDirectory::GetRegion() const
|
||||
return RegionSwitchGC(m_disk_header[3]);
|
||||
}
|
||||
|
||||
Country CVolumeDirectory::GetCountry(const Partition& partition) const
|
||||
Country VolumeDirectory::GetCountry(const Partition& partition) const
|
||||
{
|
||||
return CountrySwitch(m_disk_header[3]);
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::GetMakerID(const Partition& partition) const
|
||||
std::string VolumeDirectory::GetMakerID(const Partition& partition) const
|
||||
{
|
||||
// Not implemented
|
||||
return "00";
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::GetInternalName(const Partition& partition) const
|
||||
std::string VolumeDirectory::GetInternalName(const Partition& partition) const
|
||||
{
|
||||
char name[0x60];
|
||||
if (Read(0x20, 0x60, (u8*)name, partition))
|
||||
@ -208,7 +208,7 @@ std::string CVolumeDirectory::GetInternalName(const Partition& partition) const
|
||||
return "";
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeDirectory::GetLongNames() const
|
||||
std::map<Language, std::string> VolumeDirectory::GetLongNames() const
|
||||
{
|
||||
std::string name = GetInternalName();
|
||||
if (name.empty())
|
||||
@ -216,7 +216,7 @@ std::map<Language, std::string> CVolumeDirectory::GetLongNames() const
|
||||
return {{Language::LANGUAGE_UNKNOWN, name}};
|
||||
}
|
||||
|
||||
std::vector<u32> CVolumeDirectory::GetBanner(int* width, int* height) const
|
||||
std::vector<u32> VolumeDirectory::GetBanner(int* width, int* height) const
|
||||
{
|
||||
// Not implemented
|
||||
*width = 0;
|
||||
@ -224,25 +224,25 @@ std::vector<u32> CVolumeDirectory::GetBanner(int* width, int* height) const
|
||||
return std::vector<u32>();
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetName(const std::string& name)
|
||||
void VolumeDirectory::SetName(const std::string& name)
|
||||
{
|
||||
size_t length = std::min(name.length(), MAX_NAME_LENGTH);
|
||||
memcpy(&m_disk_header[0x20], name.c_str(), length);
|
||||
m_disk_header[length + 0x20] = 0;
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::GetApploaderDate(const Partition& partition) const
|
||||
std::string VolumeDirectory::GetApploaderDate(const Partition& partition) const
|
||||
{
|
||||
// Not implemented
|
||||
return "VOID";
|
||||
}
|
||||
|
||||
Platform CVolumeDirectory::GetVolumeType() const
|
||||
Platform VolumeDirectory::GetVolumeType() const
|
||||
{
|
||||
return m_is_wii ? Platform::WII_DISC : Platform::GAMECUBE_DISC;
|
||||
}
|
||||
|
||||
BlobType CVolumeDirectory::GetBlobType() const
|
||||
BlobType VolumeDirectory::GetBlobType() const
|
||||
{
|
||||
// VolumeDirectory isn't actually a blob, but it sort of acts
|
||||
// like one, so it makes sense that it has its own blob type.
|
||||
@ -250,19 +250,19 @@ BlobType CVolumeDirectory::GetBlobType() const
|
||||
return BlobType::DIRECTORY;
|
||||
}
|
||||
|
||||
u64 CVolumeDirectory::GetSize() const
|
||||
u64 VolumeDirectory::GetSize() const
|
||||
{
|
||||
// Not implemented
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 CVolumeDirectory::GetRawSize() const
|
||||
u64 VolumeDirectory::GetRawSize() const
|
||||
{
|
||||
// Not implemented
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string CVolumeDirectory::ExtractDirectoryName(const std::string& directory)
|
||||
std::string VolumeDirectory::ExtractDirectoryName(const std::string& directory)
|
||||
{
|
||||
std::string result = directory;
|
||||
|
||||
@ -287,7 +287,7 @@ std::string CVolumeDirectory::ExtractDirectoryName(const std::string& directory)
|
||||
return result;
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetDiskTypeWii()
|
||||
void VolumeDirectory::SetDiskTypeWii()
|
||||
{
|
||||
Write32(0x5d1c9ea3, 0x18, &m_disk_header);
|
||||
memset(&m_disk_header[0x1c], 0, 4);
|
||||
@ -296,7 +296,7 @@ void CVolumeDirectory::SetDiskTypeWii()
|
||||
m_address_shift = 2;
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetDiskTypeGC()
|
||||
void VolumeDirectory::SetDiskTypeGC()
|
||||
{
|
||||
memset(&m_disk_header[0x18], 0, 4);
|
||||
Write32(0xc2339f3d, 0x1c, &m_disk_header);
|
||||
@ -305,7 +305,7 @@ void CVolumeDirectory::SetDiskTypeGC()
|
||||
m_address_shift = 0;
|
||||
}
|
||||
|
||||
bool CVolumeDirectory::SetApploader(const std::string& apploader)
|
||||
bool VolumeDirectory::SetApploader(const std::string& apploader)
|
||||
{
|
||||
if (!apploader.empty())
|
||||
{
|
||||
@ -338,7 +338,7 @@ bool CVolumeDirectory::SetApploader(const std::string& apploader)
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeDirectory::SetDOL(const std::string& dol)
|
||||
void VolumeDirectory::SetDOL(const std::string& dol)
|
||||
{
|
||||
if (!dol.empty())
|
||||
{
|
||||
@ -354,7 +354,7 @@ void CVolumeDirectory::SetDOL(const std::string& dol)
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeDirectory::BuildFST()
|
||||
void VolumeDirectory::BuildFST()
|
||||
{
|
||||
m_fst_data.clear();
|
||||
|
||||
@ -394,8 +394,8 @@ void CVolumeDirectory::BuildFST()
|
||||
Write32((u32)(m_fst_data.size() >> m_address_shift), 0x042c, &m_disk_header);
|
||||
}
|
||||
|
||||
void CVolumeDirectory::WriteToBuffer(u64 source_start_address, u64 source_length, const u8* source,
|
||||
u64* address, u64* length, u8** buffer) const
|
||||
void VolumeDirectory::WriteToBuffer(u64 source_start_address, u64 source_length, const u8* source,
|
||||
u64* address, u64* length, u8** buffer) const
|
||||
{
|
||||
if (*length == 0)
|
||||
return;
|
||||
@ -416,7 +416,7 @@ void CVolumeDirectory::WriteToBuffer(u64 source_start_address, u64 source_length
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeDirectory::PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer) const
|
||||
void VolumeDirectory::PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer) const
|
||||
{
|
||||
if (start_address > *address && *length > 0)
|
||||
{
|
||||
@ -428,7 +428,7 @@ void CVolumeDirectory::PadToAddress(u64 start_address, u64* address, u64* length
|
||||
}
|
||||
}
|
||||
|
||||
void CVolumeDirectory::Write32(u32 data, u32 offset, std::vector<u8>* const buffer)
|
||||
void VolumeDirectory::Write32(u32 data, u32 offset, std::vector<u8>* const buffer)
|
||||
{
|
||||
(*buffer)[offset++] = (data >> 24);
|
||||
(*buffer)[offset++] = (data >> 16) & 0xff;
|
||||
@ -436,8 +436,8 @@ void CVolumeDirectory::Write32(u32 data, u32 offset, std::vector<u8>* const buff
|
||||
(*buffer)[offset] = (data)&0xff;
|
||||
}
|
||||
|
||||
void CVolumeDirectory::WriteEntryData(u32* entry_offset, u8 type, u32 name_offset, u64 data_offset,
|
||||
u64 length, u32 address_shift)
|
||||
void VolumeDirectory::WriteEntryData(u32* entry_offset, u8 type, u32 name_offset, u64 data_offset,
|
||||
u64 length, u32 address_shift)
|
||||
{
|
||||
m_fst_data[(*entry_offset)++] = type;
|
||||
|
||||
@ -452,15 +452,15 @@ void CVolumeDirectory::WriteEntryData(u32* entry_offset, u8 type, u32 name_offse
|
||||
*entry_offset += 4;
|
||||
}
|
||||
|
||||
void CVolumeDirectory::WriteEntryName(u32* name_offset, const std::string& name)
|
||||
void VolumeDirectory::WriteEntryName(u32* name_offset, const std::string& name)
|
||||
{
|
||||
strncpy((char*)&m_fst_data[*name_offset + m_fst_name_offset], name.c_str(), name.length() + 1);
|
||||
|
||||
*name_offset += (u32)(name.length() + 1);
|
||||
}
|
||||
|
||||
void CVolumeDirectory::WriteDirectory(const File::FSTEntry& parent_entry, u32* fst_offset,
|
||||
u32* name_offset, u64* data_offset, u32 parent_entry_index)
|
||||
void VolumeDirectory::WriteDirectory(const File::FSTEntry& parent_entry, u32* fst_offset,
|
||||
u32* name_offset, u64* data_offset, u32 parent_entry_index)
|
||||
{
|
||||
std::vector<File::FSTEntry> sorted_entries = parent_entry.children;
|
||||
|
||||
|
@ -30,13 +30,13 @@ enum class Language;
|
||||
enum class Region;
|
||||
enum class Platform;
|
||||
|
||||
class CVolumeDirectory : public IVolume
|
||||
class VolumeDirectory : public Volume
|
||||
{
|
||||
public:
|
||||
CVolumeDirectory(const std::string& directory, bool is_wii, const std::string& apploader = "",
|
||||
const std::string& dol = "");
|
||||
VolumeDirectory(const std::string& directory, bool is_wii, const std::string& apploader = "",
|
||||
const std::string& dol = "");
|
||||
|
||||
~CVolumeDirectory();
|
||||
~VolumeDirectory();
|
||||
|
||||
static bool IsValidDirectory(const std::string& directory);
|
||||
|
||||
|
@ -24,16 +24,16 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CVolumeGC::CVolumeGC(std::unique_ptr<IBlobReader> reader) : m_pReader(std::move(reader))
|
||||
VolumeGC::VolumeGC(std::unique_ptr<BlobReader> reader) : m_pReader(std::move(reader))
|
||||
{
|
||||
_assert_(m_pReader);
|
||||
}
|
||||
|
||||
CVolumeGC::~CVolumeGC()
|
||||
VolumeGC::~VolumeGC()
|
||||
{
|
||||
}
|
||||
|
||||
bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const
|
||||
bool VolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const
|
||||
{
|
||||
if (partition != PARTITION_NONE)
|
||||
return false;
|
||||
@ -41,7 +41,7 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& pa
|
||||
return m_pReader->Read(_Offset, _Length, _pBuffer);
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetGameID(const Partition& partition) const
|
||||
std::string VolumeGC::GetGameID(const Partition& partition) const
|
||||
{
|
||||
static const std::string NO_UID("NO_UID");
|
||||
|
||||
@ -56,19 +56,19 @@ std::string CVolumeGC::GetGameID(const Partition& partition) const
|
||||
return DecodeString(ID);
|
||||
}
|
||||
|
||||
Region CVolumeGC::GetRegion() const
|
||||
Region VolumeGC::GetRegion() const
|
||||
{
|
||||
const std::optional<u8> country_code = ReadSwapped<u8>(3, PARTITION_NONE);
|
||||
return country_code ? RegionSwitchGC(*country_code) : Region::UNKNOWN_REGION;
|
||||
}
|
||||
|
||||
Country CVolumeGC::GetCountry(const Partition& partition) const
|
||||
Country VolumeGC::GetCountry(const Partition& partition) const
|
||||
{
|
||||
const std::optional<u8> country_code = ReadSwapped<u8>(3, partition);
|
||||
return country_code ? CountrySwitch(*country_code) : Country::COUNTRY_UNKNOWN;
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetMakerID(const Partition& partition) const
|
||||
std::string VolumeGC::GetMakerID(const Partition& partition) const
|
||||
{
|
||||
char makerID[2];
|
||||
if (!Read(0x4, 0x2, (u8*)&makerID, partition))
|
||||
@ -77,13 +77,13 @@ std::string CVolumeGC::GetMakerID(const Partition& partition) const
|
||||
return DecodeString(makerID);
|
||||
}
|
||||
|
||||
std::optional<u16> CVolumeGC::GetRevision(const Partition& partition) const
|
||||
std::optional<u16> VolumeGC::GetRevision(const Partition& partition) const
|
||||
{
|
||||
std::optional<u8> revision = ReadSwapped<u8>(7, partition);
|
||||
return revision ? *revision : std::optional<u16>();
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetInternalName(const Partition& partition) const
|
||||
std::string VolumeGC::GetInternalName(const Partition& partition) const
|
||||
{
|
||||
char name[0x60];
|
||||
if (Read(0x20, 0x60, (u8*)name, partition))
|
||||
@ -92,37 +92,37 @@ std::string CVolumeGC::GetInternalName(const Partition& partition) const
|
||||
return "";
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeGC::GetShortNames() const
|
||||
std::map<Language, std::string> VolumeGC::GetShortNames() const
|
||||
{
|
||||
LoadBannerFile();
|
||||
return m_short_names;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeGC::GetLongNames() const
|
||||
std::map<Language, std::string> VolumeGC::GetLongNames() const
|
||||
{
|
||||
LoadBannerFile();
|
||||
return m_long_names;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeGC::GetShortMakers() const
|
||||
std::map<Language, std::string> VolumeGC::GetShortMakers() const
|
||||
{
|
||||
LoadBannerFile();
|
||||
return m_short_makers;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeGC::GetLongMakers() const
|
||||
std::map<Language, std::string> VolumeGC::GetLongMakers() const
|
||||
{
|
||||
LoadBannerFile();
|
||||
return m_long_makers;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeGC::GetDescriptions() const
|
||||
std::map<Language, std::string> VolumeGC::GetDescriptions() const
|
||||
{
|
||||
LoadBannerFile();
|
||||
return m_descriptions;
|
||||
}
|
||||
|
||||
std::vector<u32> CVolumeGC::GetBanner(int* width, int* height) const
|
||||
std::vector<u32> VolumeGC::GetBanner(int* width, int* height) const
|
||||
{
|
||||
LoadBannerFile();
|
||||
*width = m_image_width;
|
||||
@ -130,7 +130,7 @@ std::vector<u32> CVolumeGC::GetBanner(int* width, int* height) const
|
||||
return m_image_buffer;
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetApploaderDate(const Partition& partition) const
|
||||
std::string VolumeGC::GetApploaderDate(const Partition& partition) const
|
||||
{
|
||||
char date[16];
|
||||
if (!Read(0x2440, 0x10, (u8*)&date, partition))
|
||||
@ -139,32 +139,32 @@ std::string CVolumeGC::GetApploaderDate(const Partition& partition) const
|
||||
return DecodeString(date);
|
||||
}
|
||||
|
||||
BlobType CVolumeGC::GetBlobType() const
|
||||
BlobType VolumeGC::GetBlobType() const
|
||||
{
|
||||
return m_pReader->GetBlobType();
|
||||
}
|
||||
|
||||
u64 CVolumeGC::GetSize() const
|
||||
u64 VolumeGC::GetSize() const
|
||||
{
|
||||
return m_pReader->GetDataSize();
|
||||
}
|
||||
|
||||
u64 CVolumeGC::GetRawSize() const
|
||||
u64 VolumeGC::GetRawSize() const
|
||||
{
|
||||
return m_pReader->GetRawSize();
|
||||
}
|
||||
|
||||
std::optional<u8> CVolumeGC::GetDiscNumber(const Partition& partition) const
|
||||
std::optional<u8> VolumeGC::GetDiscNumber(const Partition& partition) const
|
||||
{
|
||||
return ReadSwapped<u8>(6, partition);
|
||||
}
|
||||
|
||||
Platform CVolumeGC::GetVolumeType() const
|
||||
Platform VolumeGC::GetVolumeType() const
|
||||
{
|
||||
return Platform::GAMECUBE_DISC;
|
||||
}
|
||||
|
||||
void CVolumeGC::LoadBannerFile() const
|
||||
void VolumeGC::LoadBannerFile() const
|
||||
{
|
||||
// If opening.bnr has been loaded already, return immediately
|
||||
if (m_banner_loaded)
|
||||
@ -173,7 +173,7 @@ void CVolumeGC::LoadBannerFile() const
|
||||
m_banner_loaded = true;
|
||||
|
||||
GCBanner banner_file;
|
||||
std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this, PARTITION_NONE));
|
||||
std::unique_ptr<FileSystem> file_system(CreateFileSystem(this, PARTITION_NONE));
|
||||
if (!file_system)
|
||||
return;
|
||||
|
||||
@ -206,7 +206,7 @@ void CVolumeGC::LoadBannerFile() const
|
||||
ExtractBannerInformation(banner_file, is_bnr1);
|
||||
}
|
||||
|
||||
void CVolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const
|
||||
void VolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const
|
||||
{
|
||||
u32 number_of_languages = 0;
|
||||
Language start_language = Language::LANGUAGE_UNKNOWN;
|
||||
|
@ -17,18 +17,18 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IBlobReader;
|
||||
class BlobReader;
|
||||
enum class BlobType;
|
||||
enum class Country;
|
||||
enum class Language;
|
||||
enum class Region;
|
||||
enum class Platform;
|
||||
|
||||
class CVolumeGC : public IVolume
|
||||
class VolumeGC : public Volume
|
||||
{
|
||||
public:
|
||||
CVolumeGC(std::unique_ptr<IBlobReader> reader);
|
||||
~CVolumeGC();
|
||||
VolumeGC(std::unique_ptr<BlobReader> reader);
|
||||
~VolumeGC();
|
||||
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer,
|
||||
const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetGameID(const Partition& partition = PARTITION_NONE) const override;
|
||||
@ -93,7 +93,7 @@ private:
|
||||
mutable int m_image_height = 0;
|
||||
mutable int m_image_width = 0;
|
||||
|
||||
std::unique_ptr<IBlobReader> m_pReader;
|
||||
std::unique_ptr<BlobReader> m_pReader;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader) : m_reader(std::move(reader))
|
||||
VolumeWAD::VolumeWAD(std::unique_ptr<BlobReader> reader) : m_reader(std::move(reader))
|
||||
{
|
||||
_assert_(m_reader);
|
||||
|
||||
@ -53,11 +53,11 @@ CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader) : m_reader(std::move
|
||||
m_tmd.SetBytes(std::move(tmd_buffer));
|
||||
}
|
||||
|
||||
CVolumeWAD::~CVolumeWAD()
|
||||
VolumeWAD::~VolumeWAD()
|
||||
{
|
||||
}
|
||||
|
||||
bool CVolumeWAD::Read(u64 offset, u64 length, u8* buffer, const Partition& partition) const
|
||||
bool VolumeWAD::Read(u64 offset, u64 length, u8* buffer, const Partition& partition) const
|
||||
{
|
||||
if (partition != PARTITION_NONE)
|
||||
return false;
|
||||
@ -65,14 +65,14 @@ bool CVolumeWAD::Read(u64 offset, u64 length, u8* buffer, const Partition& parti
|
||||
return m_reader->Read(offset, length, buffer);
|
||||
}
|
||||
|
||||
Region CVolumeWAD::GetRegion() const
|
||||
Region VolumeWAD::GetRegion() const
|
||||
{
|
||||
if (!m_tmd.IsValid())
|
||||
return Region::UNKNOWN_REGION;
|
||||
return m_tmd.GetRegion();
|
||||
}
|
||||
|
||||
Country CVolumeWAD::GetCountry(const Partition& partition) const
|
||||
Country VolumeWAD::GetCountry(const Partition& partition) const
|
||||
{
|
||||
if (!m_tmd.IsValid())
|
||||
return Country::COUNTRY_UNKNOWN;
|
||||
@ -84,17 +84,17 @@ Country CVolumeWAD::GetCountry(const Partition& partition) const
|
||||
return CountrySwitch(country_code);
|
||||
}
|
||||
|
||||
const IOS::ES::TMDReader& CVolumeWAD::GetTMD(const Partition& partition) const
|
||||
const IOS::ES::TMDReader& VolumeWAD::GetTMD(const Partition& partition) const
|
||||
{
|
||||
return m_tmd;
|
||||
}
|
||||
|
||||
std::string CVolumeWAD::GetGameID(const Partition& partition) const
|
||||
std::string VolumeWAD::GetGameID(const Partition& partition) const
|
||||
{
|
||||
return m_tmd.GetGameID();
|
||||
}
|
||||
|
||||
std::string CVolumeWAD::GetMakerID(const Partition& partition) const
|
||||
std::string VolumeWAD::GetMakerID(const Partition& partition) const
|
||||
{
|
||||
char temp[2];
|
||||
if (!Read(0x198 + m_tmd_offset, 2, (u8*)temp, partition))
|
||||
@ -108,12 +108,12 @@ std::string CVolumeWAD::GetMakerID(const Partition& partition) const
|
||||
return DecodeString(temp);
|
||||
}
|
||||
|
||||
std::optional<u64> CVolumeWAD::GetTitleID(const Partition& partition) const
|
||||
std::optional<u64> VolumeWAD::GetTitleID(const Partition& partition) const
|
||||
{
|
||||
return ReadSwapped<u64>(m_offset + 0x01DC, partition);
|
||||
}
|
||||
|
||||
std::optional<u16> CVolumeWAD::GetRevision(const Partition& partition) const
|
||||
std::optional<u16> VolumeWAD::GetRevision(const Partition& partition) const
|
||||
{
|
||||
if (!m_tmd.IsValid())
|
||||
return {};
|
||||
@ -121,12 +121,12 @@ std::optional<u16> CVolumeWAD::GetRevision(const Partition& partition) const
|
||||
return m_tmd.GetTitleVersion();
|
||||
}
|
||||
|
||||
Platform CVolumeWAD::GetVolumeType() const
|
||||
Platform VolumeWAD::GetVolumeType() const
|
||||
{
|
||||
return Platform::WII_WAD;
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeWAD::GetLongNames() const
|
||||
std::map<Language, std::string> VolumeWAD::GetLongNames() const
|
||||
{
|
||||
if (!m_tmd.IsValid() || !IOS::ES::IsChannel(m_tmd.GetTitleId()))
|
||||
return {};
|
||||
@ -137,7 +137,7 @@ std::map<Language, std::string> CVolumeWAD::GetLongNames() const
|
||||
return ReadWiiNames(name_data);
|
||||
}
|
||||
|
||||
std::vector<u32> CVolumeWAD::GetBanner(int* width, int* height) const
|
||||
std::vector<u32> VolumeWAD::GetBanner(int* width, int* height) const
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
@ -149,17 +149,17 @@ std::vector<u32> CVolumeWAD::GetBanner(int* width, int* height) const
|
||||
return GetWiiBanner(width, height, *title_id);
|
||||
}
|
||||
|
||||
BlobType CVolumeWAD::GetBlobType() const
|
||||
BlobType VolumeWAD::GetBlobType() const
|
||||
{
|
||||
return m_reader->GetBlobType();
|
||||
}
|
||||
|
||||
u64 CVolumeWAD::GetSize() const
|
||||
u64 VolumeWAD::GetSize() const
|
||||
{
|
||||
return m_reader->GetDataSize();
|
||||
}
|
||||
|
||||
u64 CVolumeWAD::GetRawSize() const
|
||||
u64 VolumeWAD::GetRawSize() const
|
||||
{
|
||||
return m_reader->GetRawSize();
|
||||
}
|
||||
|
@ -15,23 +15,23 @@
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
// --- this volume type is used for Wad files ---
|
||||
// Some of this code might look redundant with the CNANDContentLoader class, however,
|
||||
// Some of this code might look redundant with the NANDContentLoader class, however,
|
||||
// We do not do any decryption here, we do raw read, so things are -Faster-
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IBlobReader;
|
||||
class BlobReader;
|
||||
enum class BlobType;
|
||||
enum class Country;
|
||||
enum class Language;
|
||||
enum class Region;
|
||||
enum class Platform;
|
||||
|
||||
class CVolumeWAD : public IVolume
|
||||
class VolumeWAD : public Volume
|
||||
{
|
||||
public:
|
||||
CVolumeWAD(std::unique_ptr<IBlobReader> reader);
|
||||
~CVolumeWAD();
|
||||
VolumeWAD(std::unique_ptr<BlobReader> reader);
|
||||
~VolumeWAD();
|
||||
bool Read(u64 offset, u64 length, u8* buffer,
|
||||
const Partition& partition = PARTITION_NONE) const override;
|
||||
std::optional<u64> GetTitleID(const Partition& partition = PARTITION_NONE) const override;
|
||||
@ -58,7 +58,7 @@ public:
|
||||
u64 GetRawSize() const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<IBlobReader> m_reader;
|
||||
std::unique_ptr<BlobReader> m_reader;
|
||||
IOS::ES::TMDReader m_tmd;
|
||||
u32 m_offset = 0;
|
||||
u32 m_tmd_offset = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DiscIO/VolumeWiiCrypted.h"
|
||||
#include "DiscIO/VolumeWii.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@ -31,7 +31,7 @@ namespace DiscIO
|
||||
{
|
||||
constexpr u64 PARTITION_DATA_OFFSET = 0x20000;
|
||||
|
||||
CVolumeWiiCrypted::CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader)
|
||||
VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader)
|
||||
: m_pReader(std::move(reader)), m_game_partition(PARTITION_NONE), m_last_decrypted_block(-1)
|
||||
{
|
||||
_assert_(m_pReader);
|
||||
@ -50,7 +50,8 @@ CVolumeWiiCrypted::CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader)
|
||||
if (!number_of_partitions)
|
||||
continue;
|
||||
|
||||
std::optional<u32> read_buffer = m_pReader->ReadSwapped<u32>(0x40000 + (partition_group * 8) + 4);
|
||||
std::optional<u32> read_buffer =
|
||||
m_pReader->ReadSwapped<u32>(0x40000 + (partition_group * 8) + 4);
|
||||
if (!read_buffer)
|
||||
continue;
|
||||
const u64 partition_table_offset = static_cast<u64>(*read_buffer) << 2;
|
||||
@ -115,12 +116,11 @@ CVolumeWiiCrypted::CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader)
|
||||
}
|
||||
}
|
||||
|
||||
CVolumeWiiCrypted::~CVolumeWiiCrypted()
|
||||
VolumeWii::~VolumeWii()
|
||||
{
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer,
|
||||
const Partition& partition) const
|
||||
bool VolumeWii::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, const Partition& partition) const
|
||||
{
|
||||
if (partition == PARTITION_NONE)
|
||||
return m_pReader->Read(_ReadOffset, _Length, _pBuffer);
|
||||
@ -173,7 +173,7 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<Partition> CVolumeWiiCrypted::GetPartitions() const
|
||||
std::vector<Partition> VolumeWii::GetPartitions() const
|
||||
{
|
||||
std::vector<Partition> partitions;
|
||||
for (const auto& pair : m_partition_keys)
|
||||
@ -181,12 +181,12 @@ std::vector<Partition> CVolumeWiiCrypted::GetPartitions() const
|
||||
return partitions;
|
||||
}
|
||||
|
||||
Partition CVolumeWiiCrypted::GetGamePartition() const
|
||||
Partition VolumeWii::GetGamePartition() const
|
||||
{
|
||||
return m_game_partition;
|
||||
}
|
||||
|
||||
std::optional<u64> CVolumeWiiCrypted::GetTitleID(const Partition& partition) const
|
||||
std::optional<u64> VolumeWii::GetTitleID(const Partition& partition) const
|
||||
{
|
||||
const IOS::ES::TicketReader& ticket = GetTicket(partition);
|
||||
if (!ticket.IsValid())
|
||||
@ -194,19 +194,19 @@ std::optional<u64> CVolumeWiiCrypted::GetTitleID(const Partition& partition) con
|
||||
return ticket.GetTitleId();
|
||||
}
|
||||
|
||||
const IOS::ES::TicketReader& CVolumeWiiCrypted::GetTicket(const Partition& partition) const
|
||||
const IOS::ES::TicketReader& VolumeWii::GetTicket(const Partition& partition) const
|
||||
{
|
||||
auto it = m_partition_tickets.find(partition);
|
||||
return it != m_partition_tickets.end() ? it->second : INVALID_TICKET;
|
||||
}
|
||||
|
||||
const IOS::ES::TMDReader& CVolumeWiiCrypted::GetTMD(const Partition& partition) const
|
||||
const IOS::ES::TMDReader& VolumeWii::GetTMD(const Partition& partition) const
|
||||
{
|
||||
auto it = m_partition_tmds.find(partition);
|
||||
return it != m_partition_tmds.end() ? it->second : INVALID_TMD;
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::PartitionOffsetToRawOffset(u64 offset, const Partition& partition)
|
||||
u64 VolumeWii::PartitionOffsetToRawOffset(u64 offset, const Partition& partition)
|
||||
{
|
||||
if (partition == PARTITION_NONE)
|
||||
return offset;
|
||||
@ -215,7 +215,7 @@ u64 CVolumeWiiCrypted::PartitionOffsetToRawOffset(u64 offset, const Partition& p
|
||||
(offset % BLOCK_DATA_SIZE);
|
||||
}
|
||||
|
||||
std::string CVolumeWiiCrypted::GetGameID(const Partition& partition) const
|
||||
std::string VolumeWii::GetGameID(const Partition& partition) const
|
||||
{
|
||||
char ID[6];
|
||||
|
||||
@ -225,13 +225,13 @@ std::string CVolumeWiiCrypted::GetGameID(const Partition& partition) const
|
||||
return DecodeString(ID);
|
||||
}
|
||||
|
||||
Region CVolumeWiiCrypted::GetRegion() const
|
||||
Region VolumeWii::GetRegion() const
|
||||
{
|
||||
const std::optional<u32> region_code = m_pReader->ReadSwapped<u32>(0x4E000);
|
||||
return region_code ? static_cast<Region>(*region_code) : Region::UNKNOWN_REGION;
|
||||
}
|
||||
|
||||
Country CVolumeWiiCrypted::GetCountry(const Partition& partition) const
|
||||
Country VolumeWii::GetCountry(const Partition& partition) const
|
||||
{
|
||||
// The 0 that we use as a default value is mapped to COUNTRY_UNKNOWN and UNKNOWN_REGION
|
||||
u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
|
||||
@ -243,7 +243,7 @@ Country CVolumeWiiCrypted::GetCountry(const Partition& partition) const
|
||||
return CountrySwitch(country_byte);
|
||||
}
|
||||
|
||||
std::string CVolumeWiiCrypted::GetMakerID(const Partition& partition) const
|
||||
std::string VolumeWii::GetMakerID(const Partition& partition) const
|
||||
{
|
||||
char makerID[2];
|
||||
|
||||
@ -253,13 +253,13 @@ std::string CVolumeWiiCrypted::GetMakerID(const Partition& partition) const
|
||||
return DecodeString(makerID);
|
||||
}
|
||||
|
||||
std::optional<u16> CVolumeWiiCrypted::GetRevision(const Partition& partition) const
|
||||
std::optional<u16> VolumeWii::GetRevision(const Partition& partition) const
|
||||
{
|
||||
std::optional<u8> revision = ReadSwapped<u8>(7, partition);
|
||||
return revision ? *revision : std::optional<u16>();
|
||||
}
|
||||
|
||||
std::string CVolumeWiiCrypted::GetInternalName(const Partition& partition) const
|
||||
std::string VolumeWii::GetInternalName(const Partition& partition) const
|
||||
{
|
||||
char name_buffer[0x60];
|
||||
if (Read(0x20, 0x60, (u8*)&name_buffer, partition))
|
||||
@ -268,9 +268,9 @@ std::string CVolumeWiiCrypted::GetInternalName(const Partition& partition) const
|
||||
return "";
|
||||
}
|
||||
|
||||
std::map<Language, std::string> CVolumeWiiCrypted::GetLongNames() const
|
||||
std::map<Language, std::string> VolumeWii::GetLongNames() const
|
||||
{
|
||||
std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this, GetGamePartition()));
|
||||
std::unique_ptr<FileSystem> file_system(CreateFileSystem(this, GetGamePartition()));
|
||||
if (!file_system)
|
||||
return {};
|
||||
|
||||
@ -280,7 +280,7 @@ std::map<Language, std::string> CVolumeWiiCrypted::GetLongNames() const
|
||||
return ReadWiiNames(opening_bnr);
|
||||
}
|
||||
|
||||
std::vector<u32> CVolumeWiiCrypted::GetBanner(int* width, int* height) const
|
||||
std::vector<u32> VolumeWii::GetBanner(int* width, int* height) const
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
@ -292,7 +292,7 @@ std::vector<u32> CVolumeWiiCrypted::GetBanner(int* width, int* height) const
|
||||
return GetWiiBanner(width, height, *title_id);
|
||||
}
|
||||
|
||||
std::string CVolumeWiiCrypted::GetApploaderDate(const Partition& partition) const
|
||||
std::string VolumeWii::GetApploaderDate(const Partition& partition) const
|
||||
{
|
||||
char date[16];
|
||||
|
||||
@ -302,32 +302,32 @@ std::string CVolumeWiiCrypted::GetApploaderDate(const Partition& partition) cons
|
||||
return DecodeString(date);
|
||||
}
|
||||
|
||||
Platform CVolumeWiiCrypted::GetVolumeType() const
|
||||
Platform VolumeWii::GetVolumeType() const
|
||||
{
|
||||
return Platform::WII_DISC;
|
||||
}
|
||||
|
||||
std::optional<u8> CVolumeWiiCrypted::GetDiscNumber(const Partition& partition) const
|
||||
std::optional<u8> VolumeWii::GetDiscNumber(const Partition& partition) const
|
||||
{
|
||||
return ReadSwapped<u8>(6, partition);
|
||||
}
|
||||
|
||||
BlobType CVolumeWiiCrypted::GetBlobType() const
|
||||
BlobType VolumeWii::GetBlobType() const
|
||||
{
|
||||
return m_pReader->GetBlobType();
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetSize() const
|
||||
u64 VolumeWii::GetSize() const
|
||||
{
|
||||
return m_pReader->GetDataSize();
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetRawSize() const
|
||||
u64 VolumeWii::GetRawSize() const
|
||||
{
|
||||
return m_pReader->GetRawSize();
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::CheckIntegrity(const Partition& partition) const
|
||||
bool VolumeWii::CheckIntegrity(const Partition& partition) const
|
||||
{
|
||||
// Get the decryption key for the partition
|
||||
auto it = m_partition_keys.find(partition);
|
@ -19,18 +19,18 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IBlobReader;
|
||||
class BlobReader;
|
||||
enum class BlobType;
|
||||
enum class Country;
|
||||
enum class Language;
|
||||
enum class Region;
|
||||
enum class Platform;
|
||||
|
||||
class CVolumeWiiCrypted : public IVolume
|
||||
class VolumeWii : public Volume
|
||||
{
|
||||
public:
|
||||
CVolumeWiiCrypted(std::unique_ptr<IBlobReader> reader);
|
||||
~CVolumeWiiCrypted();
|
||||
VolumeWii(std::unique_ptr<BlobReader> reader);
|
||||
~VolumeWii();
|
||||
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const override;
|
||||
std::vector<Partition> GetPartitions() const override;
|
||||
Partition GetGamePartition() const override;
|
||||
@ -63,7 +63,7 @@ public:
|
||||
static constexpr unsigned int BLOCK_TOTAL_SIZE = BLOCK_HEADER_SIZE + BLOCK_DATA_SIZE;
|
||||
|
||||
private:
|
||||
std::unique_ptr<IBlobReader> m_pReader;
|
||||
std::unique_ptr<BlobReader> m_pReader;
|
||||
std::map<Partition, std::unique_ptr<mbedtls_aes_context>> m_partition_keys;
|
||||
std::map<Partition, IOS::ES::TicketReader> m_partition_tickets;
|
||||
std::map<Partition, IOS::ES::TMDReader> m_partition_tmds;
|
@ -16,7 +16,7 @@ namespace DiscIO
|
||||
{
|
||||
static constexpr u32 WBFS_MAGIC = 0x53464257; // "WBFS" (byteswapped to little endian)
|
||||
|
||||
class WbfsFileReader : public IBlobReader
|
||||
class WbfsFileReader : public BlobReader
|
||||
{
|
||||
public:
|
||||
~WbfsFileReader();
|
||||
|
@ -19,7 +19,7 @@ namespace DiscIO
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::vector<u8> CreateWADEntry(IBlobReader& reader, u32 size, u64 offset)
|
||||
std::vector<u8> CreateWADEntry(BlobReader& reader, u32 size, u64 offset)
|
||||
{
|
||||
if (size == 0)
|
||||
return {};
|
||||
@ -35,7 +35,7 @@ std::vector<u8> CreateWADEntry(IBlobReader& reader, u32 size, u64 offset)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool IsWiiWAD(IBlobReader& reader)
|
||||
bool IsWiiWAD(BlobReader& reader)
|
||||
{
|
||||
const std::optional<u32> header_size = reader.ReadSwapped<u32>(0x0);
|
||||
const std::optional<u32> header_type = reader.ReadSwapped<u32>(0x4);
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
class IBlobReader;
|
||||
class CBlobBigEndianReader;
|
||||
class BlobReader;
|
||||
|
||||
class WiiWAD
|
||||
{
|
||||
@ -35,7 +34,7 @@ private:
|
||||
|
||||
bool m_valid;
|
||||
|
||||
std::unique_ptr<IBlobReader> m_reader;
|
||||
std::unique_ptr<BlobReader> m_reader;
|
||||
|
||||
u64 m_data_app_offset = 0;
|
||||
std::vector<u8> m_certificate_chain;
|
||||
|
Reference in New Issue
Block a user