From 44dcabd214ef7f27390331855b915d8c1d89919d Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 2 Dec 2020 08:15:38 -0800 Subject: [PATCH] sm: add smDetachClient --- nx/include/switch/services/sm.h | 6 ++++++ nx/source/services/sm.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/nx/include/switch/services/sm.h b/nx/include/switch/services/sm.h index 1b8f5721..b2bddbb9 100644 --- a/nx/include/switch/services/sm.h +++ b/nx/include/switch/services/sm.h @@ -124,6 +124,12 @@ Result smRegisterService(Handle* handle_out, SmServiceName name, bool is_light, */ Result smUnregisterService(SmServiceName name); +/** + * @brief Detaches the current SM session. + * @note After this function is called, the rest of the SM API cannot be used. + */ +Result smDetachClient(void); + /** * @brief Gets the Service session used to communicate with SM. * @return Pointer to service session used to communicate with SM. diff --git a/nx/source/services/sm.c b/nx/source/services/sm.c index a271d746..2ed08c76 100644 --- a/nx/source/services/sm.c +++ b/nx/source/services/sm.c @@ -1,5 +1,6 @@ #define NX_SERVICE_ASSUME_NON_DOMAIN #include "service_guard.h" +#include "runtime/hosversion.h" #include "runtime/diag.h" static Service g_smSrv; @@ -105,3 +106,8 @@ Result smRegisterService(Handle* handle_out, SmServiceName name, bool is_light, Result smUnregisterService(SmServiceName name) { return serviceDispatchIn(&g_smSrv, 3, name); } + +Result smDetachClient(void) { + if (hosversionBefore(11,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + return serviceDispatch(&g_smSrv, 4); +}