From 5165ed9efd6e6593b969ce560c952e074f4d9e06 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 24 Dec 2023 19:20:43 -0500 Subject: service: fetch objects from the client handle table --- src/core/hle/service/jit/jit.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/core/hle/service/jit') diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 65851fc05..8648c76fa 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp @@ -188,7 +188,7 @@ public: return; } - auto tmem{process->GetHandleTable().GetObject(tmem_handle)}; + auto tmem{ctx.GetObjectFromHandle(tmem_handle)}; if (tmem.IsNull()) { LOG_ERROR(Service_JIT, "attempted to load plugin with invalid transfer memory handle"); IPC::ResponseBuilder rb{ctx, 2}; @@ -356,11 +356,7 @@ public: return; } - // Fetch using the handle table for the application process here, - // since we are not multiprocess yet. - const auto& handle_table{system.ApplicationProcess()->GetHandleTable()}; - - auto process{handle_table.GetObject(process_handle)}; + auto process{ctx.GetObjectFromHandle(process_handle)}; if (process.IsNull()) { LOG_ERROR(Service_JIT, "process is null for handle=0x{:08X}", process_handle); IPC::ResponseBuilder rb{ctx, 2}; @@ -368,7 +364,7 @@ public: return; } - auto rx_mem{handle_table.GetObject(rx_mem_handle)}; + auto rx_mem{ctx.GetObjectFromHandle(rx_mem_handle)}; if (rx_mem.IsNull()) { LOG_ERROR(Service_JIT, "rx_mem is null for handle=0x{:08X}", rx_mem_handle); IPC::ResponseBuilder rb{ctx, 2}; @@ -376,7 +372,7 @@ public: return; } - auto ro_mem{handle_table.GetObject(ro_mem_handle)}; + auto ro_mem{ctx.GetObjectFromHandle(ro_mem_handle)}; if (ro_mem.IsNull()) { LOG_ERROR(Service_JIT, "ro_mem is null for handle=0x{:08X}", ro_mem_handle); IPC::ResponseBuilder rb{ctx, 2}; -- cgit v1.2.3 From 47e44a6693ad2e8c7fbdaa23ed440d9780e1d54b Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 24 Dec 2023 19:30:16 -0500 Subject: am/jit: reference memory instance from context --- src/core/hle/service/am/am.cpp | 6 ++---- src/core/hle/service/hle_ipc.h | 4 ++++ src/core/hle/service/jit/jit.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/core/hle/service/jit') diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index dabec1119..97eb56ff0 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1523,8 +1523,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(HLERequestContext& ctx) } std::vector memory(transfer_mem->GetSize()); - system.ApplicationMemory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), - memory.size()); + ctx.GetMemory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), memory.size()); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); @@ -1556,8 +1555,7 @@ void ILibraryAppletCreator::CreateHandleStorage(HLERequestContext& ctx) { } std::vector memory(transfer_mem->GetSize()); - system.ApplicationMemory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), - memory.size()); + ctx.GetMemory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), memory.size()); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/hle_ipc.h b/src/core/hle/service/hle_ipc.h index 69a3cce36..40d86943e 100644 --- a/src/core/hle/service/hle_ipc.h +++ b/src/core/hle/service/hle_ipc.h @@ -360,6 +360,10 @@ public: return *thread; } + [[nodiscard]] Core::Memory::Memory& GetMemory() const { + return memory; + } + template Kernel::KScopedAutoObject GetObjectFromHandle(u32 handle) { auto obj = client_handle_table->GetObjectForIpc(handle, thread); diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 8648c76fa..a94d05e19 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp @@ -26,7 +26,7 @@ public: explicit IJitEnvironment(Core::System& system_, Kernel::KProcess& process_, CodeRange user_rx, CodeRange user_ro) : ServiceFramework{system_, "IJitEnvironment"}, process{&process_}, - context{system_.ApplicationMemory()} { + context{process->GetMemory()} { // clang-format off static const FunctionInfo functions[] = { {0, &IJitEnvironment::GenerateCode, "GenerateCode"}, -- cgit v1.2.3