diff --git a/libstratosphere/include/stratosphere/sm/impl/sm_user_interface.hpp b/libstratosphere/include/stratosphere/sm/impl/sm_user_interface.hpp index 84316285..6bb7c72f 100644 --- a/libstratosphere/include/stratosphere/sm/impl/sm_user_interface.hpp +++ b/libstratosphere/include/stratosphere/sm/impl/sm_user_interface.hpp @@ -32,6 +32,7 @@ namespace ams::sm::impl { AMS_SF_METHOD_INFO(C, H, 65004, Result, AtmosphereHasMitm, (sf::Out out, ServiceName service)) \ AMS_SF_METHOD_INFO(C, H, 65005, Result, AtmosphereWaitMitm, (ServiceName service)) \ AMS_SF_METHOD_INFO(C, H, 65006, Result, AtmosphereDeclareFutureMitm, (ServiceName service)) \ + AMS_SF_METHOD_INFO(C, H, 65007, Result, AtmosphereClearFutureMitm, (ServiceName service)) \ AMS_SF_METHOD_INFO(C, H, 65100, Result, AtmosphereHasService, (sf::Out out, ServiceName service)) \ AMS_SF_METHOD_INFO(C, H, 65101, Result, AtmosphereWaitService, (ServiceName service)) diff --git a/libstratosphere/include/stratosphere/sm/sm_mitm_api.hpp b/libstratosphere/include/stratosphere/sm/sm_mitm_api.hpp index fcdd46c5..d78f63b1 100644 --- a/libstratosphere/include/stratosphere/sm/sm_mitm_api.hpp +++ b/libstratosphere/include/stratosphere/sm/sm_mitm_api.hpp @@ -24,6 +24,7 @@ namespace ams::sm::mitm { Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name); Result UninstallMitm(ServiceName name); Result DeclareFutureMitm(ServiceName name); + Result ClearFutureMitm(ServiceName name); Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name); Result HasMitm(bool *out, ServiceName name); Result WaitMitm(ServiceName name); diff --git a/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp b/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp index c763dbae..37b78626 100644 --- a/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp +++ b/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp @@ -27,6 +27,10 @@ namespace ams::sf::hipc { /* Register the query handle. */ impl::RegisterMitmQueryHandle(query_handle, query_func); + + /* Clear future declarations if any, now that our query handler is present. */ + R_ABORT_UNLESS(sm::mitm::ClearFutureMitm(service_name)); + return ResultSuccess(); } diff --git a/libstratosphere/source/sm/sm_ams.c b/libstratosphere/source/sm/sm_ams.c index 233c7937..1ceb23f8 100644 --- a/libstratosphere/source/sm/sm_ams.c +++ b/libstratosphere/source/sm/sm_ams.c @@ -107,6 +107,10 @@ Result smAtmosphereMitmDeclareFuture(SmServiceName name) { return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65006); } +Result smAtmosphereMitmClearFuture(SmServiceName name) { + return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65007); +} + Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServiceName name) { struct { u64 process_id; diff --git a/libstratosphere/source/sm/sm_ams.h b/libstratosphere/source/sm/sm_ams.h index 6bdf435b..3a4885cc 100644 --- a/libstratosphere/source/sm/sm_ams.h +++ b/libstratosphere/source/sm/sm_ams.h @@ -26,6 +26,7 @@ void smAtmosphereCloseSession(Service *srv); Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name); Result smAtmosphereMitmUninstall(SmServiceName name); Result smAtmosphereMitmDeclareFuture(SmServiceName name); +Result smAtmosphereMitmClearFuture(SmServiceName name); Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *info_out, SmServiceName name); #ifdef __cplusplus diff --git a/libstratosphere/source/sm/sm_mitm_api.cpp b/libstratosphere/source/sm/sm_mitm_api.cpp index 431c3b96..8e5c8002 100644 --- a/libstratosphere/source/sm/sm_mitm_api.cpp +++ b/libstratosphere/source/sm/sm_mitm_api.cpp @@ -37,6 +37,12 @@ namespace ams::sm::mitm { }); } + Result ClearFutureMitm(ServiceName name) { + return impl::DoWithUserSession([&]() { + return smAtmosphereMitmClearFuture(impl::ConvertName(name)); + }); + } + Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name) { return impl::DoWithMitmAcknowledgementSession([&]() { return smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast(out_info), impl::ConvertName(name));