Merge branch 'master' of https://github.com/switchbrew/libnx into capsc

This commit is contained in:
HookedBehemoth 2020-02-19 02:01:14 +01:00
commit 50caa2aedd
9 changed files with 1687 additions and 73 deletions

View File

@ -28,6 +28,11 @@ typedef enum {
NifmInternetConnectionStatus_Connected = 4, ///< Internet is connected. NifmInternetConnectionStatus_Connected = 4, ///< Internet is connected.
} NifmInternetConnectionStatus; } NifmInternetConnectionStatus;
/// ClientId
typedef struct {
u32 id; ///< ClientId
} NifmClientId;
/// Initialize nifm. This is used automatically by gethostid(). /// Initialize nifm. This is used automatically by gethostid().
Result nifmInitialize(NifmServiceType service_type); Result nifmInitialize(NifmServiceType service_type);
@ -40,6 +45,11 @@ Service* nifmGetServiceSession_StaticService(void);
/// Gets the Service object for IGeneralService. /// Gets the Service object for IGeneralService.
Service* nifmGetServiceSession_GeneralService(void); Service* nifmGetServiceSession_GeneralService(void);
/**
* @brief GetClientId
*/
NifmClientId nifmGetClientId(void);
Result nifmGetCurrentIpAddress(u32* out); Result nifmGetCurrentIpAddress(u32* out);
/** /**
@ -56,6 +66,13 @@ Result nifmIsWirelessCommunicationEnabled(bool* out);
Result nifmGetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus); Result nifmGetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus);
Result nifmIsEthernetCommunicationEnabled(bool* out); Result nifmIsEthernetCommunicationEnabled(bool* out);
/**
* @brief IsAnyInternetRequestAccepted
* @param[in] id \ref NifmClientId
*/
bool nifmIsAnyInternetRequestAccepted(NifmClientId id);
Result nifmIsAnyForegroundRequestAccepted(bool* out); Result nifmIsAnyForegroundRequestAccepted(bool* out);
Result nifmPutToSleep(void); Result nifmPutToSleep(void);
Result nifmWakeUp(void); Result nifmWakeUp(void);

View File

