From 10e2e71ea22967e78d5187bad2c0166aeeea4c90 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 16 Aug 2019 20:19:50 -0400 Subject: [PATCH] Enter infinite-sleep-loop in appletRequestToShutdown/appletRequestToReboot. Minor change in appletHolderJump. --- nx/include/switch/services/applet.h | 4 ++-- nx/source/services/applet.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index cf43b4aa..83f929a7 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1199,13 +1199,13 @@ Result appletSetGamePlayRecordingState(bool state); Result appletInitializeGamePlayRecording(void); /** - * @brief Requests a system shutdown. + * @brief Requests a system shutdown. This will enter an infinite-sleep-loop on success. * @note Only available with AppletType_*Application on 3.0.0+. */ Result appletRequestToShutdown(void); /** - * @brief Requests a system reboot. + * @brief Requests a system reboot. This will enter an infinite-sleep-loop on success. * @note Only available with AppletType_*Application on 3.0.0+. */ Result appletRequestToReboot(void); diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 7ae52f7b..44bc6ca4 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -2896,9 +2896,7 @@ Result appletHolderJump(AppletHolder *h) { if (R_SUCCEEDED(rc)) rc = _appletWindAndDoReserved(); - if (R_FAILED(rc)) return rc; - - while(1)svcSleepThread(86400000000000ULL); + if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); return rc; } @@ -3856,21 +3854,29 @@ Result appletInitializeGamePlayRecording(void) { } Result appletRequestToShutdown(void) { + Result rc=0; + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - return _appletCmdNoIO(&g_appletIFunctions, 70); + rc = _appletCmdNoIO(&g_appletIFunctions, 70); + if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); + return rc; } Result appletRequestToReboot(void) { + Result rc=0; + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - return _appletCmdNoIO(&g_appletIFunctions, 71); + rc = _appletCmdNoIO(&g_appletIFunctions, 71); + if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); + return rc; } static Result _appletInitializeApplicationCopyrightFrameBuffer(TransferMemory *tmem, s32 width, s32 height) {