From 41f74a16fd55934f747f6f7e1f7a6d4d6a3d4e57 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 11 May 2015 09:15:10 -0500 Subject: Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread --- src/core/hle/svc.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 1ec6599c7..b5cf554c3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -16,6 +16,7 @@ #include "core/hle/kernel/address_arbiter.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/mutex.h" +#include "core/hle/kernel/process.h" #include "core/hle/kernel/semaphore.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/thread.h" @@ -424,6 +425,34 @@ static ResultCode ReleaseMutex(Handle handle) { return RESULT_SUCCESS; } +/// Get the ID of the specified process +static ResultCode GetProcessId(u32* process_id, Handle handle) { + LOG_TRACE(Kernel_SVC, "called process=0x%08X", handle); + + const SharedPtr process = Kernel::g_handle_table.Get(handle); + if (process == nullptr) + return ERR_INVALID_HANDLE; + + *process_id = process->GetProcessId(); + return RESULT_SUCCESS; +} + +/// Get the ID of the process that owns the specified thread +static ResultCode GetProcessIdOfThread(u32* process_id, Handle handle) { + LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); + + const SharedPtr thread = Kernel::g_handle_table.Get(handle); + if (thread == nullptr) + return ERR_INVALID_HANDLE; + + const SharedPtr process = thread->owner_process; + if (process == nullptr) + return ERR_INVALID_HANDLE; + + *process_id = process->process_id; + return RESULT_SUCCESS; +} + /// Get the ID for the specified thread. static ResultCode GetThreadId(u32* thread_id, Handle handle) { LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); @@ -674,8 +703,8 @@ static const FunctionDef SVC_Table[] = { {0x32, HLE::Wrap, "SendSyncRequest"}, {0x33, nullptr, "OpenProcess"}, {0x34, nullptr, "OpenThread"}, - {0x35, nullptr, "GetProcessId"}, - {0x36, nullptr, "GetProcessIdOfThread"}, + {0x35, HLE::Wrap, "GetProcessId"}, + {0x36, HLE::Wrap, "GetProcessIdOfThread"}, {0x37, HLE::Wrap, "GetThreadId"}, {0x38, HLE::Wrap, "GetResourceLimit"}, {0x39, nullptr, "GetResourceLimitLimitValues"}, -- cgit v1.2.3 From 25c010dc7dda010175da42e1184e87cd1a45cbe4 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 11 May 2015 18:23:45 -0500 Subject: fixup! --- src/core/hle/svc.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core/hle/svc.cpp') diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index b5cf554c3..e8159fbdb 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -426,28 +426,28 @@ static ResultCode ReleaseMutex(Handle handle) { } /// Get the ID of the specified process -static ResultCode GetProcessId(u32* process_id, Handle handle) { - LOG_TRACE(Kernel_SVC, "called process=0x%08X", handle); +static ResultCode GetProcessId(u32* process_id, Handle process_handle) { + LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); - const SharedPtr process = Kernel::g_handle_table.Get(handle); + const SharedPtr process = Kernel::g_handle_table.Get(process_handle); if (process == nullptr) return ERR_INVALID_HANDLE; - *process_id = process->GetProcessId(); + *process_id = process->process_id; return RESULT_SUCCESS; } /// Get the ID of the process that owns the specified thread -static ResultCode GetProcessIdOfThread(u32* process_id, Handle handle) { - LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); +static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { + LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); - const SharedPtr thread = Kernel::g_handle_table.Get(handle); + const SharedPtr thread = Kernel::g_handle_table.Get(thread_handle); if (thread == nullptr) return ERR_INVALID_HANDLE; const SharedPtr process = thread->owner_process; - if (process == nullptr) - return ERR_INVALID_HANDLE; + + ASSERT_MSG(process != nullptr, "Invalid parent process for thread=0x%08X", thread_handle); *process_id = process->process_id; return RESULT_SUCCESS; -- cgit v1.2.3