libctru  v1.6.0
cfgu.h
Go to the documentation of this file.
1 /**
2  * @file cfgu.h
3  * @brief CFGU (Configuration) Service
4  */
5 #pragma once
6 
7 /// Configuration region values.
8 typedef enum
9 {
10  CFG_REGION_JPN = 0, ///< Japan
11  CFG_REGION_USA = 1, ///< USA
12  CFG_REGION_EUR = 2, ///< Europe
13  CFG_REGION_AUS = 3, ///< Australia
14  CFG_REGION_CHN = 4, ///< China
15  CFG_REGION_KOR = 5, ///< Korea
16  CFG_REGION_TWN = 6, ///< Taiwan
17 } CFG_Region;
18 
19 /// Configuration language values.
20 typedef enum
21 {
22  CFG_LANGUAGE_JP = 0, ///< Japanese
23  CFG_LANGUAGE_EN = 1, ///< English
24  CFG_LANGUAGE_FR = 2, ///< French
25  CFG_LANGUAGE_DE = 3, ///< German
26  CFG_LANGUAGE_IT = 4, ///< Italian
27  CFG_LANGUAGE_ES = 5, ///< Spanish
28  CFG_LANGUAGE_ZH = 6, ///< Simplified Chinese
29  CFG_LANGUAGE_KO = 7, ///< Korean
30  CFG_LANGUAGE_NL = 8, ///< Dutch
31  CFG_LANGUAGE_PT = 9, ///< Portugese
32  CFG_LANGUAGE_RU = 10, ///< Russian
33  CFG_LANGUAGE_TW = 11, ///< Traditional Chinese
34 } CFG_Language;
35 
36 /// Initializes CFGU.
37 Result cfguInit(void);
38 
39 /// Exits CFGU.
40 void cfguExit(void);
41 
42 /**
43  * @brief Gets the system's region from secure info.
44  * @param region Pointer to output the region to. (see @ref CFG_Region)
45  */
47 
48 /**
49  * @brief Generates a console-unique hash.
50  * @param appIDSalt Salt to use.
51  * @param hash Pointer to output the hash to.
52  */
53 Result CFGU_GenHashConsoleUnique(u32 appIDSalt, u64* hash);
54 
55 /**
56  * @brief Gets whether the system's region is Canada or USA.
57  * @param value Pointer to output the result to. (0 = no, 1 = yes)
58  */
60 
61 /**
62  * @brief Gets the system's model.
63  * @param model Pointer to output the model to. (0 = O3DS, 1 = O3DSXL, 2 = N3DS, 3 = 2DS, 4 = N3DSXL, 5 = N2DSXL)
64  */
66 
67 /**
68  * @brief Gets whether the system is a 2DS.
69  * @param value Pointer to output the result to. (0 = yes, 1 = no)
70  */
72 
73 /**
74  * @brief Gets a string representing a country code.
75  * @param code Country code to use.
76  * @param string Pointer to output the string to.
77  */
79 
80 /**
81  * @brief Gets a country code ID from its string.
82  * @param string String to use.
83  * @param code Pointer to output the country code to.
84  */
85 Result CFGU_GetCountryCodeID(u16 string, u16* code);
86 
87 /**
88  * @brief Checks if NFC (code name: fangate) is supported.
89  * @param isSupported pointer to the output the result to.
90  */
91 Result CFGU_IsNFCSupported(bool* isSupported);
92 
93 /**
94  * @brief Gets a config info block with flags = 2.
95  * @param size Size of the data to retrieve.
96  * @param blkID ID of the block to retrieve.
97  * @param outData Pointer to write the block data to.
98  */
99 Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, u8* outData);
100 
101 /**
102  * @brief Gets a config info block with flags = 4.
103  * @param size Size of the data to retrieve.
104  * @param blkID ID of the block to retrieve.
105  * @param outData Pointer to write the block data to.
106  */
107 Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, u8* outData);
108 
109 /**
110  * @brief Gets a config info block with flags = 8.
111  * @param size Size of the data to retrieve.
112  * @param blkID ID of the block to retrieve.
113  * @param outData Pointer to write the block data to.
114  */
115 Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, u8* outData);
116 
117 /**
118  * @brief Sets a config info block with flags = 4.
119  * @param size Size of the data to retrieve.
120  * @param blkID ID of the block to retrieve.
121  * @param inData Pointer to block data to write.
122  */
123 Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, u8* inData);
124 
125 /**
126  * @brief Sets a config info block with flags = 8.
127  * @param size Size of the data to retrieve.
128  * @param blkID ID of the block to retrieve.
129  * @param inData Pointer to block data to write.
130  */
131 Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8* inData);
132 
133 
134 /**
135  * @brief Writes the CFG buffer in memory to the savegame in NAND.
136  */
138 
139 /**
140  * @brief Gets the system's language.
141  * @param language Pointer to write the language to. (see @ref CFG_Language)
142  */
143 Result CFGU_GetSystemLanguage(u8* language);
144 
145 /**
146  * @brief Deletes the NAND LocalFriendCodeSeed file, then recreates it using the LocalFriendCodeSeed data stored in memory.
147  */
149 
150 /**
151  * @brief Deletes the NAND SecureInfo file, then recreates it using the SecureInfo data stored in memory.
152  */
154 
155 /**
156  * @brief Deletes the "config" file stored in the NAND Config_Savegame.
157  */
159 
160 /**
161  * @brief Formats Config_Savegame.
162  */
164 
165 /**
166  * @brief Clears parental controls
167  */
169 
170 /**
171  * @brief Verifies the RSA signature for the LocalFriendCodeSeed data already stored in memory.
172  */
174 
175 /**
176  * @brief Verifies the RSA signature for the SecureInfo data already stored in memory.
177  */
179 
180 /**
181  * @brief Gets the system's serial number.
182  * @param serial Pointer to output the serial to. (This is normally 0xF)
183  */
185 
186 /**
187  * @brief Gets the 0x110-byte buffer containing the data for the LocalFriendCodeSeed.
188  * @param data Pointer to output the buffer. (The size must be at least 0x110-bytes)
189  */
191 
192 /**
193  * @brief Gets the 64-bit local friend code seed.
194  * @param seed Pointer to write the friend code seed to.
195  */
197 
198 /**
199  * @brief Gets the 0x11-byte data following the SecureInfo signature.
200  * @param data Pointer to output the buffer. (The size must be at least 0x11-bytes)
201  */
203 
204 /**
205  * @brief Gets the 0x100-byte RSA-2048 SecureInfo signature.
206  * @param data Pointer to output the buffer. (The size must be at least 0x100-bytes)
207  */
Result CFGU_GetCountryCodeID(u16 string, u16 *code)
Gets a country code ID from its string.
Spanish.
Definition: cfgu.h:27
Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8 *inData)
Sets a config info block with flags = 8.
Russian.
Definition: cfgu.h:32
Result CFGI_GetLocalFriendCodeSeedData(u8 *data)
Gets the 0x110-byte buffer containing the data for the LocalFriendCodeSeed.
China.
Definition: cfgu.h:14
s32 Result
Function result.
Definition: types.h:42
Portugese.
Definition: cfgu.h:31
French.
Definition: cfgu.h:24
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
Korea.
Definition: cfgu.h:15
Result CFGI_FormatConfig(void)
Formats Config_Savegame.
Result CFGU_GetSystemModel(u8 *model)
Gets the system's model.
Result CFGI_RestoreSecureInfo(void)
Deletes the NAND SecureInfo file, then recreates it using the SecureInfo data stored in memory.
German.
Definition: cfgu.h:25
Result CFGI_SecureInfoGetSerialNumber(u8 *serial)
Gets the system's serial number.
Result CFGI_ClearParentalControls(void)
Clears parental controls.
Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, u8 *outData)
Gets a config info block with flags = 2.
Result CFGI_VerifySigSecureInfo(void)
Verifies the RSA signature for the SecureInfo data already stored in memory.
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
Simplified Chinese.
Definition: cfgu.h:28
void cfguExit(void)
Exits CFGU.
Result CFGI_VerifySigLocalFriendCodeSeed(void)
Verifies the RSA signature for the LocalFriendCodeSeed data already stored in memory.
Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, u8 *outData)
Gets a config info block with flags = 8.
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
Result CFGU_IsNFCSupported(bool *isSupported)
Checks if NFC (code name: fangate) is supported.
Result CFGU_GetSystemLanguage(u8 *language)
Gets the system's language.
Result cfguInit(void)
Initializes CFGU.
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Taiwan.
Definition: cfgu.h:16
Australia.
Definition: cfgu.h:13
Result CFGU_GetCountryCodeString(u16 code, u16 *string)
Gets a string representing a country code.
Result CFGU_SecureInfoGetRegion(u8 *region)
Gets the system's region from secure info.
Result CFGU_GetRegionCanadaUSA(u8 *value)
Gets whether the system's region is Canada or USA.
Japanese.
Definition: cfgu.h:22
Result CFGU_GetModelNintendo2DS(u8 *value)
Gets whether the system is a 2DS.
Result CFGI_DeleteConfigSavefile(void)
Deletes the "config" file stored in the NAND Config_Savegame.
USA.
Definition: cfgu.h:11
CFG_Language
Configuration language values.
Definition: cfgu.h:20
Result CFGI_RestoreLocalFriendCodeSeed(void)
Deletes the NAND LocalFriendCodeSeed file, then recreates it using the LocalFriendCodeSeed data store...
Result CFGI_GetLocalFriendCodeSeed(u64 *seed)
Gets the 64-bit local friend code seed.
Traditional Chinese.
Definition: cfgu.h:33
Result CFGU_GenHashConsoleUnique(u32 appIDSalt, u64 *hash)
Generates a console-unique hash.
Result CFG_UpdateConfigSavegame(void)
Writes the CFG buffer in memory to the savegame in NAND.
Japan.
Definition: cfgu.h:10
Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, u8 *inData)
Sets a config info block with flags = 4.
Result CFGI_GetSecureInfoSignature(u8 *data)
Gets the 0x100-byte RSA-2048 SecureInfo signature.
Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, u8 *outData)
Gets a config info block with flags = 4.
Dutch.
Definition: cfgu.h:30
Europe.
Definition: cfgu.h:12
Italian.
Definition: cfgu.h:26
Result CFGI_GetSecureInfoData(u8 *data)
Gets the 0x11-byte data following the SecureInfo signature.
English.
Definition: cfgu.h:23
Korean.
Definition: cfgu.h:29
CFG_Region
Configuration region values.
Definition: cfgu.h:8