Better error reporting for ES / NANDContentLoader.

This commit is contained in:
comex 2013-08-31 23:39:26 -04:00
parent 3e049a130b
commit 5209abeb03
2 changed files with 27 additions and 9 deletions

View File

@ -197,7 +197,15 @@ bool CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress, bool _bForce)
u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index)
{
const DiscIO::SNANDContent* pContent = AccessContentDevice(TitleID).GetContentByIndex(Index);
const DiscIO::INANDContentLoader& Loader = AccessContentDevice(TitleID);
if (!Loader.IsValid())
{
WARN_LOG(WII_IPC_ES, "ES: loader not valid for %llx", TitleID);
return 0xffffffff;
}
const DiscIO::SNANDContent* pContent = Loader.GetContentByIndex(Index);
if (pContent == NULL)
{
@ -375,7 +383,8 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
if (Size > 0)
{
if (pDest) {
if (pDest)
{
if (rContent.m_pContent->m_pData)
{
u8* pSrc = &rContent.m_pContent->m_pData[rContent.m_Position];
@ -384,8 +393,15 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
else
{
File::IOFile* pFile = &rContent.m_File;
pFile->Seek(rContent.m_Position, SEEK_SET);
pFile->ReadBytes(pDest, Size);
if (!pFile->Seek(rContent.m_Position, SEEK_SET))
{
ERROR_LOG(WII_IPC_ES, "ES: couldn't seek!");
}
WARN_LOG(WII_IPC_ES, "2 %p", pFile->GetHandle());
if (!pFile->ReadBytes(pDest, Size))
{
ERROR_LOG(WII_IPC_ES, "ES: short read; returning uninitialized data!");
}
}
rContent.m_Position += Size;
} else {

View File

@ -213,8 +213,8 @@ bool CNANDContentLoader::Initialize(const std::string& _rName)
File::IOFile pTMDFile(TMDFileName, "rb");
if (!pTMDFile)
{
DEBUG_LOG(DISCIO, "CreateFromDirectory: error opening %s",
TMDFileName.c_str());
WARN_LOG(DISCIO, "CreateFromDirectory: error opening %s",
TMDFileName.c_str());
return false;
}
u32 pTMDSize = (u32)File::GetSize(TMDFileName);
@ -222,8 +222,7 @@ bool CNANDContentLoader::Initialize(const std::string& _rName)
pTMDFile.ReadBytes(pTMD, (size_t)pTMDSize);
pTMDFile.Close();
}
if (!pTMD)
return false;
memcpy(m_TMDView, pTMD + 0x180, TMD_VIEW_SIZE);
memcpy(m_TMDHeader, pTMD, TMD_HEADER_SIZE);
@ -276,7 +275,10 @@ bool CNANDContentLoader::Initialize(const std::string& _rName)
}
// Be graceful about incorrect tmds.
rContent.m_Size = (u32) File::GetSize(rContent.m_Filename);
if (File::Exists(rContent.m_Filename))
{
rContent.m_Size = (u32) File::GetSize(rContent.m_Filename);
}
}
delete [] pTMD;