diff options
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 15 | ||||
-rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 3 | ||||
-rw-r--r-- | src/core/hle/kernel/k_server_session.cpp | 13 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 260af87e5..45aced99f 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -41,6 +41,21 @@ SessionRequestManager::SessionRequestManager(KernelCore& kernel_) : kernel{kerne SessionRequestManager::~SessionRequestManager() = default; +bool SessionRequestManager::HasSessionRequestHandler(const HLERequestContext& context) const { + if (IsDomain() && context.HasDomainMessageHeader()) { + const auto& message_header = context.GetDomainMessageHeader(); + const auto object_id = message_header.object_id; + + if (object_id > DomainHandlerCount()) { + LOG_CRITICAL(IPC, "object_id {} is too big!", object_id); + return false; + } + return DomainHandler(object_id - 1) != nullptr; + } else { + return session_handler != nullptr; + } +} + void SessionRequestHandler::ClientConnected(KServerSession* session) { session->SetSessionHandler(shared_from_this()); } diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 159565203..a61870f8b 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -156,6 +156,8 @@ public: return session_handler->GetServiceThread(); } + bool HasSessionRequestHandler(const HLERequestContext& context) const; + private: bool is_domain{}; SessionRequestHandlerPtr session_handler; @@ -163,7 +165,6 @@ private: private: KernelCore& kernel; - std::weak_ptr<ServiceThread> service_thread; }; /** diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index 61213c20e..dd62706a8 100644 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp @@ -119,11 +119,16 @@ ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memor context->PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf); - if (auto strong_ptr = manager->GetServiceThread().lock()) { - strong_ptr->QueueSyncRequest(*parent, std::move(context)); - return ResultSuccess; + // Ensure we have a session request handler + if (manager->HasSessionRequestHandler(*context)) { + if (auto strong_ptr = manager->GetServiceThread().lock()) { + strong_ptr->QueueSyncRequest(*parent, std::move(context)); + return ResultSuccess; + } else { + ASSERT_MSG(false, "strong_ptr is nullptr!"); + } } else { - ASSERT_MSG(false, "strong_ptr was nullptr!"); + ASSERT_MSG(false, "handler is invalid!"); } return ResultSuccess; |