@ -10,6 +10,9 @@
#include "../sf/service.h" #include "../sf/service.h"
#include "../services/ncm_types.h" #include "../services/ncm_types.h"
#include "../services/async.h" #include "../services/async.h"
#include "../services/acc.h"
#include "../services/fs.h"
#include "../applets/error.h"
#include "../kernel/event.h" #include "../kernel/event.h"
#include "../kernel/tmem.h" #include "../kernel/tmem.h"
@ -43,6 +46,11 @@ typedef enum {
NsLatestSystemUpdate_Unknown2 = 2, ///< Unknown. NsLatestSystemUpdate_Unknown2 = 2, ///< Unknown.
} NsLatestSystemUpdate; } NsLatestSystemUpdate;
/// RequestServerStopper
typedef struct {
Service s; ///< IRequestServerStopper
} NsRequestServerStopper;
/// SystemUpdateControl /// SystemUpdateControl
typedef struct { typedef struct {
Service s; ///< ISystemUpdateControl Service s; ///< ISystemUpdateControl
@ -75,6 +83,53 @@ typedef struct {
u8 unk_x11[7]; ///< Unknown. u8 unk_x11[7]; ///< Unknown.
} NsApplicationRecord; } NsApplicationRecord;
/// ApplicationViewDeprecated. The below comments are for the \ref NsApplicationView to NsApplicationViewDeprecated conversion done by \ref nsGetApplicationViewDeprecated on newer system-versions.
typedef struct {
u64 application_id; ///< Same as NsApplicationView::application_id.
u8 unk_x8[0x4]; ///< Same as NsApplicationView::unk_x8.
u32 flags; ///< Same as NsApplicationView::flags.
u8 unk_x10[0x10]; ///< Same as NsApplicationView::unk_x10.
u32 unk_x20; ///< Same as NsApplicationView::unk_x20.
u16 unk_x24; ///< Same as NsApplicationView::unk_x24.
u8 unk_x26[0x2]; ///< Cleared to zero.
u8 unk_x28[0x10]; ///< Same as NsApplicationView::unk_x30.
u32 unk_x38; ///< Same as NsApplicationView::unk_x40.
u8 unk_x3c; ///< Same as NsApplicationView::unk_x44.
u8 unk_x3d[3]; ///< Cleared to zero.
} NsApplicationViewDeprecated;
/// ApplicationView
typedef struct {
u64 application_id; ///< ApplicationId.
u8 unk_x8[0x4]; ///< Unknown.
u32 flags; ///< Flags.
u8 unk_x10[0x10]; ///< Unknown.
u32 unk_x20; ///< Unknown.
u16 unk_x24; ///< Unknown.
u8 unk_x26[0x2]; ///< Unknown.
u8 unk_x28[0x8]; ///< Unknown.
u8 unk_x30[0x10]; ///< Unknown.
u32 unk_x40; ///< Unknown.
u8 unk_x44; ///< Unknown.
u8 unk_x45[0xb]; ///< Unknown.
} NsApplicationView;
/// NsPromotionInfo
typedef struct {
u64 start_timestamp; ///< POSIX timestamp for the promotion start.
u64 end_timestamp; ///< POSIX timestamp for the promotion end.
s64 remaining_time; ///< Remaining time until the promotion ends, in nanoseconds ({end_timestamp - current_time} converted to nanoseconds).
u8 unk_x18[0x4]; ///< Not set, left at zero.
u8 flags; ///< Flags. Bit0: whether the PromotionInfo is valid (including bit1). Bit1 clear: remaining_time is set.
u8 pad[3]; ///< Padding.
} NsPromotionInfo;
/// NsApplicationViewWithPromotionInfo
typedef struct {
NsApplicationView view; ///< \ref NsApplicationView
NsPromotionInfo promotion; ///< \ref NsPromotionInfo
} NsApplicationViewWithPromotionInfo;
/// LaunchProperties /// LaunchProperties
typedef struct { typedef struct {
u64 program_id; ///< program_id. u64 program_id; ///< program_id.
@ -136,6 +191,15 @@ typedef struct {
u8 hmac[0x20]; ///< HMAC-SHA256 over the above data. u8 hmac[0x20]; ///< HMAC-SHA256 over the above data.
} NsApplicationDeliveryInfo; } 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. /// Default size for \ref nssuControlSetupCardUpdate / \ref nssuControlSetupCardUpdateViaSystemUpdater. This is the size used by qlaunch for SetupCardUpdate.
#define NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT 0x100000 #define NSSU_CARDUPDATE_TMEM_SIZE_DEFAULT 0x100000
@ -164,14 +228,231 @@ Service* nsGetServiceSession_ApplicationManagerInterface(void);
Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount); Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount);
/** /**
* @brief Gets an listing of \ref NsApplicationContentMetaStatus. * @brief GetApplicationRecordUpdateSystemEvent
* @param[in] application_id ApplicationId. * @note The Event must be closed by the user once finished with it.
* @param[in] index Starting entry index. * @param[out] out_event Output Event with autoclear=true.
* @param[out] list Output array of \ref NsApplicationContentMetaStatus.
* @param[in] count Size of the list array in entries.
* @param[out] out_entrycount Total output entries.
*/ */
Result nsListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount); Result nsGetApplicationRecordUpdateSystemEvent(Event* out_event);
/**
* @brief GetApplicationViewDeprecated
* @note On [3.0.0+] you should generally use \ref nsGetApplicationView instead.
* @param[out] out Output array of \ref NsApplicationViewDeprecated.
* @param[in] application_ids Input array of ApplicationIds.
* @param[in] count Size of the input/output arrays in entries.
*/
Result nsGetApplicationViewDeprecated(NsApplicationViewDeprecated *views, const u64 *application_ids, s32 count);
/**
* @brief DeleteApplicationEntity
* @param[in] application_id ApplicationId.
*/
Result nsDeleteApplicationEntity(u64 application_id);
/**
* @brief DeleteApplicationCompletely
* @param[in] application_id ApplicationId.
*/
Result nsDeleteApplicationCompletely(u64 application_id);
/**
* @brief DeleteRedundantApplicationEntity
*/
Result nsDeleteRedundantApplicationEntity(void);
/**
* @brief IsApplicationEntityMovable
* @param[in] application_id ApplicationId.
* @param[in] storage_id \ref NcmStorageId
* @param[out] out Output flag.
*/
Result nsIsApplicationEntityMovable(u64 application_id, NcmStorageId storage_id, bool *out);
/**
* @brief MoveApplicationEntity
* @param[in] application_id ApplicationId.
* @param[in] storage_id \ref NcmStorageId
*/
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.
*/
Result nsCancelApplicationDownload(u64 application_id);
/**
* @brief ResumeApplicationDownload
* @param[in] application_id ApplicationId.
*/
Result nsResumeApplicationDownload(u64 application_id);
/**
* @brief CheckApplicationLaunchVersion
* @param[in] application_id ApplicationId.
*/
Result nsCheckApplicationLaunchVersion(u64 application_id);
/**
* @brief CalculateApplicationApplyDeltaRequiredSize
* @param[in] application_id ApplicationId.
* @param[out] storage_id Output \ref NcmStorageId.
* @param[out] size Output size.
*/
Result nsCalculateApplicationDownloadRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size);
/**
* @brief CleanupSdCard
*/
Result nsCleanupSdCard(void);
/**
* @brief GetSdCardMountStatusChangedEvent
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=false.
*/
Result nsGetSdCardMountStatusChangedEvent(Event* out_event);
/**
* @brief Returns the total storage capacity (used + free) from content manager services.
* @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard.
* @param[out] size Pointer to output the total storage size to.
*/
Result nsGetTotalSpaceSize(NcmStorageId storage_id, s64 *size);
/**
* @brief Returns the available storage capacity from content manager services.
* @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard.
* @param[out] size Pointer to output the free storage size to.
*/
Result nsGetFreeSpaceSize(NcmStorageId storage_id, s64 *size);
/**
* @brief GetGameCardUpdateDetectionEvent
* @note The Event must be closed by the user once finished with it.
* @param[out] out_event Output Event with autoclear=false.
*/
Result nsGetGameCardUpdateDetectionEvent(Event* out_event);
/**
* @brief DisableApplicationAutoDelete
* @param[in] application_id ApplicationId.
*/
Result nsDisableApplicationAutoDelete(u64 application_id);
/**
* @brief EnableApplicationAutoDelete
* @param[in] application_id ApplicationId.
*/
Result nsEnableApplicationAutoDelete(u64 application_id);
/**
* @brief SetApplicationTerminateResult
* @param[in] application_id ApplicationId.
* @param[in] res Result.
*/
Result nsSetApplicationTerminateResult(u64 application_id, Result res);
/**
* @brief ClearApplicationTerminateResult
* @param[in] application_id ApplicationId.
*/
Result nsClearApplicationTerminateResult(u64 application_id);
/**
* @brief GetLastSdCardMountUnexpectedResult
*/
Result nsGetLastSdCardMountUnexpectedResult(void);
/**
* @brief Opens a \ref NsRequestServerStopper.
* @note Only available on [2.0.0+].
* @param[out] r \ref NsRequestServerStopper
*/
Result nsGetRequestServerStopper(NsRequestServerStopper *r);
/**
* @brief CancelApplicationApplyDelta
* @note Only available on [3.0.0+].
* @param[in] application_id ApplicationId.
*/
Result nsCancelApplicationApplyDelta(u64 application_id);
/**
* @brief ResumeApplicationApplyDelta
* @note Only available on [3.0.0+].
* @param[in] application_id ApplicationId.
*/
Result nsResumeApplicationApplyDelta(u64 application_id);
/**
* @brief CalculateApplicationApplyDeltaRequiredSize
* @note Only available on [3.0.0+].
* @param[in] application_id ApplicationId.
* @param[out] storage_id Output \ref NcmStorageId.
* @param[out] size Output size.
*/
Result nsCalculateApplicationApplyDeltaRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size);
/**
* @brief ResumeAll
* @note Only available on [3.0.0+].
*/
Result nsResumeAll(void);
/**
* @brief Temporarily mounts the specified fs ContentStorage, then uses fs GetTotalSpaceSize/GetFreeSpaceSize with that mounted ContentStorage.
* @note Only available on [3.0.0+].
* @param[in] storage_id \ref NcmStorageId, must be ::NcmStorageId_BuiltInUser or ::NcmStorageId_SdCard.
* @param[out] total_space_size Output from GetTotalSpaceSize.
* @param[out] free_space_size Output from GetFreeSpaceSize.
*/
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
* @param[in] system_save_data_id SystemSaveDataId
*/
Result nsDeleteUserSystemSaveData(AccountUid uid, u64 system_save_data_id);
/**
* @brief DeleteSaveData
* @note Only available on [6.0.0+].
* @param[in] save_data_space_id \ref FsSaveDataSpaceId
* @param[in] save_data_id SaveDataId
*/
Result nsDeleteSaveData(FsSaveDataSpaceId save_data_space_id, u64 save_data_id);
/**
* @brief UnregisterNetworkServiceAccount
* @param[in] uid \ref AccountUid
*/
Result nsUnregisterNetworkServiceAccount(AccountUid uid);
/**
* @brief UnregisterNetworkServiceAccountWithUserSaveDataDeletion
* @note Only available on [6.0.0+].
* @param[in] uid \ref AccountUid
*/
Result nsUnregisterNetworkServiceAccountWithUserSaveDataDeletion(AccountUid uid);
/** /**
* @brief Gets the \ref NsApplicationControlData for the specified application. * @brief Gets the \ref NsApplicationControlData for the specified application.
@ -184,18 +465,182 @@ Result nsListApplicationContentMetaStatus(u64 application_id, s32 index, NsAppli
Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size); Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size);
/** /**
* @brief Returns the total storage capacity (used + free) from content manager services. * @brief RequestDownloadApplicationControlData
* @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard. * @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] size Pointer to output the total storage size to. * @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/ */
Result nsGetTotalSpaceSize(NcmStorageId storage_id, u64 *size); Result nsRequestDownloadApplicationControlData(AsyncResult *a, u64 application_id);
/** /**
* @brief Returns the available storage capacity from content manager services. * @brief RequestCheckGameCardRegistration
* @param[in] storage_id \ref NcmStorageId. Must be ::NcmStorageId_SdCard. * @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] size Pointer to output the free storage size to. * @note Only available on [2.0.0+].
* @param[out] a \ref AsyncResult
* @param[in] application_id ApplicationId.
*/ */
Result nsGetFreeSpaceSize(NcmStorageId storage_id, u64 *size); 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.
* @note Only available on [3.0.0+].
* @param[out] out_event Output Event with autoclear=false.
*/
Result nsGetGameCardMountFailureEvent(Event* out_event);
/**
* @brief IsGameCardInserted
* @note Only available on [3.0.0+].
* @param[out] out Output flag.
*/
Result nsIsGameCardInserted(bool *out);
/**
* @brief EnsureGameCardAccess
* @note Only available on [3.0.0+].
*/
Result nsEnsureGameCardAccess(void);
/**
* @brief GetLastGameCardMountFailureResult
* @note Only available on [3.0.0+].
*/
Result nsGetLastGameCardMountFailureResult(void);
/**
* @brief ListApplicationIdOnGameCard
* @note Only available on [5.0.0+].
* @param[out] application_ids Output array of ApplicationIds.
* @param[in] count Size of the application_ids array in entries.
* @param[out] total_out Total output entries.
*/
Result nsListApplicationIdOnGameCard(u64 *application_ids, s32 count, s32 *total_out);
/**
* @brief Gets an listing of \ref NsApplicationContentMetaStatus.
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
* @param[in] index Starting entry index.
* @param[out] list Output array of \ref NsApplicationContentMetaStatus.
* @param[in] count Size of the list array in entries.
* @param[out] out_entrycount Total output entries.
*/
Result nsListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount);
/**
* @brief TouchApplication
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
*/
Result nsTouchApplication(u64 application_id);
/**
* @brief IsApplicationUpdateRequested
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
* @param[out] flag Output flag, indicating whether out is valid.
* @param[out] out Output value.
*/
Result nsIsApplicationUpdateRequested(u64 application_id, bool *flag, u32 *out);
/**
* @brief WithdrawApplicationUpdateRequest
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
*/
Result nsWithdrawApplicationUpdateRequest(u64 application_id);
/**
* @brief IsAnyApplicationEntityInstalled
* @note Only available on [2.0.0+].
* @param[in] application_id ApplicationId.
* @param[out] out Output flag.
*/
Result nsIsAnyApplicationEntityInstalled(u64 application_id, bool *out);
/**
* @brief CleanupUnavailableAddOnContents
* @note Only available on [6.0.0+].
* @param[in] application_id ApplicationId.
* @param[in] uid \ref AccountUid
*/
Result nsCleanupUnavailableAddOnContents(u64 application_id, AccountUid uid);
/**
* @brief FormatSdCard
* @note Only available on [2.0.0+].
*/
Result nsFormatSdCard(void);
/**
* @brief NeedsSystemUpdateToFormatSdCard
* @note Only available on [2.0.0+].
* @param[out] out Output flag.
*/
Result nsNeedsSystemUpdateToFormatSdCard(bool *out);
/**
* @brief GetLastSdCardFormatUnexpectedResult
* @note Only available on [2.0.0+].
*/
Result nsGetLastSdCardFormatUnexpectedResult(void);
/**
* @brief GetApplicationView
* @note Only available on [3.0.0+], on prior system-versions use \ref nsGetApplicationViewDeprecated instead.
* @param[out] out Output array of \ref NsApplicationView.
* @param[in] application_ids Input array of ApplicationIds.
* @param[in] count Size of the input/output arrays in entries.
*/
Result nsGetApplicationView(NsApplicationView *views, const u64 *application_ids, s32 count);
/**
* @brief GetApplicationViewDownloadErrorContext
* @note Only available on [4.0.0+].
* @param[in] application_id ApplicationId
* @param[out] context \ref ErrorContext
*/
Result nsGetApplicationViewDownloadErrorContext(u64 application_id, ErrorContext *context);
/**
* @brief GetApplicationViewWithPromotionInfo
* @note Only available on [8.0.0+].
* @param[out] out Output array of \ref NsApplicationViewWithPromotionInfo.
* @param[in] application_ids Input array of ApplicationIds.
* @param[in] count Size of the input/output arrays in entries.
*/
Result nsGetApplicationViewWithPromotionInfo(NsApplicationViewWithPromotionInfo *out, const u64 *application_ids, s32 count);
/**
* @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. * @brief Generates a \ref NsSystemDeliveryInfo using the currently installed SystemUpdate meta.
@ -376,6 +821,64 @@ Result nsListNotCommittedContentMeta(NcmContentMetaKey *meta, s32 count, u64 app
*/ */
Result nsGetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s32 count, u8 *out_hash); Result nsGetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s32 count, u8 *out_hash);
/**
* @brief GetApplicationTerminateResult
* @note Only available on [6.0.0+].
* @param[in] application_id ApplicationId.
* @param[out] res Output Result.
*/
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.
* @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);
/**
* @brief GetPromotionInfo
* @note Only available on [8.0.0+].
* @param[out] promotion \ref NsPromotionInfo
* @param application_id ApplicationId.
* @param[in] uid \ref AccountUid
*/
Result nsGetPromotionInfo(NsPromotionInfo *promotion, u64 application_id, AccountUid uid);
///@}
///@name IRequestServerStopper
///@{
/**
* @brief Close a \ref NsRequestServerStopper.
* @param r \ref NsRequestServerStopper
*/
void nsRequestServerStopperClose(NsRequestServerStopper *r);
///@} ///@}
///@name ns:vm ///@name ns:vm

