mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
[APT] Gracefully handle SetApplicationCpuTimeLimit with invalid inputs
This commit is contained in:
parent
fa0ee8a080
commit
18f1ea5453
1 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "ipc.hpp"
|
#include "ipc.hpp"
|
||||||
#include "kernel.hpp"
|
#include "kernel.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace APTCommands {
|
namespace APTCommands {
|
||||||
|
@ -311,12 +312,14 @@ void APTService::setApplicationCpuTimeLimit(u32 messagePointer) {
|
||||||
log("APT::SetApplicationCpuTimeLimit (percentage = %d%%)\n", percentage);
|
log("APT::SetApplicationCpuTimeLimit (percentage = %d%%)\n", percentage);
|
||||||
|
|
||||||
if (percentage < 5 || percentage > 89 || fixed != 1) {
|
if (percentage < 5 || percentage > 89 || fixed != 1) {
|
||||||
Helpers::panic("Invalid parameters passed to APT::SetApplicationCpuTimeLimit");
|
Helpers::warn("Invalid parameter passed to APT::SetApplicationCpuTimeLimit: (percentage, fixed) = (%d, %d)\n", percentage, fixed);
|
||||||
} else {
|
// TODO: Does the clamp operation happen? Verify with getApplicationCpuTimeLimit on hardware
|
||||||
|
percentage = std::clamp<u32>(percentage, 5, 89);
|
||||||
|
}
|
||||||
|
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x4F, 1, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x4F, 1, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
cpuTimeLimit = percentage;
|
cpuTimeLimit = percentage;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APTService::getApplicationCpuTimeLimit(u32 messagePointer) {
|
void APTService::getApplicationCpuTimeLimit(u32 messagePointer) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue