mitm/cfg: pass around override status for decision-making

This commit is contained in:
Michael Scire 2019-11-21 04:03:19 -08:00 committed by SciresM
parent 37e065fa2d
commit 421324b498
59 changed files with 425 additions and 265 deletions

View File

@ -25,16 +25,15 @@ namespace ams::mitm::bpc {
RebootSystem = 1, RebootSystem = 1,
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* We will mitm: /* We will mitm:
* - am, to intercept the Reboot/Power buttons in the overlay menu. * - am, to intercept the Reboot/Power buttons in the overlay menu.
* - fatal, to simplify payload reboot logic significantly * - fatal, to simplify payload reboot logic significantly
* - applications and hbl, to allow homebrew to take advantage of the feature. * - hbl, to allow homebrew to take advantage of the feature.
*/ */
return program_id == ncm::ProgramId::Am || return client_info.program_id == ncm::ProgramId::Am ||
program_id == ncm::ProgramId::Fatal || client_info.program_id == ncm::ProgramId::Fatal ||
ncm::IsApplicationProgramId(program_id); client_info.override_status.IsHbl();
/* TODO: Hbl */
} }
public: public:
SF_MITM_SERVICE_OBJECT_CTOR(BpcMitmService) { /* ... */ } SF_MITM_SERVICE_OBJECT_CTOR(BpcMitmService) { /* ... */ }

View File

@ -25,7 +25,7 @@ namespace ams::mitm::fs {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -25,7 +25,7 @@ namespace ams::mitm::hid {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -24,7 +24,7 @@ namespace ams::mitm::ns {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -24,7 +24,7 @@ namespace ams::mitm::ns {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -24,7 +24,7 @@ namespace ams::mitm::set {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -24,7 +24,7 @@ namespace ams::mitm::set {
/* TODO */ /* TODO */
}; };
public: public:
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id) { static bool ShouldMitm(const sm::MitmProcessInfo &client_info) {
/* TODO */ /* TODO */
return false; return false;
} }

View File

@ -623,9 +623,10 @@ namespace ams::dmnt::cheat::impl {
{ {
Handle proc_h = INVALID_HANDLE; Handle proc_h = INVALID_HANDLE;
ncm::ProgramLocation loc = {}; ncm::ProgramLocation loc = {};
cfg::OverrideStatus status = {};
ON_SCOPE_EXIT { if (proc_h != INVALID_HANDLE) { R_ASSERT(svcCloseHandle(proc_h)); } }; ON_SCOPE_EXIT { if (proc_h != INVALID_HANDLE) { R_ASSERT(svcCloseHandle(proc_h)); } };
R_ASSERT_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(&proc_h, &loc, this->cheat_process_metadata.process_id)); R_ASSERT_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(&proc_h, &loc, &status, this->cheat_process_metadata.process_id));
this->cheat_process_metadata.program_id = loc.program_id; this->cheat_process_metadata.program_id = loc.program_id;
{ {
@ -638,11 +639,11 @@ namespace ams::dmnt::cheat::impl {
this->cheat_process_metadata.aslr_extents.base = as_info.aslr_base; this->cheat_process_metadata.aslr_extents.base = as_info.aslr_base;
this->cheat_process_metadata.aslr_extents.size = as_info.aslr_size; this->cheat_process_metadata.aslr_extents.size = as_info.aslr_size;
} }
}
/* If new process launch, we may not want to actually attach. */ /* If new process launch, we may not want to actually attach. */
if (on_process_launch) { if (on_process_launch) {
R_UNLESS(cfg::IsCheatEnableKeyHeld(this->cheat_process_metadata.program_id), ResultCheatNotAttached()); R_UNLESS(status.IsCheatEnabled(), ResultCheatNotAttached());
}
} }
/* Get module information from loader. */ /* Get module information from loader. */

View File

@ -13,10 +13,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "../os/os_common_types.hpp" #include "cfg_types.hpp"
#include "../ncm/ncm_types.hpp"
namespace ams::cfg { namespace ams::cfg {
@ -31,10 +29,7 @@ namespace ams::cfg {
void WaitSdCardInitialized(); void WaitSdCardInitialized();
/* Override key utilities. */ /* Override key utilities. */
bool IsProgramOverrideKeyHeld(ncm::ProgramId program_id); OverrideStatus CaptureOverrideStatus(ncm::ProgramId program_id);
bool IsHblOverrideKeyHeld(ncm::ProgramId program_id);
void GetOverrideKeyHeldStatus(bool *out_hbl, bool *out_program, ncm::ProgramId program_id);
bool IsCheatEnableKeyHeld(ncm::ProgramId program_id);
/* Flag utilities. */ /* Flag utilities. */
bool HasFlag(ncm::ProgramId program_id, const char *flag); bool HasFlag(ncm::ProgramId program_id, const char *flag);

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2018-2019 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 "../os/os_common_types.hpp"
#include "../ncm/ncm_types.hpp"
namespace ams::cfg {
namespace impl {
enum OverrideStatusFlag : u64 {
OverrideStatusFlag_Hbl = BIT(0),
OverrideStatusFlag_ProgramSpecific = BIT(1),
OverrideStatusFlag_CheatEnabled = BIT(2),
};
}
struct OverrideStatus {
u64 keys_held;
u64 flags;
constexpr inline u64 GetKeysHeld() const { return this->keys_held; }
#define DEFINE_FLAG_ACCESSORS(flag) \
constexpr inline bool Is##flag() const { return this->flags & impl::OverrideStatusFlag_##flag; } \
constexpr inline void Set##flag() { this->flags |= impl::OverrideStatusFlag_##flag; } \
constexpr inline void Clear##flag() { this->flags &= ~u64(impl::OverrideStatusFlag_##flag); }
DEFINE_FLAG_ACCESSORS(Hbl)
DEFINE_FLAG_ACCESSORS(ProgramSpecific)
DEFINE_FLAG_ACCESSORS(CheatEnabled)
#undef DEFINE_FLAG_ACCESSORS
};
static_assert(sizeof(OverrideStatus) == 0x10, "sizeof(OverrideStatus)");
static_assert(std::is_pod<OverrideStatus>::value, "std::is_pod<OverrideStatus>::value");
constexpr inline bool operator==(const OverrideStatus &lhs, const OverrideStatus &rhs) {
return lhs.keys_held == rhs.keys_held && lhs.flags == rhs.flags;
}
constexpr inline bool operator!=(const OverrideStatus &lhs, const OverrideStatus &rhs) {
return !(lhs == rhs);
}
}

View File

@ -26,4 +26,8 @@ namespace ams::ldr::pm {
Result UnpinProgram(PinId pin_id); Result UnpinProgram(PinId pin_id);
Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id); Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id);
/* Atmosphere extension API. */
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc);
Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status);
} }

View File

@ -26,7 +26,7 @@ namespace ams::pm::dmnt {
Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id); Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id);
Result GetApplicationProcessId(os::ProcessId *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::ProgramLocation *out_loc, os::ProcessId process_id); Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, 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

@ -26,6 +26,8 @@ namespace ams::pm::info {
Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id); Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id);
Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id); Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id);
Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id);
/* Information convenience API. */ /* Information convenience API. */
bool HasLaunchedProgram(ncm::ProgramId program_id); bool HasLaunchedProgram(ncm::ProgramId program_id);

View File

@ -36,7 +36,7 @@ namespace ams::sf::hipc {
NON_COPYABLE(ServerManagerBase); NON_COPYABLE(ServerManagerBase);
NON_MOVEABLE(ServerManagerBase); NON_MOVEABLE(ServerManagerBase);
public: public:
using MitmQueryFunction = bool (*)(os::ProcessId, ncm::ProgramId); using MitmQueryFunction = bool (*)(const sm::MitmProcessInfo &);
private: private:
enum class UserDataTag : uintptr_t { enum class UserDataTag : uintptr_t {
Server = 1, Server = 1,
@ -106,11 +106,10 @@ namespace ams::sf::hipc {
std::shared_ptr<::Service> forward_service = std::move(ServerSession::CreateForwardService()); std::shared_ptr<::Service> forward_service = std::move(ServerSession::CreateForwardService());
/* Get mitm forward session. */ /* Get mitm forward session. */
os::ProcessId client_process_id; sm::MitmProcessInfo client_info;
ncm::ProgramId client_program_id; R_ASSERT(sm::mitm::AcknowledgeSession(forward_service.get(), &client_info, this->service_name));
R_ASSERT(sm::mitm::AcknowledgeSession(forward_service.get(), &client_process_id, &client_program_id, this->service_name));
*out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared(std::shared_ptr<::Service>(forward_service), client_process_id, client_program_id)))); *out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared(std::shared_ptr<::Service>(forward_service), client_info))));
*out_fsrv = std::move(forward_service); *out_fsrv = std::move(forward_service);
} else { } else {
*out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared()))); *out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared())));
@ -166,8 +165,8 @@ namespace ams::sf::hipc {
} }
template<typename ServiceImpl> template<typename ServiceImpl>
static constexpr inline std::shared_ptr<ServiceImpl> MakeSharedMitm(std::shared_ptr<::Service> &&s, os::ProcessId p, ncm::ProgramId r) { static constexpr inline std::shared_ptr<ServiceImpl> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) {
return std::make_shared<ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), p, r); return std::make_shared<ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info);
} }
Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func); Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func);

View File

@ -18,3 +18,4 @@
#include <atmosphere/common.hpp> #include <atmosphere/common.hpp>
#include "../ams.hpp" #include "../ams.hpp"
#include "../os.hpp" #include "../os.hpp"
#include "../sm/sm_types.hpp"

View File