View File

@ -85,10 +85,10 @@ void pmshellExit(void);
Service* pmshellGetServiceSession(void); Service* pmshellGetServiceSession(void);
/// Initialize pm:bm. /// Initialize pm:bm.
Result pmbmInitialize(); Result pmbmInitialize(void);
/// Exit pm:bm. /// Exit pm:bm.
void pmbmExit(); void pmbmExit(void);
/// Gets the Service object for the actual pm:bm service session. /// Gets the Service object for the actual pm:bm service session.
Service* pmbmGetServiceSession(void); Service* pmbmGetServiceSession(void);

View File

@ -271,27 +271,35 @@ typedef struct {
} SetCalAccelerometerScale; } SetCalAccelerometerScale;
typedef struct { typedef struct {
u32 size;
u8 cert[0x70]; u8 cert[0x70];
} SetCalAmiiboEcdsaCertificate; } SetCalAmiiboEcdsaCertificate;
typedef struct { typedef struct {
u32 size;
u8 cert[0x20]; u8 cert[0x20];
} SetCalAmiiboEcqvBlsCertificate; } SetCalAmiiboEcqvBlsCertificate;
typedef struct { typedef struct {
u8 key[0x44]; u32 size;
u8 key[0x40];
u32 generation;
} SetCalAmiiboEcqvBlsKey; } SetCalAmiiboEcqvBlsKey;
typedef struct { typedef struct {
u32 size;
u8 cert[0x90]; u8 cert[0x90];
} SetCalAmiiboEcqvBlsRootCertificate; } SetCalAmiiboEcqvBlsRootCertificate;
typedef struct { typedef struct {
u32 size;
u8 cert[0x14]; u8 cert[0x14];
} SetCalAmiiboEcqvCertificate; } SetCalAmiiboEcqvCertificate;
typedef struct { typedef struct {
u8 key[0x54]; u32 size;
u8 key[0x50];
u32 generation;
} SetCalAmiiboKey; } SetCalAmiiboKey;
typedef struct { typedef struct {
@ -319,16 +327,17 @@ typedef struct {
} SetCalConsoleSixAxisSensorHorizontalOffset; } SetCalConsoleSixAxisSensorHorizontalOffset;
typedef struct { typedef struct {
u32 code[0x4]; ///< Country code. char code[0x3]; ///< Country code.
} SetCalCountryCode; } SetCalCountryCode;
typedef struct { typedef struct {
u32 offset; ///< Relative to current position. u8 cert[0x180];
u8 cert[0x17C];
} SetCalEccB233DeviceCertificate; } SetCalEccB233DeviceCertificate;
typedef struct { typedef struct {
u8 key[0x58]; u32 size;
u8 key[0x50];
u32 generation;
} SetCalEccB233DeviceKey; } SetCalEccB233DeviceKey;
typedef struct { typedef struct {
@ -338,6 +347,7 @@ typedef struct {
typedef struct { typedef struct {
u32 size; ///< Size of the entire key. u32 size; ///< Size of the entire key.
u8 key[0x130]; u8 key[0x130];
u32 generation;
} SetCalGameCardKey; } SetCalGameCardKey;
typedef struct { typedef struct {
@ -353,17 +363,17 @@ typedef struct {
} SetCalMacAddress; } SetCalMacAddress;
typedef struct { typedef struct {
u32 offset; ///< Relative to current position. u8 cert[0x240];
u8 cert[0x23C];
} SetCalRsa2048DeviceCertificate; } SetCalRsa2048DeviceCertificate;
typedef struct { typedef struct {
u32 size; ///< Size of the entire key. u32 size; ///< Size of the entire key.
u8 key[0x240]; u8 key[0x240];
u32 generation;
} SetCalRsa2048DeviceKey; } SetCalRsa2048DeviceKey;
typedef struct { typedef struct {
u8 number[0x18]; char number[0x18];
} SetCalSerialNumber; } SetCalSerialNumber;
typedef struct { typedef struct {
@ -378,6 +388,7 @@ typedef struct {
typedef struct { typedef struct {
u32 size; ///< Size of the entire key. u32 size; ///< Size of the entire key.
u8 key[0x130]; u8 key[0x130];
u32 generation;
} SetCalSslKey; } SetCalSslKey;
typedef struct { typedef struct {
@ -1017,23 +1028,269 @@ void setcalExit(void);
/// Gets the Service object for the actual setcal service session. /// Gets the Service object for the actual setcal service session.
Service* setcalGetServiceSession(void); Service* setcalGetServiceSession(void);
/// Gets the \ref SetCalEccB233DeviceCertificate. /**
* @brief Gets the \ref SetCalBdAddress.
* @param[out] out \ref SetCalBdAddress
*/
Result setcalGetBdAddress(SetCalBdAddress *out);
/**
* @brief Gets the \ref SetCalConfigurationId1.
* @param[out] out \ref SetCalConfigurationId1
*/
Result setcalGetConfigurationId1(SetCalConfigurationId1 *out);
/**
* @brief Gets the \ref SetCalAccelerometerOffset.
* @param[out] out \ref SetCalAccelerometerOffset
*/
Result setcalGetAccelerometerOffset(SetCalAccelerometerOffset *out);
/**
* @brief Gets the \ref SetCalAccelerometerScale.
* @param[out] out \ref SetCalAccelerometerScale
*/
Result setcalGetAccelerometerScale(SetCalAccelerometerScale *out);
/**
* @brief Gets the \ref SetCalAccelerometerOffset.
* @param[out] out \ref SetCalAccelerometerOffset
*/
Result setcalGetGyroscopeOffset(SetCalAccelerometerOffset *out);
/**
* @brief Gets the \ref SetCalGyroscopeScale.
* @param[out] out \ref SetCalGyroscopeScale
*/
Result setcalGetGyroscopeScale(SetCalGyroscopeScale *out);
/**
* @brief Gets the \ref SetCalMacAddress.
* @param[out] out \ref SetCalMacAddress
*/
Result setcalGetWirelessLanMacAddress(SetCalMacAddress *out);
/**
* @brief GetWirelessLanCountryCodeCount
* @param[out] out_count Output count
*/
Result setcalGetWirelessLanCountryCodeCount(s32 *out_count);
/**
* @brief GetWirelessLanCountryCodes
* @param[out] total_out Total output entries.
* @param[out] codes Output array of \ref SetCalCountryCode.
* @param[in] count Size of the versions array in entries.
*/
Result setcalGetWirelessLanCountryCodes(s32 *total_out, SetCalCountryCode *codes, s32 count);
/**
* @brief Gets the \ref SetCalSerialNumber.
* @param[out] out \ref SetCalSerialNumber
*/
Result setcalGetSerialNumber(SetCalSerialNumber *out);
/**
* @brief SetInitialSystemAppletProgramId
* @param[in] program_id input ProgramId.
*/
Result setcalSetInitialSystemAppletProgramId(u64 program_id);
/**
* @brief SetOverlayDispProgramId
* @param[in] program_id input ProgramId.
*/
Result setcalSetOverlayDispProgramId(u64 program_id);
/**
* @brief Gets the \ref SetBatteryLot.
* @param[out] out \ref SetBatteryLot
*/
Result setcalGetBatteryLot(SetBatteryLot *out);
/**
* @brief Gets the \ref SetCalEccB233DeviceCertificate.
* @param[out] out \ref SetCalEccB233DeviceCertificate
*/
Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out); Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out);
/// Gets the \ref SetCalRsa2048DeviceCertificate. /**
* @brief Gets the \ref SetCalRsa2048DeviceCertificate.
* @param[out] out \ref SetCalRsa2048DeviceCertificate
*/
Result setcalGetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out); Result setcalGetEticketDeviceCertificate(SetCalRsa2048DeviceCertificate *out);
/// Gets the \ref SetCalSslKey. /**
* @brief Gets the \ref SetCalSslKey.
* @param[out] out \ref SetCalSslKey
*/
Result setcalGetSslKey(SetCalSslKey *out); Result setcalGetSslKey(SetCalSslKey *out);
/// Gets the \ref SetCalSslCertificate. /**
* @brief Gets the \ref SetCalSslCertificate.
* @param[out] out \ref SetCalSslCertificate
*/
Result setcalGetSslCertificate(SetCalSslCertificate *out); Result setcalGetSslCertificate(SetCalSslCertificate *out);
/// Gets the \ref SetCalGameCardKey. /**
* @brief Gets the \ref SetCalGameCardKey.
* @param[out] out \ref SetCalGameCardKey
*/
Result setcalGetGameCardKey(SetCalGameCardKey *out); Result setcalGetGameCardKey(SetCalGameCardKey *out);
/// Gets the \ref SetCalGameCardCertificate. /**
* @brief Gets the \ref SetCalGameCardCertificate.
* @param[out] out \ref SetCalGameCardCertificate
*/
Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out); Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out);
/// Gets the \ref SetCalRsa2048DeviceKey. /**
* @brief Gets the \ref SetCalEccB233DeviceKey.
* @param[out] out \ref SetCalEccB233DeviceKey
*/
Result setcalGetEciDeviceKey(SetCalEccB233DeviceKey *out);
/**
* @brief Gets the \ref SetCalRsa2048DeviceKey.
* @param[out] out \ref SetCalRsa2048DeviceKey
*/
Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out); Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out);
/**
* @brief Gets the \ref SetCalSpeakerParameter.
* @param[out] out \ref SetCalSpeakerParameter
*/
Result setcalGetSpeakerParameter(SetCalSpeakerParameter *out);
/**
* @brief GetLcdVendorId
* @note Only available on [4.0.0+].
* @param[out] out_vendor_id Output LcdVendorId.
*/
Result setcalGetLcdVendorId(u32 *out_vendor_id);
/**
* @brief Gets the \ref SetCalRsa2048DeviceCertificate.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalRsa2048DeviceCertificate
*/
Result setcalGetEciDeviceCertificate2(SetCalRsa2048DeviceCertificate *out);
/**
* @brief Gets the \ref SetCalRsa2048DeviceKey.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalRsa2048DeviceKey
*/
Result setcalGetEciDeviceKey2(SetCalRsa2048DeviceKey *out);
/**
* @brief Gets the \ref SetCalAmiiboKey.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboKey
*/
Result setcalGetAmiiboKey(SetCalAmiiboKey *out);
/**
* @brief Gets the \ref SetCalAmiiboEcqvCertificate.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboEcqvCertificate
*/
Result setcalGetAmiiboEcqvCertificate(SetCalAmiiboEcqvCertificate *out);
/**
* @brief Gets the \ref SetCalAmiiboEcdsaCertificate.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboEcdsaCertificate
*/
Result setcalGetAmiiboEcdsaCertificate(SetCalAmiiboEcdsaCertificate *out);
/**
* @brief Gets the \ref SetCalAmiiboEcqvBlsKey.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboEcqvBlsKey
*/
Result setcalGetAmiiboEcqvBlsKey(SetCalAmiiboEcqvBlsKey *out);
/**
* @brief Gets the \ref SetCalAmiiboEcqvBlsCertificate.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboEcqvBlsCertificate
*/
Result setcalGetAmiiboEcqvBlsCertificate(SetCalAmiiboEcqvBlsCertificate *out);
/**
* @brief Gets the \ref SetCalAmiiboEcqvBlsRootCertificate.
* @note Only available on [5.0.0+].
* @param[out] out \ref SetCalAmiiboEcqvBlsRootCertificate
*/
Result setcalGetAmiiboEcqvBlsRootCertificate(SetCalAmiiboEcqvBlsRootCertificate *out);
/**
* @brief GetUsbTypeCPowerSourceCircuitVersion
* @note Only available on [5.0.0+].
* @param[out] out_version Output UsbTypeCPowerSourceCircuitVersion.
*/
Result setcalGetUsbTypeCPowerSourceCircuitVersion(u8 *out_version);
/**
* @brief GetAnalogStickModuleTypeL
* @note Only available on [8.1.1+].
* @param[out] out_version Output AnalogStickModuleType.
*/
Result setcalGetAnalogStickModuleTypeL(u8 *out_type);
/**
* @brief Gets the \ref SetCalAnalogStickModelParameter.
* @note Only available on [8.1.1+].
* @param[out] out \ref SetCalAnalogStickModelParameter
*/
Result setcalGetAnalogStickModelParameterL(SetCalAnalogStickModelParameter *out);
/**
* @brief Gets the \ref SetCalAnalogStickFactoryCalibration.
* @note Only available on [8.1.1+].
* @param[out] out \ref SetCalAnalogStickFactoryCalibration
*/
Result setcalGetAnalogStickFactoryCalibrationL(SetCalAnalogStickFactoryCalibration *out);
/**
* @brief GetAnalogStickModuleTypeR
* @note Only available on [8.1.1+].
* @param[out] out_version Output AnalogStickModuleType.
*/
Result setcalGetAnalogStickModuleTypeR(u8 *out_type);
/**
* @brief Gets the \ref SetCalAnalogStickModelParameter.
* @note Only available on [8.1.1+].
* @param[out] out \ref SetCalAnalogStickModelParameter
*/
Result setcalGetAnalogStickModelParameterR(SetCalAnalogStickModelParameter *out);
/**
* @brief Gets the \ref SetCalAnalogStickFactoryCalibration.
* @note Only available on [8.1.1+].
* @param[out] out \ref SetCalAnalogStickFactoryCalibration
*/
Result setcalGetAnalogStickFactoryCalibrationR(SetCalAnalogStickFactoryCalibration *out);
/**
* @brief GetConsoleSixAxisSensorModuleType
* @note Only available on [8.1.1+].
* @param[out] out_version Output ConsoleSixAxisSensorModuleType.
*/
Result setcalGetConsoleSixAxisSensorModuleType(u8 *out_type);
/**
* @brief Gets the \ref SetCalConsoleSixAxisSensorHorizontalOffset.
* @note Only available on [8.1.1+].
* @param[out] out \ref SetCalConsoleSixAxisSensorHorizontalOffset
*/
Result setcalGetConsoleSixAxisSensorHorizontalOffset(SetCalConsoleSixAxisSensorHorizontalOffset *out);
/**
* @brief GetBatteryVersion
* @note Only available on [6.0.0+].
* @param[out] out_version Output BatteryVersion.
*/
Result setcalGetBatteryVersion(u8 *out_version);

View File

@ -109,13 +109,13 @@ Result splCryptoGetSecurityEngineEvent(Event *out_event);
Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size); Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size);
Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size);
Result splSslSecureExpMod(const void *input, const void *modulus, void *dst); Result splSslSecureExpMod(const void *input, const void *modulus, void *dst);
Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version);
Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey); Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey);
Result splEsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey); Result splEsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey);
Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version); Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size);
Result splEsSecureExpMod(const void *input, const void *modulus, void *dst); Result splEsSecureExpMod(const void *input, const void *modulus, void *dst);
Result splEsUnwrapElicenseKey(const void *rsa_wrapped_elicense_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_elicense_key); Result splEsUnwrapElicenseKey(const void *rsa_wrapped_elicense_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_elicense_key);
Result splEsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot); Result splEsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot);

