Removed AppletStorage.isHandleStorage since it's not usable for storages not created by the current process. Hence, appletStorageGetSize no longer supports HandleStorage.

This commit is contained in:
yellows8 2018-12-15 18:11:21 -05:00
parent 10826dda13
commit 41e75d0b7d
2 changed files with 6 additions and 19 deletions

View File

@ -72,7 +72,6 @@ struct AppletHookCookie
typedef struct { typedef struct {
Service s; Service s;
TransferMemory tmem; TransferMemory tmem;
bool isHandleStorage;
} AppletStorage; } AppletStorage;
Result appletInitialize(void); 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). /// 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); 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); 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. * @brief Gets data for a HandleStorage originally from \ref appletCreateHandleStorage input.
* @note Only available on 2.0.0+. * @note Only available on 2.0.0+.
* @param out Same as \ref appletStorageGetSize. * @param out Output value.
* @param handle Output handle. * @param handle Output handle.
*/ */
Result appletStorageGetHandle(AppletStorage *s, s64 *out, Handle *handle); Result appletStorageGetHandle(AppletStorage *s, s64 *out, Handle *handle);

View File

@ -1395,7 +1395,6 @@ static Result _appletExitProcessAndReturn(void) {
Result appletCreateStorage(AppletStorage *s, s64 size) { Result appletCreateStorage(AppletStorage *s, s64 size) {
memset(s, 0, sizeof(AppletStorage)); memset(s, 0, sizeof(AppletStorage));
s->isHandleStorage = false;
return _appletGetSessionIn64(&g_appletILibraryAppletCreator, &s->s, 10, size); return _appletGetSessionIn64(&g_appletILibraryAppletCreator, &s->s, 10, size);
} }
@ -1446,7 +1445,6 @@ Result appletCreateTransferMemoryStorage(AppletStorage *s, s64 size, bool writab
Result rc=0; Result rc=0;
memset(s, 0, sizeof(AppletStorage)); memset(s, 0, sizeof(AppletStorage));
s->isHandleStorage = false;
rc = tmemCreate(&s->tmem, size, Perm_None); rc = tmemCreate(&s->tmem, size, Perm_None);
if (R_FAILED(rc)) return rc; if (R_FAILED(rc)) return rc;
@ -1461,8 +1459,6 @@ Result appletCreateHandleStorage(AppletStorage *s, s64 inval, Handle handle) {
if (!kernelAbove200()) if (!kernelAbove200())
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
s->isHandleStorage = true;
return _appletCmdInHandle64(&g_appletILibraryAppletCreator, &s->s, 12, handle, inval); return _appletCmdInHandle64(&g_appletILibraryAppletCreator, &s->s, 12, handle, inval);
} }
@ -1470,7 +1466,6 @@ Result appletCreateHandleStorageTmem(AppletStorage *s, s64 size) {
Result rc=0; Result rc=0;
memset(s, 0, sizeof(AppletStorage)); memset(s, 0, sizeof(AppletStorage));
s->isHandleStorage = true;
rc = tmemCreate(&s->tmem, size, Perm_None); rc = tmemCreate(&s->tmem, size, Perm_None);
if (R_FAILED(rc)) return rc; 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 appletStorageGetSize(AppletStorage *s, s64 *size) {
Result rc=0; Result rc=0;
Service tmp_srv;//IStorageAccessor / ITransferStorageAccessor Service tmp_srv;//IStorageAccessor
if (!serviceIsActive(&s->s)) if (!serviceIsActive(&s->s))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (!s->isHandleStorage) rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open 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
}
if (R_FAILED(rc)) return rc; if (R_FAILED(rc)) return rc;
rc = _appletCmdNoInOut64(&tmp_srv, (u64*)size, 0); 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; size_t ipcbufsize=0;
Service tmp_srv;//IStorageAccessor Service tmp_srv;//IStorageAccessor
if (!serviceIsActive(&s->s) || s->isHandleStorage) if (!serviceIsActive(&s->s))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open rc = _appletGetSession(&s->s, &tmp_srv, 0);//Open
@ -1618,7 +1606,7 @@ Result appletStorageGetHandle(AppletStorage *s, s64 *out, Handle *handle) {
Result rc=0; Result rc=0;
Service tmp_srv;//ITransferStorageAccessor Service tmp_srv;//ITransferStorageAccessor
if (!serviceIsActive(&s->s) || !s->isHandleStorage) if (!serviceIsActive(&s->s))
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (!kernelAbove200()) if (!kernelAbove200())