mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
pgl: skeleton api
This commit is contained in:
parent
c7743c6098
commit
e14dc18bd3
8 changed files with 257 additions and 39 deletions
|
@ -51,6 +51,7 @@
|
|||
#include <stratosphere/ncm.hpp>
|
||||
#include <stratosphere/nim.hpp>
|
||||
#include <stratosphere/patcher.hpp>
|
||||
#include <stratosphere/pgl.hpp>
|
||||
#include <stratosphere/psc.hpp>
|
||||
#include <stratosphere/pm.hpp>
|
||||
#include <stratosphere/reg.hpp>
|
||||
|
|
21
libraries/libstratosphere/include/stratosphere/pgl.hpp
Normal file
21
libraries/libstratosphere/include/stratosphere/pgl.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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/pgl/pgl_types.hpp>
|
||||
#include <stratosphere/pgl/pgl_event_observer.hpp>
|
||||
#include <stratosphere/pgl/pgl_shell_api.hpp>
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2019-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/os.hpp>
|
||||
#include <stratosphere/pm.hpp>
|
||||
#include <stratosphere/pgl/pgl_types.hpp>
|
||||
#include <stratosphere/pgl/sf/pgl_sf_i_event_observer.hpp>
|
||||
|
||||
namespace ams::pgl {
|
||||
|
||||
class EventObserver {
|
||||
NON_COPYABLE(EventObserver);
|
||||
private:
|
||||
std::shared_ptr<pgl::sf::IEventObserver> interface;
|
||||
public:
|
||||
EventObserver() { /* ... */ }
|
||||
explicit EventObserver(std::shared_ptr<pgl::sf::IEventObserver> intf) : interface(std::move(intf)) { /* ... */ }
|
||||
|
||||
EventObserver(EventObserver &&rhs) {
|
||||
this->interface = std::move(rhs.interface);
|
||||
}
|
||||
|
||||
EventObserver &operator=(EventObserver &&rhs) {
|
||||
EventObserver(std::move(rhs)).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Swap(EventObserver &rhs) {
|
||||
std::swap(this->interface, rhs.interface);
|
||||
}
|
||||
public:
|
||||
Result GetSystemEvent(os::SystemEventType *out) {
|
||||
ams::sf::CopyHandle handle;
|
||||
R_TRY(this->interface->GetProcessEventHandle(std::addressof(handle)));
|
||||
os::AttachSystemEvent(out, handle.GetValue(), true, svc::InvalidHandle, false, os::EventClearMode_AutoClear);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result GetProcessEventInfo(pm::ProcessEventInfo *out) {
|
||||
return this->interface->GetProcessEventInfo(out);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.hpp>
|
||||
#include <stratosphere/pgl/pgl_types.hpp>
|
||||
#include <stratosphere/pgl/pgl_event_observer.hpp>
|
||||
|
||||
namespace ams::pgl {
|
||||
|
||||
Result Initialize();
|
||||
void Finalize();
|
||||
|
||||
Result LaunchProgram(const ncm::ProgramLocation &loc, u32 process_flags, u8 pgl_flags);
|
||||
Result TerminateProcess(os::ProcessId process_id);
|
||||
Result LaunchProgramFromHost(const char *content_path, u32 process_flags);
|
||||
Result GetHostContentMetaInfo(pgl::ContentMetaInfo *out, const char *content_path);
|
||||
Result GetApplicationProcessId(os::ProcessId *out);
|
||||
Result BoostSystemMemoryResourceLimit(u64 size);
|
||||
Result EnableApplicationCrashReport(bool enabled);
|
||||
Result IsApplicationCrashReportEnabled(bool *out);
|
||||
Result EnableApplicationAllThreadDumpOnCrash(bool enabled);
|
||||
Result TriggerSnapShotDumper(const char *arg, SnapShotDumpType dump_type);
|
||||
|
||||
Result GetEventObserver(pgl::EventObserver *out);
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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.hpp>
|
||||
#include <stratosphere/os.hpp>
|
||||
#include <stratosphere/pm.hpp>
|
||||
#include <stratosphere/ncm.hpp>
|
||||
|
||||
namespace ams::pgl {
|
||||
|
||||
enum LaunchFlags : u8 {
|
||||
LaunchFlags_EnableDetailedCrashReport = (1 << 0),
|
||||
LaunchFlags_EnableCrashReportScreenShotForProduction = (1 << 1),
|
||||
LaunchFlags_EnableCrashReportScreenShotForDevelop = (1 << 2),
|
||||
};
|
||||
|
||||
enum class SnapShotDumpType : u32 {
|
||||
None = 0,
|
||||
Auto = 1,
|
||||
Full = 1,
|
||||
};
|
||||
|
||||
/* TODO: Is this really nn::ncm::Content<Something>Info? */
|
||||
struct ContentMetaInfo {
|
||||
u64 id;
|
||||
u32 version;
|
||||
ncm::ContentType content_type;
|
||||
u8 id_offset;
|
||||
u8 reserved_0E[2];
|
||||
|
||||
static constexpr ContentMetaInfo Make(u64 id, u32 version, ncm::ContentType content_type, u8 id_offset) {
|
||||
return {
|
||||
.id = id,
|
||||
.version = version,
|
||||
.content_type = content_type,
|
||||
.id_offset = id_offset,
|
||||
};
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(ContentMetaInfo) == 0x10 && std::is_pod<ContentMetaInfo>::value);
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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.hpp>
|
||||
#include <stratosphere/os.hpp>
|
||||
#include <stratosphere/pm.hpp>
|
||||
#include <stratosphere/pgl/pgl_types.hpp>
|
||||
|
||||
namespace ams::pgl::sf {
|
||||
|
||||
class IEventObserver : public ams::sf::IServiceObject {
|
||||
protected:
|
||||
enum class CommandId {
|
||||
GetProcessEventHandle = 0,
|
||||
GetProcessEventInfo = 1,
|
||||
};
|
||||
public:
|
||||
/* Actual commands. */
|
||||
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) = 0;
|
||||
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) = 0;
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
MAKE_SERVICE_COMMAND_META(GetProcessEventHandle),
|
||||
MAKE_SERVICE_COMMAND_META(GetProcessEventInfo),
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -34,6 +34,45 @@ namespace ams::pm {
|
|||
|
||||
using LimitableResource = ::LimitableResource;
|
||||
|
||||
enum class ProcessEvent {
|
||||
None = 0,
|
||||
Exited = 1,
|
||||
Started = 2,
|
||||
Exception = 3,
|
||||
DebugRunning = 4,
|
||||
DebugBreak = 5,
|
||||
};
|
||||
|
||||
enum class ProcessEventDeprecated {
|
||||
None = 0,
|
||||
Exception = 1,
|
||||
Exited = 2,
|
||||
DebugRunning = 3,
|
||||
DebugBreak = 4,
|
||||
Started = 5,
|
||||
};
|
||||
|
||||
inline u32 GetProcessEventValue(ProcessEvent event) {
|
||||
if (hos::GetVersion() >= hos::Version_5_0_0) {
|
||||
return static_cast<u32>(event);
|
||||
}
|
||||
switch (event) {
|
||||
case ProcessEvent::None:
|
||||
return static_cast<u32>(ProcessEventDeprecated::None);
|
||||
case ProcessEvent::Exited:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Exited);
|
||||
case ProcessEvent::Started:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Started);
|
||||
case ProcessEvent::Exception:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Exception);
|
||||
case ProcessEvent::DebugRunning:
|
||||
return static_cast<u32>(ProcessEventDeprecated::DebugRunning);
|
||||
case ProcessEvent::DebugBreak:
|
||||
return static_cast<u32>(ProcessEventDeprecated::DebugBreak);
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
struct ProcessEventInfo {
|
||||
u32 event;
|
||||
os::ProcessId process_id;
|
||||
|
|
|
@ -91,45 +91,6 @@ namespace ams::pm::impl {
|
|||
|
||||
#undef GET_FLAG_MASK
|
||||
|
||||
enum class ProcessEvent {
|
||||
None = 0,
|
||||
Exited = 1,
|
||||
Started = 2,
|
||||
Exception = 3,
|
||||
DebugRunning = 4,
|
||||
DebugBreak = 5,
|
||||
};
|
||||
|
||||
enum class ProcessEventDeprecated {
|
||||
None = 0,
|
||||
Exception = 1,
|
||||
Exited = 2,
|
||||
DebugRunning = 3,
|
||||
DebugBreak = 4,
|
||||
Started = 5,
|
||||
};
|
||||
|
||||
inline u32 GetProcessEventValue(ProcessEvent event) {
|
||||
if (hos::GetVersion() >= hos::Version_5_0_0) {
|
||||
return static_cast<u32>(event);
|
||||
}
|
||||
switch (event) {
|
||||
case ProcessEvent::None:
|
||||
return static_cast<u32>(ProcessEventDeprecated::None);
|
||||
case ProcessEvent::Exited:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Exited);
|
||||
case ProcessEvent::Started:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Started);
|
||||
case ProcessEvent::Exception:
|
||||
return static_cast<u32>(ProcessEventDeprecated::Exception);
|
||||
case ProcessEvent::DebugRunning:
|
||||
return static_cast<u32>(ProcessEventDeprecated::DebugRunning);
|
||||
case ProcessEvent::DebugBreak:
|
||||
return static_cast<u32>(ProcessEventDeprecated::DebugBreak);
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t MaxProcessInfos>
|
||||
class ProcessInfoAllocator {
|
||||
NON_COPYABLE(ProcessInfoAllocator);
|
||||
|
|
Loading…
Reference in a new issue