@ -25,16 +25,15 @@ namespace ams::sf {
class IMitmServiceObject : public IServiceObject { class IMitmServiceObject : public IServiceObject {
protected: protected:
std::shared_ptr<::Service> forward_service; std::shared_ptr<::Service> forward_service;
os::ProcessId process_id; sm::MitmProcessInfo client_info;
ncm::ProgramId program_id;
public: public:
IMitmServiceObject(std::shared_ptr<::Service> &&s, os::ProcessId p, ncm::ProgramId r) : forward_service(std::move(s)), process_id(p), program_id(r) { /* ... */ } IMitmServiceObject(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : forward_service(std::move(s)), client_info(c) { /* ... */ }
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id); static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id);
}; };
/* Utility. */ /* Utility. */
#define SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, os::ProcessId p, ncm::ProgramId r) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), p, r) #define SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), c)
template<typename T> template<typename T>
struct ServiceObjectTraits { struct ServiceObjectTraits {

View File

@ -23,7 +23,7 @@
namespace ams::sm::manager { namespace ams::sm::manager {
/* Manager API. */ /* Manager API. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size); Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size);
Result UnregisterProcess(os::ProcessId process_id); Result UnregisterProcess(os::ProcessId process_id);
/* Atmosphere extensions. */ /* Atmosphere extensions. */

View File

@ -17,7 +17,6 @@
#pragma once #pragma once
#include "sm_types.hpp" #include "sm_types.hpp"
#include "../ncm/ncm_types.hpp"
namespace ams::sm::mitm { namespace ams::sm::mitm {
@ -25,7 +24,7 @@ namespace ams::sm::mitm {
Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name); Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name);
Result UninstallMitm(ServiceName name); Result UninstallMitm(ServiceName name);
Result DeclareFutureMitm(ServiceName name); Result DeclareFutureMitm(ServiceName name);
Result AcknowledgeSession(Service *out_service, os::ProcessId *out_process_id, ncm::ProgramId *out_program_id, ServiceName name); Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name);
Result HasMitm(bool *out, ServiceName name); Result HasMitm(bool *out, ServiceName name);
Result WaitMitm(ServiceName name); Result WaitMitm(ServiceName name);

View File

@ -16,6 +16,8 @@
#pragma once #pragma once
#include <atmosphere/common.hpp> #include <atmosphere/common.hpp>
#include "../ncm/ncm_types.hpp"
#include "../cfg/cfg_types.hpp"
namespace ams::sm { namespace ams::sm {
@ -65,4 +67,12 @@ namespace ams::sm {
}; };
static_assert(sizeof(ServiceRecord) == 0x30, "ServiceRecord definition!"); static_assert(sizeof(ServiceRecord) == 0x30, "ServiceRecord definition!");
/* For Mitm extensions. */
struct MitmProcessInfo {
os::ProcessId process_id;
ncm::ProgramId program_id;
cfg::OverrideStatus override_status;
};
static_assert(std::is_trivial<MitmProcessInfo>::value && sizeof(MitmProcessInfo) == 0x20, "MitmProcessInfo definition!");
} }

View File

@ -164,10 +164,9 @@ namespace ams::cfg {
return 1; return 1;
} }
bool IsOverrideKeyHeld(const OverrideKey *cfg) { constexpr inline bool IsOverrideMatch(const OverrideStatus &status, const OverrideKey &cfg) {
u64 kHeld = 0; bool keys_triggered = ((status.keys_held & cfg.key_combination) != 0);
bool keys_triggered = (R_SUCCEEDED(hid::GetKeysHeld(&kHeld)) && ((kHeld & cfg->key_combination) != 0)); return (cfg.override_by_default ^ keys_triggered);
return IsSdCardInitialized() && (cfg->override_by_default ^ keys_triggered);
} }
void ParseIniFile(util::ini::Handler handler, const char *path, void *user_ctx) { void ParseIniFile(util::ini::Handler handler, const char *path, void *user_ctx) {
@ -207,82 +206,45 @@ namespace ams::cfg {
} }
bool IsHblOverrideKeyHeld(ncm::ProgramId program_id) { OverrideStatus CaptureOverrideStatus(ncm::ProgramId program_id) {
OverrideStatus status = {};
/* If the SD card isn't initialized, we can't override. */ /* If the SD card isn't initialized, we can't override. */
if (!IsSdCardInitialized()) { if (!IsSdCardInitialized()) {
return false; return status;
} }
/* For system modules and anything launched before the home menu, always override. */ /* For system modules and anything launched before the home menu, always override. */
if (program_id < ncm::ProgramId::AppletStart || !pm::info::HasLaunchedProgram(ncm::ProgramId::AppletQlaunch)) { if (program_id < ncm::ProgramId::AppletStart || !pm::info::HasLaunchedProgram(ncm::ProgramId::AppletQlaunch)) {
return true; status.SetProgramSpecific();
return status;
} }
/* Unconditionally refresh loader.ini contents. */ /* Unconditionally refresh loader.ini contents. */
RefreshLoaderConfiguration(); RefreshLoaderConfiguration();
/* Check HBL config. */ /* If we can't read the key state, don't override anything. */
return IsHblProgramId(program_id) && IsOverrideKeyHeld(&g_hbl_override_config.override_key); if (R_FAILED(hid::GetKeysHeld(&status.keys_held))) {
return status;
} }
bool IsProgramOverrideKeyHeld(ncm::ProgramId program_id) { /* Detect Hbl. */
/* If the SD card isn't initialized, we can't override. */ if (IsHblProgramId(program_id) && IsOverrideMatch(status, g_hbl_override_config.override_key)) {
if (!IsSdCardInitialized()) { status.SetHbl();
return false;
} }
/* For system modules and anything launched before the home menu, always override. */ /* Detect content specific keys. */
if (program_id < ncm::ProgramId::AppletStart || !pm::info::HasLaunchedProgram(ncm::ProgramId::AppletQlaunch)) {
return true;
}
/* Unconditionally refresh loader.ini contents. */
RefreshLoaderConfiguration();
const auto content_cfg = GetContentOverrideConfig(program_id); const auto content_cfg = GetContentOverrideConfig(program_id);
return IsOverrideKeyHeld(&content_cfg.override_key); if (IsOverrideMatch(status, content_cfg.override_key)) {
status.SetProgramSpecific();
} }
void GetOverrideKeyHeldStatus(bool *out_hbl, bool *out_program, ncm::ProgramId program_id) { /* Only allow cheat enable if not HBL. */
if (!status.IsHbl() && IsOverrideMatch(status, content_cfg.cheat_enable_key)) {
/* If the SD card isn't initialized, we can't override. */ status.SetCheatEnabled();
if (!IsSdCardInitialized()) {
*out_hbl = false;
*out_program = false;
return;
} }
/* For system modules and anything launched before the home menu, always override. */ return status;
if (program_id < ncm::ProgramId::AppletStart || !pm::info::HasLaunchedProgram(ncm::ProgramId::AppletQlaunch)) {
*out_hbl = false;
*out_program = true;
return;
}
/* Unconditionally refresh loader.ini contents. */
RefreshLoaderConfiguration();
/* Set HBL output. */
*out_hbl = IsHblProgramId(program_id) && IsOverrideKeyHeld(&g_hbl_override_config.override_key);
/* Set content specific output. */
const auto content_cfg = GetContentOverrideConfig(program_id);
*out_program = IsOverrideKeyHeld(&content_cfg.override_key);
}
bool IsCheatEnableKeyHeld(ncm::ProgramId program_id) {
/* If the SD card isn't initialized, don't apply cheats. */
if (!IsSdCardInitialized()) {
return false;
}
/* Don't apply cheats to HBL. */
if (IsHblOverrideKeyHeld(program_id)) {
return false;
}
const auto content_cfg = GetContentOverrideConfig(program_id);
return IsOverrideKeyHeld(&content_cfg.cheat_enable_key);
} }
/* HBL Configuration utilities. */ /* HBL Configuration utilities. */

View File

@ -31,3 +31,18 @@ Result ldrDmntAtmosphereHasLaunchedProgram(bool *out, u64 program_id) {
Result ldrPmAtmosphereHasLaunchedProgram(bool *out, u64 program_id) { Result ldrPmAtmosphereHasLaunchedProgram(bool *out, u64 program_id) {
return _ldrAtmosphereHasLaunchedProgram(ldrPmGetServiceSession(), out, program_id); return _ldrAtmosphereHasLaunchedProgram(ldrPmGetServiceSession(), out, program_id);
} }
Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out_program_info, CfgOverrideStatus *out_status, const NcmProgramLocation *loc) {
return serviceDispatchInOut(ldrPmGetServiceSession(), 65001, *loc, *out_status,
.buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer | SfBufferAttr_FixedSize },
.buffers = { { out_program_info, sizeof(*out_program_info) } },
);
}
Result ldrPmAtmospherePinProgram(u64 *out, const NcmProgramLocation *loc, const CfgOverrideStatus *status) {
const struct {
NcmProgramLocation loc;
CfgOverrideStatus status;
} in = { *loc, *status };
return serviceDispatchInOut(ldrPmGetServiceSession(), 65002, in, *out);
}

View File

@ -11,9 +11,17 @@
extern "C" { extern "C" {
#endif #endif
typedef struct {
u64 keys_down;
u64 flags;
} CfgOverrideStatus;
Result ldrPmAtmosphereHasLaunchedProgram(bool *out, u64 program_id); Result ldrPmAtmosphereHasLaunchedProgram(bool *out, u64 program_id);
Result ldrDmntAtmosphereHasLaunchedProgram(bool *out, u64 program_id); Result ldrDmntAtmosphereHasLaunchedProgram(bool *out, u64 program_id);
Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out, CfgOverrideStatus *out_status, const NcmProgramLocation *loc);
Result ldrPmAtmospherePinProgram(u64 *out, const NcmProgramLocation *loc, const CfgOverrideStatus *status);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -40,4 +40,15 @@ namespace ams::ldr::pm {
return ldrPmAtmosphereHasLaunchedProgram(out, static_cast<u64>(program_id)); return ldrPmAtmosphereHasLaunchedProgram(out, static_cast<u64>(program_id));
} }
Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
return ldrPmAtmosphereGetProgramInfo(reinterpret_cast<LoaderProgramInfo *>(out), reinterpret_cast<CfgOverrideStatus *>(out_status), reinterpret_cast<const NcmProgramLocation *>(&loc));
}
Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
static_assert(sizeof(*out) == sizeof(u64), "PinId definition!");
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
return ldrPmAtmospherePinProgram(reinterpret_cast<u64 *>(out), reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<const CfgOverrideStatus *>(&status));
}
} }

