diff options
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/function_wrappers.h | 8 | ||||
-rw-r--r-- | src/core/hle/svc.cpp | 31 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 3e886fdba..abc2b96a8 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h @@ -161,6 +161,14 @@ void Wrap() { FuncReturn(retval); } +template <ResultCode func(u32*, Kernel::Handle)> +void Wrap() { + u32 param_1 = 0; + u32 retval = func(¶m_1, PARAM(1)).raw; + Core::CPU().SetReg(1, param_1); + FuncReturn(retval); +} + template <ResultCode func(u32)> void Wrap() { FuncReturn(func(PARAM(0)).raw); diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 0401f763b..4b5c1dff3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -71,6 +71,33 @@ static ResultCode SendSyncRequest(Kernel::Handle handle) { return session->SendSyncRequest(Kernel::GetCurrentThread()); } +/// Get the ID for the specified thread. +static ResultCode GetThreadId(u32* thread_id, Kernel::Handle handle) { + LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); + + const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); + if (thread == nullptr) { + return ERR_INVALID_HANDLE; + } + + *thread_id = thread->GetThreadId(); + return RESULT_SUCCESS; +} + +/// Get the ID of the specified process +static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) { + LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); + + const SharedPtr<Kernel::Process> process = + Kernel::g_handle_table.Get<Kernel::Process>(process_handle); + if (process == nullptr) { + return ERR_INVALID_HANDLE; + } + + *process_id = process->process_id; + return RESULT_SUCCESS; +} + /// Break program execution static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); @@ -213,8 +240,8 @@ static const FunctionDef SVC_Table[] = { {0x21, HLE::Wrap<SendSyncRequest>, "svcSendSyncRequest"}, {0x22, nullptr, "svcSendSyncRequestWithUserBuffer"}, {0x23, nullptr, "svcSendAsyncRequestWithUserBuffer"}, - {0x24, nullptr, "svcGetProcessId"}, - {0x25, nullptr, "svcGetThreadId"}, + {0x24, HLE::Wrap<GetProcessId>, "svcGetProcessId"}, + {0x25, HLE::Wrap<GetThreadId>, "svcGetThreadId"}, {0x26, HLE::Wrap<Break>, "svcBreak"}, {0x27, HLE::Wrap<OutputDebugString>, "svcOutputDebugString"}, {0x28, nullptr, "svcReturnFromException"}, |