From c53283185da77405d893e2c302319564423214dc Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 5 Feb 2012 16:16:33 +1100 Subject: [PATCH] Added an error check for invalid contents in ES_OPENCONTENT. Fixes Jungle Speed and Doc's Punch Out. Fixes issue 3035. --- .../Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) 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 2a33d01ed9..3bfeb847aa 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 @@ -254,24 +254,27 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) } break; - case IOCTL_ES_OPENCONTENT: - { - _dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 1); - _dbg_assert_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 0); + case IOCTL_ES_OPENCONTENT: + { + _dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 1); + _dbg_assert_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 0); - u32 CFD = AccessIdentID++; - u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address); + u32 CFD = AccessIdentID++; + u32 Index = Memory::Read_U32(Buffer.InBuffer[0].m_Address); - m_ContentAccessMap[CFD].m_Position = 0; - m_ContentAccessMap[CFD].m_pContent = AccessContentDevice(m_TitleID).GetContentByIndex(Index); - _dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL); + m_ContentAccessMap[CFD].m_Position = 0; + m_ContentAccessMap[CFD].m_pContent = AccessContentDevice(m_TitleID).GetContentByIndex(Index); + _dbg_assert_(WII_IPC_ES, m_ContentAccessMap[CFD].m_pContent != NULL); - Memory::Write_U32(CFD, _CommandAddress + 0x4); + if (m_ContentAccessMap[CFD].m_pContent == NULL) + CFD = 0xffffffff; //TODO: what is the correct error value here? - INFO_LOG(WII_IPC_ES, "IOCTL_ES_OPENCONTENT: Index %i -> got CFD %x", Index, CFD); - return true; - } - break; + Memory::Write_U32(CFD, _CommandAddress + 0x4); + + INFO_LOG(WII_IPC_ES, "IOCTL_ES_OPENCONTENT: Index %i -> got CFD %x", Index, CFD); + return true; + } + break; case IOCTL_ES_READCONTENT: {