Implement parts of DIVerify that can be useful. (copy tmd to emulated nand for disc titles)

correct some parts of uid.sys as disc title ids are included
title in uid + tmd on nand is how the sysmenu knows which save files to look for.
IE games that are displayed in the disc channel at least once and have a save file will be
viewable in the sysmenu save manager

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6189 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 committed 2010-09-07 06:06:08 +00:00
1 parent dee24e5695
commit e0383634d3
9 files changed
+126 -76

No files matched your search

@@ -137,6 +137,14 @@ void SetDefaultContentFile(const std::string& _rFilename)
if (pDevice)
pDevice->LoadWAD(_rFilename);
}
void ES_DIVerify(u8 *_pTMD, u32 _sz)
{
CWII_IPC_HLE_Device_es* pDevice = (CWII_IPC_HLE_Device_es*)AccessDeviceByID(GetDeviceIDByName(std::string("/dev/es")));
if (pDevice)
pDevice->ES_DIVerify(_pTMD, _sz);
else
ERROR_LOG(WII_IPC_ES, "DIVerify called but /dev/es is not available");
}
int GetDeviceIDByName(const std::string& _rDeviceName)
{
@@ -42,6 +42,7 @@ void DoState(PointerWrap &p);
// Set default content file
void SetDefaultContentFile(const std::string& _rFilename);
void ES_DIVerify(u8 *_pTMD, u32 _sz);
int GetDeviceIDByName(const std::string& _rDeviceName);
@@ -18,6 +18,7 @@
#include "Common.h"
#include "WII_IPC_HLE_Device_DI.h"
#include "WII_IPC_HLE.h"
#include "../HW/DVDInterface.h"
#include "../HW/CPU.h"
@@ -119,13 +120,20 @@ bool CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress)
// Get TMD offset for requested partition...
u64 TMDOffset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2 ) + 0x2c0;
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: TMDOffset 0x%016llx", TMDOffset);
u32 TMDsz = CommandBuffer.PayloadBuffer[0].m_Size;
u8 *pTMD = new u8[TMDsz];
if (pTMD)
{
// Read TMD to the buffer
readOK |= VolumeHandler::RAWReadToPtr(Memory::GetPointer(CommandBuffer.PayloadBuffer[0].m_Address),
TMDOffset, CommandBuffer.PayloadBuffer[0].m_Size);
VolumeHandler::RAWReadToPtr(pTMD, TMDOffset, TMDsz);
memcpy(Memory::GetPointer(CommandBuffer.PayloadBuffer[0].m_Address), pTMD, TMDsz);
readOK |= true;
WII_IPC_HLE_Interface::ES_DIVerify(pTMD, TMDsz);
}
ReturnValue = readOK ? 1 : 0;
}
break;
@@ -55,7 +55,7 @@
#include "../Boot/Boot_DOL.h"
#include "NandPaths.h"
#include "CommonPaths.h"
CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
, m_pContentLoader(NULL)
@@ -82,9 +82,12 @@ bool CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
m_TitleID = m_pContentLoader->GetTitleID();
// System menu versions about 0xE0 will indicate that system files are corrupted if there is more than one title
// TODO: fix System menu versions above this and remove this check
if (m_pContentLoader->GetTitleVersion() <= 0xE0)
{
DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDs);
// uncomment if ES_GetOwnedTitlesCount / ES_GetOwnedTitles is implemented
// DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDsOwned, true);
}
else
{
@@ -156,7 +159,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}, // Unknown
};
switch (Buffer.Parameter)
switch (Buffer.Parameter)
{
case IOCTL_ES_GETDEVICEID:
{
@@ -387,7 +390,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberInBuffer == 1, "IOCTL_ES_SETUID no in buffer");
_dbg_assert_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 0);
// TODO: fs permissions based on this
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
INFO_LOG(WII_IPC_ES, "IOCTL_ES_SETUID titleID: %08x/%08x", (u32)(TitleID>>32), (u32)TitleID);
}
@@ -788,3 +791,35 @@ bool CWII_IPC_HLE_Device_es::IsValid(u64 _TitleID) const
}
u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
{
u64 titleID = 0xDEADBEEFDEADBEEFull;
u64 tmdTitleID = Common::swap64(*(u64*)(_pTMD+0x18c));
VolumeHandler::GetVolume()->GetTitleID((u8*)&titleID);
if (Common::swap64(titleID) != tmdTitleID)
{
return -1;
}
std::string contentPath,
dataPath,
tmdPath;
contentPath = Common::CreateTitleContentPath(tmdTitleID) + DIR_SEP;
dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP;
tmdPath = contentPath + "/title.tmd";
File::CreateFullPath(contentPath.c_str());
File::CreateFullPath(dataPath.c_str());
if(!File::Exists(tmdPath.c_str()))
{
FILE* _pTMDFile = fopen(tmdPath.c_str(), "wb");
if (_pTMDFile)
{
if (fwrite(_pTMD, _sz, 1, _pTMDFile) != 1)
ERROR_LOG(WII_IPC_ES, "DIVerify failed to write disc tmd to nand");
fclose(_pTMDFile);
}
}
DiscIO::cUIDsys::AccessInstance().AddTitle(tmdTitleID);
return 0;
}
@@ -37,7 +37,7 @@ public:
virtual bool Close(u32 _CommandAddress, bool _bForce);
virtual bool IOCtlV(u32 _CommandAddress);
u32 ES_DIVerify(u8 *_pTMD, u32 _sz);
private:
enum