ns: Added support for the following cmds: nsRequestApplicationUpdateInfo, nsRequestUpdateApplication2, nsRequestDownloadApplicationControlData, nsRequestCheckGameCardRegistration, nsRequestGameCardRegistrationGoldPoint, nsRequestRegisterGameCard, nsRequestDownloadApplicationPrepurchasedRights, nsRequestNoDownloadRightsErrorResolution, nsRequestResolveNoDownloadRightsError.

This commit is contained in:
yellows8 2020-02-16 21:32:56 -05:00
parent 9bf745524d
commit d8d931fe25
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 239 additions and 0 deletions

View File

@ -209,6 +209,14 @@ Result nsIsApplicationEntityMovable(u64 application_id, NcmStorageId storage_id,
*/
Result nsMoveApplicationEntity(u64 application_id, NcmStorageId storage_id);
/**
* @brief RequestApplicationUpdateInfo
* @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.
* @param[out] a \ref AsyncValue. The data that can be read from this is u8 ApplicationUpdateInfo. qlaunch just checks whether this is 0.
* @param application_id ApplicationId.
*/
Result nsRequestApplicationUpdateInfo(AsyncValue *a, u64 application_id);
/**
* @brief CancelApplicationDownload
* @param[in] application_id ApplicationId.
@ -343,6 +351,15 @@ Result nsResumeAll(void);
*/
Result nsGetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *free_space_size);
/**
* @brief RequestUpdateApplication2
* @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.
* @note Only available on [4.0.0+].
* @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/
Result nsRequestUpdateApplication2(AsyncResult *a, u64 application_id);
/**
* @brief DeleteUserSystemSaveData
* @param[in] uid \ref AccountUid
@ -381,6 +398,44 @@ Result nsUnregisterNetworkServiceAccountWithUserSaveDataDeletion(AccountUid uid)
*/
Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size);
/**
* @brief RequestDownloadApplicationControlData
* @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.
* @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/
Result nsRequestDownloadApplicationControlData(AsyncResult *a, u64 application_id);
/**
* @brief RequestCheckGameCardRegistration
* @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.
* @note Only available on [2.0.0+].
* @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/
Result nsRequestCheckGameCardRegistration(AsyncResult *a, u64 application_id);
/**
* @brief RequestGameCardRegistrationGoldPoint
* @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.
* @note Only available on [2.0.0+].
* @param[out] a \ref AsyncValue. The data that can be read from this is 4-bytes.
* @param[in] uid \ref AccountUid
* @param[in] application_id ApplicationId.
*/
Result nsRequestGameCardRegistrationGoldPoint(AsyncValue *a, AccountUid uid, u64 application_id);
/**
* @brief RequestRegisterGameCard
* @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.
* @note Only available on [2.0.0+].
* @param[out] a \ref AsyncResult
* @param[in] uid \ref AccountUid
* @param[in] application_id ApplicationId.
* @param[in] inval Input value.
*/
Result nsRequestRegisterGameCard(AsyncResult *a, AccountUid uid, u64 application_id, s32 inval);
/**
* @brief GetGameCardMountFailureEvent
* @note The Event must be closed by the user once finished with it.
@ -486,6 +541,15 @@ Result nsNeedsSystemUpdateToFormatSdCard(bool *out);
*/
Result nsGetLastSdCardFormatUnexpectedResult(void);
/**
* @brief RequestDownloadApplicationPrepurchasedRights
* @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.
* @note Only available on [4.0.0+].
* @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/
Result nsRequestDownloadApplicationPrepurchasedRights(AsyncResult *a, u64 application_id);
/**
* @brief Generates a \ref NsSystemDeliveryInfo using the currently installed SystemUpdate meta.
* @note Only available on [4.0.0+].
@ -673,6 +737,24 @@ Result nsGetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s
*/
Result nsGetApplicationTerminateResult(u64 application_id, Result *res);
/**
* @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.
* @note Only available on [9.0.0+].
* @param[out] a \ref AsyncValue. The data that can be read from this is u8 NoDownloadRightsErrorResolution.
* @param application_id ApplicationId.
*/
Result nsRequestNoDownloadRightsErrorResolution(AsyncValue *a, u64 application_id);
/**
* @brief RequestResolveNoDownloadRightsError
* @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.
* @note Only available on [9.0.0+].
* @param[out] a \ref AsyncValue. The data that can be read from this is u8 NoDownloadRightsErrorResolution.
* @param application_id ApplicationId.
*/
Result nsRequestResolveNoDownloadRightsError(AsyncValue *a, u64 application_id);
///@}
///@name IRequestServerStopper

View File

