mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-15 00:16:48 +00:00
pgl: Implement three more commands.
This commit is contained in:
parent
6ce038acad
commit
e53a592f72
7 changed files with 83 additions and 7 deletions
|
@ -23,7 +23,9 @@
|
|||
namespace ams::pm::shell {
|
||||
|
||||
/* Shell API. */
|
||||
Result LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 launch_flags);
|
||||
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 launch_flags);
|
||||
Result TerminateProcess(os::ProcessId process_id);
|
||||
Result GetApplicationProcessIdForShell(os::ProcessId *out);
|
||||
Result BoostSystemMemoryResourceLimit(u64 size);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <vapours/results/lr_results.hpp>
|
||||
#include <vapours/results/os_results.hpp>
|
||||
#include <vapours/results/ncm_results.hpp>
|
||||
#include <vapours/results/pgl_results.hpp>
|
||||
#include <vapours/results/pm_results.hpp>
|
||||
#include <vapours/results/psc_results.hpp>
|
||||
#include <vapours/results/ro_results.hpp>
|
||||
|
|
29
libraries/libvapours/include/vapours/results/pgl_results.hpp
Normal file
29
libraries/libvapours/include/vapours/results/pgl_results.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/results/results_common.hpp>
|
||||
|
||||
namespace ams::pgl {
|
||||
|
||||
R_DEFINE_NAMESPACE_RESULT_MODULE(228);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(ApplicationNotRunning, 3);
|
||||
R_DEFINE_ERROR_RESULT(BufferNotEnough, 4);
|
||||
R_DEFINE_ERROR_RESULT(ApplicationContentNotFound, 5);
|
||||
R_DEFINE_ERROR_RESULT(ContentMetaNotFound, 4);
|
||||
|
||||
}
|
Loading…
Reference in a new issue