Merge pull request #5056 from JosJuice/use-readswapped
Volume: Use ReadSwapped more
This commit is contained in:
commit
f63d40270d
|
@ -47,8 +47,6 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
|
|||
std::string CVolumeGC::GetGameID() const
|
||||
{
|
||||
static const std::string NO_UID("NO_UID");
|
||||
if (m_pReader == nullptr)
|
||||
return NO_UID;
|
||||
|
||||
char ID[6];
|
||||
|
||||
|
@ -64,7 +62,7 @@ std::string CVolumeGC::GetGameID() const
|
|||
Region CVolumeGC::GetRegion() const
|
||||
{
|
||||
u8 country_code;
|
||||
if (!m_pReader->Read(3, 1, &country_code))
|
||||
if (!ReadSwapped(3, &country_code, false))
|
||||
return Region::UNKNOWN_REGION;
|
||||
|
||||
return RegionSwitchGC(country_code);
|
||||
|
@ -73,7 +71,7 @@ Region CVolumeGC::GetRegion() const
|
|||
Country CVolumeGC::GetCountry() const
|
||||
{
|
||||
u8 country_code;
|
||||
if (!m_pReader->Read(3, 1, &country_code))
|
||||
if (!ReadSwapped(3, &country_code, false))
|
||||
return Country::COUNTRY_UNKNOWN;
|
||||
|
||||
return CountrySwitch(country_code);
|
||||
|
@ -81,9 +79,6 @@ Country CVolumeGC::GetCountry() const
|
|||
|
||||
std::string CVolumeGC::GetMakerID() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return std::string();
|
||||
|
||||
char makerID[2];
|
||||
if (!Read(0x4, 0x2, (u8*)&makerID))
|
||||
return std::string();
|
||||
|
@ -93,11 +88,8 @@ std::string CVolumeGC::GetMakerID() const
|
|||
|
||||
u16 CVolumeGC::GetRevision() const
|
||||
{
|
||||
if (!m_pReader)
|
||||
return 0;
|
||||
|
||||
u8 revision;
|
||||
if (!Read(7, 1, &revision))
|
||||
if (!ReadSwapped(7, &revision, false))
|
||||
return 0;
|
||||
|
||||
return revision;
|
||||
|
@ -106,7 +98,7 @@ u16 CVolumeGC::GetRevision() const
|
|||
std::string CVolumeGC::GetInternalName() const
|
||||
{
|
||||
char name[0x60];
|
||||
if (m_pReader != nullptr && Read(0x20, 0x60, (u8*)name))
|
||||
if (Read(0x20, 0x60, (u8*)name))
|
||||
return DecodeString(name);
|
||||
|
||||
return "";
|
||||
|
@ -152,9 +144,6 @@ std::vector<u32> CVolumeGC::GetBanner(int* width, int* height) const
|
|||
|
||||
u64 CVolumeGC::GetFSTSize() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return 0;
|
||||
|
||||
u32 size;
|
||||
if (!Read(0x428, 0x4, (u8*)&size))
|
||||
return 0;
|
||||
|
@ -164,9 +153,6 @@ u64 CVolumeGC::GetFSTSize() const
|
|||
|
||||
std::string CVolumeGC::GetApploaderDate() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return std::string();
|
||||
|
||||
char date[16];
|
||||
if (!Read(0x2440, 0x10, (u8*)&date))
|
||||
return std::string();
|
||||
|
@ -181,24 +167,18 @@ BlobType CVolumeGC::GetBlobType() const
|
|||
|
||||
u64 CVolumeGC::GetSize() const
|
||||
{
|
||||
if (m_pReader)
|
||||
return m_pReader->GetDataSize();
|
||||
else
|
||||
return 0;
|
||||
return m_pReader ? m_pReader->GetDataSize() : 0;
|
||||
}
|
||||
|
||||
u64 CVolumeGC::GetRawSize() const
|
||||
{
|
||||
if (m_pReader)
|
||||
return m_pReader->GetRawSize();
|
||||
else
|
||||
return 0;
|
||||
return m_pReader ? m_pReader->GetRawSize() : 0;
|
||||
}
|
||||
|
||||
u8 CVolumeGC::GetDiscNumber() const
|
||||
{
|
||||
u8 disc_number;
|
||||
Read(6, 1, &disc_number);
|
||||
ReadSwapped(6, &disc_number, false);
|
||||
return disc_number;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,11 +112,7 @@ std::string CVolumeWAD::GetMakerID() const
|
|||
|
||||
bool CVolumeWAD::GetTitleID(u64* buffer) const
|
||||
{
|
||||
if (!Read(m_offset + 0x01DC, sizeof(u64), reinterpret_cast<u8*>(buffer)))
|
||||
return false;
|
||||
|
||||
*buffer = Common::swap64(*buffer);
|
||||
return true;
|
||||
return ReadSwapped(m_offset + 0x01DC, buffer, false);
|
||||
}
|
||||
|
||||
u16 CVolumeWAD::GetRevision() const
|
||||
|
|
|
@ -106,13 +106,7 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool de
|
|||
|
||||
bool CVolumeWiiCrypted::GetTitleID(u64* buffer) const
|
||||
{
|
||||
// Tik is at m_VolumeOffset size 0x2A4
|
||||
// TitleID offset in tik is 0x1DC
|
||||
if (!Read(m_VolumeOffset + 0x1DC, sizeof(u64), reinterpret_cast<u8*>(buffer), false))
|
||||
return false;
|
||||
|
||||
*buffer = Common::swap64(*buffer);
|
||||
return true;
|
||||
return ReadSwapped(m_VolumeOffset + 0x1DC, buffer, false);
|
||||
}
|
||||
|
||||
IOS::ES::TicketReader CVolumeWiiCrypted::GetTicket() const
|
||||
|
@ -127,10 +121,9 @@ IOS::ES::TMDReader CVolumeWiiCrypted::GetTMD() const
|
|||
u32 tmd_size;
|
||||
u32 tmd_address;
|
||||
|
||||
Read(m_VolumeOffset + 0x2a4, sizeof(u32), (u8*)&tmd_size, false);
|
||||
Read(m_VolumeOffset + 0x2a8, sizeof(u32), (u8*)&tmd_address, false);
|
||||
tmd_size = Common::swap32(tmd_size);
|
||||
tmd_address = Common::swap32(tmd_address) << 2;
|
||||
ReadSwapped(m_VolumeOffset + 0x2a4, &tmd_size, false);
|
||||
ReadSwapped(m_VolumeOffset + 0x2a8, &tmd_address, false);
|
||||
tmd_address <<= 2;
|
||||
|
||||
if (tmd_size > 1024 * 1024 * 4)
|
||||
{
|
||||
|
@ -156,9 +149,6 @@ u64 CVolumeWiiCrypted::PartitionOffsetToRawOffset(u64 offset) const
|
|||
|
||||
std::string CVolumeWiiCrypted::GetGameID() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return std::string();
|
||||
|
||||
char ID[6];
|
||||
|
||||
if (!Read(0, 6, (u8*)ID, true))
|
||||
|
@ -204,9 +194,6 @@ Country CVolumeWiiCrypted::GetCountry() const
|
|||
|
||||
std::string CVolumeWiiCrypted::GetMakerID() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return std::string();
|
||||
|
||||
char makerID[2];
|
||||
|
||||
if (!Read(0x4, 0x2, (u8*)&makerID, true))
|
||||
|
@ -217,9 +204,6 @@ std::string CVolumeWiiCrypted::GetMakerID() const
|
|||
|
||||
u16 CVolumeWiiCrypted::GetRevision() const
|
||||
{
|
||||
if (!m_pReader)
|
||||
return 0;
|
||||
|
||||
u8 revision;
|
||||
if (!ReadSwapped(7, &revision, true))
|
||||
return 0;
|
||||
|
@ -230,7 +214,7 @@ u16 CVolumeWiiCrypted::GetRevision() const
|
|||
std::string CVolumeWiiCrypted::GetInternalName() const
|
||||
{
|
||||
char name_buffer[0x60];
|
||||
if (m_pReader != nullptr && Read(0x20, 0x60, (u8*)&name_buffer, true))
|
||||
if (Read(0x20, 0x60, (u8*)&name_buffer, true))
|
||||
return DecodeString(name_buffer);
|
||||
|
||||
return "";
|
||||
|
@ -259,9 +243,6 @@ std::vector<u32> CVolumeWiiCrypted::GetBanner(int* width, int* height) const
|
|||
|
||||
u64 CVolumeWiiCrypted::GetFSTSize() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return 0;
|
||||
|
||||
u32 size;
|
||||
|
||||
if (!Read(0x428, 0x4, (u8*)&size, true))
|
||||
|
@ -272,9 +253,6 @@ u64 CVolumeWiiCrypted::GetFSTSize() const
|
|||
|
||||
std::string CVolumeWiiCrypted::GetApploaderDate() const
|
||||
{
|
||||
if (m_pReader == nullptr)
|
||||
return std::string();
|
||||
|
||||
char date[16];
|
||||
|
||||
if (!Read(0x2440, 0x10, (u8*)&date, true))
|
||||
|
@ -302,18 +280,12 @@ BlobType CVolumeWiiCrypted::GetBlobType() const
|
|||
|
||||
u64 CVolumeWiiCrypted::GetSize() const
|
||||
{
|
||||
if (m_pReader)
|
||||
return m_pReader->GetDataSize();
|
||||
else
|
||||
return 0;
|
||||
return m_pReader ? m_pReader->GetDataSize() : 0;
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetRawSize() const
|
||||
{
|
||||
if (m_pReader)
|
||||
return m_pReader->GetRawSize();
|
||||
else
|
||||
return 0;
|
||||
return m_pReader ? m_pReader->GetRawSize() : 0;
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::CheckIntegrity() const
|
||||
|
@ -332,7 +304,7 @@ bool CVolumeWiiCrypted::CheckIntegrity() const
|
|||
u8 clusterMDCrypted[0x400];
|
||||
u8 clusterMD[0x400];
|
||||
u8 IV[16] = {0};
|
||||
if (!m_pReader->Read(clusterOff, 0x400, clusterMDCrypted))
|
||||
if (!Read(clusterOff, 0x400, clusterMDCrypted, false))
|
||||
{
|
||||
WARN_LOG(DISCIO, "Integrity Check: fail at cluster %d: could not read metadata", clusterID);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue