diff options
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 2b242ff98..8cb6a1c94 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -598,10 +598,24 @@ static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) { | |||
| 598 | 598 | ||
| 599 | /// Sets the priority for the specified thread | 599 | /// Sets the priority for the specified thread |
| 600 | static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { | 600 | static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) { |
| 601 | if (priority > THREADPRIO_LOWEST) { | ||
| 602 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, | ||
| 603 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 604 | } | ||
| 605 | |||
| 601 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); | 606 | SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); |
| 602 | if (thread == nullptr) | 607 | if (thread == nullptr) |
| 603 | return ERR_INVALID_HANDLE; | 608 | return ERR_INVALID_HANDLE; |
| 604 | 609 | ||
| 610 | using Kernel::ResourceLimit; | ||
| 611 | // Note: The kernel uses the current process's resource limit instead of | ||
| 612 | // the one from the thread owner's resource limit. | ||
| 613 | Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit; | ||
| 614 | if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { | ||
| 615 | return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS, | ||
| 616 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 617 | } | ||
| 618 | |||
| 605 | thread->SetPriority(priority); | 619 | thread->SetPriority(priority); |
| 606 | thread->UpdatePriority(); | 620 | thread->UpdatePriority(); |
| 607 | 621 | ||