pgl: Implement three more commands.

This commit is contained in:
Michael Scire
2020-04-16 02:45:36 -07:00
parent 6ce038acad
commit e53a592f72
7 changed files with 83 additions and 7 deletions

View File

@@ -73,6 +73,15 @@ namespace ams::pgl::srv {
}
}
std::optional<os::ProcessId> GetRunningApplicationProcessId() {
os::ProcessId process_id;
if (R_SUCCEEDED(pm::shell::GetApplicationProcessIdForShell(std::addressof(process_id)))) {
return process_id;
} else {
return std::nullopt;
}
}
}
void InitializeProcessControlTask() {
@@ -108,7 +117,29 @@ namespace ams::pgl::srv {
}
Result TerminateProcess(os::ProcessId process_id) {
/* Ask PM to terminate the process. */
return pm::shell::TerminateProcess(process_id);
}
}
Result GetApplicationProcessId(os::ProcessId *out) {
/* Get the application process id. */
auto application_process_id = GetRunningApplicationProcessId();
R_UNLESS(application_process_id, pgl::ResultApplicationNotRunning());
/* Return the id. */
*out = *application_process_id;
return ResultSuccess();
}
Result BoostSystemMemoryResourceLimit(u64 size) {
/* Ask PM to boost the limit. */
return pm::shell::BoostSystemMemoryResourceLimit(size);
}
bool IsProcessTracked(os::ProcessId process_id) {
/* Check whether a ProcessData exists for the process. */
std::scoped_lock lk(g_process_data_mutex);
return FindProcessData(process_id) != nullptr;
}
}

View File

@@ -22,5 +22,8 @@ namespace ams::pgl::srv {
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 pm_flags, u8 pgl_flags);
Result TerminateProcess(os::ProcessId process_id);
Result GetApplicationProcessId(os::ProcessId *out);
Result BoostSystemMemoryResourceLimit(u64 size);
bool IsProcessTracked(os::ProcessId process_id);
}

View File

@@ -36,15 +36,16 @@ namespace ams::pgl::srv {
}
Result ShellInterface::GetApplicationProcessId(ams::sf::Out<os::ProcessId> out) {
/* TODO */
return pgl::srv::GetApplicationProcessId(out.GetPointer());
}
Result ShellInterface::BoostSystemMemoryResourceLimit(u64 size) {
/* TODO */
return pgl::srv::BoostSystemMemoryResourceLimit(size);
}
Result ShellInterface::IsProcessTracked(ams::sf::Out<bool> out, os::ProcessId process_id) {
/* TODO */
out.SetValue(pgl::srv::IsProcessTracked(process_id));
return ResultSuccess();
}
Result ShellInterface::EnableApplicationCrashReport(bool enabled) {

View File

@@ -18,14 +18,23 @@
namespace ams::pm::shell {
/* Shell API. */
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 launch_flags) {
Result WEAK_SYMBOL LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags) {
static_assert(sizeof(ncm::ProgramLocation) == sizeof(NcmProgramLocation));
static_assert(alignof(ncm::ProgramLocation) == alignof(NcmProgramLocation));
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out_process_id));
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out));
}
Result TerminateProcess(os::ProcessId process_id) {
return ::pmshellTerminateProcess(static_cast<u64>(process_id));
}
Result GetApplicationProcessIdForShell(os::ProcessId *out) {
static_assert(sizeof(*out) == sizeof(u64));
return ::pmshellGetApplicationProcessIdForShell(reinterpret_cast<u64 *>(out));
}
Result BoostSystemMemoryResourceLimit(u64 size) {
return ::pmshellBoostSystemMemoryResourceLimit(size);
}
}