From a6e1413712feb56742b6c6ca5463b14560c00288 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 18 Dec 2018 19:37:07 -0500 Subject: [PATCH] Added storage pushing for AppletHolder. Verify that the input storage is initialized in _appletCmdInStorage(). --- nx/include/switch/services/applet.h | 24 ++++++++++++++++++++++++ nx/source/services/applet.c | 20 +++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index 60171f5e..7c6b83ec 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -237,6 +237,30 @@ void appletHolderJoin(AppletHolder *h); */ LibAppletExitReason appletHolderGetExitReason(AppletHolder *h); +/** + * @brief Pushes a storage for LibraryApplet input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param s Storage object. + */ +Result appletHolderPushInData(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pushes a storage for LibraryApplet Extra storage input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param s Storage object. + */ +Result appletHolderPushExtraStorage(AppletHolder *h, AppletStorage *s); + +/** + * @brief Pushes a storage for LibraryApplet Interactive input. + * @note This uses \ref appletStorageClose automatically. + * @param h AppletHolder object. + * @param s Storage object. + */ +Result appletHolderPushInteractiveInData(AppletHolder *h, AppletStorage *s); + /** * @brief Creates a storage. * @param s Storage object. diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index c518a92f..3c0449a6 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -743,7 +743,13 @@ static Result _appletCmdInSession(Service* srv, Service* srv_in, u64 cmd_id) { } static Result _appletCmdInStorage(Service* srv, AppletStorage* s, u64 cmd_id) { - Result rc = _appletCmdInSession(srv, &s->s, cmd_id); + Result rc=0; + + if (!serviceIsActive(&s->s)) + return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); + + rc =_appletCmdInSession(srv, &s->s, cmd_id); + appletStorageClose(s); return rc; } @@ -1627,6 +1633,18 @@ u32 appletHolderGetExitReason(AppletHolder *h) { return h->exitreason; } +Result appletHolderPushInData(AppletHolder *h, AppletStorage *s) { + return _appletCmdInStorage(&h->s, s, 100); +} + +Result appletHolderPushExtraStorage(AppletHolder *h, AppletStorage *s) { + return _appletCmdInStorage(&h->s, s, 102); +} + +Result appletHolderPushInteractiveInData(AppletHolder *h, AppletStorage *s) { + return _appletCmdInStorage(&h->s, s, 103); +} + Result appletCreateStorage(AppletStorage *s, s64 size) { memset(s, 0, sizeof(AppletStorage));