pm: update for new-ipc

This commit is contained in:
Michael Scire 2019-10-14 22:49:06 -07:00 committed by SciresM
parent 8bd2a9a23b
commit aa0826bb70
25 changed files with 239 additions and 219 deletions

View file

@ -22,11 +22,11 @@
namespace sts::pm::dmnt { namespace sts::pm::dmnt {
/* Debug Monitor API. */ /* Debug Monitor API. */
Result StartProcess(u64 process_id); Result StartProcess(os::ProcessId process_id);
Result GetProcessId(u64 *out_process_id, const ncm::TitleId title_id); Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id);
Result GetApplicationProcessId(u64 *out_process_id); Result GetApplicationProcessId(os::ProcessId *out_process_id);
Result HookToCreateApplicationProcess(Handle *out_handle); Result HookToCreateApplicationProcess(Handle *out_handle);
Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::TitleLocation *out_loc, u64 process_id); Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::TitleLocation *out_loc, os::ProcessId process_id);
Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource); Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource);
} }

View file

@ -22,8 +22,8 @@
namespace sts::pm::info { namespace sts::pm::info {
/* Information API. */ /* Information API. */
Result GetTitleId(ncm::TitleId *out_title_id, u64 process_id); Result GetTitleId(ncm::TitleId *out_title_id, os::ProcessId process_id);
Result GetProcessId(u64 *out_process_id, ncm::TitleId title_id); Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id);
Result HasLaunchedTitle(bool *out, ncm::TitleId title_id); Result HasLaunchedTitle(bool *out, ncm::TitleId title_id);
/* Information convenience API. */ /* Information convenience API. */

View file

@ -22,6 +22,6 @@
namespace sts::pm::shell { namespace sts::pm::shell {
/* Shell API. */ /* Shell API. */
Result LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags); Result LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags);
} }

View file

