Volume: Make GetTMD return a vector
This commit is contained in:
parent
e638775bc7
commit
cbeb7034eb
|
@ -268,11 +268,10 @@ bool CBoot::BootUp()
|
||||||
if (unique_id.size() >= 4)
|
if (unique_id.size() >= 4)
|
||||||
VideoInterface::SetRegionReg(unique_id.at(3));
|
VideoInterface::SetRegionReg(unique_id.at(3));
|
||||||
|
|
||||||
u32 tmd_size;
|
std::vector<u8> tmd_buffer = pVolume.GetTMD();
|
||||||
std::unique_ptr<u8[]> tmd_buf = pVolume.GetTMD(&tmd_size);
|
if (!tmd_buffer.empty())
|
||||||
if (tmd_size)
|
|
||||||
{
|
{
|
||||||
WII_IPC_HLE_Interface::ES_DIVerify(tmd_buf.get(), tmd_size);
|
WII_IPC_HLE_Interface::ES_DIVerify(tmd_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_StartupPara.bWii = pVolume.GetVolumeType() == DiscIO::IVolume::WII_DISC;
|
_StartupPara.bWii = pVolume.GetVolumeType() == DiscIO::IVolume::WII_DISC;
|
||||||
|
|
|
@ -23,6 +23,7 @@ They will also generate a true or false return for UpdateInterrupts() in WII_IPC
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/CommonPaths.h"
|
#include "Common/CommonPaths.h"
|
||||||
|
@ -206,9 +207,9 @@ void SetDefaultContentFile(const std::string& _rFilename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ES_DIVerify(u8 *_pTMD, u32 _sz)
|
void ES_DIVerify(const std::vector<u8>& tmd)
|
||||||
{
|
{
|
||||||
CWII_IPC_HLE_Device_es::ES_DIVerify(_pTMD, _sz);
|
CWII_IPC_HLE_Device_es::ES_DIVerify(tmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDIO_EventNotify()
|
void SDIO_EventNotify()
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ void DoState(PointerWrap &p);
|
||||||
|
|
||||||
// Set default content file
|
// Set default content file
|
||||||
void SetDefaultContentFile(const std::string& _rFilename);
|
void SetDefaultContentFile(const std::string& _rFilename);
|
||||||
void ES_DIVerify(u8 *_pTMD, u32 _sz);
|
void ES_DIVerify(const std::vector<u8>& tmd);
|
||||||
|
|
||||||
void SDIO_EventNotify();
|
void SDIO_EventNotify();
|
||||||
|
|
||||||
|
|
|
@ -159,10 +159,9 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress)
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset);
|
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset);
|
||||||
|
|
||||||
// Read TMD to the buffer
|
// Read TMD to the buffer
|
||||||
u32 tmd_size;
|
std::vector<u8> tmd_buffer = DVDInterface::GetVolume().GetTMD();
|
||||||
std::unique_ptr<u8[]> tmd_buf = DVDInterface::GetVolume().GetTMD(&tmd_size);
|
Memory::CopyToEmu(CommandBuffer.PayloadBuffer[0].m_Address, tmd_buffer.data(), tmd_buffer.size());
|
||||||
Memory::CopyToEmu(CommandBuffer.PayloadBuffer[0].m_Address, tmd_buf.get(), tmd_size);
|
WII_IPC_HLE_Interface::ES_DIVerify(tmd_buffer);
|
||||||
WII_IPC_HLE_Interface::ES_DIVerify(tmd_buf.get(), tmd_size);
|
|
||||||
|
|
||||||
ReturnValue = 1;
|
ReturnValue = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
// otherwise we may not get __STDC_FORMAT_MACROS
|
// otherwise we may not get __STDC_FORMAT_MACROS
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
|
@ -1096,26 +1097,26 @@ bool CWII_IPC_HLE_Device_es::IsValid(u64 _TitleID) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
|
u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector<u8>& tmd)
|
||||||
{
|
{
|
||||||
u64 titleID = 0xDEADBEEFDEADBEEFull;
|
u64 title_id = 0xDEADBEEFDEADBEEFull;
|
||||||
u64 tmdTitleID = Common::swap64(*(u64*)(_pTMD+0x18c));
|
u64 tmd_title_id = Common::swap64(&tmd[0x18C]);
|
||||||
DVDInterface::GetVolume().GetTitleID(&titleID);
|
|
||||||
if (titleID != tmdTitleID)
|
DVDInterface::GetVolume().GetTitleID(&title_id);
|
||||||
{
|
if (title_id != tmd_title_id)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
std::string tmdPath = Common::GetTMDFileName(tmdTitleID, Common::FROM_SESSION_ROOT);
|
|
||||||
|
|
||||||
File::CreateFullPath(tmdPath);
|
std::string tmd_path = Common::GetTMDFileName(tmd_title_id, Common::FROM_SESSION_ROOT);
|
||||||
File::CreateFullPath(Common::GetTitleDataPath(tmdTitleID, Common::FROM_SESSION_ROOT));
|
|
||||||
|
|
||||||
Movie::g_titleID = tmdTitleID;
|
File::CreateFullPath(tmd_path);
|
||||||
std::string savePath = Common::GetTitleDataPath(tmdTitleID, Common::FROM_SESSION_ROOT);
|
File::CreateFullPath(Common::GetTitleDataPath(tmd_title_id, Common::FROM_SESSION_ROOT));
|
||||||
|
|
||||||
|
Movie::g_titleID = tmd_title_id;
|
||||||
|
std::string save_path = Common::GetTitleDataPath(tmd_title_id, Common::FROM_SESSION_ROOT);
|
||||||
if (Movie::IsRecordingInput())
|
if (Movie::IsRecordingInput())
|
||||||
{
|
{
|
||||||
// TODO: Check for the actual save data
|
// TODO: Check for the actual save data
|
||||||
if (File::Exists(savePath + "banner.bin"))
|
if (File::Exists(save_path + "banner.bin"))
|
||||||
Movie::g_bClearSave = false;
|
Movie::g_bClearSave = false;
|
||||||
else
|
else
|
||||||
Movie::g_bClearSave = true;
|
Movie::g_bClearSave = true;
|
||||||
|
@ -1124,44 +1125,44 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
|
||||||
// TODO: Force the game to save to another location, instead of moving the user's save.
|
// TODO: Force the game to save to another location, instead of moving the user's save.
|
||||||
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
|
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
|
||||||
{
|
{
|
||||||
if (File::Exists(savePath + "banner.bin"))
|
if (File::Exists(save_path + "banner.bin"))
|
||||||
{
|
{
|
||||||
if (File::Exists(savePath + "../backup/"))
|
if (File::Exists(save_path + "../backup/"))
|
||||||
{
|
{
|
||||||
// The last run of this game must have been to play back a movie, so their save is already backed up.
|
// The last run of this game must have been to play back a movie, so their save is already backed up.
|
||||||
File::DeleteDirRecursively(savePath);
|
File::DeleteDirRecursively(save_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MoveFile(UTF8ToTStr(savePath).c_str(), UTF8ToTStr(savePath + "../backup/").c_str());
|
MoveFile(UTF8ToTStr(save_path).c_str(), UTF8ToTStr(save_path + "../backup/").c_str());
|
||||||
#else
|
#else
|
||||||
File::CopyDir(savePath, savePath + "../backup/");
|
File::CopyDir(save_path, save_path + "../backup/");
|
||||||
File::DeleteDirRecursively(savePath);
|
File::DeleteDirRecursively(save_path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (File::Exists(savePath + "../backup/"))
|
else if (File::Exists(save_path + "../backup/"))
|
||||||
{
|
{
|
||||||
// Delete the save made by a previous movie, and copy back the user's save.
|
// Delete the save made by a previous movie, and copy back the user's save.
|
||||||
if (File::Exists(savePath + "banner.bin"))
|
if (File::Exists(save_path + "banner.bin"))
|
||||||
File::DeleteDirRecursively(savePath);
|
File::DeleteDirRecursively(save_path);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MoveFile(UTF8ToTStr(savePath + "../backup/").c_str(), UTF8ToTStr(savePath).c_str());
|
MoveFile(UTF8ToTStr(save_path + "../backup/").c_str(), UTF8ToTStr(save_path).c_str());
|
||||||
#else
|
#else
|
||||||
File::CopyDir(savePath + "../backup/", savePath);
|
File::CopyDir(save_path + "../backup/", save_path);
|
||||||
File::DeleteDirRecursively(savePath + "../backup/");
|
File::DeleteDirRecursively(save_path + "../backup/");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File::Exists(tmdPath))
|
if (!File::Exists(tmd_path))
|
||||||
{
|
{
|
||||||
File::IOFile _pTMDFile(tmdPath, "wb");
|
File::IOFile tmd_file(tmd_path, "wb");
|
||||||
if (!_pTMDFile.WriteBytes(_pTMD, _sz))
|
if (!tmd_file.WriteBytes(tmd.data(), tmd.size()))
|
||||||
ERROR_LOG(WII_IPC_ES, "DIVerify failed to write disc TMD to NAND.");
|
ERROR_LOG(WII_IPC_ES, "DIVerify failed to write disc TMD to NAND.");
|
||||||
}
|
}
|
||||||
DiscIO::cUIDsys::AccessInstance().AddTitle(tmdTitleID);
|
DiscIO::cUIDsys::AccessInstance().AddTitle(tmd_title_id);
|
||||||
DiscIO::CNANDContentManager::Access().ClearCache();
|
DiscIO::CNANDContentManager::Access().ClearCache();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
|
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
|
||||||
|
|
||||||
static u32 ES_DIVerify(u8 *_pTMD, u32 _sz);
|
static u32 ES_DIVerify(const std::vector<u8>& tmd);
|
||||||
|
|
||||||
// This should only be cleared on power reset
|
// This should only be cleared on power reset
|
||||||
static std::string m_ContentFile;
|
static std::string m_ContentFile;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -82,11 +81,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool GetTitleID(u64*) const { return false; }
|
virtual bool GetTitleID(u64*) const { return false; }
|
||||||
virtual std::unique_ptr<u8[]> GetTMD(u32 *_sz) const
|
virtual std::vector<u8> GetTMD() const { return {}; }
|
||||||
{
|
|
||||||
*_sz = 0;
|
|
||||||
return std::unique_ptr<u8[]>();
|
|
||||||
}
|
|
||||||
virtual std::string GetUniqueID() const = 0;
|
virtual std::string GetUniqueID() const = 0;
|
||||||
virtual std::string GetMakerID() const = 0;
|
virtual std::string GetMakerID() const = 0;
|
||||||
virtual u16 GetRevision() const = 0;
|
virtual u16 GetRevision() const = 0;
|
||||||
|
|
|
@ -115,9 +115,8 @@ bool CVolumeWiiCrypted::GetTitleID(u64* buffer) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<u8[]> CVolumeWiiCrypted::GetTMD(u32 *size) const
|
std::vector<u8> CVolumeWiiCrypted::GetTMD() const
|
||||||
{
|
{
|
||||||
*size = 0;
|
|
||||||
u32 tmd_size;
|
u32 tmd_size;
|
||||||
u32 tmd_address;
|
u32 tmd_address;
|
||||||
|
|
||||||
|
@ -136,10 +135,10 @@ std::unique_ptr<u8[]> CVolumeWiiCrypted::GetTMD(u32 *size) const
|
||||||
tmd_size = 1024 * 1024 * 4;
|
tmd_size = 1024 * 1024 * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<u8[]> buf{ new u8[tmd_size] };
|
std::vector<u8> buffer(tmd_size);
|
||||||
Read(m_VolumeOffset + tmd_address, tmd_size, buf.get(), false);
|
Read(m_VolumeOffset + tmd_address, tmd_size, buffer.data(), false);
|
||||||
*size = tmd_size;
|
|
||||||
return buf;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CVolumeWiiCrypted::GetUniqueID() const
|
std::string CVolumeWiiCrypted::GetUniqueID() const
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -25,7 +26,7 @@ public:
|
||||||
~CVolumeWiiCrypted();
|
~CVolumeWiiCrypted();
|
||||||
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const override;
|
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const override;
|
||||||
bool GetTitleID(u64* buffer) const override;
|
bool GetTitleID(u64* buffer) const override;
|
||||||
std::unique_ptr<u8[]> GetTMD(u32 *_sz) const override;
|
std::vector<u8> GetTMD() const override;
|
||||||
std::string GetUniqueID() const override;
|
std::string GetUniqueID() const override;
|
||||||
std::string GetMakerID() const override;
|
std::string GetMakerID() const override;
|
||||||
u16 GetRevision() const override;
|
u16 GetRevision() const override;
|
||||||
|
|
Loading…
Reference in New Issue