View File

@ -105,6 +105,16 @@ static Result _nifmCreateGeneralService(Service* srv_out) {
); );
} }
NifmClientId nifmGetClientId(void) {
NifmClientId id={0};
Result rc = serviceDispatch(&g_nifmIGS, 1,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_Out },
.buffers = { { &id, sizeof(id) } },
);
if (R_FAILED(rc)) id.id = 0;
return id;
}
Result nifmGetCurrentIpAddress(u32* out) { Result nifmGetCurrentIpAddress(u32* out) {
return _nifmCmdNoInOutU32(&g_nifmIGS, out, 12); return _nifmCmdNoInOutU32(&g_nifmIGS, out, 12);
} }
@ -141,6 +151,15 @@ Result nifmIsEthernetCommunicationEnabled(bool* out) {
return _nifmCmdNoInOutBool(&g_nifmIGS, out, 20); return _nifmCmdNoInOutBool(&g_nifmIGS, out, 20);
} }
bool nifmIsAnyInternetRequestAccepted(NifmClientId id) {
u8 tmp=0;
Result rc = serviceDispatchOut(&g_nifmIGS, 21, tmp,
.buffer_attrs = { SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_In },
.buffers = { { &id, sizeof(id) } },
);
return R_SUCCEEDED(rc) ? tmp & 1 : 0;
}
Result nifmIsAnyForegroundRequestAccepted(bool* out) { Result nifmIsAnyForegroundRequestAccepted(bool* out) {
return _nifmCmdNoInOutBool(&g_nifmIGS, out, 22); return _nifmCmdNoInOutBool(&g_nifmIGS, out, 22);
} }