@ -16,6 +16,7 @@
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include "../os/os_common_types.hpp"
namespace sts::pm { namespace sts::pm {
@ -36,7 +37,7 @@ namespace sts::pm {
struct ProcessEventInfo { struct ProcessEventInfo {
u32 event; u32 event;
u64 process_id; os::ProcessId process_id;
}; };
static_assert(sizeof(ProcessEventInfo) == 0x10 && std::is_pod<ProcessEventInfo>::value, "ProcessEventInfo definition!"); static_assert(sizeof(ProcessEventInfo) == 0x10 && std::is_pod<ProcessEventInfo>::value, "ProcessEventInfo definition!");

View file

@ -581,7 +581,7 @@ namespace sts::sf::impl {
constexpr inline uintptr_t GetAddress() const { constexpr inline uintptr_t GetAddress() const {
static_assert(Offset <= Size, "Offset <= Size"); static_assert(Offset <= Size, "Offset <= Size");
static_assert(TypeSize <= Size, "TypeSize <= Size"); static_assert(TypeSize <= Size, "TypeSize <= Size");
static_assert(Offset + TypeSize <= Size, "Offset + TypeSize <= Size"); static_assert(Offset + TypeSize <= Size || false, "Offset + TypeSize <= Size");
return reinterpret_cast<uintptr_t>(&data[Offset]); return reinterpret_cast<uintptr_t>(&data[Offset]);
} }
@ -944,7 +944,7 @@ namespace sts::sf::impl {
} }
} else if constexpr (Info.arg_type == ArgumentType::OutData) { } else if constexpr (Info.arg_type == ArgumentType::OutData) {
/* New out rawdata. */ /* New out rawdata. */
constexpr size_t Offset = CommandMeta::InDataOffsets[Info.out_raw_data_index]; constexpr size_t Offset = CommandMeta::OutDataOffsets[Info.out_raw_data_index];
return T(out_raw_holder.template GetAddress<Offset, T::TypeSize>()); return T(out_raw_holder.template GetAddress<Offset, T::TypeSize>());
} else if constexpr (Info.arg_type == ArgumentType::InHandle) { } else if constexpr (Info.arg_type == ArgumentType::InHandle) {
/* New InHandle. */ /* New InHandle. */

View file

@ -18,12 +18,13 @@
#include "sm_types.hpp" #include "sm_types.hpp"
#include "../ncm/ncm_types.hpp" #include "../ncm/ncm_types.hpp"
#include "../os/os_common_types.hpp"
namespace sts::sm::manager { namespace sts::sm::manager {
/* Manager API. */ /* Manager API. */
Result RegisterProcess(u64 process_id, ncm::TitleId title_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size); Result RegisterProcess(os::ProcessId process_id, ncm::TitleId title_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size);
Result UnregisterProcess(u64 process_id); Result UnregisterProcess(os::ProcessId process_id);
/* Atmosphere extensions. */ /* Atmosphere extensions. */
Result EndInitialDefers(); Result EndInitialDefers();

View file

@ -23,16 +23,16 @@
namespace sts::pm::dmnt { namespace sts::pm::dmnt {
/* Debug Monitor API. */ /* Debug Monitor API. */
Result StartProcess(u64 process_id) { Result StartProcess(os::ProcessId process_id) {
return pmdmntStartProcess(process_id); return pmdmntStartProcess(static_cast<u64>(process_id));
} }
Result GetProcessId(u64 *out_process_id, const ncm::TitleId title_id) { Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id) {
return pmdmntGetTitlePid(out_process_id, static_cast<u64>(title_id)); return pmdmntGetTitlePid(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
} }
Result GetApplicationProcessId(u64 *out_process_id) { Result GetApplicationProcessId(os::ProcessId *out_process_id) {
return pmdmntGetApplicationPid(out_process_id); return pmdmntGetApplicationPid(reinterpret_cast<u64 *>(out_process_id));
} }
Result HookToCreateApplicationProcess(Handle *out_handle) { Result HookToCreateApplicationProcess(Handle *out_handle) {
@ -42,10 +42,10 @@ namespace sts::pm::dmnt {
return ResultSuccess; return ResultSuccess;
} }
Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::TitleLocation *out_loc, u64 process_id) { Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::TitleLocation *out_loc, os::ProcessId process_id) {
*out_handle = INVALID_HANDLE; *out_handle = INVALID_HANDLE;
*out_loc = {}; *out_loc = {};
return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<u64 *>(&out_loc->title_id), &out_loc->storage_id, process_id); return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<u64 *>(&out_loc->title_id), &out_loc->storage_id, static_cast<u64>(process_id));
} }
Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource) { Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource) {

View file

@ -31,16 +31,16 @@ namespace sts::pm::info {
} }
/* Information API. */ /* Information API. */
Result GetTitleId(ncm::TitleId *out_title_id, u64 process_id) { Result GetTitleId(ncm::TitleId *out_title_id, os::ProcessId process_id) {
std::scoped_lock lk(g_info_lock); std::scoped_lock lk(g_info_lock);
return pminfoGetTitleId(reinterpret_cast<u64 *>(out_title_id), process_id); return pminfoGetTitleId(reinterpret_cast<u64 *>(out_title_id), static_cast<u64>(process_id));
} }
Result GetProcessId(u64 *out_process_id, ncm::TitleId title_id) { Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id) {
std::scoped_lock lk(g_info_lock); std::scoped_lock lk(g_info_lock);
return pminfoAtmosphereGetProcessId(out_process_id, static_cast<u64>(title_id)); return pminfoAtmosphereGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
} }
Result WEAK HasLaunchedTitle(bool *out, ncm::TitleId title_id) { Result WEAK HasLaunchedTitle(bool *out, ncm::TitleId title_id) {

View file

@ -21,8 +21,8 @@
namespace sts::pm::shell { namespace sts::pm::shell {
/* Shell API. */ /* Shell API. */
Result WEAK LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) { Result WEAK LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {
return pmshellLaunchProcess(launch_flags, static_cast<u64>(loc.title_id), loc.storage_id, out_process_id); return pmshellLaunchProcess(launch_flags, static_cast<u64>(loc.title_id), loc.storage_id, reinterpret_cast<u64 *>(out_process_id));
} }
} }

View file

@ -24,12 +24,12 @@
namespace sts::sm::manager { namespace sts::sm::manager {
/* Manager API. */ /* Manager API. */
Result RegisterProcess(u64 process_id, ncm::TitleId title_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size) { Result RegisterProcess(os::ProcessId process_id, ncm::TitleId title_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {
return smManagerAtmosphereRegisterProcess(process_id, static_cast<u64>(title_id), acid, acid_size, aci, aci_size); return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(title_id), acid, acid_size, aci, aci_size);
} }
Result UnregisterProcess(u64 process_id) { Result UnregisterProcess(os::ProcessId process_id) {
return smManagerUnregisterProcess(process_id); return smManagerUnregisterProcess(static_cast<u64>(process_id));
} }
/* Atmosphere extensions. */ /* Atmosphere extensions. */

View file

@ -139,8 +139,8 @@ namespace sts::boot2 {
return c == '\r' || c == '\n'; return c == '\r' || c == '\n';
} }
void LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) { void LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {
u64 process_id = 0; os::ProcessId process_id = os::InvalidProcessId;
switch (pm::shell::LaunchTitle(&process_id, loc, launch_flags)) { switch (pm::shell::LaunchTitle(&process_id, loc, launch_flags)) {
case ResultKernelResourceExhausted: case ResultKernelResourceExhausted:
@ -187,7 +187,8 @@ namespace sts::boot2 {
R_ASSERT(set_sys_holder.GetResult()); R_ASSERT(set_sys_holder.GetResult());
u8 force_maintenance = 1; u8 force_maintenance = 1;
setsysGetSettingsItemValue("boot", "force_maintenance", &force_maintenance, sizeof(force_maintenance)); u64 size_out;
setsysGetSettingsItemValue("boot", "force_maintenance", &force_maintenance, sizeof(force_maintenance), &size_out);
if (force_maintenance != 0) { if (force_maintenance != 0) {
return true; return true;
} }
@ -318,7 +319,7 @@ namespace sts::boot2 {
/* Wait for other atmosphere mitm modules to initialize. */ /* Wait for other atmosphere mitm modules to initialize. */
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("set:sys"))); R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("set:sys")));
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_200) { if (hos::GetVersion() >= hos::Version_200) {
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc"))); R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc")));
} else { } else {
R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc:c"))); R_ASSERT(sm::mitm::WaitMitm(sm::ServiceName::Encode("bpc:c")));
@ -340,7 +341,7 @@ namespace sts::boot2 {
if (maintenance) { if (maintenance) {
LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms); LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms);
/* Starting in 7.0.0, npns is launched during maintenance boot. */ /* Starting in 7.0.0, npns is launched during maintenance boot. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_700) { if (hos::GetVersion() >= hos::Version_700) {
LaunchTitle(nullptr, ncm::TitleLocation::Make(ncm::TitleId::Npns, ncm::StorageId::NandSystem), 0); LaunchTitle(nullptr, ncm::TitleLocation::Make(ncm::TitleId::Npns, ncm::StorageId::NandSystem), 0);
} }
} else { } else {

View file

@ -21,7 +21,7 @@
namespace sts::pm::impl { namespace sts::pm::impl {
ProcessInfo::ProcessInfo(Handle h, u64 pid, ldr::PinId pin, const ncm::TitleLocation &l) : process_id(pid), pin_id(pin), loc(l), handle(h), state(ProcessState_Created), flags(0), waitable_holder(h) { ProcessInfo::ProcessInfo(Handle h, os::ProcessId pid, ldr::PinId pin, const ncm::TitleLocation &l) : process_id(pid), pin_id(pin), loc(l), handle(h), state(ProcessState_Created), flags(0), waitable_holder(h) {
this->waitable_holder.SetUserData(reinterpret_cast<uintptr_t>(this)); this->waitable_holder.SetUserData(reinterpret_cast<uintptr_t>(this));
} }
@ -32,7 +32,7 @@ namespace sts::pm::impl {
void ProcessInfo::Cleanup() { void ProcessInfo::Cleanup() {
if (this->handle != INVALID_HANDLE) { if (this->handle != INVALID_HANDLE) {
/* Unregister the process. */ /* Unregister the process. */
fsprUnregisterProgram(this->process_id); fsprUnregisterProgram(static_cast<u64>(this->process_id));
sm::manager::UnregisterProcess(this->process_id); sm::manager::UnregisterProcess(this->process_id);
ldr::pm::UnpinTitle(this->pin_id); ldr::pm::UnpinTitle(this->pin_id);

View file

@ -44,7 +44,7 @@ namespace sts::pm::impl {
}; };
private: private:
util::IntrusiveListNode list_node; util::IntrusiveListNode list_node;
const u64 process_id; const os::ProcessId process_id;
const ldr::PinId pin_id; const ldr::PinId pin_id;
const ncm::TitleLocation loc; const ncm::TitleLocation loc;
Handle handle; Handle handle;
@ -64,7 +64,7 @@ namespace sts::pm::impl {
return (this->flags & flag); return (this->flags & flag);
} }
public: public:
ProcessInfo(Handle h, u64 pid, ldr::PinId pin, const ncm::TitleLocation &l); ProcessInfo(Handle h, os::ProcessId pid, ldr::PinId pin, const ncm::TitleLocation &l);
~ProcessInfo(); ~ProcessInfo();
void Cleanup(); void Cleanup();
@ -76,7 +76,7 @@ namespace sts::pm::impl {
return this->handle; return this->handle;
} }
u64 GetProcessId() const { os::ProcessId GetProcessId() const {
return this->process_id; return this->process_id;
} }
@ -176,7 +176,7 @@ namespace sts::pm::impl {
this->erase(this->iterator_to(*process_info)); this->erase(this->iterator_to(*process_info));
} }
ProcessInfo *Find(u64 process_id) { ProcessInfo *Find(os::ProcessId process_id) {
for (auto it = this->begin(); it != this->end(); it++) { for (auto it = this->begin(); it != this->end(); it++) {
if ((*it).GetProcessId() == process_id) { if ((*it).GetProcessId() == process_id) {
return &*it; return &*it;

View file

@ -37,7 +37,7 @@ namespace sts::pm::impl {
}; };
struct LaunchProcessArgs { struct LaunchProcessArgs {
u64 *out_process_id; os::ProcessId *out_process_id;
ncm::TitleLocation location; ncm::TitleLocation location;
u32 flags; u32 flags;
}; };
@ -62,38 +62,38 @@ namespace sts::pm::impl {
LaunchFlagsDeprecated_SignalOnStart = (1 << 5), LaunchFlagsDeprecated_SignalOnStart = (1 << 5),
}; };
#define GET_FLAG_MASK(flag) (firmware_version >= FirmwareVersion_500 ? static_cast<u32>(LaunchFlags_##flag) : static_cast<u32>(LaunchFlagsDeprecated_##flag)) #define GET_FLAG_MASK(flag) (hos_version >= hos::Version_500 ? static_cast<u32>(LaunchFlags_##flag) : static_cast<u32>(LaunchFlagsDeprecated_##flag))
inline bool ShouldSignalOnExit(u32 launch_flags) { inline bool ShouldSignalOnExit(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
return launch_flags & GET_FLAG_MASK(SignalOnExit); return launch_flags & GET_FLAG_MASK(SignalOnExit);
} }
inline bool ShouldSignalOnStart(u32 launch_flags) { inline bool ShouldSignalOnStart(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
if (firmware_version < FirmwareVersion_200) { if (hos_version < hos::Version_200) {
return false; return false;
} }
return launch_flags & GET_FLAG_MASK(SignalOnStart); return launch_flags & GET_FLAG_MASK(SignalOnStart);
} }
inline bool ShouldSignalOnException(u32 launch_flags) { inline bool ShouldSignalOnException(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
return launch_flags & GET_FLAG_MASK(SignalOnException); return launch_flags & GET_FLAG_MASK(SignalOnException);
} }
inline bool ShouldSignalOnDebugEvent(u32 launch_flags) { inline bool ShouldSignalOnDebugEvent(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
return launch_flags & GET_FLAG_MASK(SignalOnDebugEvent); return launch_flags & GET_FLAG_MASK(SignalOnDebugEvent);
} }
inline bool ShouldStartSuspended(u32 launch_flags) { inline bool ShouldStartSuspended(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
return launch_flags & GET_FLAG_MASK(StartSuspended); return launch_flags & GET_FLAG_MASK(StartSuspended);
} }
inline bool ShouldDisableAslr(u32 launch_flags) { inline bool ShouldDisableAslr(u32 launch_flags) {
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
return launch_flags & GET_FLAG_MASK(DisableAslr); return launch_flags & GET_FLAG_MASK(DisableAslr);
} }
@ -118,7 +118,7 @@ namespace sts::pm::impl {
}; };
inline u32 GetProcessEventValue(ProcessEvent event) { inline u32 GetProcessEventValue(ProcessEvent event) {
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { if (hos::GetVersion() >= hos::Version_500) {
return static_cast<u32>(event); return static_cast<u32>(event);
} }
switch (event) { switch (event) {
@ -194,7 +194,7 @@ namespace sts::pm::impl {
inline u32 GetLoaderCreateProcessFlags(u32 launch_flags) { inline u32 GetLoaderCreateProcessFlags(u32 launch_flags) {
u32 ldr_flags = 0; u32 ldr_flags = 0;
if (ShouldSignalOnException(launch_flags) || (GetRuntimeFirmwareVersion() >= FirmwareVersion_200 && !ShouldStartSuspended(launch_flags))) { if (ShouldSignalOnException(launch_flags) || (hos::GetVersion() >= hos::Version_200 && !ShouldStartSuspended(launch_flags))) {
ldr_flags |= ldr::CreateProcessFlag_EnableDebug; ldr_flags |= ldr::CreateProcessFlag_EnableDebug;
} }
if (ShouldDisableAslr(launch_flags)) { if (ShouldDisableAslr(launch_flags)) {
@ -235,7 +235,7 @@ namespace sts::pm::impl {
ldr::ProgramInfo program_info; ldr::ProgramInfo program_info;
R_TRY(ldr::pm::GetProgramInfo(&program_info, args.location)); R_TRY(ldr::pm::GetProgramInfo(&program_info, args.location));
const bool is_application = (program_info.flags & ldr::ProgramInfoFlag_ApplicationTypeMask) == ldr::ProgramInfoFlag_Application; const bool is_application = (program_info.flags & ldr::ProgramInfoFlag_ApplicationTypeMask) == ldr::ProgramInfoFlag_Application;
const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || GetRuntimeFirmwareVersion() < FirmwareVersion_200; const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || hos::GetVersion() < hos::Version_200;
/* Ensure we only try to run one application. */ /* Ensure we only try to run one application. */
if (is_application && HasApplicationProcess()) { if (is_application && HasApplicationProcess()) {
@ -259,8 +259,8 @@ namespace sts::pm::impl {
}); });
/* Get the process id. */ /* Get the process id. */
u64 process_id; os::ProcessId process_id = os::InvalidProcessId;
R_ASSERT(svcGetProcessId(&process_id, process_handle)); R_ASSERT(svcGetProcessId(&process_id.value, process_handle));
/* Make new process info. */ /* Make new process info. */
ProcessInfo *process_info = new ProcessInfo(process_handle, process_id, pin_id, location); ProcessInfo *process_info = new ProcessInfo(process_handle, process_id, pin_id, location);
@ -285,7 +285,7 @@ namespace sts::pm::impl {
const u8 *aci_fah = acid_fac + program_info.acid_fac_size; const u8 *aci_fah = acid_fac + program_info.acid_fac_size;
/* Register with FS and SM. */ /* Register with FS and SM. */
R_TRY(fsprRegisterProgram(process_id, static_cast<u64>(location.title_id), static_cast<FsStorageId>(location.storage_id), aci_fah, program_info.aci_fah_size, acid_fac, program_info.acid_fac_size)); R_TRY(fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(location.title_id), static_cast<FsStorageId>(location.storage_id), aci_fah, program_info.aci_fah_size, acid_fac, program_info.acid_fac_size));
R_TRY(sm::manager::RegisterProcess(process_id, location.title_id, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size)); R_TRY(sm::manager::RegisterProcess(process_id, location.title_id, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size));
/* Set flags. */ /* Set flags. */
@ -348,7 +348,7 @@ namespace sts::pm::impl {
process_info->ClearSuspended(); process_info->ClearSuspended();
process_info->SetSuspendedStateChanged(); process_info->SetSuspendedStateChanged();
g_process_event.Signal(); g_process_event.Signal();
} else if (GetRuntimeFirmwareVersion() >= FirmwareVersion_200 && process_info->ShouldSignalOnStart()) { } else if (hos::GetVersion() >= hos::Version_200 && process_info->ShouldSignalOnStart()) {
process_info->SetStartedStateChanged(); process_info->SetStartedStateChanged();
process_info->ClearSignalOnStart(); process_info->ClearSignalOnStart();
g_process_event.Signal(); g_process_event.Signal();
@ -366,14 +366,14 @@ namespace sts::pm::impl {
} }
break; break;
case ProcessState_Exited: case ProcessState_Exited:
if (GetRuntimeFirmwareVersion() < FirmwareVersion_500 && process_info->ShouldSignalOnExit()) { if (hos::GetVersion() < hos::Version_500 && process_info->ShouldSignalOnExit()) {
g_process_event.Signal(); g_process_event.Signal();
} else { } else {
/* Free process resources, unlink from waitable manager. */ /* Free process resources, unlink from waitable manager. */
process_info->Cleanup(); process_info->Cleanup();
/* Handle the case where we need to keep the process alive some time longer. */ /* Handle the case where we need to keep the process alive some time longer. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500 && process_info->ShouldSignalOnExit()) { if (hos::GetVersion() >= hos::Version_500 && process_info->ShouldSignalOnExit()) {
/* Remove from the living list. */ /* Remove from the living list. */
list->Remove(process_info); list->Remove(process_info);
@ -425,7 +425,7 @@ namespace sts::pm::impl {
} }
/* Process Management. */ /* Process Management. */
Result LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 flags) { Result LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 flags) {
/* Ensure we only try to launch one title at a time. */ /* Ensure we only try to launch one title at a time. */
static os::Mutex s_lock; static os::Mutex s_lock;
std::scoped_lock lk(s_lock); std::scoped_lock lk(s_lock);
@ -442,7 +442,7 @@ namespace sts::pm::impl {
return g_process_launch_result; return g_process_launch_result;
} }
Result StartProcess(u64 process_id) { Result StartProcess(os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);
@ -459,7 +459,7 @@ namespace sts::pm::impl {
return StartProcess(process_info, &program_info); return StartProcess(process_info, &program_info);
} }
Result TerminateProcess(u64 process_id) { Result TerminateProcess(os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);
@ -515,7 +515,7 @@ namespace sts::pm::impl {
out->process_id = process.GetProcessId(); out->process_id = process.GetProcessId();
return ResultSuccess; return ResultSuccess;
} }
if (GetRuntimeFirmwareVersion() < FirmwareVersion_500 && process.ShouldSignalOnExit() && process.HasExited()) { if (hos::GetVersion() < hos::Version_500 && process.ShouldSignalOnExit() && process.HasExited()) {
out->event = GetProcessEventValue(ProcessEvent::Exited); out->event = GetProcessEventValue(ProcessEvent::Exited);
out->process_id = process.GetProcessId(); out->process_id = process.GetProcessId();
return ResultSuccess; return ResultSuccess;
@ -524,7 +524,7 @@ namespace sts::pm::impl {
} }
/* Check for event from exited process. */ /* Check for event from exited process. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { if (hos::GetVersion() >= hos::Version_500) {
ProcessListAccessor dead_list(g_dead_process_list); ProcessListAccessor dead_list(g_dead_process_list);
if (!dead_list->empty()) { if (!dead_list->empty()) {
@ -537,12 +537,12 @@ namespace sts::pm::impl {
} }
} }
out->process_id = 0; out->process_id = os::ProcessId{};
out->event = GetProcessEventValue(ProcessEvent::None); out->event = GetProcessEventValue(ProcessEvent::None);
return ResultSuccess; return ResultSuccess;
} }
Result CleanupProcess(u64 process_id) { Result CleanupProcess(os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);
@ -558,7 +558,7 @@ namespace sts::pm::impl {
return ResultSuccess; return ResultSuccess;
} }
Result ClearExceptionOccurred(u64 process_id) { Result ClearExceptionOccurred(os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);
@ -577,7 +577,7 @@ namespace sts::pm::impl {
return ResultSuccess; return ResultSuccess;
} }
Result GetExceptionProcessIdList(u32 *out_count, u64 *out_process_ids, size_t max_out_count) { Result GetExceptionProcessIdList(u32 *out_count, os::ProcessId *out_process_ids, size_t max_out_count) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
size_t count = 0; size_t count = 0;
@ -590,7 +590,7 @@ namespace sts::pm::impl {
return ResultSuccess; return ResultSuccess;
} }
Result GetProcessId(u64 *out, ncm::TitleId title_id) { Result GetProcessId(os::ProcessId *out, ncm::TitleId title_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(title_id); auto process_info = list->Find(title_id);
@ -602,7 +602,7 @@ namespace sts::pm::impl {
return ResultSuccess; return ResultSuccess;
} }
Result GetTitleId(ncm::TitleId *out, u64 process_id) { Result GetTitleId(ncm::TitleId *out, os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);
@ -614,7 +614,7 @@ namespace sts::pm::impl {
return ResultSuccess; return ResultSuccess;
} }
Result GetApplicationProcessId(u64 *out_process_id) { Result GetApplicationProcessId(os::ProcessId *out_process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
for (auto &process : *list) { for (auto &process : *list) {
@ -627,7 +627,7 @@ namespace sts::pm::impl {
return ResultPmProcessNotFound; return ResultPmProcessNotFound;
} }
Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::TitleLocation *out_loc, u64 process_id) { Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::TitleLocation *out_loc, os::ProcessId process_id) {
ProcessListAccessor list(g_process_list); ProcessListAccessor list(g_process_list);
auto process_info = list->Find(process_id); auto process_info = list->Find(process_id);

View file

@ -26,22 +26,22 @@ namespace sts::pm::impl {
Result InitializeProcessManager(); Result InitializeProcessManager();
/* Process Management. */ /* Process Management. */
Result LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 flags); Result LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 flags);
Result StartProcess(u64 process_id); Result StartProcess(os::ProcessId process_id);
Result TerminateProcess(u64 process_id); Result TerminateProcess(os::ProcessId process_id);
Result TerminateTitle(ncm::TitleId title_id); Result TerminateTitle(ncm::TitleId title_id);
Result GetProcessEventHandle(Handle *out); Result GetProcessEventHandle(Handle *out);
Result GetProcessEventInfo(ProcessEventInfo *out); Result GetProcessEventInfo(ProcessEventInfo *out);
Result CleanupProcess(u64 process_id); Result CleanupProcess(os::ProcessId process_id);
Result ClearExceptionOccurred(u64 process_id); Result ClearExceptionOccurred(os::ProcessId process_id);
/* Information Getters. */ /* Information Getters. */
Result GetModuleIdList(u32 *out_count, u8 *out_buf, size_t max_out_count, u64 unused); Result GetModuleIdList(u32 *out_count, u8 *out_buf, size_t max_out_count, u64 unused);
Result GetExceptionProcessIdList(u32 *out_count, u64 *out_process_ids, size_t max_out_count); Result GetExceptionProcessIdList(u32 *out_count, os::ProcessId *out_process_ids, size_t max_out_count);
Result GetProcessId(u64 *out, ncm::TitleId title_id); Result GetProcessId(os::ProcessId *out, ncm::TitleId title_id);
Result GetTitleId(ncm::TitleId *out, u64 process_id); Result GetTitleId(ncm::TitleId *out, os::ProcessId process_id);
Result GetApplicationProcessId(u64 *out_process_id); Result GetApplicationProcessId(os::ProcessId *out_process_id);
Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::TitleLocation *out_loc, u64 process_id); Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::TitleLocation *out_loc, os::ProcessId process_id);
/* Hook API. */ /* Hook API. */
Result HookToCreateProcess(Handle *out_hook, ncm::TitleId title_id); Result HookToCreateProcess(Handle *out_hook, ncm::TitleId title_id);

View file

@ -182,9 +182,9 @@ namespace sts::pm::resource {
} }
} }
/* Adjust resource limits based on firmware version. */ /* Adjust resource limits based on hos firmware version. */
const auto firmware_version = GetRuntimeFirmwareVersion(); const auto hos_version = hos::GetVersion();
if (firmware_version >= FirmwareVersion_400) { if (hos_version >= hos::Version_400) {
/* 4.0.0 increased the system thread limit. */ /* 4.0.0 increased the system thread limit. */
g_resource_limits[ResourceLimitGroup_System][LimitableResource_Threads] += ExtraSystemThreadCount400; g_resource_limits[ResourceLimitGroup_System][LimitableResource_Threads] += ExtraSystemThreadCount400;
/* 4.0.0 also took memory away from applet and gave it to system, for the Standard and StandardForSystemDev profiles. */ /* 4.0.0 also took memory away from applet and gave it to system, for the Standard and StandardForSystemDev profiles. */
@ -193,21 +193,21 @@ namespace sts::pm::resource {
g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_System] += ExtraSystemMemorySize400; g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_System] += ExtraSystemMemorySize400;
g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize400; g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize400;
} }
if (firmware_version >= FirmwareVersion_500) { if (hos_version >= hos::Version_500) {
/* 5.0.0 took more memory away from applet and gave it to system, for the Standard and StandardForSystemDev profiles. */ /* 5.0.0 took more memory away from applet and gave it to system, for the Standard and StandardForSystemDev profiles. */
g_memory_resource_limits[spl::MemoryArrangement_Standard][ResourceLimitGroup_System] += ExtraSystemMemorySize500; g_memory_resource_limits[spl::MemoryArrangement_Standard][ResourceLimitGroup_System] += ExtraSystemMemorySize500;
g_memory_resource_limits[spl::MemoryArrangement_Standard][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize500; g_memory_resource_limits[spl::MemoryArrangement_Standard][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize500;
g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_System] += ExtraSystemMemorySize500; g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_System] += ExtraSystemMemorySize500;
g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize500; g_memory_resource_limits[spl::MemoryArrangement_StandardForSystemDev][ResourceLimitGroup_Applet] -= ExtraSystemMemorySize500;
} }
if (firmware_version >= FirmwareVersion_600) { if (hos_version >= hos::Version_600) {
/* 6.0.0 increased the system event and session limits. */ /* 6.0.0 increased the system event and session limits. */
g_resource_limits[ResourceLimitGroup_System][LimitableResource_Events] += ExtraSystemEventCount600; g_resource_limits[ResourceLimitGroup_System][LimitableResource_Events] += ExtraSystemEventCount600;
g_resource_limits[ResourceLimitGroup_System][LimitableResource_Sessions] += ExtraSystemSessionCount600; g_resource_limits[ResourceLimitGroup_System][LimitableResource_Sessions] += ExtraSystemSessionCount600;
} }
/* 7.0.0+: Calculate the number of extra application threads available. */ /* 7.0.0+: Calculate the number of extra application threads available. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_700) { if (hos::GetVersion() >= hos::Version_700) {
/* See how many threads we have available. */ /* See how many threads we have available. */
u64 total_threads_available = 0; u64 total_threads_available = 0;
R_ASSERT(svcGetResourceLimitLimitValue(&total_threads_available, GetResourceLimitHandle(ResourceLimitGroup_System), LimitableResource_Threads)); R_ASSERT(svcGetResourceLimitLimitValue(&total_threads_available, GetResourceLimitHandle(ResourceLimitGroup_System), LimitableResource_Threads));
@ -225,7 +225,7 @@ namespace sts::pm::resource {
} }
/* Choose and initialize memory arrangement. */ /* Choose and initialize memory arrangement. */
if (firmware_version >= FirmwareVersion_600) { if (hos_version >= hos::Version_600) {
/* 6.0.0 retrieves memory limit information from the kernel, rather than using a hardcoded profile. */ /* 6.0.0 retrieves memory limit information from the kernel, rather than using a hardcoded profile. */
g_memory_arrangement = spl::MemoryArrangement_Dynamic; g_memory_arrangement = spl::MemoryArrangement_Dynamic;
@ -253,7 +253,7 @@ namespace sts::pm::resource {
/* We take memory away from applet normally, but away from application on < 3.0.0 to avoid a rare hang on boot. */ /* We take memory away from applet normally, but away from application on < 3.0.0 to avoid a rare hang on boot. */
for (size_t i = 0; i < spl::MemoryArrangement_Count; i++) { for (size_t i = 0; i < spl::MemoryArrangement_Count; i++) {
g_memory_resource_limits[i][ResourceLimitGroup_System] += ExtraSystemMemorySizeAtmosphere; g_memory_resource_limits[i][ResourceLimitGroup_System] += ExtraSystemMemorySizeAtmosphere;
if (firmware_version >= FirmwareVersion_300) { if (hos_version >= hos::Version_300) {
g_memory_resource_limits[i][ResourceLimitGroup_Applet] -= ExtraSystemMemorySizeAtmosphere; g_memory_resource_limits[i][ResourceLimitGroup_Applet] -= ExtraSystemMemorySizeAtmosphere;
} else { } else {
g_memory_resource_limits[i][ResourceLimitGroup_Application] -= ExtraSystemMemorySizeAtmosphere; g_memory_resource_limits[i][ResourceLimitGroup_Application] -= ExtraSystemMemorySizeAtmosphere;
@ -282,7 +282,7 @@ namespace sts::pm::resource {
{ {
std::scoped_lock lk(g_resource_limit_lock); std::scoped_lock lk(g_resource_limit_lock);
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { if (hos::GetVersion() >= hos::Version_500) {
/* Starting in 5.0.0, PM does not allow for only one of the sets to fail. */ /* Starting in 5.0.0, PM does not allow for only one of the sets to fail. */
if (boost_size < g_system_memory_boost_size) { if (boost_size < g_system_memory_boost_size) {
R_TRY(svcSetUnsafeLimit(boost_size)); R_TRY(svcSetUnsafeLimit(boost_size));
@ -332,7 +332,7 @@ namespace sts::pm::resource {
void WaitResourceAvailable(const ldr::ProgramInfo *info) { void WaitResourceAvailable(const ldr::ProgramInfo *info) {
if (GetResourceLimitGroup(info) == ResourceLimitGroup_Application) { if (GetResourceLimitGroup(info) == ResourceLimitGroup_Application) {
WaitResourceAvailable(ResourceLimitGroup_Application); WaitResourceAvailable(ResourceLimitGroup_Application);
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { if (hos::GetVersion() >= hos::Version_500) {
WaitApplicationMemoryAvailable(); WaitApplicationMemoryAvailable();
} }
} }

View file

@ -35,7 +35,7 @@ namespace sts::pm::bm {
} }
/* Service command implementations. */ /* Service command implementations. */
void BootModeService::GetBootMode(Out<u32> out) { void BootModeService::GetBootMode(sf::Out<u32> out) {
out.SetValue(static_cast<u32>(pm::bm::GetBootMode())); out.SetValue(static_cast<u32>(pm::bm::GetBootMode()));
} }

View file

@ -21,7 +21,7 @@
namespace sts::pm::bm { namespace sts::pm::bm {
class BootModeService final : public IServiceObject { class BootModeService final : public sf::IServiceObject {
private: private:
enum class CommandId { enum class CommandId {
GetBootMode = 0, GetBootMode = 0,
@ -29,12 +29,12 @@ namespace sts::pm::bm {
}; };
private: private:
/* Actual command implementations. */ /* Actual command implementations. */
void GetBootMode(Out<u32> out); void GetBootMode(sf::Out<u32> out);
void SetMaintenanceBoot(); void SetMaintenanceBoot();
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(BootModeService, GetBootMode), MAKE_SERVICE_COMMAND_META(GetBootMode),
MAKE_SERVICE_COMMAND_META(BootModeService, SetMaintenanceBoot), MAKE_SERVICE_COMMAND_META(SetMaintenanceBoot),
}; };
}; };

View file

@ -21,37 +21,37 @@
namespace sts::pm::dmnt { namespace sts::pm::dmnt {
/* Actual command implementations. */ /* Actual command implementations. */
Result DebugMonitorServiceBase::GetModuleIdList(Out<u32> out_count, OutBuffer<u8> out_buf, u64 unused) { Result DebugMonitorServiceBase::GetModuleIdList(sf::Out<u32> out_count, const sf::OutBuffer &out_buf, u64 unused) {
if (out_buf.num_elements > std::numeric_limits<s32>::max()) { if (out_buf.GetSize() > std::numeric_limits<s32>::max()) {
return ResultPmInvalidSize; return ResultPmInvalidSize;
} }
return impl::GetModuleIdList(out_count.GetPointer(), out_buf.buffer, out_buf.num_elements, unused); return impl::GetModuleIdList(out_count.GetPointer(), out_buf.GetPointer(), out_buf.GetSize(), unused);
} }
Result DebugMonitorServiceBase::GetExceptionProcessIdList(Out<u32> out_count, OutBuffer<u64> out_process_ids) { Result DebugMonitorServiceBase::GetExceptionProcessIdList(sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids) {
if (out_process_ids.num_elements > std::numeric_limits<s32>::max()) { if (out_process_ids.GetSize() > std::numeric_limits<s32>::max()) {
return ResultPmInvalidSize; return ResultPmInvalidSize;
} }
return impl::GetExceptionProcessIdList(out_count.GetPointer(), out_process_ids.buffer, out_process_ids.num_elements); return impl::GetExceptionProcessIdList(out_count.GetPointer(), out_process_ids.GetPointer(), out_process_ids.GetSize());
} }
Result DebugMonitorServiceBase::StartProcess(u64 process_id) { Result DebugMonitorServiceBase::StartProcess(os::ProcessId process_id) {
return impl::StartProcess(process_id); return impl::StartProcess(process_id);
} }
Result DebugMonitorServiceBase::GetProcessId(Out<u64> out, ncm::TitleId title_id) { Result DebugMonitorServiceBase::GetProcessId(sf::Out<os::ProcessId> out, ncm::TitleId title_id) {
return impl::GetProcessId(out.GetPointer(), title_id); return impl::GetProcessId(out.GetPointer(), title_id);
} }
Result DebugMonitorServiceBase::HookToCreateProcess(Out<CopiedHandle> out_hook, ncm::TitleId title_id) { Result DebugMonitorServiceBase::HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::TitleId title_id) {
return impl::HookToCreateProcess(out_hook.GetHandlePointer(), title_id); return impl::HookToCreateProcess(out_hook.GetHandlePointer(), title_id);
} }
Result DebugMonitorServiceBase::GetApplicationProcessId(Out<u64> out) { Result DebugMonitorServiceBase::GetApplicationProcessId(sf::Out<os::ProcessId> out) {
return impl::GetApplicationProcessId(out.GetPointer()); return impl::GetApplicationProcessId(out.GetPointer());
} }
Result DebugMonitorServiceBase::HookToCreateApplicationProcess(Out<CopiedHandle> out_hook) { Result DebugMonitorServiceBase::HookToCreateApplicationProcess(sf::OutCopyHandle out_hook) {
return impl::HookToCreateApplicationProcess(out_hook.GetHandlePointer()); return impl::HookToCreateApplicationProcess(out_hook.GetHandlePointer());
} }
@ -60,11 +60,11 @@ namespace sts::pm::dmnt {
} }
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
Result DebugMonitorServiceBase::AtmosphereGetProcessInfo(Out<CopiedHandle> out_process_handle, Out<ncm::TitleLocation> out_loc, u64 process_id) { Result DebugMonitorServiceBase::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::TitleLocation> out_loc, os::ProcessId process_id) {
return impl::AtmosphereGetProcessInfo(out_process_handle.GetHandlePointer(), out_loc.GetPointer(), process_id); return impl::AtmosphereGetProcessInfo(out_process_handle.GetHandlePointer(), out_loc.GetPointer(), process_id);
} }
Result DebugMonitorServiceBase::AtmosphereGetCurrentLimitInfo(Out<u64> out_cur_val, Out<u64> out_lim_val, u32 group, u32 resource) { Result DebugMonitorServiceBase::AtmosphereGetCurrentLimitInfo(sf::Out<u64> out_cur_val, sf::Out<u64> out_lim_val, u32 group, u32 resource) {
return impl::AtmosphereGetCurrentLimitInfo(out_cur_val.GetPointer(), out_lim_val.GetPointer(), group, resource); return impl::AtmosphereGetCurrentLimitInfo(out_cur_val.GetPointer(), out_lim_val.GetPointer(), group, resource);
} }

View file

@ -22,25 +22,21 @@
namespace sts::pm::dmnt { namespace sts::pm::dmnt {
class DebugMonitorServiceBase : public IServiceObject { class DebugMonitorServiceBase : public sf::IServiceObject {
protected: protected:
/* Actual command implementations. */ /* Actual command implementations. */
virtual Result GetModuleIdList(Out<u32> out_count, OutBuffer<u8> out_buf, u64 unused); virtual Result GetModuleIdList(sf::Out<u32> out_count, const sf::OutBuffer &out_buf, u64 unused);
virtual Result GetExceptionProcessIdList(Out<u32> out_count, OutBuffer<u64> out_process_ids); virtual Result GetExceptionProcessIdList(sf::Out<u32> out_count, const sf::OutArray<os::ProcessId> &out_process_ids);
virtual Result StartProcess(u64 process_id); virtual Result StartProcess(os::ProcessId process_id);
virtual Result GetProcessId(Out<u64> out, ncm::TitleId title_id); virtual Result GetProcessId(sf::Out<os::ProcessId> out, ncm::TitleId title_id);
virtual Result HookToCreateProcess(Out<CopiedHandle> out_hook, ncm::TitleId title_id); virtual Result HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::TitleId title_id);
virtual Result GetApplicationProcessId(Out<u64> out); virtual Result GetApplicationProcessId(sf::Out<os::ProcessId> out);
virtual Result HookToCreateApplicationProcess(Out<CopiedHandle> out_hook); virtual Result HookToCreateApplicationProcess(sf::OutCopyHandle out_hook);
virtual Result ClearHook(u32 which); virtual Result ClearHook(u32 which);
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
virtual Result AtmosphereGetProcessInfo(Out<CopiedHandle> out_process_handle, Out<ncm::TitleLocation> out_loc, u64 process_id); virtual Result AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::TitleLocation> out_loc, os::ProcessId process_id);
virtual Result AtmosphereGetCurrentLimitInfo(Out<u64> out_cur_val, Out<u64> out_lim_val, u32 group, u32 resource); virtual Result AtmosphereGetCurrentLimitInfo(sf::Out<u64> out_cur_val, sf::Out<u64> out_lim_val, u32 group, u32 resource);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* No entries, because DebugMonitorServiceBase is abstract. */
};
}; };
/* This represents modern DebugMonitorService (5.0.0+). */ /* This represents modern DebugMonitorService (5.0.0+). */
@ -62,19 +58,19 @@ namespace sts::pm::dmnt {
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
/* 5.0.0-* */ /* 5.0.0-* */
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetExceptionProcessIdList), MAKE_SERVICE_COMMAND_META(GetExceptionProcessIdList),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, StartProcess), MAKE_SERVICE_COMMAND_META(StartProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetProcessId), MAKE_SERVICE_COMMAND_META(GetProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, HookToCreateProcess), MAKE_SERVICE_COMMAND_META(HookToCreateProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetApplicationProcessId), MAKE_SERVICE_COMMAND_META(GetApplicationProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, HookToCreateApplicationProcess), MAKE_SERVICE_COMMAND_META(HookToCreateApplicationProcess),
/* 6.0.0-* */ /* 6.0.0-* */
MAKE_SERVICE_COMMAND_META(DebugMonitorService, ClearHook, FirmwareVersion_600), MAKE_SERVICE_COMMAND_META(ClearHook, hos::Version_600),
/* Atmosphere extensions. */ /* Atmosphere extensions. */
MAKE_SERVICE_COMMAND_META(DebugMonitorService, AtmosphereGetProcessInfo), MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, AtmosphereGetCurrentLimitInfo), MAKE_SERVICE_COMMAND_META(AtmosphereGetCurrentLimitInfo),
}; };
}; };
@ -96,17 +92,17 @@ namespace sts::pm::dmnt {
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.1.0 */ /* 1.0.0-4.1.0 */
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetModuleIdList), MAKE_SERVICE_COMMAND_META(GetModuleIdList),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetExceptionProcessIdList), MAKE_SERVICE_COMMAND_META(GetExceptionProcessIdList),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, StartProcess), MAKE_SERVICE_COMMAND_META(StartProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetProcessId), MAKE_SERVICE_COMMAND_META(GetProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, HookToCreateProcess), MAKE_SERVICE_COMMAND_META(HookToCreateProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetApplicationProcessId), MAKE_SERVICE_COMMAND_META(GetApplicationProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, HookToCreateApplicationProcess), MAKE_SERVICE_COMMAND_META(HookToCreateApplicationProcess),
/* Atmosphere extensions. */ /* Atmosphere extensions. */
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, AtmosphereGetProcessInfo), MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, AtmosphereGetCurrentLimitInfo), MAKE_SERVICE_COMMAND_META(AtmosphereGetCurrentLimitInfo),
}; };
}; };

View file

@ -28,16 +28,16 @@ namespace sts::pm::info {
} }
/* Actual command implementations. */ /* Actual command implementations. */
Result InformationService::GetTitleId(Out<ncm::TitleId> out, u64 process_id) { Result InformationService::GetTitleId(sf::Out<ncm::TitleId> out, os::ProcessId process_id) {
return impl::GetTitleId(out.GetPointer(), process_id); return impl::GetTitleId(out.GetPointer(), process_id);
} }
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
Result InformationService::AtmosphereGetProcessId(Out<u64> out, ncm::TitleId title_id) { Result InformationService::AtmosphereGetProcessId(sf::Out<os::ProcessId> out, ncm::TitleId title_id) {
return impl::GetProcessId(out.GetPointer(), title_id); return impl::GetProcessId(out.GetPointer(), title_id);
} }
Result InformationService::AtmosphereHasLaunchedTitle(Out<bool> out, ncm::TitleId title_id) { Result InformationService::AtmosphereHasLaunchedTitle(sf::Out<bool> out, ncm::TitleId title_id) {
return pm::info::HasLaunchedTitle(out.GetPointer(), title_id); return pm::info::HasLaunchedTitle(out.GetPointer(), title_id);
} }

View file

@ -22,7 +22,7 @@
namespace sts::pm::info { namespace sts::pm::info {
class InformationService final : public IServiceObject { class InformationService final : public sf::IServiceObject {
private: private:
enum class CommandId { enum class CommandId {
GetTitleId = 0, GetTitleId = 0,
@ -32,17 +32,17 @@ namespace sts::pm::info {
}; };
private: private:
/* Actual command implementations. */ /* Actual command implementations. */
Result GetTitleId(Out<ncm::TitleId> out, u64 process_id); Result GetTitleId(sf::Out<ncm::TitleId> out, os::ProcessId process_id);
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
Result AtmosphereGetProcessId(Out<u64> out, ncm::TitleId title_id); Result AtmosphereGetProcessId(sf::Out<os::ProcessId> out, ncm::TitleId title_id);
Result AtmosphereHasLaunchedTitle(Out<bool> out, ncm::TitleId title_id); Result AtmosphereHasLaunchedTitle(sf::Out<bool> out, ncm::TitleId title_id);
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(InformationService, GetTitleId), MAKE_SERVICE_COMMAND_META(GetTitleId),
MAKE_SERVICE_COMMAND_META(InformationService, AtmosphereGetProcessId), MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessId),
MAKE_SERVICE_COMMAND_META(InformationService, AtmosphereHasLaunchedTitle), MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedTitle),
}; };
}; };

View file

@ -17,7 +17,6 @@
#include <cstdlib> #include <cstdlib>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <malloc.h>
#include <switch.h> #include <switch.h>
#include <atmosphere.h> #include <atmosphere.h>
@ -36,6 +35,7 @@ extern "C" {
extern u32 __start__; extern u32 __start__;
u32 __nx_applet_type = AppletType_None; u32 __nx_applet_type = AppletType_None;
u32 __nx_fs_num_sessions = 1;
#define INNER_HEAP_SIZE 0x40000 #define INNER_HEAP_SIZE 0x40000
size_t nx_inner_heap_size = INNER_HEAP_SIZE; size_t nx_inner_heap_size = INNER_HEAP_SIZE;
@ -70,6 +70,8 @@ void __libnx_initheap(void) {
fake_heap_end = (char*)addr + size; fake_heap_end = (char*)addr + size;
} }
using namespace sts;
namespace { namespace {
constexpr u32 PrivilegedFileAccessHeader[0x1C / sizeof(u32)] = {0x00000001, 0x00000000, 0x80000000, 0x0000001C, 0x00000000, 0x0000001C, 0x00000000}; constexpr u32 PrivilegedFileAccessHeader[0x1C / sizeof(u32)] = {0x00000001, 0x00000000, 0x80000000, 0x0000001C, 0x00000000, 0x0000001C, 0x00000000};
@ -78,22 +80,22 @@ namespace {
constexpr size_t ProcessCountMax = 0x40; constexpr size_t ProcessCountMax = 0x40;
/* This uses debugging SVCs to retrieve a process's title id. */ /* This uses debugging SVCs to retrieve a process's title id. */
sts::ncm::TitleId GetProcessTitleId(u64 process_id) { ncm::TitleId GetProcessTitleId(os::ProcessId process_id) {
/* Check if we should return our title id. */ /* Check if we should return our title id. */
/* Doing this here works around a bug fixed in 6.0.0. */ /* Doing this here works around a bug fixed in 6.0.0. */
/* Not doing so will cause svcDebugActiveProcess to deadlock on lower firmwares if called for it's own process. */ /* Not doing so will cause svcDebugActiveProcess to deadlock on lower firmwares if called for it's own process. */
u64 current_process_id = 0; os::ProcessId current_process_id = os::InvalidProcessId;
R_ASSERT(svcGetProcessId(&current_process_id, CUR_PROCESS_HANDLE)); R_ASSERT(svcGetProcessId(&current_process_id.value, CUR_PROCESS_HANDLE));
if (current_process_id == process_id) { if (current_process_id == process_id) {
return __stratosphere_title_id; return __stratosphere_title_id;
} }
/* Get a debug handle. */ /* Get a debug handle. */
sts::os::ManagedHandle debug_handle; os::ManagedHandle debug_handle;
R_ASSERT(svcDebugActiveProcess(debug_handle.GetPointer(), process_id)); R_ASSERT(svcDebugActiveProcess(debug_handle.GetPointer(), static_cast<u64>(process_id)));
/* Loop until we get the event that tells us about the process. */ /* Loop until we get the event that tells us about the process. */
sts::svc::DebugEventInfo d; svc::DebugEventInfo d;
while (true) { while (true) {
R_ASSERT(svcGetDebugEvent(reinterpret_cast<u8 *>(&d), debug_handle.Get())); R_ASSERT(svcGetDebugEvent(reinterpret_cast<u8 *>(&d), debug_handle.Get()));
if (d.type == sts::svc::DebugEventType::AttachProcess) { if (d.type == sts::svc::DebugEventType::AttachProcess) {
@ -105,22 +107,22 @@ namespace {
/* This works around a bug fixed by FS in 4.0.0. */ /* This works around a bug fixed by FS in 4.0.0. */
/* Not doing so will cause KIPs with higher process IDs than 7 to be unable to use filesystem services. */ /* Not doing so will cause KIPs with higher process IDs than 7 to be unable to use filesystem services. */
/* It also registers privileged processes with SM, so that their title IDs can be known. */ /* It also registers privileged processes with SM, so that their title IDs can be known. */
void RegisterPrivilegedProcess(u64 process_id) { void RegisterPrivilegedProcess(os::ProcessId process_id) {
fsprUnregisterProgram(process_id); fsprUnregisterProgram(static_cast<u64>(process_id));
fsprRegisterProgram(process_id, process_id, FsStorageId_NandSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl)); fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(process_id), FsStorageId_NandSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl));
sts::sm::manager::UnregisterProcess(process_id); sts::sm::manager::UnregisterProcess(process_id);
sts::sm::manager::RegisterProcess(process_id, GetProcessTitleId(process_id), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl)); sts::sm::manager::RegisterProcess(process_id, GetProcessTitleId(process_id), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl));
} }
void RegisterPrivilegedProcesses() { void RegisterPrivilegedProcesses() {
/* Get privileged process range. */ /* Get privileged process range. */
u64 min_priv_process_id = 0, max_priv_process_id = 0; os::ProcessId min_priv_process_id = os::InvalidProcessId, max_priv_process_id = os::InvalidProcessId;
sts::cfg::GetInitialProcessRange(&min_priv_process_id, &max_priv_process_id); sts::cfg::GetInitialProcessRange(&min_priv_process_id, &max_priv_process_id);
/* Get list of processes, register all privileged ones. */ /* Get list of processes, register all privileged ones. */
u32 num_pids; u32 num_pids;
u64 pids[ProcessCountMax]; os::ProcessId pids[ProcessCountMax];
R_ASSERT(svcGetProcessList(&num_pids, pids, ProcessCountMax)); R_ASSERT(svcGetProcessList(&num_pids, reinterpret_cast<u64 *>(pids), ProcessCountMax));
for (size_t i = 0; i < num_pids; i++) { for (size_t i = 0; i < num_pids; i++) {
if (min_priv_process_id <= pids[i] && pids[i] <= max_priv_process_id) { if (min_priv_process_id <= pids[i] && pids[i] <= max_priv_process_id) {
RegisterPrivilegedProcess(pids[i]); RegisterPrivilegedProcess(pids[i]);
@ -131,7 +133,7 @@ namespace {
} }
void __appInit(void) { void __appInit(void) {
SetFirmwareVersionForLibnx(); hos::SetVersionForLibnx();
DoWithSmSession([&]() { DoWithSmSession([&]() {
R_ASSERT(fsprInitialize()); R_ASSERT(fsprInitialize());
@ -164,29 +166,52 @@ void __appExit(void) {
fsprExit(); fsprExit();
} }
namespace {
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
constexpr sm::ServiceName ShellServiceName = sm::ServiceName::Encode("pm:shell");
constexpr size_t ShellMaxSessions = 3;
constexpr sm::ServiceName DebugMonitorServiceName = sm::ServiceName::Encode("pm:dmnt");
constexpr size_t DebugMonitorMaxSessions = 3;
constexpr sm::ServiceName BootModeServiceName = sm::ServiceName::Encode("pm:bm");
constexpr size_t BootModeMaxSessions = 6;
constexpr sm::ServiceName InformationServiceName = sm::ServiceName::Encode("pm:info");
constexpr size_t InformationMaxSessions = 32 - (ShellMaxSessions + DebugMonitorMaxSessions + BootModeMaxSessions);
static_assert(InformationMaxSessions >= 16, "InformationMaxSessions");
/* pm:shell, pm:dmnt, pm:bm, pm:info. */
constexpr size_t NumServers = 4;
constexpr size_t MaxSessions = ShellMaxSessions + DebugMonitorMaxSessions + BootModeMaxSessions + InformationMaxSessions;
static_assert(MaxSessions == 32, "MaxSessions");
sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions> g_server_manager;
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
/* Initialize process manager implementation. */ /* Initialize process manager implementation. */
R_ASSERT(sts::pm::impl::InitializeProcessManager()); R_ASSERT(sts::pm::impl::InitializeProcessManager());
/* Create Server Manager. */
static auto s_server_manager = WaitableManager(1);
/* Create Services. */ /* Create Services. */
/* NOTE: Extra sessions have been added to pm:bm and pm:info to facilitate access by the rest of stratosphere. */ /* NOTE: Extra sessions have been added to pm:bm and pm:info to facilitate access by the rest of stratosphere. */
/* Also Note: PM was rewritten in 5.0.0, so the shell and dmnt services are different before/after. */ /* Also Note: PM was rewritten in 5.0.0, so the shell and dmnt services are different before/after. */
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_500) { if (hos::GetVersion() >= hos::Version_500) {
s_server_manager.AddWaitable(new ServiceServer<sts::pm::shell::ShellService>("pm:shell", 3)); R_ASSERT((g_server_manager.RegisterServer<pm::shell::ShellService>(ShellServiceName, ShellMaxSessions)));
s_server_manager.AddWaitable(new ServiceServer<sts::pm::dmnt::DebugMonitorService>("pm:dmnt", 3)); R_ASSERT((g_server_manager.RegisterServer<pm::dmnt::DebugMonitorService>(DebugMonitorServiceName, DebugMonitorMaxSessions)));
} else { } else {
s_server_manager.AddWaitable(new ServiceServer<sts::pm::shell::ShellServiceDeprecated>("pm:shell", 3)); R_ASSERT((g_server_manager.RegisterServer<pm::shell::ShellServiceDeprecated>(ShellServiceName, ShellMaxSessions)));
s_server_manager.AddWaitable(new ServiceServer<sts::pm::dmnt::DebugMonitorServiceDeprecated>("pm:dmnt", 3)); R_ASSERT((g_server_manager.RegisterServer<pm::dmnt::DebugMonitorServiceDeprecated>(DebugMonitorServiceName, DebugMonitorMaxSessions)));
} }
s_server_manager.AddWaitable(new ServiceServer<sts::pm::bm::BootModeService>("pm:bm", 6)); R_ASSERT((g_server_manager.RegisterServer<pm::bm::BootModeService>(BootModeServiceName, BootModeMaxSessions)));
s_server_manager.AddWaitable(new ServiceServer<sts::pm::info::InformationService>("pm:info", 19)); R_ASSERT((g_server_manager.RegisterServer<pm::info::InformationService>(InformationServiceName, InformationMaxSessions)));
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
s_server_manager.Process(); g_server_manager.LoopProcess();
return 0; return 0;
} }

View file

@ -20,16 +20,16 @@
namespace sts::pm::shell { namespace sts::pm::shell {
/* Overrides for libstratosphere pm::shell commands. */ /* Overrides for libstratosphere pm::shell commands. */
Result LaunchTitle(u64 *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) { Result LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {
return impl::LaunchTitle(out_process_id, loc, launch_flags); return impl::LaunchTitle(out_process_id, loc, launch_flags);
} }
/* Service command implementations. */ /* Service command implementations. */
Result ShellServiceBase::LaunchTitle(Out<u64> out_process_id, ncm::TitleLocation loc, u32 flags) { Result ShellServiceBase::LaunchTitle(sf::Out<os::ProcessId> out_process_id, const ncm::TitleLocation &loc, u32 flags) {
return pm::shell::LaunchTitle(out_process_id.GetPointer(), loc, flags); return pm::shell::LaunchTitle(out_process_id.GetPointer(), loc, flags);
} }
Result ShellServiceBase::TerminateProcess(u64 process_id) { Result ShellServiceBase::TerminateProcess(os::ProcessId process_id) {
return impl::TerminateProcess(process_id); return impl::TerminateProcess(process_id);
} }
@ -37,19 +37,19 @@ namespace sts::pm::shell {
return impl::TerminateTitle(title_id); return impl::TerminateTitle(title_id);
} }
void ShellServiceBase::GetProcessEventHandle(Out<CopiedHandle> out) { void ShellServiceBase::GetProcessEventHandle(sf::OutCopyHandle out) {
R_ASSERT(impl::GetProcessEventHandle(out.GetHandlePointer())); R_ASSERT(impl::GetProcessEventHandle(out.GetHandlePointer()));
} }
void ShellServiceBase::GetProcessEventInfo(Out<ProcessEventInfo> out) { void ShellServiceBase::GetProcessEventInfo(sf::Out<ProcessEventInfo> out) {
R_ASSERT(impl::GetProcessEventInfo(out.GetPointer())); R_ASSERT(impl::GetProcessEventInfo(out.GetPointer()));
} }
Result ShellServiceBase::CleanupProcess(u64 process_id) { Result ShellServiceBase::CleanupProcess(os::ProcessId process_id) {
return impl::CleanupProcess(process_id); return impl::CleanupProcess(process_id);
} }
Result ShellServiceBase::ClearExceptionOccurred(u64 process_id) { Result ShellServiceBase::ClearExceptionOccurred(os::ProcessId process_id) {
return impl::ClearExceptionOccurred(process_id); return impl::ClearExceptionOccurred(process_id);
} }
@ -57,7 +57,7 @@ namespace sts::pm::shell {
R_ASSERT(impl::NotifyBootFinished()); R_ASSERT(impl::NotifyBootFinished());
} }
Result ShellServiceBase::GetApplicationProcessIdForShell(Out<u64> out) { Result ShellServiceBase::GetApplicationProcessIdForShell(sf::Out<os::ProcessId> out) {
return impl::GetApplicationProcessId(out.GetPointer()); return impl::GetApplicationProcessId(out.GetPointer());
} }
@ -69,7 +69,7 @@ namespace sts::pm::shell {
return impl::BoostApplicationThreadResourceLimit(); return impl::BoostApplicationThreadResourceLimit();
} }
void ShellServiceBase::GetBootFinishedEventHandle(Out<CopiedHandle> out) { void ShellServiceBase::GetBootFinishedEventHandle(sf::OutCopyHandle out) {
R_ASSERT(impl::GetBootFinishedEventHandle(out.GetHandlePointer())); R_ASSERT(impl::GetBootFinishedEventHandle(out.GetHandlePointer()));
} }

View file

@ -22,25 +22,21 @@
namespace sts::pm::shell { namespace sts::pm::shell {
class ShellServiceBase : public IServiceObject { class ShellServiceBase : public sf::IServiceObject {
protected: protected:
/* Actual command implementations. */ /* Actual command implementations. */
virtual Result LaunchTitle(Out<u64> out_process_id, ncm::TitleLocation loc, u32 flags); virtual Result LaunchTitle(sf::Out<os::ProcessId> out_process_id, const ncm::TitleLocation &loc, u32 flags);
virtual Result TerminateProcess(u64 process_id); virtual Result TerminateProcess(os::ProcessId process_id);
virtual Result TerminateTitle(ncm::TitleId title_id); virtual Result TerminateTitle(ncm::TitleId title_id);
virtual void GetProcessEventHandle(Out<CopiedHandle> out); virtual void GetProcessEventHandle(sf::OutCopyHandle out);
virtual void GetProcessEventInfo(Out<ProcessEventInfo> out); virtual void GetProcessEventInfo(sf::Out<ProcessEventInfo> out);
virtual Result CleanupProcess(u64 process_id); virtual Result CleanupProcess(os::ProcessId process_id);
virtual Result ClearExceptionOccurred(u64 process_id); virtual Result ClearExceptionOccurred(os::ProcessId process_id);
virtual void NotifyBootFinished(); virtual void NotifyBootFinished();
virtual Result GetApplicationProcessIdForShell(Out<u64> out); virtual Result GetApplicationProcessIdForShell(sf::Out<os::ProcessId> out);
virtual Result BoostSystemMemoryResourceLimit(u64 boost_size); virtual Result BoostSystemMemoryResourceLimit(u64 boost_size);
virtual Result BoostApplicationThreadResourceLimit(); virtual Result BoostApplicationThreadResourceLimit();
virtual void GetBootFinishedEventHandle(Out<CopiedHandle> out); virtual void GetBootFinishedEventHandle(sf::OutCopyHandle out);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* No entries, because ShellServiceBase is abstract. */
};
}; };
/* This represents modern ShellService (5.0.0+). */ /* This represents modern ShellService (5.0.0+). */
@ -61,20 +57,20 @@ namespace sts::pm::shell {
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
/* 5.0.0-* */ /* 5.0.0-* */
MAKE_SERVICE_COMMAND_META(ShellService, LaunchTitle), MAKE_SERVICE_COMMAND_META(LaunchTitle),
MAKE_SERVICE_COMMAND_META(ShellService, TerminateProcess), MAKE_SERVICE_COMMAND_META(TerminateProcess),
MAKE_SERVICE_COMMAND_META(ShellService, TerminateTitle), MAKE_SERVICE_COMMAND_META(TerminateTitle),
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessEventHandle), MAKE_SERVICE_COMMAND_META(GetProcessEventHandle),
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessEventInfo), MAKE_SERVICE_COMMAND_META(GetProcessEventInfo),
MAKE_SERVICE_COMMAND_META(ShellService, NotifyBootFinished), MAKE_SERVICE_COMMAND_META(NotifyBootFinished),
MAKE_SERVICE_COMMAND_META(ShellService, GetApplicationProcessIdForShell), MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell),
MAKE_SERVICE_COMMAND_META(ShellService, BoostSystemMemoryResourceLimit), MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit),
/* 7.0.0-* */ /* 7.0.0-* */
MAKE_SERVICE_COMMAND_META(ShellService, BoostApplicationThreadResourceLimit, FirmwareVersion_700), MAKE_SERVICE_COMMAND_META(BoostApplicationThreadResourceLimit, hos::Version_700),
/* 8.0.0-* */ /* 8.0.0-* */
MAKE_SERVICE_COMMAND_META(ShellService, GetBootFinishedEventHandle, FirmwareVersion_800), MAKE_SERVICE_COMMAND_META(GetBootFinishedEventHandle, hos::Version_800),
}; };
}; };
@ -96,18 +92,18 @@ namespace sts::pm::shell {
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.1.0 */ /* 1.0.0-4.1.0 */
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, LaunchTitle), MAKE_SERVICE_COMMAND_META(LaunchTitle),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateProcess), MAKE_SERVICE_COMMAND_META(TerminateProcess),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateTitle), MAKE_SERVICE_COMMAND_META(TerminateTitle),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessEventHandle), MAKE_SERVICE_COMMAND_META(GetProcessEventHandle),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessEventInfo), MAKE_SERVICE_COMMAND_META(GetProcessEventInfo),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, CleanupProcess), MAKE_SERVICE_COMMAND_META(CleanupProcess),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, ClearExceptionOccurred), MAKE_SERVICE_COMMAND_META(ClearExceptionOccurred),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, NotifyBootFinished), MAKE_SERVICE_COMMAND_META(NotifyBootFinished),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetApplicationProcessIdForShell), MAKE_SERVICE_COMMAND_META(GetApplicationProcessIdForShell),
/* 4.0.0-4.1.0 */ /* 4.0.0-4.1.0 */
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, BoostSystemMemoryResourceLimit), MAKE_SERVICE_COMMAND_META(BoostSystemMemoryResourceLimit, hos::Version_400),
}; };
}; };