View File

@ -28,10 +28,31 @@ Result pminfoAtmosphereHasLaunchedProgram(bool *out, u64 program_id) {
return rc; return rc;
} }
Result pmdmntAtmosphereGetProcessInfo(Handle* handle_out, NcmProgramLocation *loc_out, u64 pid) { Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid) {
struct {
NcmProgramLocation loc;
CfgOverrideStatus status;
} out;
Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65002, pid, out);
if (R_SUCCEEDED(rc)) {
if (loc_out) *loc_out = out.loc;
if (status_out) *status_out = out.status;
}
return rc;
}
Result pmdmntAtmosphereGetProcessInfo(Handle* handle_out, NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid) {
Handle tmp_handle; Handle tmp_handle;
Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65000, pid, *loc_out, struct {
NcmProgramLocation loc;
CfgOverrideStatus status;
} out;
Result rc = serviceDispatchInOut(pmdmntGetServiceSession(), 65000, pid, out,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy }, .out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &tmp_handle, .out_handles = &tmp_handle,
); );
@ -42,6 +63,9 @@ Result pmdmntAtmosphereGetProcessInfo(Handle* handle_out, NcmProgramLocation *lo
} else { } else {
svcCloseHandle(tmp_handle); svcCloseHandle(tmp_handle);
} }
if (loc_out) *loc_out = out.loc;
if (status_out) *status_out = out.status;
} }
return rc; return rc;

View File

@ -11,10 +11,16 @@
extern "C" { extern "C" {
#endif #endif
typedef struct {
u64 keys_held;
u64 flags;
} CfgOverrideStatus;
Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 program_id); Result pminfoAtmosphereGetProcessId(u64 *out_pid, u64 program_id);
Result pminfoAtmosphereHasLaunchedProgram(bool *out, u64 program_id); Result pminfoAtmosphereHasLaunchedProgram(bool *out, u64 program_id);
Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid);
Result pmdmntAtmosphereGetProcessInfo(Handle *out, NcmProgramLocation *loc_out, u64 pid); Result pmdmntAtmosphereGetProcessInfo(Handle *out, NcmProgramLocation *loc_out, CfgOverrideStatus *status_out, u64 pid);
Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource); Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group, u32 resource);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -39,10 +39,12 @@ namespace ams::pm::dmnt {
return ResultSuccess(); return ResultSuccess();
} }
Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::ProgramLocation *out_loc, os::ProcessId process_id) { Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id) {
*out_handle = INVALID_HANDLE; *out_handle = INVALID_HANDLE;
*out_loc = {}; *out_loc = {};
return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<NcmProgramLocation *>(out_loc), static_cast<u64>(process_id)); *out_status = {};
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus));
return pmdmntAtmosphereGetProcessInfo(out_handle, reinterpret_cast<NcmProgramLocation *>(out_loc), reinterpret_cast<CfgOverrideStatus *>(out_status), 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

@ -40,6 +40,15 @@ namespace ams::pm::info {
return pminfoAtmosphereGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(program_id)); return pminfoAtmosphereGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(program_id));
} }
Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id) {
std::scoped_lock lk(g_info_lock);
*out_loc = {};
*out_status = {};
static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus));
return pminfoAtmosphereGetProcessInfo(reinterpret_cast<NcmProgramLocation *>(out_loc), reinterpret_cast<CfgOverrideStatus *>(out_status), static_cast<u64>(process_id));
}
Result WEAK HasLaunchedProgram(bool *out, ncm::ProgramId program_id) { Result WEAK HasLaunchedProgram(bool *out, ncm::ProgramId program_id) {
std::scoped_lock lk(g_info_lock); std::scoped_lock lk(g_info_lock);

View File

@ -30,8 +30,8 @@ namespace ams::sf::hipc::impl {
public: public:
MitmQueryService(ServerManagerBase::MitmQueryFunction qf) : query_function(qf) { /* ... */ } MitmQueryService(ServerManagerBase::MitmQueryFunction qf) : query_function(qf) { /* ... */ }
void ShouldMitm(sf::Out<bool> out, os::ProcessId process_id, ncm::ProgramId program_id) { void ShouldMitm(sf::Out<bool> out, const sm::MitmProcessInfo &client_info) {
out.SetValue(this->query_function(process_id, program_id)); out.SetValue(this->query_function(client_info));
} }
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {

View File

@ -107,21 +107,16 @@ Result smAtmosphereMitmDeclareFuture(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65006); return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65006);
} }
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, SmServiceName name) { Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServiceName name) {
struct { struct {
u64 pid; u64 process_id;
u64 tid; u64 program_id;
} out; u64 keys_held;
u64 flags;
} *out = _out;
Result rc = serviceDispatchInOut(&g_smAtmosphereMitmSrv, 65003, name, out, return serviceDispatchInOut(&g_smAtmosphereMitmSrv, 65003, name, *out,
.out_num_objects = 1, .out_num_objects = 1,
.out_objects = srv_out, .out_objects = srv_out,
); );
if (R_SUCCEEDED(rc)) {
if (pid_out) *pid_out = out.pid;
if (tid_out) *tid_out = out.tid;
}
return rc;
} }

View File

