diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index a0de1ce9c6..21a9c94c82 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -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 { diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index b0dcd302f7..974f8a9945 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -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;