libnx  v4.7.0
ncm.h
Go to the documentation of this file.
1 /**
2  * @file ncm.h
3  * @brief Content Manager (ncm) service IPC wrapper.
4  * @author Adubbz & zhuowei
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../services/ncm_types.h"
10 #include "../services/fs.h"
11 #include "../sf/service.h"
12 
13 /// ContentStorage
14 typedef struct {
15  Service s; ///< IContentStorage
17 
18 /// ContentMetaDatabase
19 typedef struct {
20  Service s; ///< IContentMetaDatabase
22 
23 /// RightsId
24 typedef struct {
25  FsRightsId rights_id;
26  u8 key_generation; ///< [3.0.0+]
27  u8 pad[7]; ///< [3.0.0+]
28 } NcmRightsId;
29 
30 /// Initialize ncm.
32 
33 /// Exit ncm.
34 void ncmExit(void);
35 
36 /// Gets the Service object for the actual ncm service session.
38 
39 Result ncmCreateContentStorage(NcmStorageId storage_id);
40 Result ncmCreateContentMetaDatabase(NcmStorageId storage_id);
41 Result ncmVerifyContentStorage(NcmStorageId storage_id);
42 Result ncmVerifyContentMetaDatabase(NcmStorageId storage_id);
43 Result ncmOpenContentStorage(NcmContentStorage* out_content_storage, NcmStorageId storage_id);
44 Result ncmOpenContentMetaDatabase(NcmContentMetaDatabase* out_content_meta_database, NcmStorageId storage_id);
47 Result ncmCleanupContentMetaDatabase(NcmStorageId storage_id);
48 Result ncmActivateContentStorage(NcmStorageId storage_id); ///< [2.0.0+]
52 Result ncmInvalidateRightsIdCache(void); ///< [9.0.0+]
54 
55 void ncmContentStorageClose(NcmContentStorage* cs);
56 Result ncmContentStorageGeneratePlaceHolderId(NcmContentStorage* cs, NcmPlaceHolderId* out_id);
57 Result ncmContentStorageCreatePlaceHolder(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id, s64 size);
58 Result ncmContentStorageDeletePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id);
59 Result ncmContentStorageHasPlaceHolder(NcmContentStorage* cs, bool* out, const NcmPlaceHolderId* placeholder_id);
60 Result ncmContentStorageWritePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, u64 offset, const void* data, size_t data_size);
61 Result ncmContentStorageRegister(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id);
62 Result ncmContentStorageDelete(NcmContentStorage* cs, const NcmContentId* content_id);
63 Result ncmContentStorageHas(NcmContentStorage* cs, bool* out, const NcmContentId* content_id);
64 Result ncmContentStorageGetPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmContentId* content_id);
65 Result ncmContentStorageGetPlaceHolderPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmPlaceHolderId* placeholder_id);
66 Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs);
67 Result ncmContentStorageListPlaceHolder(NcmContentStorage* cs, NcmPlaceHolderId* out_ids, s32 count, s32* out_count);
68 Result ncmContentStorageGetContentCount(NcmContentStorage* cs, s32* out_count);
69 Result ncmContentStorageListContentId(NcmContentStorage* cs, NcmContentId* out_ids, s32 count, s32* out_count, s32 start_offset);
70 Result ncmContentStorageGetSizeFromContentId(NcmContentStorage* cs, s64* out_size, const NcmContentId* content_id);
71 Result ncmContentStorageDisableForcibly(NcmContentStorage* cs);
72 Result ncmContentStorageRevertToPlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, const NcmContentId* old_content_id, const NcmContentId* new_content_id); ///< [2.0.0+]
73 Result ncmContentStorageSetPlaceHolderSize(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, s64 size); ///< [2.0.0+]
74 Result ncmContentStorageReadContentIdFile(NcmContentStorage* cs, void* out_data, size_t out_data_size, const NcmContentId* content_id, s64 offset); ///< [2.0.0+]
77 Result ncmContentStorageWriteContentForDebug(NcmContentStorage* cs, const NcmContentId* content_id, s64 offset, const void* data, size_t data_size); ///< [2.0.0+]
81 Result ncmContentStorageGetSizeFromPlaceHolderId(NcmContentStorage* cs, s64* out_size, const NcmPlaceHolderId* placeholder_id); ///< [4.0.0+]
83 Result ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, const NcmContentId* cache_content_id, FsContentAttributes attr); ///< [8.0.0+]
84 Result ncmContentStorageRegisterPath(NcmContentStorage* cs, const NcmContentId* content_id, const char *path); ///< [13.0.0+]
87 
88 void ncmContentMetaDatabaseClose(NcmContentMetaDatabase* db);
89 Result ncmContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, const void* data, u64 data_size);
90 Result ncmContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u64* out_size, void* out_data, u64 out_data_size);
91 Result ncmContentMetaDatabaseRemove(NcmContentMetaDatabase* db, const NcmContentMetaKey *key);
92 Result ncmContentMetaDatabaseGetContentIdByType(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type);
93 Result ncmContentMetaDatabaseListContentInfo(NcmContentMetaDatabase* db, s32* out_entries_written, NcmContentInfo* out_info, s32 count, const NcmContentMetaKey* key, s32 start_index);
94 Result ncmContentMetaDatabaseList(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type, u64 id, u64 id_min, u64 id_max, NcmContentInstallType install_type);
95 Result ncmContentMetaDatabaseGetLatestContentMetaKey(NcmContentMetaDatabase* db, NcmContentMetaKey* out_key, u64 id);
96 Result ncmContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmApplicationContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type);
97 Result ncmContentMetaDatabaseHas(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key);
98 Result ncmContentMetaDatabaseHasAll(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* keys, s32 count);
99 Result ncmContentMetaDatabaseGetSize(NcmContentMetaDatabase* db, u64* out_size, const NcmContentMetaKey* key);
100 Result ncmContentMetaDatabaseGetRequiredSystemVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key);
101 Result ncmContentMetaDatabaseGetPatchContentMetaId(NcmContentMetaDatabase* db, u64* out_patch_id, const NcmContentMetaKey* key);
102 Result ncmContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db);
103 Result ncmContentMetaDatabaseLookupOrphanContent(NcmContentMetaDatabase* db, bool* out_orphaned, const NcmContentId* content_ids, s32 count);
104 Result ncmContentMetaDatabaseCommit(NcmContentMetaDatabase* db);
105 Result ncmContentMetaDatabaseHasContent(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key, const NcmContentId* content_id);
106 Result ncmContentMetaDatabaseListContentMetaInfo(NcmContentMetaDatabase* db, s32* out_entries_written, void* out_meta_info, s32 count, const NcmContentMetaKey* key, s32 start_index);
107 Result ncmContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u8* out);
FsContentStorageId
Definition: fs.h:186
FsContentAttributes
FsContentAttributes.
Definition: fs.h:370
Result ncmInvalidateRightsIdCache(void)
[9.0.0+]
Result ncmContentStorageRegisterPath(NcmContentStorage *cs, const NcmContentId *content_id, const char *path)
[13.0.0+]
Result ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmPlaceHolderId *placeholder_id, const NcmContentId *cache_content_id, FsContentAttributes attr)
[8.0.0+]
Result ncmActivateContentStorage(NcmStorageId storage_id)
[2.0.0+]
Result ncmContentStorageGetTotalSpaceSize(NcmContentStorage *cs, s64 *out_size)
[2.0.0+]
Result ncmContentStorageClearRegisteredPath(NcmContentStorage *cs)
[13.0.0+]
Result ncmContentStorageRepairInvalidFileAttribute(NcmContentStorage *cs)
[4.0.0+]
Result ncmInactivateContentMetaDatabase(NcmStorageId storage_id)
[2.0.0+]
Result ncmContentStorageGetSizeFromPlaceHolderId(NcmContentStorage *cs, s64 *out_size, const NcmPlaceHolderId *placeholder_id)
[4.0.0+]
Result ncmContentStorageGetProgramId(NcmContentStorage *cs, u64 *out, const NcmContentId *content_id, FsContentAttributes attr)
[17.0.0+]
Result ncmContentStorageWriteContentForDebug(NcmContentStorage *cs, const NcmContentId *content_id, s64 offset, const void *data, size_t data_size)
[2.0.0+]
Service * ncmGetServiceSession(void)
Gets the Service object for the actual ncm service session.
Result ncmContentMetaDatabaseGetPlatform(NcmContentMetaDatabase *db, u8 *out, const NcmContentMetaKey *key)
[17.0.0+]
Result ncmContentMetaDatabaseGetRequiredApplicationVersion(NcmContentMetaDatabase *db, u32 *out_version, const NcmContentMetaKey *key)
[2.0.0+]
Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmContentId *content_id, FsContentAttributes attr)
[2.0.0+]
Result ncmContentStorageRevertToPlaceHolder(NcmContentStorage *cs, const NcmPlaceHolderId *placeholder_id, const NcmContentId *old_content_id, const NcmContentId *new_content_id)
[2.0.0+]
Result ncmContentStorageFlushPlaceHolder(NcmContentStorage *cs)
[3.0.0+]
Result ncmCloseContentStorageForcibly(NcmStorageId storage_id)
[1.0.0]
Result ncmContentStorageSetPlaceHolderSize(NcmContentStorage *cs, const NcmPlaceHolderId *placeholder_id, s64 size)
[2.0.0+]
Result ncmActivateFsContentStorage(FsContentStorageId fs_storage_id)
[16.0.0+]
Result ncmContentStorageGetRightsIdFromPlaceHolderId(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmPlaceHolderId *placeholder_id, FsContentAttributes attr)
[2.0.0+]
Result ncmContentStorageReadContentIdFile(NcmContentStorage *cs, void *out_data, size_t out_data_size, const NcmContentId *content_id, s64 offset)
[2.0.0+]
Result ncmCloseContentMetaDatabaseForcibly(NcmStorageId storage_id)
[1.0.0]
void ncmExit(void)
Exit ncm.
Result ncmInactivateContentStorage(NcmStorageId storage_id)
[2.0.0+]
Result ncmActivateContentMetaDatabase(NcmStorageId storage_id)
[2.0.0+]
Result ncmContentStorageGetFreeSpaceSize(NcmContentStorage *cs, s64 *out_size)
[2.0.0+]
Result ncmInitialize(void)
Initialize ncm.
Result ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(NcmContentMetaDatabase *db, NcmContentId *out_content_id, const NcmContentMetaKey *key, NcmContentType type, u8 id_offset)
[5.0.0+]
NcmStorageId
StorageId.
Definition: ncm_types.h:12
NcmContentInstallType
ContentInstallType.
Definition: ncm_types.h:57
NcmContentMetaType
ContentMetaType.
Definition: ncm_types.h:34
NcmContentType
ContentType.
Definition: ncm_types.h:23
Definition: fs.h:23
ApplicationContentMetaKey.
Definition: ncm_types.h:88
ContentId.
Definition: ncm_types.h:69
ContentInfo.
Definition: ncm_types.h:94
ContentMetaDatabase.
Definition: ncm.h:19
Service s
IContentMetaDatabase.
Definition: ncm.h:20
ContentMetaKey.
Definition: ncm_types.h:79
ContentStorage.
Definition: ncm.h:14
Service s
IContentStorage.
Definition: ncm.h:15
PlaceHolderId.
Definition: ncm_types.h:74
RightsId.
Definition: ncm.h:24
u8 key_generation
[3.0.0+]
Definition: ncm.h:26
Service object structure.
Definition: service.h:14
int64_t s64
64-bit signed integer.
Definition: types.h:28
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21