From 447ca35c29668d4b55c426a044b58f047253c77c Mon Sep 17 00:00:00 2001 From: yellows8 Date: Mon, 19 Aug 2019 22:08:19 -0400 Subject: [PATCH] Added appletPopRequestLaunchApplicationForDebug. --- nx/include/switch/services/applet.h | 10 +++++++ nx/source/services/applet.c | 44 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 3863bdbf..5ff96c44 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1371,6 +1371,16 @@ Result appletGetPopFromGeneralChannelEvent(Event *out_event); */ Result appletGetHomeButtonWriterLockAccessor(AppletLockAccessor *a); +/** + * @brief PopRequestLaunchApplicationForDebug + * @note Only available with AppletType_SystemApplet on [6.0.0+]. + * @param[out] userIDs Output array of userIDs. + * @param[in] count Size of the userID array in entries, must be at least the size stored in state. + * @param[out] titleID Output Application titleID. + * @param[out] total_out Total output userID entries. + */ +Result appletPopRequestLaunchApplicationForDebug(u128 *userIDs, s32 count, u64 *titleID, s32 *total_out); + // IGlobalStateController /** diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 91c79e26..3da3f8c1 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -4270,6 +4270,50 @@ Result appletGetHomeButtonWriterLockAccessor(AppletLockAccessor *a) { return _appletGetHomeButtonRwLockAccessor(&g_appletIFunctions, a, 30); } +Result appletPopRequestLaunchApplicationForDebug(u128 *userIDs, s32 count, u64 *titleID, s32 *total_out) { + if (__nx_applet_type != AppletType_SystemApplet) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + ipcAddRecvBuffer(&c, userIDs, count*sizeof(u128), BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletIFunctions, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 100; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u64 titleID; + s32 total_out; + } *resp; + + serviceIpcParse(&g_appletIFunctions, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && titleID) *titleID = resp->titleID; + if (R_SUCCEEDED(rc) && total_out) *total_out = resp->total_out; + } + + return rc; +} + // IGlobalStateController Result appletStartSleepSequence(bool flag) {