summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-24 11:54:16 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:53 +0200
commit7866eb03bb2e84917ba3930efed6c6b52035f368 (patch)
tree42a91cb32c9cda9c64f06a7b0f243892aa740789
parenthle: kernel: Migrate to KHandleTable. (diff)
downloadyuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar.gz
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar.bz2
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar.lz
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar.xz
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.tar.zst
yuzu-7866eb03bb2e84917ba3930efed6c6b52035f368.zip
-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
}
/// Connect to an OS service given the port name, returns the handle to the port to out
-static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
- VAddr port_name_address) {
+static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) {
auto& memory = system.Memory();
if (!memory.IsValidVirtualAddress(port_name_address)) {
LOG_ERROR(Kernel_SVC,
@@ -324,15 +323,21 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
}
auto port = it->second;
+ // Reserve a handle for the port.
+ // NOTE: Nintendo really does write directly to the output handle here.
+ R_TRY(handle_table.Reserve(out));
+ auto handle_guard = SCOPE_GUARD({ handle_table.Unreserve(*out); });
+
// Create a session.
KClientSession* session{};
R_TRY(port->CreateSession(std::addressof(session)));
// Register the session in the table, close the extra reference.
- handle_table.Add(out_handle, session);
+ handle_table.Register(*out, session);
session->Close();
// We succeeded.
+ handle_guard.Cancel();
return RESULT_SUCCESS;
}