mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-22 20:06:40 +00:00
pgl: update with client C++ bindings
This commit is contained in:
parent
e14dc18bd3
commit
eca2b453ae
5 changed files with 140 additions and 5 deletions
|
@ -24,12 +24,13 @@ namespace ams::pgl {
|
||||||
Result Initialize();
|
Result Initialize();
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
Result LaunchProgram(const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags);
|
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags);
|
||||||
Result TerminateProcess(os::ProcessId process_id);
|
Result TerminateProcess(os::ProcessId process_id);
|
||||||
Result LaunchProgramFromHost(const char *content_path, u32 process_flags);
|
Result LaunchProgramFromHost(os::ProcessId *out, const char *content_path, u32 process_flags);
|
||||||
Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path);
|
Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path);
|
||||||
Result GetApplicationProcessId(os::ProcessId *out);
|
Result GetApplicationProcessId(os::ProcessId *out);
|
||||||
Result BoostSystemMemoryResourceLimit(u64 size);
|
Result BoostSystemMemoryResourceLimit(u64 size);
|
||||||
|
Result IsProcessTracked(bool *out, os::ProcessId process_id);
|
||||||
Result EnableApplicationCrashReport(bool enabled);
|
Result EnableApplicationCrashReport(bool enabled);
|
||||||
Result IsApplicationCrashReportEnabled(bool *out);
|
Result IsApplicationCrashReportEnabled(bool *out);
|
||||||
Result EnableApplicationAllThreadDumpOnCrash(bool enabled);
|
Result EnableApplicationAllThreadDumpOnCrash(bool enabled);
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace ams::pgl {
|
||||||
enum class SnapShotDumpType : u32 {
|
enum class SnapShotDumpType : u32 {
|
||||||
None = 0,
|
None = 0,
|
||||||
Auto = 1,
|
Auto = 1,
|
||||||
Full = 1,
|
Full = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO: Is this really nn::ncm::Content<Something>Info? */
|
/* TODO: Is this really nn::ncm::Content<Something>Info? */
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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 <stratosphere.hpp>
|
||||||
|
|
||||||
|
namespace ams::pgl {
|
||||||
|
|
||||||
|
class RemoteEventObserver final : public pgl::sf::IEventObserver {
|
||||||
|
NON_COPYABLE(RemoteEventObserver);
|
||||||
|
NON_MOVEABLE(RemoteEventObserver);
|
||||||
|
private:
|
||||||
|
::PglEventObserver observer;
|
||||||
|
public:
|
||||||
|
constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ }
|
||||||
|
virtual ~RemoteEventObserver() override {
|
||||||
|
::pglEventObserverClose(std::addressof(this->observer));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override {
|
||||||
|
::Event ev;
|
||||||
|
R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev)));
|
||||||
|
out.SetValue(ev.revent);
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override {
|
||||||
|
static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo));
|
||||||
|
return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
89
libraries/libstratosphere/source/pgl/pgl_shell_api.cpp
Normal file
89
libraries/libstratosphere/source/pgl/pgl_shell_api.cpp
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
#include "pgl_remote_event_observer.hpp"
|
||||||
|
|
||||||
|
namespace ams::pgl {
|
||||||
|
|
||||||
|
Result Initialize() {
|
||||||
|
return ::pglInitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Finalize() {
|
||||||
|
return pglExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result LaunchProgram(os::ProcessId *out, const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags) {
|
||||||
|
static_assert(sizeof(*out) == sizeof(u64));
|
||||||
|
static_assert(sizeof(loc) == sizeof(::NcmProgramLocation));
|
||||||
|
return ::pglLaunchProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const ::NcmProgramLocation *>(std::addressof(loc)), process_flags, pgl_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result TerminateProcess(os::ProcessId process_id) {
|
||||||
|
return ::pglTerminateProcess(static_cast<u64>(process_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
Result LaunchProgramFromHost(os::ProcessId *out, const char *content_path, u32 process_flags) {
|
||||||
|
static_assert(sizeof(*out) == sizeof(u64));
|
||||||
|
return ::pglLaunchProgramFromHost(reinterpret_cast<u64 *>(out), content_path, process_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path) {
|
||||||
|
static_assert(sizeof(*out) == sizeof(::PglContentMetaInfo));
|
||||||
|
return ::pglGetHostContentMetaInfo(reinterpret_cast<::PglContentMetaInfo *>(out), content_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result GetApplicationProcessId(os::ProcessId *out) {
|
||||||
|
static_assert(sizeof(*out) == sizeof(u64));
|
||||||
|
return ::pglGetApplicationProcessId(reinterpret_cast<u64 *>(out));
|
||||||
|
}
|
||||||
|
|
||||||
|
Result BoostSystemMemoryResourceLimit(u64 size) {
|
||||||
|
return ::pglBoostSystemMemoryResourceLimit(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IsProcessTracked(bool *out, os::ProcessId process_id) {
|
||||||
|
return ::pglIsProcessTracked(out, static_cast<u64>(process_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
Result EnableApplicationCrashReport(bool enabled) {
|
||||||
|
return ::pglEnableApplicationCrashReport(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result IsApplicationCrashReportEnabled(bool *out) {
|
||||||
|
return ::pglIsApplicationCrashReportEnabled(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result EnableApplicationAllThreadDumpOnCrash(bool enabled) {
|
||||||
|
return ::pglEnableApplicationAllThreadDumpOnCrash(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result TriggerSnapShotDumper(const char *arg, SnapShotDumpType dump_type) {
|
||||||
|
return ::pglTriggerSnapShotDumper(arg, static_cast<::PglSnapShotDumpType>(dump_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
Result GetEventObserver(pgl::EventObserver *out) {
|
||||||
|
::PglEventObserver obs;
|
||||||
|
R_TRY(::pglGetEventObserver(std::addressof(obs)));
|
||||||
|
|
||||||
|
auto remote_observer = std::make_shared<RemoteEventObserver>(obs);
|
||||||
|
AMS_ABORT_UNLESS(remote_observer != nullptr);
|
||||||
|
|
||||||
|
*out = pgl::EventObserver(remote_observer);
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -110,9 +110,9 @@ int main(int argc, char **argv) {
|
||||||
/* Try to terminate the process. */
|
/* Try to terminate the process. */
|
||||||
if (hos::GetVersion() >= hos::Version_10_0_0) {
|
if (hos::GetVersion() >= hos::Version_10_0_0) {
|
||||||
/* On 10.0.0+, use pgl to terminate. */
|
/* On 10.0.0+, use pgl to terminate. */
|
||||||
sm::ScopedServiceHolder<pglInitialize, pglExit> pgl_holder;
|
sm::ScopedServiceHolder<pgl::Initialize, pgl::Finalize> pgl_holder;
|
||||||
if (pgl_holder) {
|
if (pgl_holder) {
|
||||||
pglTerminateProcess(static_cast<u64>(crashed_pid));
|
pgl::TerminateProcess(crashed_pid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* On < 10.0.0, use ns:dev to terminate. */
|
/* On < 10.0.0, use ns:dev to terminate. */
|
||||||
|
|
Loading…
Reference in a new issue