libnx  v4.2.0
ncm_types.h
Go to the documentation of this file.
1 /**
2  * @file ncm_types.h
3  * @brief Content Manager (ncm) service types (see ncm.h for the rest).
4  * @author Adubbz, zhuowei, and yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../crypto/sha256.h"
10 
11 /// StorageId
12 typedef enum {
13  NcmStorageId_None = 0, ///< None
14  NcmStorageId_Host = 1, ///< Host
15  NcmStorageId_GameCard = 2, ///< GameCard
16  NcmStorageId_BuiltInSystem = 3, ///< BuiltInSystem
17  NcmStorageId_BuiltInUser = 4, ///< BuiltInUser
18  NcmStorageId_SdCard = 5, ///< SdCard
19  NcmStorageId_Any = 6, ///< Any
20 } NcmStorageId;
21 
22 /// ContentType
23 typedef enum {
24  NcmContentType_Meta = 0, ///< Meta
25  NcmContentType_Program = 1, ///< Program
26  NcmContentType_Data = 2, ///< Data
27  NcmContentType_Control = 3, ///< Control
28  NcmContentType_HtmlDocument = 4, ///< HtmlDocument
29  NcmContentType_LegalInformation = 5, ///< LegalInformation
30  NcmContentType_DeltaFragment = 6, ///< DeltaFragment
32 
33 /// ContentMetaType
34 typedef enum {
35  NcmContentMetaType_Unknown = 0x0, ///< Unknown
36  NcmContentMetaType_SystemProgram = 0x1, ///< SystemProgram
37  NcmContentMetaType_SystemData = 0x2, ///< SystemData
38  NcmContentMetaType_SystemUpdate = 0x3, ///< SystemUpdate
39  NcmContentMetaType_BootImagePackage = 0x4, ///< BootImagePackage
40  NcmContentMetaType_BootImagePackageSafe = 0x5, ///< BootImagePackageSafe
41  NcmContentMetaType_Application = 0x80, ///< Application
42  NcmContentMetaType_Patch = 0x81, ///< Patch
43  NcmContentMetaType_AddOnContent = 0x82, ///< AddOnContent
44  NcmContentMetaType_Delta = 0x83, ///< Delta
46 
47 /// ContentMetaAttribute
48 typedef enum {
50  NcmContentMetaAttribute_IncludesExFatDriver = BIT(0), ///< IncludesExFatDriver
53 
54 /// ContentInstallType
55 typedef enum {
57  NcmContentInstallType_FragmentOnly = 1, ///< FragmentOnly
60 
61 /// ContentId
62 typedef struct {
63  alignas(4) u8 c[0x10]; ///< Id
64 } NcmContentId;
65 
66 /// PlaceHolderId
67 typedef struct {
68  alignas(8) Uuid uuid; ///< UUID
70 
71 /// ContentMetaKey
72 typedef struct {
73  u64 id; ///< Id.
74  u32 version; ///< Version.
75  u8 type; ///< \ref NcmContentMetaType
76  u8 install_type; ///< \ref NcmContentInstallType
77  u8 padding[2]; ///< Padding.
79 
80 /// ApplicationContentMetaKey
81 typedef struct {
82  NcmContentMetaKey key; ///< \ref NcmContentMetaKey
83  u64 application_id; ///< ApplicationId.
85 
86 /// ContentInfo
87 typedef struct {
88  NcmContentId content_id; ///< \ref NcmContentId
89  u8 size[0x6]; ///< Content size.
90  u8 content_type; ///< \ref NcmContentType.
91  u8 id_offset; ///< Offset of this content. Unused by most applications.
93 
94 /// PackagedContentInfo
95 typedef struct {
96  u8 hash[SHA256_HASH_SIZE];
97  NcmContentInfo info;
99 
100 /// ContentMetaInfo
101 typedef struct {
102  u64 id; ///< Id.
103  u32 version; ///< Version.
104  u8 type; ///< \ref NcmContentMetaType
105  u8 attr; ///< \ref NcmContentMetaAttribute
106  u8 padding[2]; ///< Padding.
108 
109 /// ContentMetaHeader
110 typedef struct {
111  u16 extended_header_size; ///< Size of optional struct that comes after this one.
112  u16 content_count; ///< Number of NcmContentInfos after the extra bytes.
113  u16 content_meta_count; ///< Number of NcmContentMetaInfos that come after the NcmContentInfos.
114  u8 attributes; ///< Usually None (0).
115  u8 storage_id; ///< Usually None (0).
117 
118 /// ApplicationMetaExtendedHeader
119 typedef struct {
120  u64 patch_id; ///< PatchId of this application's patch.
121  u32 required_system_version; ///< Firmware version required by this application.
122  u32 required_application_version; ///< [9.0.0+] Owner application version required by this application. Previously padding.
124 
125 /// PatchMetaExtendedHeader
126 typedef struct {
127  u64 application_id; ///< ApplicationId of this patch's corresponding application.
128  u32 required_system_version; ///< Firmware version required by this patch.
129  u32 extended_data_size; ///< Size of the extended data following the NcmContentInfos.
130  u8 reserved[0x8]; ///< Unused.
132 
133 /// AddOnContentMetaExtendedHeader
134 typedef struct {
135  u64 application_id; ///< ApplicationId of this add-on-content's corresponding application.
136  u32 required_application_version; ///< Version of the application required by this add-on-content.
137  u32 padding; ///< Padding.
139 
140 /// SystemUpdateMetaExtendedHeader
141 typedef struct {
142  u32 extended_data_size; ///< Size of the extended data after NcmContentInfos and NcmContentMetaInfos.
144 
145 /// ProgramLocation
146 typedef struct {
147  u64 program_id; ///< ProgramId
148  u8 storageID; ///< \ref NcmStorageId
149  u8 pad[7]; ///< Padding
NcmContentType_Meta
@ NcmContentType_Meta
Meta.
Definition: ncm_types.h:24
NcmContentInfo::content_type
u8 content_type
NcmContentType.
Definition: ncm_types.h:90
NcmContentMetaInfo
ContentMetaInfo.
Definition: ncm_types.h:101
NcmContentMetaType_BootImagePackage
@ NcmContentMetaType_BootImagePackage
BootImagePackage.
Definition: ncm_types.h:39
NcmContentMetaType_Application
@ NcmContentMetaType_Application
Application.
Definition: ncm_types.h:41
NcmContentInstallType_Unknown
@ NcmContentInstallType_Unknown
Unknown.
Definition: ncm_types.h:58
NcmContentMetaKey
ContentMetaKey.
Definition: ncm_types.h:72
NcmStorageId
NcmStorageId
StorageId.
Definition: ncm_types.h:12
NcmContentMetaAttribute
NcmContentMetaAttribute
ContentMetaAttribute.
Definition: ncm_types.h:48
NcmContentMetaHeader::extended_header_size
u16 extended_header_size
Size of optional struct that comes after this one.
Definition: ncm_types.h:111
NcmAddOnContentMetaExtendedHeader::required_application_version
u32 required_application_version
Version of the application required by this add-on-content.
Definition: ncm_types.h:136
NcmContentMetaHeader::content_meta_count
u16 content_meta_count
Number of NcmContentMetaInfos that come after the NcmContentInfos.
Definition: ncm_types.h:113
NcmApplicationContentMetaKey
ApplicationContentMetaKey.
Definition: ncm_types.h:81
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
NcmPatchMetaExtendedHeader::required_system_version
u32 required_system_version
Firmware version required by this patch.
Definition: ncm_types.h:128
NcmContentType
NcmContentType
ContentType.
Definition: ncm_types.h:23
NcmContentType_LegalInformation
@ NcmContentType_LegalInformation
LegalInformation.
Definition: ncm_types.h:29
NcmStorageId_GameCard
@ NcmStorageId_GameCard
GameCard.
Definition: ncm_types.h:15
NcmContentMetaHeader
ContentMetaHeader.
Definition: ncm_types.h:110
NcmPatchMetaExtendedHeader::application_id
u64 application_id
ApplicationId of this patch's corresponding application.
Definition: ncm_types.h:127
NcmContentType_DeltaFragment
@ NcmContentType_DeltaFragment
DeltaFragment.
Definition: ncm_types.h:30
NcmContentInfo::id_offset
u8 id_offset
Offset of this content. Unused by most applications.
Definition: ncm_types.h:91
NcmContentMetaKey::type
u8 type
NcmContentMetaType
Definition: ncm_types.h:75
NcmAddOnContentMetaExtendedHeader::application_id
u64 application_id
ApplicationId of this add-on-content's corresponding application.
Definition: ncm_types.h:135
NcmContentInstallType_Full
@ NcmContentInstallType_Full
Full.
Definition: ncm_types.h:56
NcmContentMetaHeader::content_count
u16 content_count
Number of NcmContentInfos after the extra bytes.
Definition: ncm_types.h:112
NcmContentInfo
ContentInfo.
Definition: ncm_types.h:87
NcmContentInstallType_FragmentOnly
@ NcmContentInstallType_FragmentOnly
FragmentOnly.
Definition: ncm_types.h:57
NcmContentMetaInfo::version
u32 version
Version.
Definition: ncm_types.h:103
NcmContentMetaHeader::storage_id
u8 storage_id
Usually None (0).
Definition: ncm_types.h:115
NcmStorageId_Host
@ NcmStorageId_Host
Host.
Definition: ncm_types.h:14
NcmContentType_Data
@ NcmContentType_Data
Data.
Definition: ncm_types.h:26
NcmContentMetaKey::id
u64 id
Id.
Definition: ncm_types.h:73
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
NcmProgramLocation::storageID
u8 storageID
NcmStorageId
Definition: ncm_types.h:148
NcmContentMetaAttribute_IncludesExFatDriver
@ NcmContentMetaAttribute_IncludesExFatDriver
IncludesExFatDriver.
Definition: ncm_types.h:50
NcmContentMetaInfo::attr
u8 attr
NcmContentMetaAttribute
Definition: ncm_types.h:105
NcmContentMetaKey::version
u32 version
Version.
Definition: ncm_types.h:74
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
NcmApplicationMetaExtendedHeader
ApplicationMetaExtendedHeader.
Definition: ncm_types.h:119
NcmApplicationContentMetaKey::key
NcmContentMetaKey key
NcmContentMetaKey
Definition: ncm_types.h:82
NcmAddOnContentMetaExtendedHeader
AddOnContentMetaExtendedHeader.
Definition: ncm_types.h:134
NcmContentMetaInfo::id
u64 id
Id.
Definition: ncm_types.h:102
NcmContentType_HtmlDocument
@ NcmContentType_HtmlDocument
HtmlDocument.
Definition: ncm_types.h:28
NcmContentMetaKey::install_type
u8 install_type
NcmContentInstallType
Definition: ncm_types.h:76
NcmContentType_Control
@ NcmContentType_Control
Control.
Definition: ncm_types.h:27
NcmAddOnContentMetaExtendedHeader::padding
u32 padding
Padding.
Definition: ncm_types.h:137
NcmStorageId_Any
@ NcmStorageId_Any
Any.
Definition: ncm_types.h:19
Uuid
Definition: types.h:48
NcmContentType_Program
@ NcmContentType_Program
Program.
Definition: ncm_types.h:25
NcmSystemUpdateMetaExtendedHeader::extended_data_size
u32 extended_data_size
Size of the extended data after NcmContentInfos and NcmContentMetaInfos.
Definition: ncm_types.h:142
NcmContentMetaType_Patch
@ NcmContentMetaType_Patch
Patch.
Definition: ncm_types.h:42
NcmApplicationContentMetaKey::application_id
u64 application_id
ApplicationId.
Definition: ncm_types.h:83
NcmPackagedContentInfo
PackagedContentInfo.
Definition: ncm_types.h:95
NcmStorageId_BuiltInSystem
@ NcmStorageId_BuiltInSystem
BuiltInSystem.
Definition: ncm_types.h:16
NcmPatchMetaExtendedHeader::extended_data_size
u32 extended_data_size
Size of the extended data following the NcmContentInfos.
Definition: ncm_types.h:129
NcmContentMetaHeader::attributes
u8 attributes
Usually None (0).
Definition: ncm_types.h:114
NcmStorageId_SdCard
@ NcmStorageId_SdCard
SdCard.
Definition: ncm_types.h:18
NcmSystemUpdateMetaExtendedHeader
SystemUpdateMetaExtendedHeader.
Definition: ncm_types.h:141
NcmApplicationMetaExtendedHeader::required_application_version
u32 required_application_version
[9.0.0+] Owner application version required by this application. Previously padding.
Definition: ncm_types.h:122
NcmPatchMetaExtendedHeader
PatchMetaExtendedHeader.
Definition: ncm_types.h:126
NcmProgramLocation::program_id
u64 program_id
ProgramId.
Definition: ncm_types.h:147
NcmStorageId_None
@ NcmStorageId_None
None.
Definition: ncm_types.h:13
NcmContentMetaType_Unknown
@ NcmContentMetaType_Unknown
Unknown.
Definition: ncm_types.h:35
BIT
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
NcmApplicationMetaExtendedHeader::required_system_version
u32 required_system_version
Firmware version required by this application.
Definition: ncm_types.h:121
NcmStorageId_BuiltInUser
@ NcmStorageId_BuiltInUser
BuiltInUser.
Definition: ncm_types.h:17
NcmContentMetaInfo::type
u8 type
NcmContentMetaType
Definition: ncm_types.h:104
NcmContentMetaType
NcmContentMetaType
ContentMetaType.
Definition: ncm_types.h:34
NcmPlaceHolderId
PlaceHolderId.
Definition: ncm_types.h:67
NcmProgramLocation
ProgramLocation.
Definition: ncm_types.h:146
NcmContentInfo::content_id
NcmContentId content_id
NcmContentId
Definition: ncm_types.h:88
NcmContentMetaType_AddOnContent
@ NcmContentMetaType_AddOnContent
AddOnContent.
Definition: ncm_types.h:43
NcmContentMetaType_SystemProgram
@ NcmContentMetaType_SystemProgram
SystemProgram.
Definition: ncm_types.h:36
NcmContentInstallType
NcmContentInstallType
ContentInstallType.
Definition: ncm_types.h:55
NcmContentMetaType_SystemUpdate
@ NcmContentMetaType_SystemUpdate
SystemUpdate.
Definition: ncm_types.h:38
NcmContentMetaAttribute_None
@ NcmContentMetaAttribute_None
None.
Definition: ncm_types.h:49
NcmApplicationMetaExtendedHeader::patch_id
u64 patch_id
PatchId of this application's patch.
Definition: ncm_types.h:120
NcmContentId
ContentId.
Definition: ncm_types.h:62
u16
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
NcmContentMetaType_BootImagePackageSafe
@ NcmContentMetaType_BootImagePackageSafe
BootImagePackageSafe.
Definition: ncm_types.h:40
NcmContentMetaType_Delta
@ NcmContentMetaType_Delta
Delta.
Definition: ncm_types.h:44
NcmContentMetaAttribute_Rebootless
@ NcmContentMetaAttribute_Rebootless
Rebootless.
Definition: ncm_types.h:51
NcmContentMetaType_SystemData
@ NcmContentMetaType_SystemData
SystemData.
Definition: ncm_types.h:37