From 860f07f5a14a53376b12b1f84b6a868e2693b27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 13 Jun 2017 00:52:53 +0200 Subject: [PATCH] IOS/ES: Expose GetDeviceId --- Source/Core/Core/IOS/ES/ES.cpp | 2 +- Source/Core/Core/IOS/ES/ES.h | 4 +++- Source/Core/Core/IOS/ES/Identity.cpp | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index e215e67570..eac70ae1dd 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -423,7 +423,7 @@ IPCCommandResult ES::IOCtlV(const IOCtlVRequest& request) case IOCTL_ES_ADDTITLECANCEL: return ImportTitleCancel(*context, request); case IOCTL_ES_GETDEVICEID: - return GetConsoleID(request); + return GetDeviceId(request); case IOCTL_ES_OPENTITLECONTENT: return OpenTitleContent(context->uid, request); case IOCTL_ES_OPENCONTENT: diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index 0cb7deadef..b53a8780f5 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -132,6 +132,8 @@ public: ReturnCode DeleteSharedContent(const std::array& sha1) const; ReturnCode DeleteContent(u64 title_id, u32 content_id) const; + ReturnCode GetDeviceId(u32* device_id) const; + // Views ReturnCode GetV0TicketFromView(const u8* ticket_view, u8* ticket) const; ReturnCode GetTicketFromView(const u8* ticket_view, u8* ticket, u32* ticket_size) const; @@ -237,7 +239,7 @@ private: IPCCommandResult DeleteContent(const IOCtlVRequest& request); // Device identity and encryption - IPCCommandResult GetConsoleID(const IOCtlVRequest& request); + IPCCommandResult GetDeviceId(const IOCtlVRequest& request); IPCCommandResult GetDeviceCertificate(const IOCtlVRequest& request); IPCCommandResult CheckKoreaRegion(const IOCtlVRequest& request); IPCCommandResult Sign(const IOCtlVRequest& request); diff --git a/Source/Core/Core/IOS/ES/Identity.cpp b/Source/Core/Core/IOS/ES/Identity.cpp index eb58e9c656..9e24a78959 100644 --- a/Source/Core/Core/IOS/ES/Identity.cpp +++ b/Source/Core/Core/IOS/ES/Identity.cpp @@ -18,14 +18,24 @@ namespace HLE { namespace Device { -IPCCommandResult ES::GetConsoleID(const IOCtlVRequest& request) +ReturnCode ES::GetDeviceId(u32* device_id) const { - if (!request.HasNumberOfValidVectors(0, 1)) + const EcWii& ec = EcWii::GetInstance(); + *device_id = ec.GetNGID(); + INFO_LOG(IOS_ES, "GetDeviceId: %08X", *device_id); + return IPC_SUCCESS; +} + +IPCCommandResult ES::GetDeviceId(const IOCtlVRequest& request) +{ + if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != sizeof(u32)) return GetDefaultReply(ES_EINVAL); - const EcWii& ec = EcWii::GetInstance(); - INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICEID %08X", ec.GetNGID()); - Memory::Write_U32(ec.GetNGID(), request.io_vectors[0].address); + u32 device_id; + const ReturnCode ret = GetDeviceId(&device_id); + if (ret != IPC_SUCCESS) + return GetDefaultReply(ret); + Memory::Write_U32(device_id, request.io_vectors[0].address); return GetDefaultReply(IPC_SUCCESS); }