# libSceNpTus technical debt ### Unknown function info - [TUS variable outputs](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the layouts of the variable arrays of the `sceNpTusGetMultiSlotVariable*` calls and of `outVariable` in `sceNpTusAddAndGetVariableAAsync` are not verified, so the output is never written and `variableArraySize` / `outVariableSize` are not checked; shadPS4, and RPCS3 in its PS3 `sceNpTusGetMultiSlotVariable*` and `sceNpTusAddAndGetVariable*` calls, return `INVALID_ALIGNMENT` unless the size is `arrayLen` variables of the call's type, or one variable for `outVariable`. The signatures and the community error codes follow [shadPS4](https://github.com/shadps4-emu/shadPS4/tree/main/src/core/libraries/np/np_tus), which fpPS4 agrees with for the context and request calls; no console measurement. - [Multi-slot variable calls](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks of the multi-slot get, set and delete calls are not measured on a console; they follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/c1b26558352b863f80142256e4df38585aa7d727/src/core/libraries/np/np_tus/np_tus.cpp), where they differ between functions: `arrayLen < 1` is `INSUFFICIENT_ARGUMENT` in the NpId and virtual-user delete calls and in `sceNpTusGetMultiSlotVariableVUserAsync`, and `INVALID_ARGUMENT` in the others; a null NpId is accepted except in delete; an empty virtual user ID is `INVALID_ARGUMENT`. RPCS3's [PS3 module](https://github.com/RPCS3/rpcs3/blob/1a9dca3a3a84a18df866e3021918322bd295160a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp) has only the NpId and virtual-user calls; it returns `INVALID_ARGUMENT` for an empty array in all of them, rejects a null target in get and set and does not check for an empty virtual user ID. - [Variable, data, data status and TSS requests](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks of the 82 add-and-get, try-and-set, data, data status, multi-user, friends and `sceNpTssGetSmallStorage` calls are not measured on a console; their signatures, checks and order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/np/np_tus/np_tus.cpp), including its differences between forms: the NpId try-and-set calls return `INVALID_ARGUMENT` for an operation type outside 1-6 where the others return `INVALID_TYPE`, and the NpId and virtual-user multi-slot data status calls return `TOO_MANY_NPID` for more than 64 slots. As for the calls above, the output and structure sizes are not checked, and every request finishes with `SCE_NP_ERROR_SIGNED_OUT` - [sceNpTusSetThreadParam](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTusCreateTitleCtx](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTusSetTimeout](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTusChangeModeForOtherSaveDataOwners](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTusDeleteMultiSlotDataVUser](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusDeleteMultiSlotDataVUserAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L2040) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`. The checks of `sceNpTusDeleteMultiSlotDataVUserAsync` apply. - [sceNpTusDeleteMultiSlotDataVUserAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L2054) and are not measured on a console: a null virtual user, null slot ids or no slot are `INSUFFICIENT_ARGUMENT`, a non-null `option`, a negative slot id or an empty virtual user are `INVALID_ARGUMENT` and more than 64 slots are `TOO_MANY_SLOTID`. The request finishes with `SCE_NP_ERROR_SIGNED_OUT` and no slot data exists to delete. - [sceNpTssGetStorage](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTssGetStorageAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unknown signature - [sceNpTssGetDataAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the implemented argument checks and their order are not measured on a console: a non-null `option` must have size 0x20 or returns `INVALID_ALIGNMENT`; a non-null `dataStatus` must have `dataStatusSize` 0x18 or also returns `INVALID_ALIGNMENT`; a null `dataStatus` is accepted and its size is ignored; and a slot id outside 0 to 15 returns `INVALID_ARGUMENT`. The option-size check precedes the data-status-size check, which precedes the slot and request checks. The data-status layout is unverified, and nothing is written to the data status or the data. The option's offsets and condition are not read, and the transfer offset that shadPS4 keeps per request is not kept. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [sceNpTssGetData](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTssGetDataAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L4939) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`. The checks of `sceNpTssGetDataAsync` apply. - [sceNpTusGetDataForCrossSaveVUser](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusGetDataForCrossSaveVUserAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3852) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`. The checks of `sceNpTusGetDataForCrossSaveVUserAsync` apply. - [sceNpTusGetDataForCrossSaveVUserAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3867) and are not measured on a console. `dataStatusSize` and the layout of `dataStatus` are not checked, and `dataStatus` and `data` are never written, so no transfer offset is kept between calls. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [sceNpTusGetFriendsVariableA](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusGetFriendsVariableAAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3178) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`; the number of entries read that the console returns on success is never produced. The checks of `sceNpTusGetFriendsVariableAAsync` apply. - [sceNpTusGetFriendsVariableAAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3194) and are not measured on a console. `variableArraySize` and the size of its entries are not checked and the array is never written. A non-null `option` is read as `size`, `startSerialRank` and `hits` (0x18 bytes): another size is `INVALID_ALIGNMENT` and a `startSerialRank` of 0 is `INVALID_ARGUMENT`; `hits` is never written, and the option is accepted where `sceNpTusGetFriendsVariableAsync` refuses every option. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [sceNpTusGetFriendsVariableForCrossSave](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusGetFriendsVariableForCrossSaveAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L4024) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`; the number of entries read that the console returns on success is never produced. The checks of `sceNpTusGetFriendsVariableForCrossSaveAsync` apply. - [sceNpTusGetFriendsVariableForCrossSaveAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L4039) and are not measured on a console. `variableArraySize` and the size of its entries are not checked and the array is never written. A non-null `option` is read as `size`, `startSerialRank` and `hits` (0x18 bytes): another size is `INVALID_ALIGNMENT` and a `startSerialRank` of 0 is `INVALID_ARGUMENT`; `hits` is never written, and the option is accepted where `sceNpTusGetFriendsVariableAsync` refuses every option. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [sceNpTusGetFriendsDataStatusA](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusGetFriendsDataStatusAAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3086) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`; the number of entries read that the console returns on success is never produced. The checks of `sceNpTusGetFriendsDataStatusAAsync` apply. - [sceNpTusGetFriendsDataStatusAAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3102) and are not measured on a console. `statusArraySize` and the size of its entries are not checked and the array is never written. A non-null `option` is read as `size`, `startSerialRank` and `hits` (0x18 bytes): another size is `INVALID_ALIGNMENT` and a `startSerialRank` of 0 is `INVALID_ARGUMENT`; `hits` is never written, and the option is accepted where `sceNpTusGetFriendsDataStatusAsync` refuses every option. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [sceNpTusGetFriendsDataStatusForCrossSave](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - waits on the request that `sceNpTusGetFriendsDataStatusForCrossSaveAsync` starts, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3931) does, and returns its argument error or `SCE_NP_ERROR_SIGNED_OUT`; the number of entries read that the console returns on success is never produced. The checks of `sceNpTusGetFriendsDataStatusForCrossSaveAsync` apply. - [sceNpTusGetFriendsDataStatusForCrossSaveAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the argument checks and their order follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/12a4564543ccec527f9723676d2180580d1d7a94/src/core/libraries/np/np_tus/np_tus.cpp#L3946) and are not measured on a console. `statusArraySize` and the size of its entries are not checked and the array is never written. A non-null `option` is read as `size`, `startSerialRank` and `hits` (0x18 bytes): another size is `INVALID_ALIGNMENT` and a `startSerialRank` of 0 is `INVALID_ARGUMENT`; `hits` is never written, and the option is accepted where `sceNpTusGetFriendsDataStatusAsync` refuses every option. The request finishes with `SCE_NP_ERROR_SIGNED_OUT`. - [Friends, cross-save and virtual-user argument checks](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - unverified: the checks of the `A` and `ForCrossSave` friends calls, `sceNpTusGetDataForCrossSaveVUser` and `sceNpTusDeleteMultiSlotDataVUser`, and their `*Async` forms, follow shadPS4 and their tests assert those results; no console measured them. An emulator run of the firmware 13.42 module ([report](https://github.com/boykopovar/AnyPS5/pull/10675#issuecomment-6390507411)) differs: the friends calls refuse an array size other than `arrayLen` times the entry size with `0x80550714`, answer an option `size` mismatch with `0x80550704`, accept start rank 0 and zero the array for SDK 5.50 and later; the data status call takes only a `dataStatusSize` of 0x1F0 or 0x210 and accepts a null status or empty name; the delete call accepts a null or empty virtual user and `arrayLen` -1, and refuses 0 with `0x80550704`. - [sceNpTusDeleteNpTitleCtx](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - the PS5 signature, error codes and child-request lifetime have not been measured on a console. Deletion invalidates the context and all its requests, following [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/a808e7626e3c7de8d0f0fda6a91f620b42f6c762/src/core/libraries/np/np_tus/np_tus.cpp#L158-L180). ### Functional - [sceNpTusCreateNpTitleCtxA](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - creates a title context without checking sign-in, up to 32 contexts (`TOO_MANY_OBJECTS` beyond); shadPS4 returns the `sceNpGetNpId` error instead. Requests are limited to 256, and the limits are not measured on a console. - [sceNpTssCreateNpTitleCtx and sceNpTssCreateNpTitleCtxA](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - that TSS title contexts share the TUS context table and its 32-context limit is inferred from [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/615bcba5e21b82dc59588575f7ecbce8da09ca2c/src/core/libraries/np/np_tus/np_tus.cpp#L146-L168), which redirects both to the TUS creators, and from TSS requests coming from `sceNpTusCreateRequest`; nothing is measured on a console. The `A` form is `sceNpTusCreateNpTitleCtxA`. The `NpId` form returns `INSUFFICIENT_ARGUMENT` for a null `npId` and `INVALID_ARGUMENT` for service label `0xFFFFFFFF` before the limit, as shadPS4's [sceNpTusCreateNpTitleCtx](https://github.com/shadps4-emu/shadPS4/blob/615bcba5e21b82dc59588575f7ecbce8da09ca2c/src/core/libraries/np/np_tus/np_tus.cpp#L122-L143) does; the signatures are shadPS4's and fpPS4's, and Orbital's for the `A` form. - [sceNpTusCreateNpTitleCtx](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - not measured on a console, and the `npId` contents are neither read nor kept with the context, where shadPS4 keeps them for its requests. It is `sceNpTssCreateNpTitleCtx`: `INSUFFICIENT_ARGUMENT` for a null `npId`, then `INVALID_ARGUMENT` for service label `0xFFFFFFFF`, then a context in the shared 32-context table, as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/db79f9d24348/src/core/libraries/np/np_tus/np_tus.cpp#L122-L143); the signature is shadPS4's and [fpPS4](https://github.com/red-prig/fpPS4/blob/04cefd43e6fd/src/np/ps4_libscenptus.pas#L72-L75)'s. - [sceNpTusPollAsync, sceNpTusWaitAsync](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - there is no PSN, so every implemented `*Async` call whose arguments pass the checks starts a request that finishes at once with `SCE_NP_ERROR_SIGNED_OUT`, which poll and wait report and the blocking calls return; shadPS4 returns `SIGNED_OUT` from the `*Async` call itself when no shadNet client is signed in, and RPCS3 returns `INVALID_ONLINE_ID` while offline, marked there as probable behaviour. An abort stays set, so every later operation on the request, blocking ones included, finishes with `ABORTED`; in shadPS4 an abort only ends the operation in progress. Until an operation has started, poll returns 1 and wait returns `INVALID_ARGUMENT` as in shadPS4; RPCS3 [blocks until a result is set](https://github.com/RPCS3/rpcs3/blob/1a9dca3a3a84a18df866e3021918322bd295160a/rpcs3/Emu/NP/np_contexts.cpp#L40-L52). - [sceNpTusGetData, sceNpTusGetDataVUser, sceNpTusGetMultiSlotVariable, sceNpTusGetMultiSlotVariableVUser, sceNpTusGetMultiUserVariableForCrossSave, sceNpTusSetData, sceNpTusSetDataVUser, sceNpTusSetMultiSlotVariable and sceNpTusSetMultiSlotVariableVUser](../../../core/libs/prx/libSceNpTus/Export.cpp) (libSceNpTus) - block on their `*Async` forms with the same parameters, as [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/396c2a09a38d22eaa02aab32c1967263dceab95f/src/core/libraries/np/np_tus/np_tus.cpp) does, so they inherit those forms' unmeasured checks and the offline `SIGNED_OUT` result