WFSI: Implement both GET_TMD ioctls.
This commit is contained in:
parent
c81636d9a8
commit
56aa3cc558
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "Core/IOS/WFS/WFSI.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <mbedtls/aes.h>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
@ -248,6 +249,33 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
break;
|
||||
|
||||
case IOCTL_WFSI_GET_TMD:
|
||||
{
|
||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
INFO_LOG(IOS, "IOCTL_WFSI_GET_TMD: subtitle ID %016" PRIx64, subtitle_id);
|
||||
|
||||
u32 tmd_size;
|
||||
return_error_code = GetTmd(m_group_id, m_title_id, subtitle_id, address, &tmd_size);
|
||||
Memory::Write_U32(tmd_size, request.buffer_out);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_WFSI_GET_TMD_ABSOLUTE:
|
||||
{
|
||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
u16 group_id = Memory::Read_U16(request.buffer_in + 36);
|
||||
u32 title_id = Memory::Read_U32(request.buffer_in + 32);
|
||||
INFO_LOG(IOS, "IOCTL_WFSI_GET_TMD_ABSOLUTE: tid %08x, gid %04x, subtitle ID %016" PRIx64,
|
||||
title_id, group_id, subtitle_id);
|
||||
|
||||
u32 tmd_size;
|
||||
return_error_code = GetTmd(group_id, title_id, subtitle_id, address, &tmd_size);
|
||||
Memory::Write_U32(tmd_size, request.buffer_out);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_WFSI_SET_FST_BUFFER:
|
||||
{
|
||||
INFO_LOG(IOS, "IOCTL_WFSI_SET_FST_BUFFER: address %08x, size %08x", request.buffer_in,
|
||||
|
@ -309,6 +337,27 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
return GetDefaultReply(return_error_code);
|
||||
}
|
||||
|
||||
u32 WFSI::GetTmd(u16 group_id, u32 title_id, u64 subtitle_id, u32 address, u32* size) const
|
||||
{
|
||||
// TODO(wfs): This is using a separate copy of tid/gid in wfssrv. Why?
|
||||
std::string path =
|
||||
StringFromFormat("/vol/%s/title/%s/%s/meta/%016" PRIx64 ".tmd", m_device_name.c_str(),
|
||||
m_group_id_str.c_str(), m_title_id_str.c_str(), subtitle_id);
|
||||
File::IOFile fp(WFS::NativePath(path), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
WARN_LOG(IOS, "GetTmd: no such file or directory: %s", path.c_str());
|
||||
return WFSI_ENOENT;
|
||||
}
|
||||
if (address)
|
||||
{
|
||||
fp.ReadBytes(Memory::GetPointer(address), fp.GetSize());
|
||||
}
|
||||
*size = fp.GetSize();
|
||||
return IPC_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace Device
|
||||
} // namespace HLE
|
||||
} // namespace IOS
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
|
||||
|
||||
private:
|
||||
u32 GetTmd(u16 group_id, u32 title_id, u64 subtitle_id, u32 address, u32* size) const;
|
||||
std::string m_device_name;
|
||||
|
||||
mbedtls_aes_context m_aes_ctx;
|
||||
|
@ -84,6 +85,9 @@ private:
|
|||
|
||||
IOCTL_WFSI_APPLY_TITLE_PROFILE = 0x89,
|
||||
|
||||
IOCTL_WFSI_GET_TMD = 0x8a,
|
||||
IOCTL_WFSI_GET_TMD_ABSOLUTE = 0x8b,
|
||||
|
||||
IOCTL_WFSI_SET_FST_BUFFER = 0x8e,
|
||||
|
||||
IOCTL_WFSI_LOAD_DOL = 0x90,
|
||||
|
|
Loading…
Reference in New Issue