Merge pull request #1618 from JosJuice/dvd-low-open-partition

Fix Wii disc partitions
This commit is contained in:
skidau
2014-12-03 21:24:56 +11:00
8 changed files with 107 additions and 69 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <memory>
#include "Common/CommonTypes.h"
#include "Common/Logging/LogManager.h"
@ -107,19 +108,16 @@ bool CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress)
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[1].m_Address == 0, "DVDLowOpenPartition with ticket");
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[2].m_Address == 0, "DVDLowOpenPartition with cert chain");
// Get TMD offset for requested partition...
u64 const TMDOffset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2 ) + 0x2c0;
u64 const partition_offset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2);
VolumeHandler::GetVolume()->ChangePartition(partition_offset);
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: TMDOffset 0x%016" PRIx64, TMDOffset);
static u32 const TMDsz = 0x208; //CommandBuffer.PayloadBuffer[0].m_Size;
u8 pTMD[TMDsz];
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset);
// Read TMD to the buffer
VolumeHandler::RAWReadToPtr(pTMD, TMDOffset, TMDsz);
Memory::CopyToEmu(CommandBuffer.PayloadBuffer[0].m_Address, pTMD, TMDsz);
WII_IPC_HLE_Interface::ES_DIVerify(pTMD, TMDsz);
u32 tmd_size;
std::unique_ptr<u8[]> tmd_buf = VolumeHandler::GetVolume()->GetTMD(&tmd_size);
Memory::CopyToEmu(CommandBuffer.PayloadBuffer[0].m_Address, tmd_buf.get(), tmd_size);
WII_IPC_HLE_Interface::ES_DIVerify(tmd_buf.get(), tmd_size);
ReturnValue = 1;
}