diff --git a/nx/include/switch/services/ns.h b/nx/include/switch/services/ns.h index 12559a82..77c879b8 100644 --- a/nx/include/switch/services/ns.h +++ b/nx/include/switch/services/ns.h @@ -143,6 +143,15 @@ typedef struct { u8 hmac[0x20]; ///< HMAC-SHA256 over the above data. } NsApplicationDeliveryInfo; +/// NsApplicationRightsOnClient +typedef struct { + u64 application_id; ///< ApplicationId. + AccountUid uid; ///< \ref AccountUid + u8 flags_x18; ///< qlaunch uses bit0-bit4 and bit7 from here. + u8 flags_x19; ///< qlaunch uses bit0 from here. + u8 unk_x1a[0x6]; ///< Unknown. +} NsApplicationRightsOnClient; + /// Default size for \ref nssuControlSetupCardUpdate / \ref nssuControlSetupCardUpdateViaSystemUpdater. This is the size used by qlaunch for SetupCardUpdate. #define NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT 0x100000 @@ -737,6 +746,18 @@ Result nsGetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s */ Result nsGetApplicationTerminateResult(u64 application_id, Result *res); +/** + * @brief GetApplicationRightsOnClient + * @note Only available on [6.0.0+]. + * @param[out] rights Output array of \ref NsApplicationRightsOnClient. + * @param[in] count Size of the rights array in entries. qlaunch uses value 3 for this. + * @param[in] application_id ApplicationId + * @param[in] uid \ref AccountUid, can optionally be all-zero. + * @param[in] flags Flags. Official sw hard-codes this to value 0x3. + * @param[out] total_out Total output entries. + */ +Result nsGetApplicationRightsOnClient(NsApplicationRightsOnClient *rights, s32 count, u64 application_id, AccountUid uid, u32 flags, s32 *total_out); + /** * @brief RequestNoDownloadRightsErrorResolution * @note \ref nifmInitialize must be used prior to this. Before using the cmd, this calls \ref nifmIsAnyInternetRequestAccepted with the output from \ref nifmGetClientId, an error is returned when that returns false. diff --git a/nx/source/services/ns.c b/nx/source/services/ns.c index 3fa3b530..35ac9c4f 100644 --- a/nx/source/services/ns.c +++ b/nx/source/services/ns.c @@ -940,6 +940,23 @@ Result nsGetApplicationTerminateResult(u64 application_id, Result *res) { return serviceDispatchInOut(&g_nsAppManSrv, 2100, application_id, *res); } +Result nsGetApplicationRightsOnClient(NsApplicationRightsOnClient *rights, s32 count, u64 application_id, AccountUid uid, u32 flags, s32 *total_out) { + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + const struct { + u32 flags; + u32 pad; + u64 application_id; + AccountUid uid; + } in = { flags, 0, application_id, uid }; + + return serviceDispatchInOut(&g_nsAppManSrv, 2050, in, *total_out, + .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, + .buffers = { { rights, count*sizeof(NsApplicationRightsOnClient) } }, + ); +} + Result nsRequestNoDownloadRightsErrorResolution(AsyncValue *a, u64 application_id) { if (hosversionBefore(9,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);