diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index e37c72cc15..3caca2f93e 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -42,6 +42,7 @@ ResultVal> ServiceManager::RegisterService( auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name); + registered_services_inverse.emplace(client_port->GetObjectId(), name); registered_services.emplace(std::move(name), std::move(client_port)); return MakeResult(std::move(server_port)); } @@ -65,4 +66,12 @@ ResultVal> ServiceManager::ConnectToServi return client_port->Connect(); } +std::string ServiceManager::GetServiceNameByPortId(u32 port) const { + if (registered_services_inverse.count(port)) { + return registered_services_inverse.at(port); + } + + return ""; +} + } // namespace Service::SM diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index dc26d88148..6e47fd1525 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -51,6 +51,8 @@ public: unsigned int max_sessions); ResultVal> GetServicePort(const std::string& name); ResultVal> ConnectToService(const std::string& name); + // For IPC Recorder + std::string GetServiceNameByPortId(u32 port) const; template std::shared_ptr GetService(const std::string& service_name) const { @@ -74,6 +76,10 @@ private: /// Map of registered services, retrieved using GetServicePort or ConnectToService. std::unordered_map> registered_services; + + // For IPC Recorder + /// client port Object id -> service name + std::unordered_map registered_services_inverse; }; } // namespace Service::SM