diff --git a/nx/include/switch/services/sm.h b/nx/include/switch/services/sm.h index cf21a53f..366e94f1 100644 --- a/nx/include/switch/services/sm.h +++ b/nx/include/switch/services/sm.h @@ -151,12 +151,6 @@ Result smRegisterService(Handle* handle_out, const char* name, bool is_light, in */ Result smUnregisterService(const char* name); -/** - * @brief Check whether SM is initialized. - * @return true if initialized. - */ -bool smHasInitialized(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/fatal.c b/nx/source/services/fatal.c index d3552c59..2b8cf163 100644 --- a/nx/source/services/fatal.c +++ b/nx/source/services/fatal.c @@ -17,29 +17,27 @@ static void _fatalImpl(u32 cmd_id, Result err, FatalType type, FatalContext *ctx svcBreak(0x80000000, err, 0); } - if (!smHasInitialized()) { - rc = smInitialize(); + Handle session; + rc = smInitialize(); + if (R_SUCCEEDED(rc)) { + rc = smGetServiceOriginal(&session, smEncodeName("fatal:u")); + smExit(); } if (R_SUCCEEDED(rc)) { - Handle srv; - rc = smGetServiceOriginal(&srv, smEncodeName("fatal:u")); + const struct { + u32 result; + u32 type; + u64 pid_placeholder; + } in = { err, type }; - if (R_SUCCEEDED(rc)) { - const struct { - u32 result; - u32 type; - u64 pid_placeholder; - } in = { err, type }; - - Service s; - serviceCreate(&s, srv); - serviceDispatchIn(&s, cmd_id, in, - .buffer_attrs = { ctx ? (SfBufferAttr_In | SfBufferAttr_HipcMapAlias) : 0U }, - .buffers = { { ctx, sizeof(*ctx) } }, - .in_send_pid = true, - ); - } + Service s; + serviceCreate(&s, session); + serviceDispatchIn(&s, cmd_id, in, + .buffer_attrs = { ctx ? (SfBufferAttr_In | SfBufferAttr_HipcMapAlias) : 0U }, + .buffers = { { ctx, sizeof(*ctx) } }, + .in_send_pid = true, + ); } switch (type) { diff --git a/nx/source/services/sm.c b/nx/source/services/sm.c index 153841c5..63f03c3d 100644 --- a/nx/source/services/sm.c +++ b/nx/source/services/sm.c @@ -44,9 +44,6 @@ Handle smGetServiceOverride(u64 name) return INVALID_HANDLE; } -bool smHasInitialized(void) { - return serviceIsActive(&g_smSrv); -} Result smInitialize(void) {