From 0a424b86d20cf7de81cb458625d5717707dd0000 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 2 Feb 2019 15:39:54 -0500 Subject: [PATCH] ServerSession: replace GetPointer with block copy for HLE translation Do it in the same way as HLERequestContext::SleepClientThread callback and avoid unsafe GetPointer --- src/core/hle/kernel/server_session.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index c07bc98400..27923ac5d6 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -66,14 +66,13 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr thread) { // If this ServerSession has an associated HLE handler, forward the request to it. if (hle_handler != nullptr) { - // TODO(wwylele): avoid GetPointer - u32* cmd_buf = - reinterpret_cast(kernel.memory.GetPointer(thread->GetCommandBufferAddress())); - + std::array cmd_buf; Kernel::Process* current_process = thread->owner_process; + kernel.memory.ReadBlock(*current_process, thread->GetCommandBufferAddress(), cmd_buf.data(), + cmd_buf.size() * sizeof(u32)); Kernel::HLERequestContext context(this); - context.PopulateFromIncomingCommandBuffer(cmd_buf, *current_process); + context.PopulateFromIncomingCommandBuffer(cmd_buf.data(), *current_process); hle_handler->HandleSyncRequest(context); @@ -83,7 +82,9 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr thread) { // put the thread to sleep then the writing of the command buffer will be deferred to the // wakeup callback. if (thread->status == Kernel::ThreadStatus::Running) { - context.WriteToOutgoingCommandBuffer(cmd_buf, *current_process); + context.WriteToOutgoingCommandBuffer(cmd_buf.data(), *current_process); + kernel.memory.WriteBlock(*current_process, thread->GetCommandBufferAddress(), + cmd_buf.data(), cmd_buf.size() * sizeof(u32)); } }