mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-28 01:20:58 +01:00
pm/mitm: okay, that api won't work, try a different one
This commit is contained in:
parent
9b480e4757
commit
efe7b63576
@ -73,6 +73,7 @@
|
||||
#include <stratosphere/ldr.hpp>
|
||||
#include <stratosphere/lr.hpp>
|
||||
#include <stratosphere/lm.hpp>
|
||||
#include <stratosphere/mitm.hpp>
|
||||
#include <stratosphere/ncm.hpp>
|
||||
#include <stratosphere/nim.hpp>
|
||||
#include <stratosphere/ns.hpp>
|
||||
|
20
libraries/libstratosphere/include/stratosphere/mitm.hpp
Normal file
20
libraries/libstratosphere/include/stratosphere/mitm.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stratosphere/mitm/impl/mitm_pm_interface.hpp>
|
||||
#include <stratosphere/mitm/mitm_pm_api.hpp>
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/ncm/ncm_program_id.hpp>
|
||||
#include <stratosphere/cfg/cfg_types.hpp>
|
||||
#include <stratosphere/sf.hpp>
|
||||
|
||||
#define AMS_MITM_PM_IMPL_I_PM_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 65000, Result, PrepareLaunchProgram, (sf::Out<u64> out_boost_size, ncm::ProgramId program_id, const cfg::OverrideStatus &override_status, bool is_application), (out_boost_size, program_id, override_status, is_application))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::mitm::pm::impl, IPmInterface, AMS_MITM_PM_IMPL_I_PM_INTERFACE_INFO, 0xEA88789C)
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/ncm/ncm_program_id.hpp>
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
/* PM API. */
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
Result PrepareLaunchProgram(u64 *out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, bool is_application);
|
||||
|
||||
}
|
@ -30,8 +30,7 @@
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 8, Result, BoostApplicationThreadResourceLimit, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, void, GetBootFinishedEventHandle, (sf::OutCopyHandle out), (out), hos::Version_8_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereBoostSystemMemoryResourceLimitForMitm, (u64 boost_size), (boost_size))
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ())
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IShellInterface, AMS_PM_I_SHELL_INTERFACE_INTERFACE_INFO, 0x387D60C0)
|
||||
|
||||
@ -46,7 +45,6 @@ AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IShellInterface, AMS_PM_I_SHELL_INTERFACE
|
||||
AMS_SF_METHOD_INFO(C, H, 7, void, NotifyBootFinished, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 8, Result, GetApplicationProcessIdForShell, (sf::Out<os::ProcessId> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, BoostSystemMemoryResourceLimit, (u64 boost_size), (boost_size), hos::Version_4_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 65000, Result, AtmosphereBoostSystemMemoryResourceLimitForMitm, (u64 boost_size), (boost_size))
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, BoostSystemThreadResourceLimit, (), ())
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::pm::impl, IDeprecatedShellInterface, AMS_PM_I_DEPRECATED_SHELL_INTERFACE_INTERFACE_INFO, 0x387D60C0)
|
||||
|
@ -32,6 +32,4 @@ namespace ams::pm::shell {
|
||||
Result BoostApplicationThreadResourceLimit();
|
||||
Result BoostSystemThreadResourceLimit();
|
||||
|
||||
Result AtmosphereBoostSystemMemoryResourceLimitForMitm(u64 size);
|
||||
|
||||
}
|
||||
|
44
libraries/libstratosphere/source/mitm/mitm_pm.os.horizon.c
Normal file
44
libraries/libstratosphere/source/mitm/mitm_pm.os.horizon.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 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/>.
|
||||
*/
|
||||
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||
#include "../service_guard.h"
|
||||
#include "mitm_pm.os.horizon.h"
|
||||
|
||||
static Service g_amsMitmPmSrv;
|
||||
|
||||
NX_GENERATE_SERVICE_GUARD(amsMitmPm);
|
||||
|
||||
Result _amsMitmPmInitialize(void) {
|
||||
return smGetService(&g_amsMitmPmSrv, "mitm:pm");
|
||||
}
|
||||
|
||||
void _amsMitmPmCleanup(void) {
|
||||
serviceClose(&g_amsMitmPmSrv);
|
||||
}
|
||||
|
||||
Service *amsMitmPmGetServiceSession(void) {
|
||||
return &g_amsMitmPmSrv;
|
||||
}
|
||||
|
||||
Result amsMitmPmPrepareLaunchProgram(u64 *out, u64 program_id, const CfgOverrideStatus *status, bool is_application) {
|
||||
const struct {
|
||||
u8 is_application;
|
||||
u64 program_id;
|
||||
CfgOverrideStatus status;
|
||||
} in = { is_application ? 1 : 0, program_id, *status };
|
||||
|
||||
return serviceDispatchInOut(&g_amsMitmPmSrv, 65000, in, *out);
|
||||
}
|
37
libraries/libstratosphere/source/mitm/mitm_pm.os.horizon.h
Normal file
37
libraries/libstratosphere/source/mitm/mitm_pm.os.horizon.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 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 <switch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
u64 keys_down;
|
||||
u64 flags;
|
||||
} CfgOverrideStatus;
|
||||
|
||||
Result amsMitmPmInitialize(void);
|
||||
void amsMitmPmExit(void);
|
||||
Service *amsMitmPmGetServiceSession(void);
|
||||
|
||||
Result amsMitmPmPrepareLaunchProgram(u64 *out, u64 program_id, const CfgOverrideStatus *status, bool is_application);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
37
libraries/libstratosphere/source/mitm/mitm_pm_api.cpp
Normal file
37
libraries/libstratosphere/source/mitm/mitm_pm_api.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "mitm_pm.os.horizon.h"
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
/* PM API. */
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
void Initialize() {
|
||||
R_ABORT_UNLESS(amsMitmPmInitialize());
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
amsMitmPmExit();
|
||||
}
|
||||
|
||||
Result PrepareLaunchProgram(u64 *out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, bool is_application) {
|
||||
static_assert(sizeof(status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!");
|
||||
R_RETURN(amsMitmPmPrepareLaunchProgram(out, program_id.value, reinterpret_cast<const CfgOverrideStatus *>(std::addressof(status)), is_application));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -90,9 +90,3 @@ Result pmdmntAtmosphereGetCurrentLimitInfo(u64 *out_cur, u64 *out_lim, u32 group
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result pmshellAtmosphereBoostSystemMemoryResourceLimitForMitm(u64 size) {
|
||||
return serviceDispatchIn(pmshellGetServiceSession(), 65000, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,8 +26,6 @@ Result pminfoAtmosphereGetProcessInfo(NcmProgramLocation *loc_out, CfgOverrideSt
|
||||
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 pmshellAtmosphereBoostSystemMemoryResourceLimitForMitm(u64 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -58,10 +58,6 @@ namespace ams::pm::shell {
|
||||
Result BoostSystemThreadResourceLimit() {
|
||||
R_RETURN(::pmshellBoostSystemThreadResourceLimit());
|
||||
}
|
||||
|
||||
Result AtmosphereBoostSystemMemoryResourceLimitForMitm(u64 size) {
|
||||
R_RETURN(pmshellAtmosphereBoostSystemMemoryResourceLimitForMitm(size));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ns_mitm/nsmitm_module.hpp"
|
||||
#include "dns_mitm/dnsmitm_module.hpp"
|
||||
#include "sysupdater/sysupdater_module.hpp"
|
||||
#include "mitm_pm/mitm_pm_module.hpp"
|
||||
|
||||
namespace ams::mitm {
|
||||
|
||||
@ -37,6 +38,7 @@ namespace ams::mitm {
|
||||
ModuleId_NsMitm,
|
||||
ModuleId_DnsMitm,
|
||||
ModuleId_Sysupdater,
|
||||
ModuleId_PmService,
|
||||
|
||||
ModuleId_Count,
|
||||
};
|
||||
@ -70,6 +72,7 @@ namespace ams::mitm {
|
||||
GetModuleDefinition<ns::MitmModule>(),
|
||||
GetModuleDefinition<socket::resolver::MitmModule>(),
|
||||
GetModuleDefinition<sysupdater::MitmModule>(),
|
||||
GetModuleDefinition<pm::MitmModule>(),
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace ams::mitm::fs {
|
||||
Result OpenHblWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id) {
|
||||
/* Verify eligibility. */
|
||||
bool is_hbl;
|
||||
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), program_id)), sm::mitm::ResultShouldForwardToSession());
|
||||
R_UNLESS(R_SUCCEEDED(ams::pm::info::IsHblProgramId(std::addressof(is_hbl), program_id)), sm::mitm::ResultShouldForwardToSession());
|
||||
R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
/* Hbl html directory must exist. */
|
||||
|
@ -26,6 +26,18 @@ namespace ams::mitm::fs {
|
||||
namespace {
|
||||
|
||||
/* TODO: Fancy Dynamic allocation globals. */
|
||||
constinit os::SdkMutex g_romfs_build_lock;
|
||||
//constinit size_t g_dynamic_heap_size = 0;
|
||||
|
||||
void InitializeDynamicHeapForBuildRomfs(ncm::ProgramId program_id) {
|
||||
/* TODO */
|
||||
AMS_UNUSED(program_id);
|
||||
}
|
||||
|
||||
void FinalizeDynamicHeapForBuildRomfs(ncm::ProgramId program_id) {
|
||||
/* TODO */
|
||||
AMS_UNUSED(program_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -315,6 +327,12 @@ namespace ams::mitm::fs {
|
||||
}
|
||||
|
||||
Builder::Builder(ncm::ProgramId pr_id) : m_program_id(pr_id), m_num_dirs(0), m_num_files(0), m_dir_table_size(0), m_file_table_size(0), m_dir_hash_table_size(0), m_file_hash_table_size(0), m_file_partition_size(0) {
|
||||
/* Ensure only one romfs is built at any time. */
|
||||
g_romfs_build_lock.Lock();
|
||||
|
||||
/* If we should be using dynamic heap, turn it on. */
|
||||
InitializeDynamicHeapForBuildRomfs(m_program_id);
|
||||
|
||||
auto res = m_directories.emplace(std::unique_ptr<BuildDirectoryContext>(AllocateTyped<BuildDirectoryContext>(AllocationType_BuildDirContext, BuildDirectoryContext::RootTag{})));
|
||||
AMS_ABORT_UNLESS(res.second);
|
||||
m_root = res.first->get();
|
||||
@ -322,6 +340,15 @@ namespace ams::mitm::fs {
|
||||
m_dir_table_size = 0x18;
|
||||
}
|
||||
|
||||
Builder::~Builder() {
|
||||
/* If we have nothing remaining in dynamic heap, release it. */
|
||||
FinalizeDynamicHeapForBuildRomfs(m_program_id);
|
||||
|
||||
/* Release the romfs build lock. */
|
||||
g_romfs_build_lock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
void Builder::AddDirectory(BuildDirectoryContext **out, BuildDirectoryContext *parent_ctx, std::unique_ptr<BuildDirectoryContext> child_ctx) {
|
||||
/* Set parent context member. */
|
||||
child_ctx->parent = parent_ctx;
|
||||
|
@ -366,6 +366,7 @@ namespace ams::mitm::fs::romfs {
|
||||
void AddFile(BuildDirectoryContext *parent_ctx, std::unique_ptr<BuildFileContext> file_ctx);
|
||||
public:
|
||||
Builder(ncm::ProgramId pr_id);
|
||||
~Builder();
|
||||
|
||||
void AddSdFiles();
|
||||
void AddStorageFiles(ams::fs::IStorage *storage, DataSourceType source_type);
|
||||
|
45
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_module.cpp
Normal file
45
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_module.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "../amsmitm_initialization.hpp"
|
||||
#include "mitm_pm_module.hpp"
|
||||
#include "mitm_pm_service.hpp"
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr sm::ServiceName PmServiceName = sm::ServiceName::Encode("mitm:pm");
|
||||
constexpr size_t PmMaxSessions = 1;
|
||||
|
||||
constexpr size_t MaxServers = 1;
|
||||
constexpr size_t MaxSessions = PmMaxSessions;
|
||||
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
|
||||
sf::hipc::ServerManager<MaxServers, ServerOptions, MaxSessions> g_server_manager;
|
||||
|
||||
constinit sf::UnmanagedServiceObject<mitm::pm::impl::IPmInterface, mitm::pm::PmService> g_pm_service_object;
|
||||
|
||||
}
|
||||
|
||||
void MitmModule::ThreadFunction(void *) {
|
||||
/* Create bpc:ams. */
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_pm_service_object.GetShared(), PmServiceName, PmMaxSessions));
|
||||
|
||||
/* Loop forever, servicing our services. */
|
||||
g_server_manager.LoopProcess();
|
||||
}
|
||||
|
||||
}
|
24
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_module.hpp
Normal file
24
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_module.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
#include "../amsmitm_module.hpp"
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x1000, AMS_GET_SYSTEM_THREAD_PRIORITY(fs, WorkerThreadPool) - 2);
|
||||
|
||||
}
|
29
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_service.cpp
Normal file
29
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_service.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "../amsmitm_initialization.hpp"
|
||||
#include "mitm_pm_service.hpp"
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
Result PmService::PrepareLaunchProgram(sf::Out<u64> out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, bool is_application) {
|
||||
/* TODO */
|
||||
*out = 0;
|
||||
AMS_UNUSED(program_id, status, is_application);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
27
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_service.hpp
Normal file
27
stratosphere/ams_mitm/source/mitm_pm/mitm_pm_service.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::mitm::pm {
|
||||
|
||||
class PmService {
|
||||
public:
|
||||
Result PrepareLaunchProgram(sf::Out<u64> out, ncm::ProgramId program_id, const cfg::OverrideStatus &status, bool is_application);
|
||||
};
|
||||
static_assert(impl::IsIPmInterface<PmService>);
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ namespace ams::mitm::ns {
|
||||
Result NsAmMitmService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
||||
/* Always succeed for web applets asking about HBL to enable hbl_html, and applications with manual_html to allow custom manual data. */
|
||||
bool is_hbl = false;
|
||||
if ((R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||
if ((R_SUCCEEDED(ams::pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||
nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace ams::mitm::ns {
|
||||
Result NsDocumentService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) {
|
||||
/* Always succeed for web applets asking about HBL to enable hbl_html, and applications with manual_html to allow custom manual data. */
|
||||
bool is_hbl = false;
|
||||
if ((R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||
if ((R_SUCCEEDED(ams::pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) || (static_cast<ncm::ContentType>(content_type) == ncm::ContentType::HtmlDocument && mitm::fs::HasSdManualHtmlContent(application_id))) {
|
||||
nswebResolveApplicationContentPath(m_srv.get(), static_cast<u64>(application_id), static_cast<NcmContentType>(content_type));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace ams::mitm::settings {
|
||||
SetMitmService::SetMitmService(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : sf::MitmServiceImplBase(std::forward<std::shared_ptr<::Service>>(s), c) {
|
||||
if (m_client_info.program_id == ncm::SystemProgramId::Ns) {
|
||||
os::ProcessId application_process_id;
|
||||
if (R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id))) && g_application_process_id == application_process_id) {
|
||||
if (R_SUCCEEDED(ams::pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id))) && g_application_process_id == application_process_id) {
|
||||
m_locale = g_application_locale;
|
||||
m_is_valid_language = g_valid_language;
|
||||
m_is_valid_region = g_valid_region;
|
||||
@ -61,8 +61,8 @@ namespace ams::mitm::settings {
|
||||
|
||||
if (is_ns) {
|
||||
/* When NS asks for a locale, refresh to get the current application locale. */
|
||||
R_TRY(pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id)));
|
||||
R_TRY(pm::info::GetProgramId(std::addressof(program_id), application_process_id));
|
||||
R_TRY(ams::pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id)));
|
||||
R_TRY(ams::pm::info::GetProgramId(std::addressof(program_id), application_process_id));
|
||||
}
|
||||
m_locale = cfg::GetOverrideLocale(program_id);
|
||||
m_is_valid_language = settings::IsValidLanguageCode(m_locale.language_code);
|
||||
|
@ -29,7 +29,7 @@ namespace ams::mitm::settings {
|
||||
PortIndex_Count,
|
||||
};
|
||||
|
||||
constexpr sm::ServiceName SetMitmServiceName = sm::ServiceName::Encode("set");
|
||||
constexpr sm::ServiceName SetMitmServiceName = sm::ServiceName::Encode("set");
|
||||
constexpr sm::ServiceName SetSysMitmServiceName = sm::ServiceName::Encode("set:sys");
|
||||
|
||||
struct ServerOptions {
|
||||
|
@ -244,6 +244,22 @@ namespace ams::pm::impl {
|
||||
/* If we fail after now, unpin. */
|
||||
ON_RESULT_FAILURE { ldr::pm::UnpinProgram(pin_id); };
|
||||
|
||||
/* Ensure we can talk to mitm services. */
|
||||
{
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_initialized_mitm, false);
|
||||
if (!s_initialized_mitm) {
|
||||
mitm::pm::Initialize();
|
||||
s_initialized_mitm = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine boost size for mitm. */
|
||||
u64 mitm_boost_size = 0;
|
||||
R_TRY(mitm::pm::PrepareLaunchProgram(std::addressof(mitm_boost_size), program_info.program_id, override_status, is_application));
|
||||
|
||||
R_ABORT_UNLESS(BoostSystemMemoryResourceLimitForMitm(mitm_boost_size));
|
||||
ON_RESULT_FAILURE_2 { R_ABORT_UNLESS(BoostSystemMemoryResourceLimitForMitm(0)); };
|
||||
|
||||
/* Ensure resources are available. */
|
||||
resource::WaitResourceAvailable(std::addressof(program_info));
|
||||
|
||||
|
@ -87,8 +87,4 @@ namespace ams::pm {
|
||||
R_RETURN(impl::BoostSystemThreadResourceLimit());
|
||||
}
|
||||
|
||||
Result ShellService::AtmosphereBoostSystemMemoryResourceLimitForMitm(u64 boost_size) {
|
||||
R_RETURN(impl::BoostSystemMemoryResourceLimitForMitm(boost_size));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,9 +34,6 @@ namespace ams::pm {
|
||||
Result BoostApplicationThreadResourceLimit();
|
||||
void GetBootFinishedEventHandle(sf::OutCopyHandle out);
|
||||
Result BoostSystemThreadResourceLimit();
|
||||
|
||||
/* Atmosphere extension command implementations. */
|
||||
Result AtmosphereBoostSystemMemoryResourceLimitForMitm(u64 boost_size);
|
||||
};
|
||||
static_assert(pm::impl::IsIShellInterface<ShellService>);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user