summaryrefslogtreecommitdiff
path: root/src/core/hle/ipc_helpers.h
diff options
context:
space:
mode:
authorGravatar Subv2018-01-06 21:14:14 -0500
committerGravatar bunnei2018-01-07 17:11:43 -0500
commit226786f0b05405b4c0287786f106ae2e08feefec (patch)
treef4cb770adc575fa749b98e60f8f5fa0012cdc4c6 /src/core/hle/ipc_helpers.h
parentsvc: Implement svcSignalProcessWideKey. (diff)
downloadyuzu-226786f0b05405b4c0287786f106ae2e08feefec.tar.gz
yuzu-226786f0b05405b4c0287786f106ae2e08feefec.tar.xz
yuzu-226786f0b05405b4c0287786f106ae2e08feefec.zip
IPC: Use the correct size when pushing raw data to the command buffer and fixed pushing domain objects.
Domain object ids are always stored immediately after the raw data.
Diffstat (limited to 'src/core/hle/ipc_helpers.h')
-rw-r--r--src/core/hle/ipc_helpers.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index 28a2b8545..705943e6b 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -58,14 +58,20 @@ public:
58 RequestBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {} 58 RequestBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {}
59 59
60 RequestBuilder(Kernel::HLERequestContext& context, unsigned normal_params_size, 60 RequestBuilder(Kernel::HLERequestContext& context, unsigned normal_params_size,
61 u32 num_handles_to_copy = 0, u32 num_handles_to_move = 0) 61 u32 num_handles_to_copy = 0, u32 num_handles_to_move = 0, u32 num_domain_objects = 0)
62 : RequestHelperBase(context) { 62 : RequestHelperBase(context) {
63 memset(cmdbuf, 0, 64); 63 memset(cmdbuf, 0, 64);
64 64
65 context.ClearIncomingObjects(); 65 context.ClearIncomingObjects();
66 66
67 IPC::CommandHeader header{}; 67 IPC::CommandHeader header{};
68 header.data_size.Assign(normal_params_size * sizeof(u32)); 68
69 // The entire size of the raw data section in u32 units, including the 16 bytes of mandatory padding.
70 u32 raw_data_size = sizeof(IPC::DataPayloadHeader) / 4 + 4 + normal_params_size;
71 if (context.IsDomain())
72 raw_data_size += sizeof(DomainResponseMessageHeader) / 4 + num_domain_objects;
73
74 header.data_size.Assign(raw_data_size);
69 if (num_handles_to_copy || num_handles_to_move) { 75 if (num_handles_to_copy || num_handles_to_move) {
70 header.enable_handle_descriptor.Assign(1); 76 header.enable_handle_descriptor.Assign(1);
71 } 77 }
@@ -82,7 +88,9 @@ public:
82 AlignWithPadding(); 88 AlignWithPadding();
83 89
84 if (context.IsDomain()) { 90 if (context.IsDomain()) {
85 PushRaw(IPC::DomainMessageHeader{}); 91 IPC::DomainResponseMessageHeader domain_header{};
92 domain_header.num_objects = num_domain_objects;
93 PushRaw(domain_header);
86 } 94 }
87 95
88 IPC::DataPayloadHeader data_payload_header{}; 96 IPC::DataPayloadHeader data_payload_header{};
@@ -93,9 +101,10 @@ public:
93 template <class T> 101 template <class T>
94 void PushIpcInterface() { 102 void PushIpcInterface() {
95 auto& request_handlers = context->Domain()->request_handlers; 103 auto& request_handlers = context->Domain()->request_handlers;
96 request_handlers.push_back(std::move(std::make_shared<T>()->shared_from_this())); 104 request_handlers.emplace_back(std::make_shared<T>());
97 Push(RESULT_SUCCESS); 105 Push(RESULT_SUCCESS);
98 AlignWithPadding(); 106 Push<u32>(0); // The error code is the lower word of an u64, so we fill the rest with 0.
107 // Now push the id of the newly-added object.
99 Push<u32>(static_cast<u32>(request_handlers.size())); 108 Push<u32>(static_cast<u32>(request_handlers.size()));
100 } 109 }
101 110