From 19741cb103860265a69de5c51c798602a1a93903 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 16 Aug 2019 23:56:29 -0400 Subject: [PATCH] Added appletRequestLaunchApplicationWithUserAndArgumentForDebug. --- nx/include/switch/services/applet.h | 11 ++++++++ nx/source/services/applet.c | 42 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index ee511528..803f49eb 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1709,6 +1709,17 @@ Result appletPerformSystemButtonPressing(AppletSystemButtonType type); */ Result appletInvalidateTransitionLayer(void); +/** + * @brief Requests to launch the specified Application, with the specified users. + * @note Only available on [6.0.0+]. + * @param[in] userIDs Input array of userIDs. + * @param[in] total_userIDs Total input userIDs, must be <=ACC_USER_LIST_SIZE. + * @param[in] flag Whether to use the specified buffer to create a storage which will be pushed for ::AppletLaunchParameterKind_UserChannel. + * @param[in] buffer Buffer containing the above storage data. + * @param[in] size Size of the storage buffer. + */ +Result appletRequestLaunchApplicationWithUserAndArgumentForDebug(u64 titleID, u128 *userIDs, size_t total_userIDs, bool flag, const void* buffer, size_t size); + // State / other /** diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index b153a4df..6756e1a7 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -4795,6 +4795,48 @@ Result appletInvalidateTransitionLayer(void) { return _appletCmdNoIO(&g_appletIDebugFunctions, 20); } +Result appletRequestLaunchApplicationWithUserAndArgumentForDebug(u64 titleID, u128 *userIDs, size_t total_userIDs, bool flag, const void* buffer, size_t size) { + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + ipcAddSendBuffer(&c, userIDs, total_userIDs*sizeof(u128), BufferType_Normal); + ipcAddSendBuffer(&c, buffer, size, BufferType_Normal); + + struct { + u64 magic; + u64 cmd_id; + u8 flag; + u64 titleID; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletIDebugFunctions, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 30; + raw->flag = flag!=0; + raw->titleID = titleID; + + Result rc = serviceIpcDispatch(&g_appletIDebugFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + } *resp; + + serviceIpcParse(&g_appletIDebugFunctions, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + // State / other u8 appletGetOperationMode(void) {