diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 368b500115fffcec67dbe6cdebec2bacf1d547e0..e5b296d60a675e2eada8a178dd70fbeb7599cb98 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -233,6 +233,12 @@ public: */ template <typename T> T PopRaw(); + + template <typename T> + Kernel::SharedPtr<T> GetMoveObject(size_t index); + + template <typename T> + Kernel::SharedPtr<T> GetCopyObject(size_t index); }; /// Pop /// @@ -293,4 +299,14 @@ void RequestParser::Pop(First& first_value, Other&... other_values) { Pop(other_values...); } +template <typename T> +Kernel::SharedPtr<T> RequestParser::GetMoveObject(size_t index) { + return context->GetMoveObject<T>(index); +} + +template <typename T> +Kernel::SharedPtr<T> RequestParser::GetCopyObject(size_t index) { + return context->GetCopyObject<T>(index); +} + } // namespace IPC diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 0ab28c0a2edfd06c636680f6c293fd740192bdb3..1c6adb4a003aecdcc0006eda39fbe3d721a595ee 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<Handle>())); + } + for (u32 handle = 0; handle < handle_descriptor_header->num_handles_to_move; ++handle) { + move_objects.push_back(Kernel::g_handle_table.GetGeneric(rp.Pop<Handle>())); + } + } 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 48730a2b24a2e960d29b225676d9fc869bbc0224..266fcf9c1e82f8ce64c296843cb7bac2c60450e8 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<typename T> + SharedPtr<T> GetCopyObject(size_t index) { + ASSERT(index < copy_objects.size()); + return DynamicObjectCast(copy_objects[index]); + } + + template<typename T> + SharedPtr<T> GetMoveObject(size_t index) { + ASSERT(index < move_objects.size()); + return DynamicObjectCast(move_objects[index]); + } + void AddMoveObject(SharedPtr<Object> object) { move_objects.emplace_back(std::move(object)); }