summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index d3293a1fe..80d70a816 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -291,8 +291,7 @@ static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr
291} 291}
292 292
293/// Connect to an OS service given the port name, returns the handle to the port to out 293/// Connect to an OS service given the port name, returns the handle to the port to out
294static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, 294static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) {
295 VAddr port_name_address) {
296 auto& memory = system.Memory(); 295 auto& memory = system.Memory();
297 if (!memory.IsValidVirtualAddress(port_name_address)) { 296 if (!memory.IsValidVirtualAddress(port_name_address)) {
298 LOG_ERROR(Kernel_SVC, 297 LOG_ERROR(Kernel_SVC,
@@ -324,15 +323,21 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
324 } 323 }
325 auto port = it->second; 324 auto port = it->second;
326 325
326 // Reserve a handle for the port.
327 // NOTE: Nintendo really does write directly to the output handle here.
328 R_TRY(handle_table.Reserve(out));
329 auto handle_guard = SCOPE_GUARD({ handle_table.Unreserve(*out); });
330
327 // Create a session. 331 // Create a session.
328 KClientSession* session{}; 332 KClientSession* session{};
329 R_TRY(port->CreateSession(std::addressof(session))); 333 R_TRY(port->CreateSession(std::addressof(session)));
330 334
331 // Register the session in the table, close the extra reference. 335 // Register the session in the table, close the extra reference.
332 handle_table.Add(out_handle, session); 336 handle_table.Register(*out, session);
333 session->Close(); 337 session->Close();
334 338
335 // We succeeded. 339 // We succeeded.
340 handle_guard.Cancel();
336 return RESULT_SUCCESS; 341 return RESULT_SUCCESS;
337} 342}
338 343