summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2023-12-09 11:25:21 -0500
committerGravatar Liam2023-12-09 13:45:25 -0500
commit5feda37688cafee8054910cd05916742c8263f89 (patch)
treed43fcaac349a7c636d2214cc1cb4e8ddaa69d8af
parentservice: use interface factory in server manager (diff)
downloadyuzu-5feda37688cafee8054910cd05916742c8263f89.tar.gz
yuzu-5feda37688cafee8054910cd05916742c8263f89.tar.xz
yuzu-5feda37688cafee8054910cd05916742c8263f89.zip
service: populate pid and handle table from client
-rw-r--r--src/core/hle/kernel/k_server_session.cpp3
-rw-r--r--src/core/hle/service/hle_ipc.cpp15
-rw-r--r--src/core/hle/service/hle_ipc.h14
3 files changed, 19 insertions, 13 deletions
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp
index 3ea653163..598ec7878 100644
--- a/src/core/hle/kernel/k_server_session.cpp
+++ b/src/core/hle/kernel/k_server_session.cpp
@@ -462,8 +462,7 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<Service::HLERequestContext
462 std::make_shared<Service::HLERequestContext>(m_kernel, memory, this, client_thread); 462 std::make_shared<Service::HLERequestContext>(m_kernel, memory, this, client_thread);
463 (*out_context)->SetSessionRequestManager(manager); 463 (*out_context)->SetSessionRequestManager(manager);
464 (*out_context) 464 (*out_context)
465 ->PopulateFromIncomingCommandBuffer(client_thread->GetOwnerProcess()->GetHandleTable(), 465 ->PopulateFromIncomingCommandBuffer(*client_thread->GetOwnerProcess(), cmd_buf);
466 cmd_buf);
467 } else { 466 } else {
468 KThread* server_thread = GetCurrentThreadPointer(m_kernel); 467 KThread* server_thread = GetCurrentThreadPointer(m_kernel);
469 KProcess& src_process = *client_thread->GetOwnerProcess(); 468 KProcess& src_process = *client_thread->GetOwnerProcess();
diff --git a/src/core/hle/service/hle_ipc.cpp b/src/core/hle/service/hle_ipc.cpp
index ff374ae39..38955932c 100644
--- a/src/core/hle/service/hle_ipc.cpp
+++ b/src/core/hle/service/hle_ipc.cpp
@@ -146,8 +146,10 @@ HLERequestContext::HLERequestContext(Kernel::KernelCore& kernel_, Core::Memory::
146 146
147HLERequestContext::~HLERequestContext() = default; 147HLERequestContext::~HLERequestContext() = default;
148 148
149void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_table, 149void HLERequestContext::ParseCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf,
150 u32_le* src_cmdbuf, bool incoming) { 150 bool incoming) {
151 client_handle_table = &process.GetHandleTable();
152
151 IPC::RequestParser rp(src_cmdbuf); 153 IPC::RequestParser rp(src_cmdbuf);
152 command_header = rp.PopRaw<IPC::CommandHeader>(); 154 command_header = rp.PopRaw<IPC::CommandHeader>();
153 155
@@ -160,7 +162,8 @@ void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_ta
160 if (command_header->enable_handle_descriptor) { 162 if (command_header->enable_handle_descriptor) {
161 handle_descriptor_header = rp.PopRaw<IPC::HandleDescriptorHeader>(); 163 handle_descriptor_header = rp.PopRaw<IPC::HandleDescriptorHeader>();
162 if (handle_descriptor_header->send_current_pid) { 164 if (handle_descriptor_header->send_current_pid) {
163 pid = rp.Pop<u64>(); 165 pid = process.GetProcessId();
166 rp.Skip(2, false);
164 } 167 }
165 if (incoming) { 168 if (incoming) {
166 // Populate the object lists with the data in the IPC request. 169 // Populate the object lists with the data in the IPC request.
@@ -267,9 +270,9 @@ void HLERequestContext::ParseCommandBuffer(const Kernel::KHandleTable& handle_ta
267 rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. 270 rp.Skip(1, false); // The command is actually an u64, but we don't use the high part.
268} 271}
269 272
270Result HLERequestContext::PopulateFromIncomingCommandBuffer( 273Result HLERequestContext::PopulateFromIncomingCommandBuffer(Kernel::KProcess& process,
271 const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf) { 274 u32_le* src_cmdbuf) {
272 ParseCommandBuffer(handle_table, src_cmdbuf, true); 275 ParseCommandBuffer(process, src_cmdbuf, true);
273 276
274 if (command_header->IsCloseCommand()) { 277 if (command_header->IsCloseCommand()) {
275 // Close does not populate the rest of the IPC header 278 // Close does not populate the rest of the IPC header
diff --git a/src/core/hle/service/hle_ipc.h b/src/core/hle/service/hle_ipc.h
index 4436f4f83..18d464c63 100644
--- a/src/core/hle/service/hle_ipc.h
+++ b/src/core/hle/service/hle_ipc.h
@@ -38,6 +38,7 @@ namespace Kernel {
38class KAutoObject; 38class KAutoObject;
39class KernelCore; 39class KernelCore;
40class KHandleTable; 40class KHandleTable;
41class KProcess;
41class KServerSession; 42class KServerSession;
42class KThread; 43class KThread;
43} // namespace Kernel 44} // namespace Kernel
@@ -195,8 +196,7 @@ public:
195 } 196 }
196 197
197 /// Populates this context with data from the requesting process/thread. 198 /// Populates this context with data from the requesting process/thread.
198 Result PopulateFromIncomingCommandBuffer(const Kernel::KHandleTable& handle_table, 199 Result PopulateFromIncomingCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf);
199 u32_le* src_cmdbuf);
200 200
201 /// Writes data from this context back to the requesting process/thread. 201 /// Writes data from this context back to the requesting process/thread.
202 Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread); 202 Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread);
@@ -359,6 +359,10 @@ public:
359 return *thread; 359 return *thread;
360 } 360 }
361 361
362 Kernel::KHandleTable& GetClientHandleTable() {
363 return *client_handle_table;
364 }
365
362 [[nodiscard]] std::shared_ptr<SessionRequestManager> GetManager() const { 366 [[nodiscard]] std::shared_ptr<SessionRequestManager> GetManager() const {
363 return manager.lock(); 367 return manager.lock();
364 } 368 }
@@ -374,12 +378,12 @@ public:
374private: 378private:
375 friend class IPC::ResponseBuilder; 379 friend class IPC::ResponseBuilder;
376 380
377 void ParseCommandBuffer(const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf, 381 void ParseCommandBuffer(Kernel::KProcess& process, u32_le* src_cmdbuf, bool incoming);
378 bool incoming);
379 382
380 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; 383 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
381 Kernel::KServerSession* server_session{}; 384 Kernel::KServerSession* server_session{};
382 Kernel::KThread* thread; 385 Kernel::KHandleTable* client_handle_table{};
386 Kernel::KThread* thread{};
383 387
384 std::vector<Handle> incoming_move_handles; 388 std::vector<Handle> incoming_move_handles;
385 std::vector<Handle> incoming_copy_handles; 389 std::vector<Handle> incoming_copy_handles;