From 8fd2f057414d51e4145f71675c356359bcbd1902 Mon Sep 17 00:00:00 2001 From: BhaaL Date: Mon, 14 Mar 2016 21:49:51 +0100 Subject: [PATCH] remove all accesses to m_pContent this fixes the crashes, but leaves the "else" part of ES_READCONTENT temporarily broken until the next commit. WAD access that are performed on the encrypted WAD will most likely fail with this commit. --- .../Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 20 ++++++++++--------- .../Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp index b14dae1ad0..3f28100833 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -163,7 +163,7 @@ void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p) SContentAccess& Access = pair.second; Position = Access.m_Position; TitleID = Access.m_TitleID; - Index = Access.m_pContent->m_Index; + Index = Access.m_Index; p.Do(CFD); p.Do(Position); p.Do(TitleID); @@ -220,7 +220,8 @@ u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index) SContentAccess Access; Access.m_Position = 0; - Access.m_pContent = pContent; + Access.m_Index = pContent->m_Index; + Access.m_Size = pContent->m_Size; Access.m_TitleID = TitleID; Access.m_pFile = nullptr; @@ -391,16 +392,17 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) u8* pDest = Memory::GetPointer(Addr); - if (rContent.m_Position + Size > rContent.m_pContent->m_Size) + if (rContent.m_Position + Size > rContent.m_Size) { - Size = rContent.m_pContent->m_Size-rContent.m_Position; + Size = rContent.m_Size - rContent.m_Position; } if (Size > 0) { if (pDest) { - if (rContent.m_pContent->m_data.empty()) + // FIXME: this breaks WAD access (the else part), fixed in the next commit + //if (rContent.m_pContent->m_data.empty()) { auto& pFile = rContent.m_pFile; if (!pFile->Seek(rContent.m_Position, SEEK_SET)) @@ -413,11 +415,11 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) ERROR_LOG(WII_IPC_ES, "ES: short read; returning uninitialized data!"); } } - else + /*else { const u8* src = &rContent.m_pContent->m_data[rContent.m_Position]; memcpy(pDest, src, Size); - } + }*/ rContent.m_Position += Size; } @@ -427,7 +429,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) } } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_READCONTENT: CFD %x, Address 0x%x, Size %i -> stream pos %i (Index %i)", CFD, Addr, Size, rContent.m_Position, rContent.m_pContent->m_Index); + INFO_LOG(WII_IPC_ES, "IOCTL_ES_READCONTENT: CFD %x, Address 0x%x, Size %i -> stream pos %i (Index %i)", CFD, Addr, Size, rContent.m_Position, rContent.m_Index); Memory::Write_U32(Size, _CommandAddress + 0x4); return GetDefaultReply(); @@ -486,7 +488,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) break; case 2: // END - rContent.m_Position = rContent.m_pContent->m_Size + Addr; + rContent.m_Position = rContent.m_Size + Addr; break; } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h index 42836735be..07b5fbede4 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h @@ -125,7 +125,8 @@ private: { u32 m_Position; u64 m_TitleID; - const DiscIO::SNANDContent* m_pContent; + u16 m_Index; + u32 m_Size; // This is a (raw) pointer to work around a MSVC bug. File::IOFile* m_pFile; };