View File

@ -4,6 +4,7 @@
#include "runtime/hosversion.h" #include "runtime/hosversion.h"
#include "services/ns.h" #include "services/ns.h"
#include "services/async.h" #include "services/async.h"
#include "services/nifm.h"
static Service g_nsAppManSrv, g_nsGetterSrv; static Service g_nsAppManSrv, g_nsGetterSrv;
static Service g_nsvmSrv; static Service g_nsvmSrv;
@ -109,6 +110,35 @@ static Result _nsCmdNoInOutU64(Service* srv, u64 *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out); return serviceDispatchOut(srv, cmd_id, *out);
} }
static Result _nsCmdInU8U64NoOut(Service* srv, u8 in8, u64 in64, u32 cmd_id) {
const struct {
u8 in8;
u8 pad[7];
u64 in64;
} in = { in8, {0}, in64 };
return serviceDispatchIn(srv, cmd_id, in);
}
static Result _nsCmdInU64OutStorageIdS64(Service* srv, u64 inval, NcmStorageId *storage_id, s64 *outval, u32 cmd_id) {
struct {
u8 storage_id;
u8 pad[7];
s64 outval;
} out;
Result rc = serviceDispatchInOut(srv, cmd_id, inval, out);
if (R_SUCCEEDED(rc)) {
if (storage_id) *storage_id = out.storage_id;
if (outval) *outval = out.outval;
}
return rc;
}
static Result _nsCmdInUidNoOut(Service* srv, AccountUid uid, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, uid);
}
static Result _nsCmdNoInOutSystemUpdateProgress(Service* srv, NsSystemUpdateProgress *out, u32 cmd_id) { static Result _nsCmdNoInOutSystemUpdateProgress(Service* srv, NsSystemUpdateProgress *out, u32 cmd_id) {
return serviceDispatchOut(srv, cmd_id, *out); return serviceDispatchOut(srv, cmd_id, *out);
} }
@ -168,6 +198,42 @@ static Result _nsCmdNoInOutAsyncResult(Service* srv, AsyncResult *a, u32 cmd_id)
return rc; 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) { Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entry_offset, s32* out_entrycount) {
return serviceDispatchInOut(&g_nsAppManSrv, 0, entry_offset, *out_entrycount, return serviceDispatchInOut(&g_nsAppManSrv, 0, entry_offset, *out_entrycount,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
@ -175,23 +241,217 @@ Result nsListApplicationRecord(NsApplicationRecord* records, s32 count, s32 entr
); );
} }
Result nsListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount) { Result nsGetApplicationRecordUpdateSystemEvent(Event* out_event) {
const struct { return _nsCmdGetEvent(&g_nsAppManSrv, out_event, true, 2);
s32 index; }
u64 application_id;
} in = { index, application_id };
return serviceDispatchInOut(&g_nsAppManSrv, 601, in, *out_entrycount, Result nsGetApplicationViewDeprecated(NsApplicationViewDeprecated *views, const u64 *application_ids, s32 count) {
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, return serviceDispatch(&g_nsAppManSrv, 3,
.buffers = { { list, count*sizeof(NsApplicationContentMetaStatus) } }, .buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ views, count*sizeof(NsApplicationViewDeprecated) },
{ application_ids, count*sizeof(u64) },
},
); );
} }
Result nsDeleteApplicationEntity(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 4);
}
Result nsDeleteApplicationCompletely(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 5);
}
Result nsDeleteRedundantApplicationEntity(void) {
return _nsCmdNoIO(&g_nsAppManSrv, 7);
}
Result nsIsApplicationEntityMovable(u64 application_id, NcmStorageId storage_id, bool *out) {
const struct {
u8 storage_id;
u8 pad[7];
u64 application_id;
} in = { storage_id, {0}, application_id };
u8 tmp=0;
Result rc = serviceDispatchInOut(&g_nsAppManSrv, 8, in, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
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);
}
Result nsResumeApplicationDownload(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 33);
}
Result nsCheckApplicationLaunchVersion(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 38);
}
Result nsCalculateApplicationDownloadRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size) {
return _nsCmdInU64OutStorageIdS64(&g_nsAppManSrv, application_id, storage_id, size, 41);
}
Result nsCleanupSdCard(void) {
return _nsCmdNoIO(&g_nsAppManSrv, 42);
}
Result nsGetSdCardMountStatusChangedEvent(Event* out_event) {
return _nsCmdGetEvent(&g_nsAppManSrv, out_event, false, 44);
}
Result nsGetTotalSpaceSize(NcmStorageId storage_id, s64 *size) {
return _nsCmdInU64OutU64(&g_nsAppManSrv, storage_id, (u64*)size, 47);
}
Result nsGetFreeSpaceSize(NcmStorageId storage_id, s64 *size) {
return _nsCmdInU64OutU64(&g_nsAppManSrv, storage_id, (u64*)size, 48);
}
Result nsGetGameCardUpdateDetectionEvent(Event* out_event) {
return _nsCmdGetEvent(&g_nsAppManSrv, out_event, false, 52);
}
Result nsDisableApplicationAutoDelete(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 53);
}
Result nsEnableApplicationAutoDelete(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 54);
}
Result nsSetApplicationTerminateResult(u64 application_id, Result res) {
const struct {
Result res;
u32 pad;
u64 application_id;
} in = { res, 0, application_id };
return serviceDispatchIn(&g_nsAppManSrv, 56, in);
}
Result nsClearApplicationTerminateResult(u64 application_id) {
return _nsCmdInU64(&g_nsAppManSrv, application_id, 57);
}
Result nsGetLastSdCardMountUnexpectedResult(void) {
return _nsCmdNoIO(&g_nsAppManSrv, 58);
}
Result nsGetRequestServerStopper(NsRequestServerStopper *r) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsGetSession(&g_nsAppManSrv, &r->s, 65);
}
Result nsCancelApplicationApplyDelta(u64 application_id) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU64(&g_nsAppManSrv, application_id, 67);
}
Result nsResumeApplicationApplyDelta(u64 application_id) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU64(&g_nsAppManSrv, application_id, 68);
}
Result nsCalculateApplicationApplyDeltaRequiredSize(u64 application_id, NcmStorageId *storage_id, s64 *size) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU64OutStorageIdS64(&g_nsAppManSrv, application_id, storage_id, size, 69);
}
Result nsResumeAll(void) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoIO(&g_nsAppManSrv, 70);
}
Result nsGetStorageSize(NcmStorageId storage_id, s64 *total_space_size, s64 *free_space_size) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
struct {
s64 total_space_size;
s64 free_space_size;
} out;
u8 tmp = storage_id;
Result rc = serviceDispatchInOut(&g_nsAppManSrv, 71, tmp, out);
if (R_SUCCEEDED(rc)) {
if (total_space_size) *total_space_size = out.total_space_size;
if (free_space_size) *free_space_size = out.free_space_size;
}
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;
u64 system_save_data_id;
} in = { uid, system_save_data_id };
return serviceDispatchIn(&g_nsAppManSrv, 210, in);
}
Result nsDeleteSaveData(FsSaveDataSpaceId save_data_space_id, u64 save_data_id) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU8U64NoOut(&g_nsAppManSrv, save_data_space_id, save_data_id, 211);
}
Result nsUnregisterNetworkServiceAccount(AccountUid uid) {
return _nsCmdInUidNoOut(&g_nsAppManSrv, uid, 220);
}
Result nsUnregisterNetworkServiceAccountWithUserSaveDataDeletion(AccountUid uid) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInUidNoOut(&g_nsAppManSrv, uid, 221);
}
Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size) { Result nsGetApplicationControlData(NsApplicationControlSource source, u64 application_id, NsApplicationControlData* buffer, size_t size, u64* actual_size) {
const struct { const struct {
u8 source; u8 source;
u8 pad[7];
u64 application_id; u64 application_id;
} in = { source, application_id }; } in = { source, {0}, application_id };
u32 tmp=0; u32 tmp=0;
@ -203,12 +463,258 @@ Result nsGetApplicationControlData(NsApplicationControlSource source, u64 applic
return rc; return rc;
} }
Result nsGetTotalSpaceSize(NcmStorageId storage_id, u64 *size) { Result nsRequestDownloadApplicationControlData(AsyncResult *a, u64 application_id) {
return _nsCmdInU64OutU64(&g_nsAppManSrv, storage_id, size, 47); Result rc = _nsCheckNifm();
if (R_FAILED(rc)) return rc;
return _nsCmdInU64OutAsyncResult(&g_nsAppManSrv, a, application_id, 402);
} }
Result nsGetFreeSpaceSize(NcmStorageId storage_id, u64 *size) { Result nsRequestCheckGameCardRegistration(AsyncResult *a, u64 application_id) {
return _nsCmdInU64OutU64(&g_nsAppManSrv, storage_id, size, 48); 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);
return _nsCmdGetEvent(&g_nsAppManSrv, out_event, false, 505);
}
Result nsIsGameCardInserted(bool *out) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoInOutBool(&g_nsAppManSrv, out, 506);
}
Result nsEnsureGameCardAccess(void) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoIO(&g_nsAppManSrv, 507);
}
Result nsGetLastGameCardMountFailureResult(void) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoIO(&g_nsAppManSrv, 508);
}
Result nsListApplicationIdOnGameCard(u64 *application_ids, s32 count, s32 *total_out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_nsAppManSrv, 509, *total_out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { application_ids, count*sizeof(u64) } },
);
}
Result nsListApplicationContentMetaStatus(u64 application_id, s32 index, NsApplicationContentMetaStatus* list, s32 count, s32* out_entrycount) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
const struct {
s32 index;
u32 pad;
u64 application_id;
} in = { index, 0, application_id };
return serviceDispatchInOut(&g_nsAppManSrv, 601, in, *out_entrycount,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { list, count*sizeof(NsApplicationContentMetaStatus) } },
);
}
Result nsTouchApplication(u64 application_id) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU64(&g_nsAppManSrv, application_id, 904);
}
Result nsIsApplicationUpdateRequested(u64 application_id, bool *flag, u32 *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
struct {
u8 flag;
u8 pad[3];
u32 out;
} tmpout;
Result rc = serviceDispatchInOut(&g_nsAppManSrv, 906, application_id, tmpout);
if (R_SUCCEEDED(rc)) {
if (flag) *flag = tmpout.flag & 1;
if (out) *out = tmpout.out;
}
return rc;
}
Result nsWithdrawApplicationUpdateRequest(u64 application_id) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdInU64(&g_nsAppManSrv, application_id, 907);
}
Result nsIsAnyApplicationEntityInstalled(u64 application_id, bool *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u8 tmp=0;
Result rc = serviceDispatchInOut(&g_nsAppManSrv, 1300, application_id, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
Result nsCleanupUnavailableAddOnContents(u64 application_id, AccountUid uid) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
const struct {
u64 application_id;
AccountUid uid;
} in = { application_id, uid };
return serviceDispatchIn(&g_nsAppManSrv, 1309, in);
}
Result nsFormatSdCard(void) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoIO(&g_nsAppManSrv, 1500);
}
Result nsNeedsSystemUpdateToFormatSdCard(bool *out) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoInOutBool(&g_nsAppManSrv, out, 1501);
}
Result nsGetLastSdCardFormatUnexpectedResult(void) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _nsCmdNoIO(&g_nsAppManSrv, 1502);
}
Result nsGetApplicationView(NsApplicationView *views, const u64 *application_ids, s32 count) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_nsAppManSrv, 1701,
.buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ views, count*sizeof(NsApplicationView) },
{ application_ids, count*sizeof(u64) },
},
);
}
Result nsGetApplicationViewDownloadErrorContext(u64 application_id, ErrorContext *context) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchIn(&g_nsAppManSrv, 1703, application_id,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { context, sizeof(*context) } },
);
}
Result nsGetApplicationViewWithPromotionInfo(NsApplicationViewWithPromotionInfo *out, const u64 *application_ids, s32 count) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_nsAppManSrv, 1704,
.buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ out, count*sizeof(NsApplicationViewWithPromotionInfo) },
{ application_ids, count*sizeof(u64) },
},
);
}
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) { Result nsGetSystemDeliveryInfo(NsSystemDeliveryInfo *info) {
@ -482,6 +988,76 @@ Result nsGetApplicationDeliveryInfoHash(const NsApplicationDeliveryInfo *info, s
return rc; return rc;
} }
Result nsGetApplicationTerminateResult(u64 application_id, Result *res) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
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);
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);
}
Result nsGetPromotionInfo(NsPromotionInfo *promotion, u64 application_id, AccountUid uid) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
// These are arrays, but official sw uses hard-coded value 1 for array-count.
return serviceDispatch(&g_nsAppManSrv, 2400,
.buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
},
.buffers = {
{ promotion, sizeof(NsPromotionInfo) },
{ &application_id, sizeof(u64) },
{ &uid, sizeof(AccountUid) },
},
);
}
// IRequestServerStopper
void nsRequestServerStopperClose(NsRequestServerStopper *r) {
serviceClose(&r->s);
}
// ns:vm // ns:vm
NX_GENERATE_SERVICE_GUARD(nsvm); NX_GENERATE_SERVICE_GUARD(nsvm);

