diff --git a/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp index 7f442da3..f3151543 100644 --- a/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ b/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp @@ -27,7 +27,7 @@ namespace ams::fs { namespace ams::fssrv::impl { - class StorageInterfaceAdapter final { + class StorageInterfaceAdapter { NON_COPYABLE(StorageInterfaceAdapter); private: /* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */ @@ -39,7 +39,7 @@ namespace ams::fssrv::impl { public: StorageInterfaceAdapter(fs::IStorage *storage); StorageInterfaceAdapter(std::unique_ptr storage); - explicit StorageInterfaceAdapter(std::shared_ptr &&storage); + explicit StorageInterfaceAdapter(std::shared_ptr storage); /* TODO: Other constructors. */ ~StorageInterfaceAdapter(); diff --git a/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index 7b2deea4..19986c90 100644 --- a/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -53,13 +53,24 @@ namespace ams::sf::hipc { friend class ServerManager; NON_COPYABLE(Server); NON_MOVEABLE(Server); - protected: + private: cmif::ServiceObjectHolder static_object; ::Handle port_handle; sm::ServiceName service_name; int index; bool service_managed; bool is_mitm_server; + public: + void AcknowledgeMitmSession(std::shared_ptr<::Service> *out_fsrv, sm::MitmProcessInfo *out_client_info) { + /* Check mitm server. */ + AMS_ABORT_UNLESS(this->is_mitm_server); + + /* Create forward service. */ + *out_fsrv = ServerSession::CreateForwardService(); + + /* Get client info. */ + R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, this->service_name)); + } }; private: /* Management of waitables. */ @@ -172,6 +183,11 @@ namespace ams::sf::hipc { Result AcceptImpl(Server *server, SharedPointer p) { return ServerSessionManager::AcceptSession(server->port_handle, std::move(p)); } + + template + Result AcceptMitmImpl(Server *server, SharedPointer p, std::shared_ptr<::Service> forward_service) { + return ServerSessionManager::AcceptMitmSession(server->port_handle, std::move(p), std::move(forward_service)); + } public: ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) : ServerDomainSessionManager(entry_storage, entry_count), diff --git a/libstratosphere/include/stratosphere/sf/impl/sf_impl_autogen_impl_macros.hpp b/libstratosphere/include/stratosphere/sf/impl/sf_impl_autogen_impl_macros.hpp index 09c7da59..dda9a3af 100644 --- a/libstratosphere/include/stratosphere/sf/impl/sf_impl_autogen_impl_macros.hpp +++ b/libstratosphere/include/stratosphere/sf/impl/sf_impl_autogen_impl_macros.hpp @@ -25,10 +25,10 @@ namespace ams::sf::impl { return ImplGetter::GetImplPointer(static_cast(this))->NAME ARGNAMES; \ } - #define AMS_SF_DEFINE_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \ + #define AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \ namespace NAMESPACE { \ \ - AMS_SF_DEFINE_INTERFACE_IMPL(::ams::sf::IServiceObject, INTERFACE, CMD_MACRO) \ + AMS_SF_DEFINE_INTERFACE_IMPL(BASE, INTERFACE, CMD_MACRO) \ \ } \ \ @@ -45,6 +45,12 @@ namespace ams::sf::impl { \ } + #define AMS_SF_DEFINE_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \ + AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, ::ams::sf::IServiceObject, CMD_MACRO) + + #define AMS_SF_DEFINE_MITM_INTERFACE(NAMESPACE, INTERFACE, CMD_MACRO) \ + AMS_SF_DEFINE_INTERFACE_WITH_DEFAULT_BASE(NAMESPACE, INTERFACE, ::ams::sf::IMitmServiceObject, CMD_MACRO) + #define AMS_SF_DEFINE_INTERFACE_WITH_BASE(NAMESPACE, INTERFACE, BASE, CMD_MACRO) \ namespace NAMESPACE { \ \ diff --git a/libstratosphere/source/ams/ams_environment.cpp b/libstratosphere/source/ams/ams_environment.cpp index 674dcf0d..e18a8019 100644 --- a/libstratosphere/source/ams/ams_environment.cpp +++ b/libstratosphere/source/ams/ams_environment.cpp @@ -196,16 +196,8 @@ extern "C" { } -namespace { - - constinit ams::os::Mutex g_abort_lock(true); - -} - /* Custom abort handler, so that std::abort will trigger these. */ void abort() { - std::scoped_lock lk(g_abort_lock); - ams::AbortImpl(); __builtin_unreachable(); } diff --git a/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index f36bf026..384db7d1 100644 --- a/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp @@ -26,7 +26,7 @@ namespace ams::fssrv::impl { /* ... */ } - StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr &&storage) : base_storage(std::move(storage)) { + StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr storage) : base_storage(std::move(storage)) { /* ... */ }