@ -4,6 +4,7 @@
#include "runtime/hosversion.h"
#include "services/ns.h"
#include "services/async.h"
#include "services/nifm.h"
static Service g_nsAppManSrv, g_nsGetterSrv;
static Service g_nsvmSrv;
@ -197,6 +198,42 @@ static Result _nsCmdNoInOutAsyncResult(Service* srv, AsyncResult *a, u32 cmd_id)
return rc;
}
static Result _nsCmdInU64OutAsyncValue(Service* srv, AsyncValue *a, u64 inval, u32 cmd_id) {
memset(a, 0, sizeof(*a));
Handle event = INVALID_HANDLE;
Result rc = serviceDispatchIn(srv, cmd_id, inval,
.out_num_objects = 1,
.out_objects = &a->s,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &event,
);
if (R_SUCCEEDED(rc))
eventLoadRemote(&a->event, event, false);
return rc;
}
static Result _nsCmdInU64OutAsyncResult(Service* srv, AsyncResult *a, u64 inval, u32 cmd_id) {
memset(a, 0, sizeof(*a));
Handle event = INVALID_HANDLE;
Result rc = serviceDispatchIn(srv, cmd_id, inval,
.out_num_objects = 1,
.out_objects = &a->s,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &event,
);
if (R_SUCCEEDED(rc))
eventLoadRemote(&a->event, event, false);
return rc;
}
static Result _nsCheckNifm(void) {
return nifmIsAnyInternetRequestAccepted(nifmGetClientId()) ? 0 : MAKERESULT(16, 340);
}
Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount) {
return serviceDispatchInOut(&g_nsAppManSrv, 0, entry_offset, *out_entrycount,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
@ -237,6 +274,13 @@ Result nsMoveApplicationEntity(u64 application_id, NcmStorageId storage_id) {
return _nsCmdInU8U64NoOut(&g_nsAppManSrv, storage_id, application_id, 9);
}
Result nsRequestApplicationUpdateInfo(AsyncValue *a, u64 application_id) {
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncValue(&g_nsAppManSrv, a, application_id, 30);
}
Result nsCancelApplicationDownload(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 32);
}
@ -352,6 +396,16 @@ Result nsGetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *fre
return rc;
}
Result nsRequestUpdateApplication2(AsyncResult *a, u64 application_id) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 85);
}
Result nsDeleteUserSystemSaveData(AccountUid uid, u64 system_save_data_id) {
const struct {
AccountUid uid;
@ -396,6 +450,79 @@ Result nsGetApplicationControlData(NsApplicationControlSource source, u64 applic
return rc;
}
Result nsRequestDownloadApplicationControlData(AsyncResult *a, u64 application_id) {
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 402);
}
Result nsRequestCheckGameCardRegistration(AsyncResult *a, u64 application_id) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 502);
}
Result nsRequestGameCardRegistrationGoldPoint(AsyncValue *a, AccountUid uid, u64 application_id) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
const struct {
AccountUid uid;
u64 application_id;
} in = { uid, application_id };
memset(a, 0, sizeof(*a));
Handle event = INVALID_HANDLE;
rc = serviceDispatchIn(&g_nsAppManSrv, 503, in,
.out_num_objects = 1,
.out_objects = &a->s,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &event,
);
if (R_SUCCEEDED(rc))
eventLoadRemote(&a->event, event, false);
return rc;
}
Result nsRequestRegisterGameCard(AsyncResult *a, AccountUid uid, u64 application_id, s32 inval) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
const struct {
s32 inval;
u32 pad;
AccountUid uid;
u64 application_id;
} in = { inval, 0, uid, application_id };
memset(a, 0, sizeof(*a));
Handle event = INVALID_HANDLE;
rc = serviceDispatchIn(&g_nsAppManSrv, 504, in,
.out_num_objects = 1,
.out_objects = &a->s,
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
.out_handles = &event,
);
if (R_SUCCEEDED(rc))
eventLoadRemote(&a->event, event, false);
return rc;
}
Result nsGetGameCardMountFailureEvent(Event* out_event) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
@ -525,6 +652,16 @@ Result nsGetLastSdCardFormatUnexpectedResult(void) {
return _nsCmdNoIO(&g_nsAppManSrv, 1502);
}
Result nsRequestDownloadApplicationPrepurchasedRights(AsyncResult *a, u64 application_id) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 1901);
}
Result nsGetSystemDeliveryInfo(NsSystemDeliveryInfo *info) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
@ -803,6 +940,26 @@ Result nsGetApplicationTerminateResult(u64 application_id, Result *res) {
return serviceDispatchInOut(&g_nsAppManSrv, 2100, application_id, *res);
}
Result nsRequestNoDownloadRightsErrorResolution(AsyncValue *a, u64 application_id) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncValue(&g_nsAppManSrv, a, application_id, 2351);
}
Result nsRequestResolveNoDownloadRightsError(AsyncValue *a, u64 application_id) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncValue(&g_nsAppManSrv, a, application_id, 2352);
}
// IRequestServerStopper
void nsRequestServerStopperClose(NsRequestServerStopper *r) {