summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-12-19 05:09:08 +0100
committerLioncash <mathew1800@gmail.com>2018-12-19 18:16:15 +0100
commitb74eb88c68e85d08695667eaf4603bb565c8eb64 (patch)
treec77772e3f471ecf327cdce440fe49c1df81be84d /src
parentkernel/kernel: Use correct initial PID for userland Process instances (diff)
downloadyuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar.gz
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar.bz2
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar.lz
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar.xz
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.tar.zst
yuzu-b74eb88c68e85d08695667eaf4603bb565c8eb64.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/svc.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index bcc9864f3..030333077 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -364,20 +364,33 @@ static ResultCode GetThreadId(u64* thread_id, Handle thread_handle) {
return RESULT_SUCCESS;
}
-/// Get the ID of the specified process
-static ResultCode GetProcessId(u64* process_id, Handle process_handle) {
- LOG_TRACE(Kernel_SVC, "called process=0x{:08X}", process_handle);
+/// Gets the ID of the specified process or a specified thread's owning process.
+static ResultCode GetProcessId(u64* process_id, Handle handle) {
+ LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
- const SharedPtr<Process> process = handle_table.Get<Process>(process_handle);
- if (!process) {
- LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
- process_handle);
- return ERR_INVALID_HANDLE;
+ const SharedPtr<Process> process = handle_table.Get<Process>(handle);
+ if (process) {
+ *process_id = process->GetProcessID();
+ return RESULT_SUCCESS;
}
- *process_id = process->GetProcessID();
- return RESULT_SUCCESS;
+ const SharedPtr<Thread> thread = handle_table.Get<Thread>(handle);
+ if (thread) {
+ const Process* const owner_process = thread->GetOwnerProcess();
+ if (!owner_process) {
+ LOG_ERROR(Kernel_SVC, "Non-existent owning process encountered.");
+ return ERR_INVALID_HANDLE;
+ }
+
+ *process_id = owner_process->GetProcessID();
+ return RESULT_SUCCESS;
+ }
+
+ // NOTE: This should also handle debug objects before returning.
+
+ LOG_ERROR(Kernel_SVC, "Handle does not exist, handle=0x{:08X}", handle);
+ return ERR_INVALID_HANDLE;
}
/// Default thread wakeup callback for WaitSynchronization