From 41e75d0b7d156a4ad346ee4eab8888cea1ab50a8 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 15 Dec 2018 18:11:21 -0500 Subject: [PATCH] Removed AppletStorage.isHandleStorage since it's not usable for storages not created by the current process. Hence, appletStorageGetSize no longer supports HandleStorage. --- nx/include/switch/services/applet.h | 5 ++--- nx/source/services/applet.c | 20 ++++---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/nx/include/switch/services/applet.h b/nx/include/switch/services/applet.h index bbb7de41..0973d684 100644 --- a/nx/include/switch/services/applet.h +++ b/nx/include/switch/services/applet.h @@ -72,7 +72,6 @@ struct AppletHookCookie typedef struct { Service s; TransferMemory tmem; - bool isHandleStorage; } AppletStorage; Result appletInitialize(void); @@ -169,7 +168,7 @@ void appletStorageClose(AppletStorage *s); /// Closes the TransferMemory in the storage object. For TransferMemory storage created by the current process, this must be called after the LibraryApplet finishes using it (if sent to one). void appletStorageCloseTmem(AppletStorage *s); -/// Gets the size of the storage. For HandleStorage, this returns the input s64 originally from /ref appletCreateHandleStorage / \ref appletCreateHandleStorageTmem. +/// Gets the size of the storage. This is not usable with HandleStorage, use \ref appletStorageGetHandle or \ref appletStorageMap instead for that. Result appletStorageGetSize(AppletStorage *s, s64 *size); /** @@ -195,7 +194,7 @@ Result appletStorageRead(AppletStorage *s, s64 offset, void* buffer, size_t size /** * @brief Gets data for a HandleStorage originally from \ref appletCreateHandleStorage input. * @note Only available on 2.0.0+. - * @param out Same as \ref appletStorageGetSize. + * @param out Output value. * @param handle Output handle. */ Result appletStorageGetHandle(AppletStorage *s, s64 *out, Handle *handle); diff --git a/nx/source/services/applet.c b/nx/source/services/applet.c index 751d473a..1f00d3c4 100644 --- a/nx/source/services/applet.c +++ b/nx/source/services/applet.c @@ -1395,7 +1395,6 @@ static Result _appletExitProcessAndReturn(void) { Result appletCreateStorage(AppletStorage *s, s64 size) { memset(s, 0, sizeof(AppletStorage)); - s->isHandleStorage = false; return _appletGetSessionIn64(&g_appletILibraryAppletCreator, &s->s, 10, size); } @@ -1446,7 +1445,6 @@ Result appletCreateTransferMemoryStorage(AppletStorage *s, s64 size, bool writab Result rc=0; memset(s, 0, sizeof(AppletStorage)); - s->isHandleStorage = false; rc = tmemCreate(&s->tmem, size, Perm_None); if (R_FAILED(rc)) return rc; @@ -1461,8 +1459,6 @@ Result appletCreateHandleStorage(AppletStorage *s, s64 inval, Handle handle) { if (!kernelAbove200()) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - s->isHandleStorage = true; - return _appletCmdInHandle64(&g_appletILibraryAppletCreator, &s->s, 12, handle, inval); } @@ -1470,7 +1466,6 @@ Result appletCreateHandleStorageTmem(AppletStorage *s, s64 size) { Result rc=0; memset(s, 0, sizeof(AppletStorage)); - s->isHandleStorage = true; rc = tmemCreate(&s->tmem, size, Perm_None); if (R_FAILED(rc)) return rc; @@ -1528,19 +1523,12 @@ static Result _appletStorageAccessorRW(Service* srv, size_t ipcbufsize, s64 offs Result appletStorageGetSize(AppletStorage *s, s64 *size) { Result rc=0; - Service tmp_srv;//IStorageAccessor / ITransferStorageAccessor + Service tmp_srv;//IStorageAccessor if (!serviceIsActive(&s->s)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); - if (!s->isHandleStorage) rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open - if (s->isHandleStorage) { - if (!kernelAbove200()) - return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - - rc = _appletGetSession(&s->s, &tmp_srv, 1);//OpenTransferStorage - } - + rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open if (R_FAILED(rc)) return rc; rc = _appletCmdNoInOut64(&tmp_srv, (u64*)size, 0); @@ -1554,7 +1542,7 @@ static Result _appletStorageRW(AppletStorage *s, s64 offset, void* buffer, size_ size_t ipcbufsize=0; Service tmp_srv;//IStorageAccessor - if (!serviceIsActive(&s->s) || s->isHandleStorage) + if (!serviceIsActive(&s->s)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open @@ -1618,7 +1606,7 @@ Result appletStorageGetHandle(AppletStorage *s, s64 *out, Handle *handle) { Result rc=0; Service tmp_srv;//ITransferStorageAccessor - if (!serviceIsActive(&s->s) || !s->isHandleStorage) + if (!serviceIsActive(&s->s)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (!kernelAbove200())