From 32847d8b860af1210612027680eea1cbf9765b51 Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 7 Jan 2018 09:22:20 -0500 Subject: IPC: Add functions to read the input move/copy objects from an IPC request. --- src/core/hle/kernel/hle_ipc.cpp | 16 ++++++++++++++-- src/core/hle/kernel/hle_ipc.h | 12 ++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 0ab28c0a2..1c6adb4a0 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -53,8 +53,20 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) { if (handle_descriptor_header->send_current_pid) { rp.Skip(2, false); } - rp.Skip(handle_descriptor_header->num_handles_to_copy, false); - rp.Skip(handle_descriptor_header->num_handles_to_move, false); + if (incoming) { + // Populate the object lists with the data in the IPC request. + for (u32 handle = 0; handle < handle_descriptor_header->num_handles_to_copy; ++handle) { + copy_objects.push_back(Kernel::g_handle_table.GetGeneric(rp.Pop())); + } + for (u32 handle = 0; handle < handle_descriptor_header->num_handles_to_move; ++handle) { + move_objects.push_back(Kernel::g_handle_table.GetGeneric(rp.Pop())); + } + } else { + // For responses we just ignore the handles, they're empty and will be populated when + // translating the response. + rp.Skip(handle_descriptor_header->num_handles_to_copy, false); + rp.Skip(handle_descriptor_header->num_handles_to_move, false); + } } for (unsigned i = 0; i < command_header->num_buf_x_descriptors; ++i) { diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 48730a2b2..266fcf9c1 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -147,6 +147,18 @@ public: return domain != nullptr; } + template + SharedPtr GetCopyObject(size_t index) { + ASSERT(index < copy_objects.size()); + return DynamicObjectCast(copy_objects[index]); + } + + template + SharedPtr GetMoveObject(size_t index) { + ASSERT(index < move_objects.size()); + return DynamicObjectCast(move_objects[index]); + } + void AddMoveObject(SharedPtr object) { move_objects.emplace_back(std::move(object)); } -- cgit v1.2.3