View File

@ -781,6 +781,61 @@ Result setsysSetTouchScreenMode(SetSysTouchScreenMode mode) {
return _setCmdInU32NoOut(&g_setsysSrv, mode, 188); return _setCmdInU32NoOut(&g_setsysSrv, mode, 188);
} }
Result setcalGetBdAddress(SetCalBdAddress *out) {
return serviceDispatchOut(&g_setsysSrv, 0, *out);
}
Result setcalGetConfigurationId1(SetCalConfigurationId1 *out) {
return serviceDispatchOut(&g_setsysSrv, 1, *out);
}
Result setcalGetAccelerometerOffset(SetCalAccelerometerOffset *out) {
return serviceDispatchOut(&g_setsysSrv, 2, *out);
}
Result setcalGetAccelerometerScale(SetCalAccelerometerScale *out) {
return serviceDispatchOut(&g_setsysSrv, 3, *out);
}
Result setcalGetGyroscopeOffset(SetCalAccelerometerOffset *out) {
return serviceDispatchOut(&g_setsysSrv, 4, *out);
}
Result setcalGetGyroscopeScale(SetCalGyroscopeScale *out) {
return serviceDispatchOut(&g_setsysSrv, 5, *out);
}
Result setcalGetWirelessLanMacAddress(SetCalMacAddress *out) {
return serviceDispatchOut(&g_setsysSrv, 6, *out);
}
Result setcalGetWirelessLanCountryCodeCount(s32 *out_count) {
return _setCmdNoInOutU32(&g_setsysSrv, (u32*)out_count, 7);
}
Result setcalGetWirelessLanCountryCodes(s32 *total_out, SetCalCountryCode *codes, s32 count) {
return serviceDispatchOut(&g_setsysSrv, 8, *total_out,
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_Out },
.buffers = { { codes, count*sizeof(SetCalCountryCode) } },
);
}
Result setcalGetSerialNumber(SetCalSerialNumber *out) {
return serviceDispatchOut(&g_setsysSrv, 9, *out);
}
Result setcalSetInitialSystemAppletProgramId(u64 program_id) {
return _setCmdInU64NoOut(&g_setsysSrv, program_id, 10);
}
Result setcalSetOverlayDispProgramId(u64 program_id) {
return _setCmdInU64NoOut(&g_setsysSrv, program_id, 11);
}
Result setcalGetBatteryLot(SetBatteryLot *out) {
return serviceDispatchOut(&g_setsysSrv, 12, *out);
}
Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out) { Result setcalGetEciDeviceCertificate(SetCalEccB233DeviceCertificate *out) {
return serviceDispatch(&g_setcalSrv, 14, return serviceDispatch(&g_setcalSrv, 14,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
@ -823,9 +878,156 @@ Result setcalGetGameCardCertificate(SetCalGameCardCertificate *out) {
); );
} }
Result setcalGetEciDeviceKey(SetCalEccB233DeviceKey *out) {
return serviceDispatchOut(&g_setcalSrv, 20, *out);
}
Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out) { Result setcalGetEticketDeviceKey(SetCalRsa2048DeviceKey *out) {
return serviceDispatch(&g_setcalSrv, 21, return serviceDispatch(&g_setcalSrv, 21,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalRsa2048DeviceKey) } }, .buffers = { { out, sizeof(SetCalRsa2048DeviceKey) } },
); );
} }
Result setcalGetSpeakerParameter(SetCalSpeakerParameter *out) {
return serviceDispatchOut(&g_setcalSrv, 22, *out);
}
Result setcalGetLcdVendorId(u32 *out_vendor_id) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU32(&g_setcalSrv, out_vendor_id, 23);
}
Result setcalGetEciDeviceCertificate2(SetCalRsa2048DeviceCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setcalSrv, 24,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalRsa2048DeviceCertificate) } },
);
}
Result setcalGetEciDeviceKey2(SetCalRsa2048DeviceKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatch(&g_setcalSrv, 25,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { out, sizeof(SetCalRsa2048DeviceKey) } },
);
}
Result setcalGetAmiiboKey(SetCalAmiiboKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 26, *out);
}
Result setcalGetAmiiboEcqvCertificate(SetCalAmiiboEcqvCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 27, *out);
}
Result setcalGetAmiiboEcdsaCertificate(SetCalAmiiboEcdsaCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 28, *out);
}
Result setcalGetAmiiboEcqvBlsKey(SetCalAmiiboEcqvBlsKey *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 29, *out);
}
Result setcalGetAmiiboEcqvBlsCertificate(SetCalAmiiboEcqvBlsCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 30, *out);
}
Result setcalGetAmiiboEcqvBlsRootCertificate(SetCalAmiiboEcqvBlsRootCertificate *out) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 31, *out);
}
Result setcalGetUsbTypeCPowerSourceCircuitVersion(u8 *out_version) {
if (hosversionBefore(5,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_version, 32);
}
Result setcalGetAnalogStickModuleTypeL(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 33);
}
Result setcalGetAnalogStickModelParameterL(SetCalAnalogStickModelParameter *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 34, *out);
}
Result setcalGetAnalogStickFactoryCalibrationL(SetCalAnalogStickFactoryCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 35, *out);
}
Result setcalGetAnalogStickModuleTypeR(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 36);
}
Result setcalGetAnalogStickModelParameterR(SetCalAnalogStickModelParameter *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 37, *out);
}
Result setcalGetAnalogStickFactoryCalibrationR(SetCalAnalogStickFactoryCalibration *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 38, *out);
}
Result setcalGetConsoleSixAxisSensorModuleType(u8 *out_type) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_type, 39);
}
Result setcalGetConsoleSixAxisSensorHorizontalOffset(SetCalConsoleSixAxisSensorHorizontalOffset *out) {
if (hosversionBefore(8,1,1))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return serviceDispatchOut(&g_setcalSrv, 40, *out);
}
Result setcalGetBatteryVersion(u8 *out_version) {
if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _setCmdNoInOutU8(&g_setcalSrv, out_version, 41);
}

