From c3b32581c9f2c2f604541d5ddd8662e624e44bfa Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 20 Aug 2019 18:16:45 -0400 Subject: [PATCH] Added appletGetLaunchStorageInfoForDebug. --- nx/include/switch/services/applet.h | 8 ++++++ nx/source/services/applet.c | 42 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index fbb92e08..0bd0cfcc 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -1211,6 +1211,14 @@ Result appletSetTerminateResult(Result res); */ Result appletGetDisplayVersion(char *displayVersion); +/** + * @brief Gets the LaunchStorageInfo. + * @note Only available with AppletType_*Application on [2.0.0+]. + * @param[out] app_storageId Same as AppletApplicationLaunchProperty::app_storageId. + * @param[out] update_storageId Same as AppletApplicationLaunchProperty::update_storageId. + */ +Result appletGetLaunchStorageInfoForDebug(FsStorageId *app_storageId, FsStorageId *update_storageId); + /** * @brief Blocks the usage of the home button, for short (Home Menu) and long (Overlay) presses. * @note Only available with AppletType_*Application. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 4b35606a..84e8fceb 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -3772,6 +3772,48 @@ Result appletGetDisplayVersion(char *displayVersion) { return rc; } +Result appletGetLaunchStorageInfoForDebug(FsStorageId *app_storageId, FsStorageId *update_storageId) { + if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + if (hosversionBefore(2,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_appletIFunctions, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 24; + + Result rc = serviceIpcDispatch(&g_appletIFunctions); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u8 app_storageId; + u8 update_storageId; + } *resp; + + serviceIpcParse(&g_appletIFunctions, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc) && app_storageId) *app_storageId = resp->app_storageId; + if (R_SUCCEEDED(rc) && update_storageId) *update_storageId = resp->update_storageId; + } + + return rc; +} + Result appletBeginBlockingHomeButtonShortAndLongPressed(s64 val) { if (!serviceIsActive(&g_appletSrv) || !_appletIsApplication()) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);