From 4e667bc7c13e3a54c62df5c7c67d87260dce93a2 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 10 Jul 2020 00:28:30 -0700 Subject: [PATCH] kern: implement remaining non-KServerSession:: part of Reply/Receive --- libraries/libmesosphere/source/svc/kern_svc_ipc.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp b/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp index 803e7b5fc..259fa8b5c 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_ipc.cpp @@ -37,8 +37,17 @@ namespace ams::kern::svc { ALWAYS_INLINE Result ReplyAndReceiveImpl(int32_t *out_index, uintptr_t message, size_t buffer_size, KPhysicalAddress message_paddr, KSynchronizationObject **objs, int32_t num_objects, ams::svc::Handle reply_target, int64_t timeout_ns) { /* Reply to the target, if one is specified. */ if (reply_target != ams::svc::InvalidHandle) { - /* TODO */ - MESOSPHERE_UNIMPLEMENTED(); + KScopedAutoObject session = GetCurrentProcess().GetHandleTable().GetObject(reply_target); + R_UNLESS(session.IsNotNull(), svc::ResultInvalidHandle()); + + /* If we fail to reply, we want to set the output index to -1. */ + auto reply_idx_guard = SCOPE_GUARD { *out_index = -1; }; + + /* Send the reply. */ + R_TRY(session->SendReply(message, buffer_size, message_paddr)); + + /* Cancel our guard. */ + reply_idx_guard.Cancel(); } /* Receive a message. */