View File

@ -294,25 +294,42 @@ Result splCryptoGetSecurityEngineEvent(Event *out_event) {
/* SPL IRsaService functionality. NOTE: IRsaService is not a real part of inheritance, unlike ICryptoService/IGeneralService. */ /* SPL IRsaService functionality. NOTE: IRsaService is not a real part of inheritance, unlike ICryptoService/IGeneralService. */
Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size) { Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size) {
const struct { if (hosversionBefore(5,0,0)) {
SplKey sealed_kek; const struct {
SplKey wrapped_key; SplKey sealed_kek;
u32 version; SplKey wrapped_key;
} in = { *((const SplKey *)sealed_kek), *((const SplKey *)wrapped_key), version }; u32 version;
return serviceDispatchIn(_splGetRsaSrv(), 13, in, } in = { *((const SplKey *)sealed_kek), *((const SplKey *)wrapped_key), version };
.buffer_attrs = { return serviceDispatchIn(_splGetRsaSrv(), 13, in,
SfBufferAttr_HipcPointer | SfBufferAttr_Out, .buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_In, SfBufferAttr_HipcPointer | SfBufferAttr_Out,
}, SfBufferAttr_HipcPointer | SfBufferAttr_In,
.buffers = { },
{ dst, dst_size }, .buffers = {
{ wrapped_rsa_key, wrapped_rsa_key_size }, { dst, dst_size },
}, { wrapped_rsa_key, wrapped_rsa_key_size },
); },
);
} else {
const struct {
SplKey sealed_kek;
SplKey wrapped_key;
} in = { *((const SplKey *)sealed_kek), *((const SplKey *)wrapped_key) };
return serviceDispatchIn(_splGetRsaSrv(), 13, in,
.buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_Out,
SfBufferAttr_HipcPointer | SfBufferAttr_In,
},
.buffers = {
{ dst, dst_size },
{ wrapped_rsa_key, wrapped_rsa_key_size },
},
);
}
} }
/* Helper function for RSA key importing. */ /* Helper function for RSA key importing. */
NX_INLINE Result _splImportSecureExpModKey(Service* srv, u32 cmd_id, const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { static Result _splImportSecureExpModKeyDeprecated(Service* srv, u32 cmd_id, const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) {
const struct { const struct {
SplKey sealed_kek; SplKey sealed_kek;
SplKey wrapped_key; SplKey wrapped_key;
@ -328,7 +345,22 @@ NX_INLINE Result _splImportSecureExpModKey(Service* srv, u32 cmd_id, const void
); );
} }
NX_INLINE Result _splSecureExpMod(Service* srv, u32 cmd_id, const void *input, const void *modulus, void *dst) { static Result _splImportSecureExpModKey(Service* srv, u32 cmd_id, const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size) {
const struct {
SplKey sealed_kek;
SplKey wrapped_key;
} in = { *((const SplKey *)sealed_kek), *((const SplKey *)wrapped_key) };
return serviceDispatchIn(srv, cmd_id, in,
.buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_In,
},
.buffers = {
{ wrapped_rsa_key, wrapped_rsa_key_size },
},
);
}
static Result _splSecureExpMod(Service* srv, u32 cmd_id, const void *input, const void *modulus, void *dst) {
return serviceDispatch(srv, cmd_id, return serviceDispatch(srv, cmd_id,
.buffer_attrs = { .buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_Out, SfBufferAttr_HipcPointer | SfBufferAttr_Out,
@ -344,11 +376,11 @@ NX_INLINE Result _splSecureExpMod(Service* srv, u32 cmd_id, const void *input, c
} }
/* SPL ISslService functionality. */ /* SPL ISslService functionality. */
Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size) {
if (hosversionBefore(5,0,0)) { if (hosversionBefore(5,0,0)) {
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
} }
return _splImportSecureExpModKey(&g_splSslSrv, 26, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); return _splImportSecureExpModKey(&g_splSslSrv, 26, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size);
} }
Result splSslSecureExpMod(const void *input, const void *modulus, void *dst) { Result splSslSecureExpMod(const void *input, const void *modulus, void *dst) {
@ -359,7 +391,7 @@ Result splSslSecureExpMod(const void *input, const void *modulus, void *dst) {
} }
/* SPL IEsService functionality. */ /* SPL IEsService functionality. */
NX_INLINE Result _splUnwrapRsaOaepWrappedKey(Service *srv, u32 cmd_id, const void *rsa_wrapped_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_key) { static Result _splUnwrapRsaOaepWrappedKey(Service *srv, u32 cmd_id, const void *rsa_wrapped_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_key) {
return serviceDispatchInOut(srv, cmd_id, key_generation, *((SplKey *)out_sealed_key), return serviceDispatchInOut(srv, cmd_id, key_generation, *((SplKey *)out_sealed_key),
.buffer_attrs = { .buffer_attrs = {
SfBufferAttr_HipcPointer | SfBufferAttr_In, SfBufferAttr_HipcPointer | SfBufferAttr_In,
@ -374,7 +406,7 @@ NX_INLINE Result _splUnwrapRsaOaepWrappedKey(Service *srv, u32 cmd_id, const voi
); );
} }
NX_INLINE Result _splLoadContentKey(Service *srv, u32 cmd_id, const void *sealed_key, u32 keyslot) { static Result _splLoadContentKey(Service *srv, u32 cmd_id, const void *sealed_key, u32 keyslot) {
const struct { const struct {
SplKey sealed_key; SplKey sealed_key;
u32 keyslot; u32 keyslot;
@ -383,7 +415,11 @@ NX_INLINE Result _splLoadContentKey(Service *srv, u32 cmd_id, const void *sealed
} }
Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) {
return _splImportSecureExpModKey(_splGetEsSrv(), 17, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); if (hosversionBefore(5,0,0)) {
return _splImportSecureExpModKeyDeprecated(_splGetEsSrv(), 17, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version);
} else {
return _splImportSecureExpModKey(_splGetEsSrv(), 17, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size);
}
} }
Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey) { Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey) {
@ -401,11 +437,11 @@ Result splEsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_g
return serviceDispatchInOut(_splGetEsSrv(), 20, in, *((SplKey *)out_sealed_titlekey)); return serviceDispatchInOut(_splGetEsSrv(), 20, in, *((SplKey *)out_sealed_titlekey));
} }
Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size) {
if (hosversionBefore(5,0,0)) { if (hosversionBefore(5,0,0)) {
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
} }
return _splImportSecureExpModKey(&g_splEsSrv, 28, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); return _splImportSecureExpModKey(&g_splEsSrv, 28, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size);
} }
Result splEsSecureExpMod(const void *input, const void *modulus, void *dst) { Result splEsSecureExpMod(const void *input, const void *modulus, void *dst) {
@ -431,7 +467,11 @@ Result splEsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot) {
/* SPL IFsService functionality. */ /* SPL IFsService functionality. */
Result splFsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) { Result splFsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version) {
return _splImportSecureExpModKey(_splGetFsSrv(), 9, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version); if (hosversionBefore(5,0,0)) {
return _splImportSecureExpModKeyDeprecated(_splGetFsSrv(), 9, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size, version);
} else {
return _splImportSecureExpModKey(_splGetFsSrv(), 9, sealed_kek, wrapped_key, wrapped_rsa_key, wrapped_rsa_key_size);
}
} }
Result splFsSecureExpMod(const void *input, const void *modulus, void *dst) { Result splFsSecureExpMod(const void *input, const void *modulus, void *dst) {