@ -28,7 +28,7 @@ void smAtmosphereCloseSession(Service *srv);
Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name); Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name);
Result smAtmosphereMitmUninstall(SmServiceName name); Result smAtmosphereMitmUninstall(SmServiceName name);
Result smAtmosphereMitmDeclareFuture(SmServiceName name); Result smAtmosphereMitmDeclareFuture(SmServiceName name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, SmServiceName name); Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *info_out, SmServiceName name);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -19,8 +19,9 @@
namespace ams::sm::manager { namespace ams::sm::manager {
/* Manager API. */ /* Manager API. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const void *acid, size_t acid_size, const void *aci, size_t aci_size) { Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus status, const void *acid, size_t acid_size, const void *aci, size_t aci_size) {
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), acid, acid_size, aci, aci_size); static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition");
return smManagerAtmosphereRegisterProcess(static_cast<u64>(process_id), static_cast<u64>(program_id), reinterpret_cast<const CfgOverrideStatus *>(&status), acid, acid_size, aci, aci_size);
} }
Result UnregisterProcess(os::ProcessId process_id) { Result UnregisterProcess(os::ProcessId process_id) {

View File

@ -36,9 +36,9 @@ namespace ams::sm::mitm {
}); });
} }
Result AcknowledgeSession(Service *out_service, os::ProcessId *out_process_id, ncm::ProgramId *out_program_id, ServiceName name) { Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name) {
return impl::DoWithMitmAcknowledgementSession([&]() { return impl::DoWithMitmAcknowledgementSession([&]() {
return smAtmosphereMitmAcknowledgeSession(out_service, &out_process_id->value, &out_program_id->value, impl::ConvertName(name)); return smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast<void *>(out_info), impl::ConvertName(name));
}); });
} }

View File

@ -19,11 +19,12 @@ Result smManagerAtmosphereEndInitialDefers(void) {
return serviceDispatch(smManagerGetServiceSession(), 65000); return serviceDispatch(smManagerGetServiceSession(), 65000);
} }
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) { Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideStatus *status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
const struct { const struct {
u64 pid; u64 pid;
u64 tid; u64 tid;
} in = { pid, tid }; CfgOverrideStatus status;
} in = { pid, tid, *status };
return serviceDispatchIn(smManagerGetServiceSession(), 65002, in, return serviceDispatchIn(smManagerGetServiceSession(), 65002, in,
.buffer_attrs = { .buffer_attrs = {
SfBufferAttr_In | SfBufferAttr_HipcMapAlias, SfBufferAttr_In | SfBufferAttr_HipcMapAlias,

View File

@ -11,8 +11,13 @@
extern "C" { extern "C" {
#endif #endif
typedef struct {
u64 keys_held;
u64 flags;
} CfgOverrideStatus;
Result smManagerAtmosphereEndInitialDefers(void); Result smManagerAtmosphereEndInitialDefers(void);
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size); Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideStatus *status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size);
Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name); Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -31,10 +31,6 @@ namespace ams::ldr {
/* Globals. */ /* Globals. */
bool g_has_mounted_sd_card = false; bool g_has_mounted_sd_card = false;
ncm::ProgramId g_should_override_program_id;
bool g_should_override_hbl = false;
bool g_should_override_sd = false;
/* Helpers. */ /* Helpers. */
inline void FixFileSystemPath(char *path) { inline void FixFileSystemPath(char *path) {
/* Paths will fail when passed to FS if they use the wrong kinds of slashes. */ /* Paths will fail when passed to FS if they use the wrong kinds of slashes. */
@ -53,27 +49,6 @@ namespace ams::ldr {
return relative_path; return relative_path;
} }
void UpdateShouldOverrideCache(ncm::ProgramId program_id) {
if (g_should_override_program_id != program_id) {
cfg::GetOverrideKeyHeldStatus(&g_should_override_hbl, &g_should_override_sd, program_id);
}
g_should_override_program_id = program_id;
}
void InvalidateShouldOverrideCache() {
g_should_override_program_id = {};
}
bool ShouldOverrideWithHbl(ncm::ProgramId program_id) {
UpdateShouldOverrideCache(program_id);
return g_should_override_hbl;
}
bool ShouldOverrideWithSd(ncm::ProgramId program_id) {
UpdateShouldOverrideCache(program_id);
return g_should_override_sd;
}
Result MountSdCardFileSystem() { Result MountSdCardFileSystem() {
return fsdevMountSdmc(); return fsdevMountSdmc();
} }
@ -109,14 +84,14 @@ namespace ams::ldr {
return OpenFile(SdCardFileSystemDeviceName, path); return OpenFile(SdCardFileSystemDeviceName, path);
} }
bool IsFileStubbed(ncm::ProgramId program_id, const char *relative_path) { bool IsFileStubbed(ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path) {
/* Allow nullptr relative path -- those are simply not openable. */ /* Allow nullptr relative path -- those are simply not openable. */
if (relative_path == nullptr) { if (relative_path == nullptr) {
return true; return true;
} }
/* Only allow stubbing in the case where we're considering SD card content. */ /* Only allow stubbing in the case where we're considering SD card content. */
if (!ShouldOverrideWithSd(program_id)) { if (!status.IsProgramSpecific()) {
return false; return false;
} }
@ -131,14 +106,14 @@ namespace ams::ldr {
return true; return true;
} }
FILE *OpenBaseExefsFile(ncm::ProgramId program_id, const char *relative_path) { FILE *OpenBaseExefsFile(ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path) {
/* Allow nullptr relative path -- those are simply not openable. */ /* Allow nullptr relative path -- those are simply not openable. */
if (relative_path == nullptr) { if (relative_path == nullptr) {
return nullptr; return nullptr;
} }
/* Check if stubbed. */ /* Check if stubbed. */
if (IsFileStubbed(program_id, relative_path)) { if (IsFileStubbed(program_id, status, relative_path)) {
return nullptr; return nullptr;
} }
@ -148,7 +123,11 @@ namespace ams::ldr {
} }
/* ScopedCodeMount functionality. */ /* ScopedCodeMount functionality. */
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc) : is_code_mounted(false), is_hbl_mounted(false) { ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc) : has_status(false), is_code_mounted(false), is_hbl_mounted(false) {
this->result = this->Initialize(loc);
}
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o) : override_status(o), has_status(true), is_code_mounted(false), is_hbl_mounted(false) {
this->result = this->Initialize(loc); this->result = this->Initialize(loc);
} }
@ -160,9 +139,6 @@ namespace ams::ldr {
if (this->is_hbl_mounted) { if (this->is_hbl_mounted) {
fsdevUnmountDevice(HblFileSystemDeviceName); fsdevUnmountDevice(HblFileSystemDeviceName);
} }
/* Unmounting code means we should invalidate our configuration cache. */
InvalidateShouldOverrideCache();
} }
Result ScopedCodeMount::MountCodeFileSystem(const ncm::ProgramLocation &loc) { Result ScopedCodeMount::MountCodeFileSystem(const ncm::ProgramLocation &loc) {
@ -219,12 +195,17 @@ namespace ams::ldr {
} }
} }
/* Capture override status, if necessary. */
if (!this->has_status) {
this->InitializeOverrideStatus(loc);
}
/* Check if we should override contents. */ /* Check if we should override contents. */
if (ShouldOverrideWithHbl(loc.program_id)) { if (this->override_status.IsHbl()) {
/* Try to mount HBL. */ /* Try to mount HBL. */
this->MountHblFileSystem(); this->MountHblFileSystem();
} }
if (ShouldOverrideWithSd(loc.program_id)) { if (this->override_status.IsProgramSpecific()) {
/* Try to mount Code NSP on SD. */ /* Try to mount Code NSP on SD. */
this->MountSdCardCodeFileSystem(loc); this->MountSdCardCodeFileSystem(loc);
} }
@ -237,25 +218,31 @@ namespace ams::ldr {
return ResultSuccess(); return ResultSuccess();
} }
Result OpenCodeFile(FILE *&out, ncm::ProgramId program_id, const char *relative_path) { void ScopedCodeMount::InitializeOverrideStatus(const ncm::ProgramLocation &loc) {
AMS_ASSERT(!this->has_status);
this->override_status = cfg::CaptureOverrideStatus(loc.program_id);
this->has_status = true;
}
Result OpenCodeFile(FILE *&out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path) {
FILE *f = nullptr; FILE *f = nullptr;
const char *ecs_device_name = ecs::Get(program_id); const char *ecs_device_name = ecs::Get(program_id);
if (ecs_device_name != nullptr) { if (ecs_device_name != nullptr) {
/* First priority: Open from external content. */ /* First priority: Open from external content. */
f = OpenFile(ecs_device_name, relative_path); f = OpenFile(ecs_device_name, relative_path);
} else if (ShouldOverrideWithHbl(program_id)) { } else if (status.IsHbl()) {
/* Next, try to open from HBL. */ /* Next, try to open from HBL. */
f = OpenFile(HblFileSystemDeviceName, relative_path); f = OpenFile(HblFileSystemDeviceName, relative_path);
} else { } else {
/* If not ECS or HBL, try a loose file on the SD. */ /* If not ECS or HBL, try a loose file on the SD. */
if (ShouldOverrideWithSd(program_id)) { if (status.IsProgramSpecific()) {
f = OpenLooseSdFile(program_id, relative_path); f = OpenLooseSdFile(program_id, relative_path);
} }
/* If we fail, try the original exefs. */ /* If we fail, try the original exefs. */
if (f == nullptr) { if (f == nullptr) {
f = OpenBaseExefsFile(program_id, relative_path); f = OpenBaseExefsFile(program_id, status, relative_path);
} }
} }
@ -266,9 +253,9 @@ namespace ams::ldr {
return ResultSuccess(); return ResultSuccess();
} }
Result OpenCodeFileFromBaseExefs(FILE *&out, ncm::ProgramId program_id, const char *relative_path) { Result OpenCodeFileFromBaseExefs(FILE *&out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path) {
/* Open the file. */ /* Open the file. */
FILE *f = OpenBaseExefsFile(program_id, relative_path); FILE *f = OpenBaseExefsFile(program_id, status, relative_path);
R_UNLESS(f != nullptr, fs::ResultPathNotFound()); R_UNLESS(f != nullptr, fs::ResultPathNotFound());
out = f; out = f;

View File

@ -23,10 +23,13 @@ namespace ams::ldr {
NON_COPYABLE(ScopedCodeMount); NON_COPYABLE(ScopedCodeMount);
private: private:
Result result; Result result;
cfg::OverrideStatus override_status;
bool has_status;
bool is_code_mounted; bool is_code_mounted;
bool is_hbl_mounted; bool is_hbl_mounted;
public: public:
ScopedCodeMount(const ncm::ProgramLocation &loc); ScopedCodeMount(const ncm::ProgramLocation &loc);
ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status);
~ScopedCodeMount(); ~ScopedCodeMount();
Result GetResult() const { Result GetResult() const {
@ -41,17 +44,24 @@ namespace ams::ldr {
return this->is_hbl_mounted; return this->is_hbl_mounted;
} }
const cfg::OverrideStatus &GetOverrideStatus() const {
AMS_ASSERT(this->has_status);
return this->override_status;
}
private: private:
Result Initialize(const ncm::ProgramLocation &loc); Result Initialize(const ncm::ProgramLocation &loc);
void InitializeOverrideStatus(const ncm::ProgramLocation &loc);
Result MountCodeFileSystem(const ncm::ProgramLocation &loc); Result MountCodeFileSystem(const ncm::ProgramLocation &loc);
Result MountSdCardCodeFileSystem(const ncm::ProgramLocation &loc); Result MountSdCardCodeFileSystem(const ncm::ProgramLocation &loc);
Result MountHblFileSystem(); Result MountHblFileSystem();
}; };
/* Content Management API. */ /* Content Management API. */
Result OpenCodeFile(FILE *&out, ncm::ProgramId program_id, const char *relative_path); Result OpenCodeFile(FILE *&out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path);
Result OpenCodeFileFromBaseExefs(FILE *&out, ncm::ProgramId program_id, const char *relative_path); Result OpenCodeFileFromBaseExefs(FILE *&out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, const char *relative_path);
/* Redirection API. */ /* Redirection API. */
Result ResolveContentPath(char *out_path, const ncm::ProgramLocation &loc); Result ResolveContentPath(char *out_path, const ncm::ProgramLocation &loc);

View File

@ -23,27 +23,14 @@
namespace ams::ldr { namespace ams::ldr {
/* Official commands. */ namespace {
Result LoaderService::CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h) {
os::ManagedHandle reslimit_holder(reslimit_h.GetValue());
ncm::ProgramLocation loc;
char path[FS_MAX_PATH];
/* Get location. */ Result GetProgramInfoImpl(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
R_TRY(ldr::ro::GetProgramLocation(&loc, id));
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None)) {
R_TRY(ResolveContentPath(path, loc));
}
return ldr::CreateProcess(proc_h.GetHandlePointer(), id, loc, path, flags, reslimit_holder.Get());
}
Result LoaderService::GetProgramInfo(sf::Out<ProgramInfo> out, const ncm::ProgramLocation &loc) {
/* Zero output. */ /* Zero output. */
std::memset(out.GetPointer(), 0, sizeof(*out.GetPointer())); std::memset(out, 0, sizeof(*out));
cfg::OverrideStatus status = {};
R_TRY(ldr::GetProgramInfo(out.GetPointer(), loc)); R_TRY(ldr::GetProgramInfo(out, &status, loc));
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) { if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) {
char path[FS_MAX_PATH]; char path[FS_MAX_PATH];
@ -58,11 +45,38 @@ namespace ams::ldr {
} }
} }
if (out_status != nullptr) {
*out_status = status;
}
return ResultSuccess(); return ResultSuccess();
} }
}
/* Official commands. */
Result LoaderService::CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h) {
os::ManagedHandle reslimit_holder(reslimit_h.GetValue());
ncm::ProgramLocation loc;
cfg::OverrideStatus override_status;
char path[FS_MAX_PATH];
/* Get location and override status. */
R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id));
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None)) {
R_TRY(ResolveContentPath(path, loc));
}
return ldr::CreateProcess(proc_h.GetHandlePointer(), id, loc, override_status, path, flags, reslimit_holder.Get());
}
Result LoaderService::GetProgramInfo(sf::Out<ProgramInfo> out, const ncm::ProgramLocation &loc) {
return GetProgramInfoImpl(out.GetPointer(), nullptr, loc);
}
Result LoaderService::PinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc) { Result LoaderService::PinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc) {
return ldr::ro::PinProgram(out_id.GetPointer(), loc); return ldr::ro::PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{});
} }
Result LoaderService::UnpinProgram(PinId id) { Result LoaderService::UnpinProgram(PinId id) {
@ -95,4 +109,12 @@ namespace ams::ldr {
out.SetValue(ldr::HasLaunchedProgram(program_id)); out.SetValue(ldr::HasLaunchedProgram(program_id));
} }
Result LoaderService::AtmosphereGetProgramInfo(sf::Out<ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc) {
return GetProgramInfoImpl(out_program_info.GetPointer(), out_status.GetPointer(), loc);
}
Result LoaderService::AtmospherePinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status) {
return ldr::ro::PinProgram(out_id.GetPointer(), loc, override_status);
}
} }

