mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 15:19:42 -06:00
Merge pull request #1895 from JosJuice/isvolumewiidisc
Don't read from disk when checking volume type
This commit is contained in:
@ -8,7 +8,6 @@
|
||||
#include "DiscIO/BannerLoaderGC.h"
|
||||
#include "DiscIO/BannerLoaderWii.h"
|
||||
#include "DiscIO/Filesystem.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
@ -18,7 +17,7 @@ class IVolume;
|
||||
|
||||
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume)
|
||||
{
|
||||
if (IsVolumeWiiDisc(pVolume) || IsVolumeWadFile(pVolume))
|
||||
if (pVolume->IsWiiDisc() || pVolume->IsWadFile())
|
||||
return new CBannerLoaderWii(pVolume);
|
||||
if (_rFileSystem.IsValid())
|
||||
return new CBannerLoaderGC(_rFileSystem, pVolume);
|
||||
|
@ -79,7 +79,7 @@ void ReadFileSystem(const std::string& filename)
|
||||
if (!OpenISO)
|
||||
return;
|
||||
|
||||
if (!DiscIO::IsVolumeWadFile(OpenISO))
|
||||
if (!OpenISO->IsWadFile())
|
||||
{
|
||||
pFileSystem = DiscIO::CreateFileSystem(OpenISO);
|
||||
|
||||
|
@ -36,9 +36,11 @@ public:
|
||||
virtual std::vector<std::string> GetNames() const = 0;
|
||||
virtual u32 GetFSTSize() const = 0;
|
||||
virtual std::string GetApploaderDate() const = 0;
|
||||
virtual bool IsDiscTwo() const { return false; }
|
||||
virtual bool IsWiiDisc() const { return false; }
|
||||
virtual bool IsWadFile() const { return false; }
|
||||
virtual bool SupportsIntegrityCheck() const { return false; }
|
||||
virtual bool CheckIntegrity() const { return false; }
|
||||
virtual bool IsDiscTwo() const { return false; }
|
||||
|
||||
virtual bool ChangePartition(u64 offset) { return false; }
|
||||
|
||||
|
@ -120,15 +120,6 @@ IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool IsVolumeWiiDisc(const IVolume *_rVolume)
|
||||
{
|
||||
u32 MagicWord = 0;
|
||||
_rVolume->Read(0x18, 4, (u8*)&MagicWord, false);
|
||||
|
||||
return (Common::swap32(MagicWord) == 0x5D1C9EA3);
|
||||
//GameCube 0xc2339f3d
|
||||
}
|
||||
|
||||
bool IsVolumeWadFile(const IVolume *_rVolume)
|
||||
{
|
||||
u32 MagicWord = 0;
|
||||
|
@ -67,12 +67,7 @@ bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
||||
|
||||
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
|
||||
{
|
||||
// VolumeHandler::IsWii is used here to check whether a Wii disc is used.
|
||||
// That function calls this function to check a magic word in the disc header,
|
||||
// so it is important that VolumeHandler::IsWii is not called when the header
|
||||
// is being read with decrypt=false, as it would result in a stack overflow.
|
||||
|
||||
if (!decrypt && (_Offset + _Length >= 0x400) && VolumeHandler::IsWii())
|
||||
if (!decrypt && (_Offset + _Length >= 0x400) && m_is_wii)
|
||||
{
|
||||
// Fully supporting this would require re-encrypting every file that's read.
|
||||
// Only supporting the areas that IOS allows software to read could be more feasible.
|
||||
@ -82,7 +77,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt
|
||||
return false;
|
||||
}
|
||||
|
||||
if (decrypt && !VolumeHandler::IsWii())
|
||||
if (decrypt && !m_is_wii)
|
||||
PanicAlertT("Tried to decrypt data from a non-Wii volume");
|
||||
|
||||
// header
|
||||
@ -214,6 +209,11 @@ std::string CVolumeDirectory::GetApploaderDate() const
|
||||
return "VOID";
|
||||
}
|
||||
|
||||
bool CVolumeDirectory::IsWiiDisc() const
|
||||
{
|
||||
return m_is_wii;
|
||||
}
|
||||
|
||||
u64 CVolumeDirectory::GetSize() const
|
||||
{
|
||||
return 0;
|
||||
@ -257,6 +257,7 @@ void CVolumeDirectory::SetDiskTypeWii()
|
||||
m_diskHeader[0x1b] = 0xa3;
|
||||
memset(&m_diskHeader[0x1c], 0, 4);
|
||||
|
||||
m_is_wii = true;
|
||||
m_addressShift = 2;
|
||||
}
|
||||
|
||||
@ -268,6 +269,7 @@ void CVolumeDirectory::SetDiskTypeGC()
|
||||
m_diskHeader[0x1e] = 0x9f;
|
||||
m_diskHeader[0x1f] = 0x3d;
|
||||
|
||||
m_is_wii = false;
|
||||
m_addressShift = 0;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
u32 GetFSTSize() const override;
|
||||
|
||||
std::string GetApploaderDate() const override;
|
||||
bool IsWiiDisc() const override;
|
||||
|
||||
ECountry GetCountry() const override;
|
||||
|
||||
@ -85,6 +86,8 @@ private:
|
||||
|
||||
u32 m_totalNameSize;
|
||||
|
||||
bool m_is_wii;
|
||||
|
||||
// GameCube has no shift, Wii has 2 bit shift
|
||||
u32 m_addressShift;
|
||||
|
||||
|
@ -103,6 +103,11 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVolumeWAD::IsWadFile() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> CVolumeWAD::GetNames() const
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
std::vector<std::string> GetNames() const override;
|
||||
u32 GetFSTSize() const override { return 0; }
|
||||
std::string GetApploaderDate() const override { return "0"; }
|
||||
bool IsWadFile() const override;
|
||||
ECountry GetCountry() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
@ -227,6 +227,11 @@ std::string CVolumeWiiCrypted::GetApploaderDate() const
|
||||
return date;
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::IsWiiDisc() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetSize() const
|
||||
{
|
||||
if (m_pReader)
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
std::vector<std::string> GetNames() const override;
|
||||
u32 GetFSTSize() const override;
|
||||
std::string GetApploaderDate() const override;
|
||||
bool IsWiiDisc() const override;
|
||||
ECountry GetCountry() const override;
|
||||
u64 GetSize() const override;
|
||||
u64 GetRawSize() const override;
|
||||
|
Reference in New Issue
Block a user