diff options
| author | 2015-05-11 17:44:26 -0700 | |
|---|---|---|
| committer | 2015-05-11 17:44:26 -0700 | |
| commit | 820b97787c9bdfaed018558f33b8d3542e6d6b1f (patch) | |
| tree | f2050259d4a9584aa3000335e91b7fc210ec1947 /src/core/hle/svc.cpp | |
| parent | Merge pull request #754 from purpasmart96/nwm_typo_fix (diff) | |
| parent | fixup! (diff) | |
| download | yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.gz yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.tar.xz yuzu-820b97787c9bdfaed018558f33b8d3542e6d6b1f.zip | |
Merge pull request #750 from Subv/process_svc
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 1ec6599c7..e8159fbdb 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "core/hle/kernel/address_arbiter.h" | 16 | #include "core/hle/kernel/address_arbiter.h" |
| 17 | #include "core/hle/kernel/event.h" | 17 | #include "core/hle/kernel/event.h" |
| 18 | #include "core/hle/kernel/mutex.h" | 18 | #include "core/hle/kernel/mutex.h" |
| 19 | #include "core/hle/kernel/process.h" | ||
| 19 | #include "core/hle/kernel/semaphore.h" | 20 | #include "core/hle/kernel/semaphore.h" |
| 20 | #include "core/hle/kernel/shared_memory.h" | 21 | #include "core/hle/kernel/shared_memory.h" |
| 21 | #include "core/hle/kernel/thread.h" | 22 | #include "core/hle/kernel/thread.h" |
| @@ -424,6 +425,34 @@ static ResultCode ReleaseMutex(Handle handle) { | |||
| 424 | return RESULT_SUCCESS; | 425 | return RESULT_SUCCESS; |
| 425 | } | 426 | } |
| 426 | 427 | ||
| 428 | /// Get the ID of the specified process | ||
| 429 | static ResultCode GetProcessId(u32* process_id, Handle process_handle) { | ||
| 430 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); | ||
| 431 | |||
| 432 | const SharedPtr<Kernel::Process> process = Kernel::g_handle_table.Get<Kernel::Process>(process_handle); | ||
| 433 | if (process == nullptr) | ||
| 434 | return ERR_INVALID_HANDLE; | ||
| 435 | |||
| 436 | *process_id = process->process_id; | ||
| 437 | return RESULT_SUCCESS; | ||
| 438 | } | ||
| 439 | |||
| 440 | /// Get the ID of the process that owns the specified thread | ||
| 441 | static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { | ||
| 442 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); | ||
| 443 | |||
| 444 | const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(thread_handle); | ||
| 445 | if (thread == nullptr) | ||
| 446 | return ERR_INVALID_HANDLE; | ||
| 447 | |||
| 448 | const SharedPtr<Kernel::Process> process = thread->owner_process; | ||
| 449 | |||
| 450 | ASSERT_MSG(process != nullptr, "Invalid parent process for thread=0x%08X", thread_handle); | ||
| 451 | |||
| 452 | *process_id = process->process_id; | ||
| 453 | return RESULT_SUCCESS; | ||
| 454 | } | ||
| 455 | |||
| 427 | /// Get the ID for the specified thread. | 456 | /// Get the ID for the specified thread. |
| 428 | static ResultCode GetThreadId(u32* thread_id, Handle handle) { | 457 | static ResultCode GetThreadId(u32* thread_id, Handle handle) { |
| 429 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); | 458 | LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); |
| @@ -674,8 +703,8 @@ static const FunctionDef SVC_Table[] = { | |||
| 674 | {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"}, | 703 | {0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"}, |
| 675 | {0x33, nullptr, "OpenProcess"}, | 704 | {0x33, nullptr, "OpenProcess"}, |
| 676 | {0x34, nullptr, "OpenThread"}, | 705 | {0x34, nullptr, "OpenThread"}, |
| 677 | {0x35, nullptr, "GetProcessId"}, | 706 | {0x35, HLE::Wrap<GetProcessId>, "GetProcessId"}, |
| 678 | {0x36, nullptr, "GetProcessIdOfThread"}, | 707 | {0x36, HLE::Wrap<GetProcessIdOfThread>, "GetProcessIdOfThread"}, |
| 679 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, | 708 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, |
| 680 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, | 709 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, |
| 681 | {0x39, nullptr, "GetResourceLimitLimitValues"}, | 710 | {0x39, nullptr, "GetResourceLimitLimitValues"}, |