View File

@ -33,6 +33,8 @@ namespace ams::ldr {
virtual Result AtmosphereSetExternalContentSource(sf::OutMoveHandle out, ncm::ProgramId program_id); virtual Result AtmosphereSetExternalContentSource(sf::OutMoveHandle out, ncm::ProgramId program_id);
virtual void AtmosphereClearExternalContentSource(ncm::ProgramId program_id); virtual void AtmosphereClearExternalContentSource(ncm::ProgramId program_id);
virtual void AtmosphereHasLaunchedProgram(sf::Out<bool> out, ncm::ProgramId program_id); virtual void AtmosphereHasLaunchedProgram(sf::Out<bool> out, ncm::ProgramId program_id);
virtual Result AtmosphereGetProgramInfo(sf::Out<ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc);
virtual Result AtmospherePinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status);
}; };
namespace pm { namespace pm {
@ -46,6 +48,8 @@ namespace ams::ldr {
UnpinProgram = 3, UnpinProgram = 3,
AtmosphereHasLaunchedProgram = 65000, AtmosphereHasLaunchedProgram = 65000,
AtmosphereGetProgramInfo = 65001,
AtmospherePinProgram = 65002,
}; };
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
@ -55,6 +59,8 @@ namespace ams::ldr {
MAKE_SERVICE_COMMAND_META(UnpinProgram), MAKE_SERVICE_COMMAND_META(UnpinProgram),
MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedProgram), MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedProgram),
MAKE_SERVICE_COMMAND_META(AtmosphereGetProgramInfo),
MAKE_SERVICE_COMMAND_META(AtmospherePinProgram),
}; };
}; };

View File

@ -33,6 +33,7 @@ namespace ams::ldr {
/* Global storage. */ /* Global storage. */
ncm::ProgramId g_cached_program_id; ncm::ProgramId g_cached_program_id;
cfg::OverrideStatus g_cached_override_status;
MetaCache g_meta_cache; MetaCache g_meta_cache;
MetaCache g_original_meta_cache; MetaCache g_original_meta_cache;
@ -144,11 +145,11 @@ namespace ams::ldr {
} }
/* API. */ /* API. */
Result LoadMeta(Meta *out_meta, ncm::ProgramId program_id) { Result LoadMeta(Meta *out_meta, ncm::ProgramId program_id, const cfg::OverrideStatus &status) {
FILE *f = nullptr; FILE *f = nullptr;
/* Try to load meta from file. */ /* Try to load meta from file. */
R_TRY(OpenCodeFile(f, program_id, MetaFilePath)); R_TRY(OpenCodeFile(f, program_id, status, MetaFilePath));
{ {
ON_SCOPE_EXIT { fclose(f); }; ON_SCOPE_EXIT { fclose(f); };
R_TRY(LoadMetaFromFile(f, &g_meta_cache)); R_TRY(LoadMetaFromFile(f, &g_meta_cache));
@ -161,8 +162,8 @@ namespace ams::ldr {
meta->aci->program_id = program_id; meta->aci->program_id = program_id;
/* For HBL, we need to copy some information from the base meta. */ /* For HBL, we need to copy some information from the base meta. */
if (cfg::IsHblOverrideKeyHeld(program_id)) { if (status.IsHbl()) {
if (R_SUCCEEDED(OpenCodeFileFromBaseExefs(f, program_id, MetaFilePath))) { if (R_SUCCEEDED(OpenCodeFileFromBaseExefs(f, program_id, status, MetaFilePath))) {
ON_SCOPE_EXIT { fclose(f); }; ON_SCOPE_EXIT { fclose(f); };
if (R_SUCCEEDED(LoadMetaFromFile(f, &g_original_meta_cache))) { if (R_SUCCEEDED(LoadMetaFromFile(f, &g_original_meta_cache))) {
Meta *o_meta = &g_original_meta_cache.meta; Meta *o_meta = &g_original_meta_cache.meta;
@ -182,14 +183,15 @@ namespace ams::ldr {
/* Set output. */ /* Set output. */
g_cached_program_id = program_id; g_cached_program_id = program_id;
g_cached_override_status = status;
*out_meta = *meta; *out_meta = *meta;
return ResultSuccess(); return ResultSuccess();
} }
Result LoadMetaFromCache(Meta *out_meta, ncm::ProgramId program_id) { Result LoadMetaFromCache(Meta *out_meta, ncm::ProgramId program_id, const cfg::OverrideStatus &status) {
if (g_cached_program_id != program_id) { if (g_cached_program_id != program_id || g_cached_override_status != status) {
return LoadMeta(out_meta, program_id); return LoadMeta(out_meta, program_id, status);
} }
*out_meta = g_meta_cache.meta; *out_meta = g_meta_cache.meta;
return ResultSuccess(); return ResultSuccess();

View File

@ -33,8 +33,8 @@ namespace ams::ldr {
}; };
/* Meta API. */ /* Meta API. */
Result LoadMeta(Meta *out_meta, ncm::ProgramId program_id); Result LoadMeta(Meta *out_meta, ncm::ProgramId program_id, const cfg::OverrideStatus &status);
Result LoadMetaFromCache(Meta *out_meta, ncm::ProgramId program_id); Result LoadMetaFromCache(Meta *out_meta, ncm::ProgramId program_id, const cfg::OverrideStatus &status);
void InvalidateMetaCache(); void InvalidateMetaCache();
} }

View File

@ -265,14 +265,14 @@ namespace ams::ldr {
return static_cast<Acid::PoolPartition>((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift); return static_cast<Acid::PoolPartition>((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift);
} }
Result LoadNsoHeaders(ncm::ProgramId program_id, NsoHeader *nso_headers, bool *has_nso) { Result LoadNsoHeaders(ncm::ProgramId program_id, const cfg::OverrideStatus &override_status, NsoHeader *nso_headers, bool *has_nso) {
/* Clear NSOs. */ /* Clear NSOs. */
std::memset(nso_headers, 0, sizeof(*nso_headers) * Nso_Count); std::memset(nso_headers, 0, sizeof(*nso_headers) * Nso_Count);
std::memset(has_nso, 0, sizeof(*has_nso) * Nso_Count); std::memset(has_nso, 0, sizeof(*has_nso) * Nso_Count);
for (size_t i = 0; i < Nso_Count; i++) { for (size_t i = 0; i < Nso_Count; i++) {
FILE *f = nullptr; FILE *f = nullptr;
if (R_SUCCEEDED(OpenCodeFile(f, program_id, GetNsoName(i)))) { if (R_SUCCEEDED(OpenCodeFile(f, program_id, override_status, GetNsoName(i)))) {
ON_SCOPE_EXIT { fclose(f); }; ON_SCOPE_EXIT { fclose(f); };
/* Read NSO header. */ /* Read NSO header. */
R_UNLESS(fread(nso_headers + i, sizeof(*nso_headers), 1, f) == 1, ResultInvalidNso()); R_UNLESS(fread(nso_headers + i, sizeof(*nso_headers), 1, f) == 1, ResultInvalidNso());
@ -611,14 +611,14 @@ namespace ams::ldr {
return ResultSuccess(); return ResultSuccess();
} }
Result LoadNsosIntoProcessMemory(const ProcessInfo *process_info, const ncm::ProgramId program_id, const NsoHeader *nso_headers, const bool *has_nso, const args::ArgumentInfo *arg_info) { Result LoadNsosIntoProcessMemory(const ProcessInfo *process_info, const ncm::ProgramId program_id, const cfg::OverrideStatus &override_status, const NsoHeader *nso_headers, const bool *has_nso, const args::ArgumentInfo *arg_info) {
const Handle process_handle = process_info->process_handle.Get(); const Handle process_handle = process_info->process_handle.Get();
/* Load each NSO. */ /* Load each NSO. */
for (size_t i = 0; i < Nso_Count; i++) { for (size_t i = 0; i < Nso_Count; i++) {
if (has_nso[i]) { if (has_nso[i]) {
FILE *f = nullptr; FILE *f = nullptr;
R_TRY(OpenCodeFile(f, program_id, GetNsoName(i))); R_TRY(OpenCodeFile(f, program_id, override_status, GetNsoName(i)));
ON_SCOPE_EXIT { fclose(f); }; ON_SCOPE_EXIT { fclose(f); };
uintptr_t map_address = 0; uintptr_t map_address = 0;
@ -655,7 +655,7 @@ namespace ams::ldr {
} }
/* Process Creation API. */ /* Process Creation API. */
Result CreateProcess(Handle *out, PinId pin_id, const ncm::ProgramLocation &loc, const char *path, u32 flags, Handle reslimit_h) { Result CreateProcess(Handle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, u32 flags, Handle reslimit_h) {
/* Use global storage for NSOs. */ /* Use global storage for NSOs. */
NsoHeader *nso_headers = g_nso_headers; NsoHeader *nso_headers = g_nso_headers;
bool *has_nso = g_has_nso; bool *has_nso = g_has_nso;
@ -663,18 +663,18 @@ namespace ams::ldr {
{ {
/* Mount code. */ /* Mount code. */
ScopedCodeMount mount(loc); ScopedCodeMount mount(loc, override_status);
R_TRY(mount.GetResult()); R_TRY(mount.GetResult());
/* Load meta, possibly from cache. */ /* Load meta, possibly from cache. */
Meta meta; Meta meta;
R_TRY(LoadMetaFromCache(&meta, loc.program_id)); R_TRY(LoadMetaFromCache(&meta, loc.program_id, override_status));
/* Validate meta. */ /* Validate meta. */
R_TRY(ValidateMeta(&meta, loc)); R_TRY(ValidateMeta(&meta, loc));
/* Load, validate NSOs. */ /* Load, validate NSOs. */
R_TRY(LoadNsoHeaders(loc.program_id, nso_headers, has_nso)); R_TRY(LoadNsoHeaders(loc.program_id, override_status, nso_headers, has_nso));
R_TRY(ValidateNsoHeaders(nso_headers, has_nso)); R_TRY(ValidateNsoHeaders(nso_headers, has_nso));
/* Actually create process. */ /* Actually create process. */
@ -682,7 +682,7 @@ namespace ams::ldr {
R_TRY(CreateProcessImpl(&info, &meta, nso_headers, has_nso, arg_info, flags, reslimit_h)); R_TRY(CreateProcessImpl(&info, &meta, nso_headers, has_nso, arg_info, flags, reslimit_h));
/* Load NSOs into process memory. */ /* Load NSOs into process memory. */
R_TRY(LoadNsosIntoProcessMemory(&info, loc.program_id, nso_headers, has_nso, arg_info)); R_TRY(LoadNsosIntoProcessMemory(&info, loc.program_id, override_status, nso_headers, has_nso, arg_info));
/* Register NSOs with ro manager. */ /* Register NSOs with ro manager. */
{ {
@ -719,14 +719,17 @@ namespace ams::ldr {
return ResultSuccess(); return ResultSuccess();
} }
Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) { Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
Meta meta; Meta meta;
/* Load Meta. */ /* Load Meta. */
{ {
ScopedCodeMount mount(loc); ScopedCodeMount mount(loc);
R_TRY(mount.GetResult()); R_TRY(mount.GetResult());
R_TRY(LoadMeta(&meta, loc.program_id)); R_TRY(LoadMeta(&meta, loc.program_id, mount.GetOverrideStatus()));
if (out_status != nullptr) {
*out_status = mount.GetOverrideStatus();
}
} }
return GetProgramInfoFromMeta(out, &meta); return GetProgramInfoFromMeta(out, &meta);

View File

@ -19,7 +19,7 @@
namespace ams::ldr { namespace ams::ldr {
/* Process Creation API. */ /* Process Creation API. */
Result CreateProcess(Handle *out, PinId pin_id, const ncm::ProgramLocation &loc, const char *path, u32 flags, Handle reslimit_h); Result CreateProcess(Handle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, u32 flags, Handle reslimit_h);
Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc); Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc);
} }

View File

@ -34,6 +34,7 @@ namespace ams::ldr::ro {
PinId pin_id; PinId pin_id;
os::ProcessId process_id; os::ProcessId process_id;
ncm::ProgramId program_id; ncm::ProgramId program_id;
cfg::OverrideStatus override_status;
ncm::ProgramLocation loc; ncm::ProgramLocation loc;
ModuleInfo modules[ModuleCountMax]; ModuleInfo modules[ModuleCountMax];
bool in_use; bool in_use;
@ -76,7 +77,7 @@ namespace ams::ldr::ro {
} }
/* RO Manager API. */ /* RO Manager API. */
Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) { Result PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
*out = InvalidPinId; *out = InvalidPinId;
ProcessInfo *info = GetFreeProcessInfo(); ProcessInfo *info = GetFreeProcessInfo();
R_UNLESS(info != nullptr, ldr::ResultTooManyProcesses()); R_UNLESS(info != nullptr, ldr::ResultTooManyProcesses());
@ -86,6 +87,7 @@ namespace ams::ldr::ro {
std::memset(info, 0, sizeof(*info)); std::memset(info, 0, sizeof(*info));
info->pin_id = { s_cur_pin_id++ }; info->pin_id = { s_cur_pin_id++ };
info->loc = loc; info->loc = loc;
info->override_status = status;
info->in_use = true; info->in_use = true;
*out = info->pin_id; *out = info->pin_id;
return ResultSuccess(); return ResultSuccess();
@ -100,11 +102,12 @@ namespace ams::ldr::ro {
} }
Result GetProgramLocation(ncm::ProgramLocation *out, PinId id) { Result GetProgramLocationAndStatus(ncm::ProgramLocation *out, cfg::OverrideStatus *out_status, PinId id) {
ProcessInfo *info = GetProcessInfo(id); ProcessInfo *info = GetProcessInfo(id);
R_UNLESS(info != nullptr, ldr::ResultNotPinned()); R_UNLESS(info != nullptr, ldr::ResultNotPinned());
*out = info->loc; *out = info->loc;
*out_status = info->override_status;
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -19,9 +19,9 @@
namespace ams::ldr::ro { namespace ams::ldr::ro {
/* RO Manager API. */ /* RO Manager API. */
Result PinProgram(PinId *out, const ncm::ProgramLocation &loc); Result PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status);
Result UnpinProgram(PinId id); Result UnpinProgram(PinId id);
Result GetProgramLocation(ncm::ProgramLocation *out, PinId id); Result GetProgramLocationAndStatus(ncm::ProgramLocation *out, cfg::OverrideStatus *out_status, PinId id);
Result RegisterProcess(PinId id, os::ProcessId process_id, ncm::ProgramId program_id); Result RegisterProcess(PinId id, os::ProcessId process_id, ncm::ProgramId program_id);
Result RegisterModule(PinId id, const u8 *build_id, uintptr_t address, size_t size); Result RegisterModule(PinId id, const u8 *build_id, uintptr_t address, size_t size);
Result GetProcessModuleInfo(u32 *out_count, ModuleInfo *out, size_t max_out_count, os::ProcessId process_id); Result GetProcessModuleInfo(u32 *out_count, ModuleInfo *out, size_t max_out_count, os::ProcessId process_id);

View File

@ -17,7 +17,7 @@
namespace ams::pm::impl { namespace ams::pm::impl {
ProcessInfo::ProcessInfo(Handle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &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::ProgramLocation &l, const cfg::OverrideStatus &s) : process_id(pid), pin_id(pin), loc(l), status(s), 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));
} }

View File

@ -41,6 +41,7 @@ namespace ams::pm::impl {
const os::ProcessId process_id; const os::ProcessId process_id;
const ldr::PinId pin_id; const ldr::PinId pin_id;
const ncm::ProgramLocation loc; const ncm::ProgramLocation loc;
const cfg::OverrideStatus status;
Handle handle; Handle handle;
ProcessState state; ProcessState state;
u32 flags; u32 flags;
@ -58,7 +59,7 @@ namespace ams::pm::impl {
return (this->flags & flag); return (this->flags & flag);
} }
public: public:
ProcessInfo(Handle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l); ProcessInfo(Handle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s);
~ProcessInfo(); ~ProcessInfo();
void Cleanup(); void Cleanup();
@ -78,10 +79,14 @@ namespace ams::pm::impl {
return this->pin_id; return this->pin_id;
} }
const ncm::ProgramLocation &GetProgramLocation() { const ncm::ProgramLocation &GetProgramLocation() const {
return this->loc; return this->loc;
} }
const cfg::OverrideStatus &GetOverrideStatus() const {
return this->status;
}
ProcessState GetState() const { ProcessState GetState() const {
return this->state; return this->state;
} }

View File

@ -277,7 +277,8 @@ namespace ams::pm::impl {
Result LaunchProcess(os::WaitableManager &waitable_manager, const LaunchProcessArgs &args) { Result LaunchProcess(os::WaitableManager &waitable_manager, const LaunchProcessArgs &args) {
/* Get Program Info. */ /* Get Program Info. */
ldr::ProgramInfo program_info; ldr::ProgramInfo program_info;
R_TRY(ldr::pm::GetProgramInfo(&program_info, args.location)); cfg::OverrideStatus override_status;
R_TRY(ldr::pm::AtmosphereGetProgramInfo(&program_info, &override_status, 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) || hos::GetVersion() < hos::Version_200; const bool allow_debug = (program_info.flags & ldr::ProgramInfoFlag_AllowDebug) || hos::GetVersion() < hos::Version_200;
@ -289,8 +290,7 @@ namespace ams::pm::impl {
/* Pin the program with loader. */ /* Pin the program with loader. */
ldr::PinId pin_id; ldr::PinId pin_id;
R_TRY(ldr::pm::PinProgram(&pin_id, location)); R_TRY(ldr::pm::AtmospherePinProgram(&pin_id, location, override_status));
/* Ensure resources are available. */ /* Ensure resources are available. */
resource::WaitResourceAvailable(&program_info); resource::WaitResourceAvailable(&program_info);
@ -309,7 +309,7 @@ namespace ams::pm::impl {
/* Make new process info. */ /* Make new process info. */
void *process_info_storage = g_process_info_allocator.AllocateProcessInfoStorage(); void *process_info_storage = g_process_info_allocator.AllocateProcessInfoStorage();
AMS_ASSERT(process_info_storage != nullptr); AMS_ASSERT(process_info_storage != nullptr);
ProcessInfo *process_info = new (process_info_storage) ProcessInfo(process_handle, process_id, pin_id, location); ProcessInfo *process_info = new (process_info_storage) ProcessInfo(process_handle, process_id, pin_id, location, override_status);
/* Link new process info. */ /* Link new process info. */
{ {
@ -332,7 +332,7 @@ namespace ams::pm::impl {
/* Register with FS and SM. */ /* Register with FS and SM. */
R_TRY(fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(location.program_id), static_cast<NcmStorageId>(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.program_id), static_cast<NcmStorageId>(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.program_id, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size)); R_TRY(sm::manager::RegisterProcess(process_id, location.program_id, override_status, acid_sac, program_info.acid_sac_size, aci_sac, program_info.aci_sac_size));
/* Set flags. */ /* Set flags. */
if (is_application) { if (is_application) {
@ -648,7 +648,7 @@ namespace ams::pm::impl {
return pm::ResultProcessNotFound(); return pm::ResultProcessNotFound();
} }
Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::ProgramLocation *out_loc, os::ProcessId process_id) { Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, 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);
@ -656,6 +656,7 @@ namespace ams::pm::impl {
*out_process_handle = process_info->GetHandle(); *out_process_handle = process_info->GetHandle();
*out_loc = process_info->GetProgramLocation(); *out_loc = process_info->GetProgramLocation();
*out_status = process_info->GetOverrideStatus();
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -37,7 +37,7 @@ namespace ams::pm::impl {
Result GetProcessId(os::ProcessId *out, ncm::ProgramId program_id); Result GetProcessId(os::ProcessId *out, ncm::ProgramId program_id);
Result GetProgramId(ncm::ProgramId *out, os::ProcessId process_id); Result GetProgramId(ncm::ProgramId *out, os::ProcessId process_id);
Result GetApplicationProcessId(os::ProcessId *out_process_id); Result GetApplicationProcessId(os::ProcessId *out_process_id);
Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::ProgramLocation *out_loc, os::ProcessId process_id); Result AtmosphereGetProcessInfo(Handle *out_process_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id);
/* Hook API. */ /* Hook API. */
Result HookToCreateProcess(Handle *out_hook, ncm::ProgramId program_id); Result HookToCreateProcess(Handle *out_hook, ncm::ProgramId program_id);

View File

@ -54,8 +54,8 @@ namespace ams::pm::dmnt {
} }
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
Result DebugMonitorServiceBase::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, os::ProcessId process_id) { Result DebugMonitorServiceBase::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, 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(), out_status.GetPointer(), process_id);
} }
Result DebugMonitorServiceBase::AtmosphereGetCurrentLimitInfo(sf::Out<u64> out_cur_val, sf::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) {

View File

@ -31,7 +31,7 @@ namespace ams::pm::dmnt {
virtual Result ClearHook(u32 which); virtual Result ClearHook(u32 which);
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
virtual Result AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, os::ProcessId process_id); virtual Result AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id);
virtual Result AtmosphereGetCurrentLimitInfo(sf::Out<u64> out_cur_val, sf::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);
}; };

View File

@ -37,4 +37,9 @@ namespace ams::pm::info {
return pm::info::HasLaunchedProgram(out.GetPointer(), program_id); return pm::info::HasLaunchedProgram(out.GetPointer(), program_id);
} }
Result InformationService::AtmosphereGetProcessInfo(sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id) {
Handle dummy_handle;
return impl::AtmosphereGetProcessInfo(&dummy_handle, out_loc.GetPointer(), out_status.GetPointer(), process_id);
}
} }

View File

@ -25,6 +25,7 @@ namespace ams::pm::info {
AtmosphereGetProcessId = 65000, AtmosphereGetProcessId = 65000,
AtmosphereHasLaunchedProgram = 65001, AtmosphereHasLaunchedProgram = 65001,
AtmosphereGetProcessInfo = 65002,
}; };
private: private:
/* Actual command implementations. */ /* Actual command implementations. */
@ -33,12 +34,14 @@ namespace ams::pm::info {
/* Atmosphere extension commands. */ /* Atmosphere extension commands. */
Result AtmosphereGetProcessId(sf::Out<os::ProcessId> out, ncm::ProgramId program_id); Result AtmosphereGetProcessId(sf::Out<os::ProcessId> out, ncm::ProgramId program_id);
Result AtmosphereHasLaunchedProgram(sf::Out<bool> out, ncm::ProgramId program_id); Result AtmosphereHasLaunchedProgram(sf::Out<bool> out, ncm::ProgramId program_id);
Result AtmosphereGetProcessInfo(sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status, os::ProcessId process_id);
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(GetProgramId), MAKE_SERVICE_COMMAND_META(GetProgramId),
MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessId), MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessId),
MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedProgram), MAKE_SERVICE_COMMAND_META(AtmosphereHasLaunchedProgram),
MAKE_SERVICE_COMMAND_META(AtmosphereGetProcessInfo),
}; };
}; };

View File

@ -106,7 +106,7 @@ namespace {
fsprUnregisterProgram(static_cast<u64>(process_id)); fsprUnregisterProgram(static_cast<u64>(process_id));
fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(process_id), NcmStorageId_BuiltInSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl)); fsprRegisterProgram(static_cast<u64>(process_id), static_cast<u64>(process_id), NcmStorageId_BuiltInSystem, PrivilegedFileAccessHeader, sizeof(PrivilegedFileAccessHeader), PrivilegedFileAccessControl, sizeof(PrivilegedFileAccessControl));
sm::manager::UnregisterProcess(process_id); sm::manager::UnregisterProcess(process_id);
sm::manager::RegisterProcess(process_id, GetProcessProgramId(process_id), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl)); sm::manager::RegisterProcess(process_id, GetProcessProgramId(process_id), cfg::OverrideStatus{}, PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl), PrivilegedServiceAccessControl, sizeof(PrivilegedServiceAccessControl));
} }
void RegisterPrivilegedProcesses() { void RegisterPrivilegedProcesses() {

View File

@ -29,6 +29,7 @@ namespace ams::sm::impl {
struct ProcessInfo { struct ProcessInfo {
os::ProcessId process_id; os::ProcessId process_id;
ncm::ProgramId program_id; ncm::ProgramId program_id;
cfg::OverrideStatus override_status;
size_t access_control_size; size_t access_control_size;
u8 access_control[AccessControlSizeMax]; u8 access_control[AccessControlSizeMax];
@ -39,13 +40,14 @@ namespace ams::sm::impl {
void Free() { void Free() {
this->process_id = os::InvalidProcessId; this->process_id = os::InvalidProcessId;
this->program_id = ncm::InvalidProgramId; this->program_id = ncm::InvalidProgramId;
this->override_status = {};
this->access_control_size = 0; this->access_control_size = 0;
std::memset(this->access_control, 0, sizeof(this->access_control)); std::memset(this->access_control, 0, sizeof(this->access_control));
} }
}; };
/* Forward declaration, for use in ServiceInfo. */ /* Forward declaration, for use in ServiceInfo. */
ncm::ProgramId GetProgramIdForMitm(os::ProcessId process_id); void GetMitmProcessInfo(MitmProcessInfo *out, os::ProcessId process_id);
struct ServiceInfo { struct ServiceInfo {
ServiceName name; ServiceName name;
@ -96,10 +98,9 @@ namespace ams::sm::impl {
this->mitm_process_id = os::InvalidProcessId; this->mitm_process_id = os::InvalidProcessId;
} }
void AcknowledgeMitmSession(os::ProcessId *out_process_id, ncm::ProgramId *out_program_id, Handle *out_hnd) { void AcknowledgeMitmSession(MitmProcessInfo *out_info, Handle *out_hnd) {
/* Copy to output. */ /* Copy to output. */
*out_process_id = this->mitm_waiting_ack_process_id; GetMitmProcessInfo(out_info, this->mitm_waiting_ack_process_id);
*out_program_id = GetProgramIdForMitm(this->mitm_waiting_ack_process_id);
*out_hnd = this->mitm_fwd_sess_h.Move(); *out_hnd = this->mitm_fwd_sess_h.Move();
this->mitm_waiting_ack = false; this->mitm_waiting_ack = false;
this->mitm_waiting_ack_process_id = os::InvalidProcessId; this->mitm_waiting_ack_process_id = os::InvalidProcessId;
@ -224,11 +225,15 @@ namespace ams::sm::impl {
return service_info != nullptr && IsValidProcessId(service_info->mitm_process_id); return service_info != nullptr && IsValidProcessId(service_info->mitm_process_id);
} }
ncm::ProgramId GetProgramIdForMitm(os::ProcessId process_id) { void GetMitmProcessInfo(MitmProcessInfo *out_info, os::ProcessId process_id) {
/* Anything that can request a mitm session must have a process info. */ /* Anything that can request a mitm session must have a process info. */
const auto process_info = GetProcessInfo(process_id); const auto process_info = GetProcessInfo(process_id);
AMS_ASSERT(process_info != nullptr); AMS_ASSERT(process_info != nullptr);
return process_info->program_id;
/* Write to output. */
out_info->process_id = process_id;
out_info->program_id = process_info->program_id;
out_info->override_status = process_info->override_status;
} }
bool IsMitmDisallowed(ncm::ProgramId program_id) { bool IsMitmDisallowed(ncm::ProgramId program_id) {
@ -341,16 +346,12 @@ namespace ams::sm::impl {
return service == ServiceName::Encode("fsp-srv"); return service == ServiceName::Encode("fsp-srv");
} }
Result GetMitmServiceHandleImpl(Handle *out, ServiceInfo *service_info, os::ProcessId process_id, ncm::ProgramId program_id) { Result GetMitmServiceHandleImpl(Handle *out, ServiceInfo *service_info, const MitmProcessInfo &client_info) {
/* Send command to query if we should mitm. */ /* Send command to query if we should mitm. */
bool should_mitm; bool should_mitm;
{ {
Service srv { .session = service_info->mitm_query_h.Get() }; Service srv { .session = service_info->mitm_query_h.Get() };
const struct { R_TRY(serviceDispatchInOut(&srv, 65000, client_info, should_mitm));
os::ProcessId process_id;
ncm::ProgramId program_id;
} in = { process_id, program_id };
R_TRY(serviceDispatchInOut(&srv, 65000, in, should_mitm));
} }
/* If we shouldn't mitm, give normal session. */ /* If we shouldn't mitm, give normal session. */
@ -365,7 +366,7 @@ namespace ams::sm::impl {
*out = hnd.Move(); *out = hnd.Move();
} }
service_info->mitm_waiting_ack_process_id = process_id; service_info->mitm_waiting_ack_process_id = client_info.process_id;
service_info->mitm_waiting_ack = true; service_info->mitm_waiting_ack = true;
return ResultSuccess(); return ResultSuccess();
@ -377,11 +378,12 @@ namespace ams::sm::impl {
/* Check if we should return a mitm handle. */ /* Check if we should return a mitm handle. */
if (IsValidProcessId(service_info->mitm_process_id) && service_info->mitm_process_id != process_id) { if (IsValidProcessId(service_info->mitm_process_id) && service_info->mitm_process_id != process_id) {
/* Get program id, ensure that we're allowed to mitm the given program. */ /* Get mitm process info, ensure that we're allowed to mitm the given program. */
const ncm::ProgramId program_id = GetProgramIdForMitm(process_id); MitmProcessInfo client_info;
if (!IsMitmDisallowed(program_id)) { GetMitmProcessInfo(&client_info, process_id);
if (!IsMitmDisallowed(client_info.program_id)) {
/* We're mitm'd. Assert, because mitm service host dead is an error state. */ /* We're mitm'd. Assert, because mitm service host dead is an error state. */
R_ASSERT(GetMitmServiceHandleImpl(out, service_info, process_id, program_id)); R_ASSERT(GetMitmServiceHandleImpl(out, service_info, client_info));
return ResultSuccess(); return ResultSuccess();
} }
} }
@ -423,7 +425,7 @@ namespace ams::sm::impl {
} }
/* Process management. */ /* Process management. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) { Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
/* Check that access control will fit in the ServiceInfo. */ /* Check that access control will fit in the ServiceInfo. */
R_UNLESS(aci_sac_size <= AccessControlSizeMax, sm::ResultTooLargeAccessControl()); R_UNLESS(aci_sac_size <= AccessControlSizeMax, sm::ResultTooLargeAccessControl());
@ -438,6 +440,7 @@ namespace ams::sm::impl {
/* Save info. */ /* Save info. */
proc->process_id = process_id; proc->process_id = process_id;
proc->program_id = program_id; proc->program_id = program_id;
proc->override_status = override_status;
proc->access_control_size = aci_sac_size; proc->access_control_size = aci_sac_size;
std::memcpy(proc->access_control, aci_sac, proc->access_control_size); std::memcpy(proc->access_control, aci_sac, proc->access_control_size);
return ResultSuccess(); return ResultSuccess();
@ -651,7 +654,7 @@ namespace ams::sm::impl {
return ResultSuccess(); return ResultSuccess();
} }
Result AcknowledgeMitmSession(os::ProcessId *out_process_id, ncm::ProgramId *out_program_id, Handle *out_hnd, os::ProcessId process_id, ServiceName service) { Result AcknowledgeMitmSession(MitmProcessInfo *out_info, Handle *out_hnd, os::ProcessId process_id, ServiceName service) {
/* Validate service name. */ /* Validate service name. */
R_TRY(ValidateServiceName(service)); R_TRY(ValidateServiceName(service));
@ -670,7 +673,7 @@ namespace ams::sm::impl {
R_UNLESS(service_info->mitm_waiting_ack, sm::ResultNotAllowed()); R_UNLESS(service_info->mitm_waiting_ack, sm::ResultNotAllowed());
/* Acknowledge. */ /* Acknowledge. */
service_info->AcknowledgeMitmSession(out_process_id, out_program_id, out_hnd); service_info->AcknowledgeMitmSession(out_info, out_hnd);
return ResultSuccess(); return ResultSuccess();
} }

View File

@ -20,7 +20,7 @@
namespace ams::sm::impl { namespace ams::sm::impl {
/* Process management. */ /* Process management. */
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size); Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size);
Result UnregisterProcess(os::ProcessId process_id); Result UnregisterProcess(os::ProcessId process_id);
/* Service management. */ /* Service management. */
@ -37,7 +37,7 @@ namespace ams::sm::impl {
Result InstallMitm(Handle *out, Handle *out_query, os::ProcessId process_id, ServiceName service); Result InstallMitm(Handle *out, Handle *out_query, os::ProcessId process_id, ServiceName service);
Result UninstallMitm(os::ProcessId process_id, ServiceName service); Result UninstallMitm(os::ProcessId process_id, ServiceName service);
Result DeclareFutureMitm(os::ProcessId process_id, ServiceName service); Result DeclareFutureMitm(os::ProcessId process_id, ServiceName service);
Result AcknowledgeMitmSession(os::ProcessId *out_process_id, ncm::ProgramId *out_program_id, Handle *out_hnd, os::ProcessId process_id, ServiceName service); Result AcknowledgeMitmSession(MitmProcessInfo *out_info, Handle *out_hnd, os::ProcessId process_id, ServiceName service);
/* Dmnt record extensions. */ /* Dmnt record extensions. */
Result GetServiceRecord(ServiceRecord *out, ServiceName service); Result GetServiceRecord(ServiceRecord *out, ServiceName service);

View File

@ -19,7 +19,7 @@
namespace ams::sm { namespace ams::sm {
Result ManagerService::RegisterProcess(os::ProcessId process_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) { Result ManagerService::RegisterProcess(os::ProcessId process_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) {
return impl::RegisterProcess(process_id, ncm::ProgramId::Invalid, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize()); return impl::RegisterProcess(process_id, ncm::ProgramId::Invalid, cfg::OverrideStatus{}, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize());
} }
Result ManagerService::UnregisterProcess(os::ProcessId process_id) { Result ManagerService::UnregisterProcess(os::ProcessId process_id) {
@ -34,9 +34,9 @@ namespace ams::sm {
R_ASSERT(impl::HasMitm(out.GetPointer(), service)); R_ASSERT(impl::HasMitm(out.GetPointer(), service));
} }
Result ManagerService::AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) { Result ManagerService::AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) {
/* This takes in a program id, unlike RegisterProcess. */ /* This takes in a program id and override status, unlike RegisterProcess. */
return impl::RegisterProcess(process_id, program_id, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize()); return impl::RegisterProcess(process_id, program_id, override_status, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize());
} }
} }

View File

@ -36,7 +36,7 @@ namespace ams::sm {
virtual Result UnregisterProcess(os::ProcessId process_id); virtual Result UnregisterProcess(os::ProcessId process_id);
virtual void AtmosphereEndInitDefers(); virtual void AtmosphereEndInitDefers();
virtual void AtmosphereHasMitm(sf::Out<bool> out, ServiceName service); virtual void AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
virtual Result AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac); virtual Result AtmosphereRegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac);
public: public:
DEFINE_SERVICE_DISPATCH_TABLE { DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(RegisterProcess), MAKE_SERVICE_COMMAND_META(RegisterProcess),

View File

@ -56,9 +56,9 @@ namespace ams::sm {
return impl::UninstallMitm(this->process_id, service); return impl::UninstallMitm(this->process_id, service);
} }
Result UserService::AtmosphereAcknowledgeMitmSession(sf::Out<os::ProcessId> client_process_id, sf::Out<ncm::ProgramId> client_program_id, sf::OutMoveHandle fwd_h, ServiceName service) { Result UserService::AtmosphereAcknowledgeMitmSession(sf::Out<MitmProcessInfo> client_info, sf::OutMoveHandle fwd_h, ServiceName service) {
R_TRY(this->EnsureInitialized()); R_TRY(this->EnsureInitialized());
return impl::AcknowledgeMitmSession(client_process_id.GetPointer(), client_program_id.GetPointer(), fwd_h.GetHandlePointer(), this->process_id, service); return impl::AcknowledgeMitmSession(client_info.GetPointer(), fwd_h.GetHandlePointer(), this->process_id, service);
} }
Result UserService::AtmosphereHasMitm(sf::Out<bool> out, ServiceName service) { Result UserService::AtmosphereHasMitm(sf::Out<bool> out, ServiceName service) {

View File

@ -55,7 +55,7 @@ namespace ams::sm {
/* Atmosphere commands. */ /* Atmosphere commands. */
virtual Result AtmosphereInstallMitm(sf::OutMoveHandle srv_h, sf::OutMoveHandle qry_h, ServiceName service); virtual Result AtmosphereInstallMitm(sf::OutMoveHandle srv_h, sf::OutMoveHandle qry_h, ServiceName service);
virtual Result AtmosphereUninstallMitm(ServiceName service); virtual Result AtmosphereUninstallMitm(ServiceName service);
virtual Result AtmosphereAcknowledgeMitmSession(sf::Out<os::ProcessId> client_process_id, sf::Out<ncm::ProgramId> client_program_id, sf::OutMoveHandle fwd_h, ServiceName service); virtual Result AtmosphereAcknowledgeMitmSession(sf::Out<MitmProcessInfo> client_info, sf::OutMoveHandle fwd_h, ServiceName service);
virtual Result AtmosphereHasMitm(sf::Out<bool> out, ServiceName service); virtual Result AtmosphereHasMitm(sf::Out<bool> out, ServiceName service);
virtual Result AtmosphereWaitMitm(ServiceName service); virtual Result AtmosphereWaitMitm(ServiceName service);
virtual Result AtmosphereDeclareFutureMitm(ServiceName service); virtual Result AtmosphereDeclareFutureMitm(ServiceName service);