cfgu.h
Go to the documentation of this file.
/**
* @file cfgu.h
* @brief CFGU (Configuration) Service
*/
#pragma once
#include <3ds/types.h>
/// Configuration region values.
typedef enum
{
CFG_REGION_JPN = 0, ///< Japan
CFG_REGION_USA = 1, ///< USA
CFG_REGION_EUR = 2, ///< Europe
CFG_REGION_AUS = 3, ///< Australia
CFG_REGION_CHN = 4, ///< China
CFG_REGION_KOR = 5, ///< Korea
CFG_REGION_TWN = 6, ///< Taiwan
} CFG_Region;
/// Configuration language values.
typedef enum
{
CFG_LANGUAGE_DEFAULT = -1, ///< Use system language in errorInit
CFG_LANGUAGE_JP, ///< Japanese
CFG_LANGUAGE_EN, ///< English
CFG_LANGUAGE_FR, ///< French
CFG_LANGUAGE_DE, ///< German
CFG_LANGUAGE_IT, ///< Italian
CFG_LANGUAGE_ES, ///< Spanish
CFG_LANGUAGE_ZH, ///< Simplified Chinese
CFG_LANGUAGE_KO, ///< Korean
CFG_LANGUAGE_NL, ///< Dutch
CFG_LANGUAGE_PT, ///< Portugese
CFG_LANGUAGE_RU, ///< Russian
CFG_LANGUAGE_TW, ///< Traditional Chinese
} CFG_Language;
// Configuration system model values.
typedef enum
{
CFG_MODEL_3DS = 0, ///< Old 3DS (CTR)
CFG_MODEL_3DSXL = 1, ///< Old 3DS XL (SPR)
CFG_MODEL_N3DS = 2, ///< New 3DS (KTR)
CFG_MODEL_2DS = 3, ///< Old 2DS (FTR)
CFG_MODEL_N3DSXL = 4, ///< New 3DS XL (RED)
CFG_MODEL_N2DSXL = 5, ///< New 2DS XL (JAN)
} CFG_SystemModel;
/// Initializes CFGU.
Result cfguInit(void);
/// Exits CFGU.
void cfguExit(void);
/**
* @brief Gets the system's region from secure info.
* @param region Pointer to output the region to. (see @ref CFG_Region)
*/
Result CFGU_SecureInfoGetRegion(u8* region);
/**
* @brief Generates a console-unique hash.
* @param appIDSalt Salt to use.
* @param hash Pointer to output the hash to.
*/
Result CFGU_GenHashConsoleUnique(u32 appIDSalt, u64* hash);
/**
* @brief Gets whether the system's region is Canada or USA.
* @param value Pointer to output the result to. (0 = no, 1 = yes)
*/
Result CFGU_GetRegionCanadaUSA(u8* value);
/**
* @brief Gets the system's model.
* @param model Pointer to output the model to. (see @ref CFG_SystemModel)
*/
Result CFGU_GetSystemModel(u8* model);
/**
* @brief Gets whether the system is a 2DS.
* @param value Pointer to output the result to. (0 = yes, 1 = no)
*/
Result CFGU_GetModelNintendo2DS(u8* value);
/**
* @brief Gets a string representing a country code.
* @param code Country code to use.
* @param string Pointer to output the string to.
*/
Result CFGU_GetCountryCodeString(u16 code, u16* string);
/**
* @brief Gets a country code ID from its string.
* @param string String to use.
* @param code Pointer to output the country code to.
*/
Result CFGU_GetCountryCodeID(u16 string, u16* code);
/**
* @brief Checks if NFC (code name: fangate) is supported.
* @param isSupported pointer to the output the result to.
*/
Result CFGU_IsNFCSupported(bool* isSupported);
/**
* @brief Gets a config info block with flags = 2.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, void* outData);
/**
* @brief Gets a config info block with flags = 4.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, void* outData);
/**
* @brief Gets a config info block with flags = 8.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, void* outData);
/**
* @brief Sets a config info block with flags = 4.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param inData Pointer to block data to write.
*/
Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, const void* inData);
/**
* @brief Sets a config info block with flags = 8.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param inData Pointer to block data to write.
*/
Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, const void* inData);
/**
* @brief Writes the CFG buffer in memory to the savegame in NAND.
*/
Result CFG_UpdateConfigSavegame(void);
/**
* @brief Gets the system's language.
* @param language Pointer to write the language to. (see @ref CFG_Language)
*/
Result CFGU_GetSystemLanguage(u8* language);
/**
* @brief Deletes the NAND LocalFriendCodeSeed file, then recreates it using the LocalFriendCodeSeed data stored in memory.
*/
Result CFGI_RestoreLocalFriendCodeSeed(void);
/**
* @brief Deletes the NAND SecureInfo file, then recreates it using the SecureInfo data stored in memory.
*/
Result CFGI_RestoreSecureInfo(void);
/**
* @brief Deletes the "config" file stored in the NAND Config_Savegame.
*/
Result CFGI_DeleteConfigSavefile(void);
/**
* @brief Formats Config_Savegame.
*/
Result CFGI_FormatConfig(void);
/**
* @brief Clears parental controls
*/
Result CFGI_ClearParentalControls(void);
/**
* @brief Verifies the RSA signature for the LocalFriendCodeSeed data already stored in memory.
*/
Result CFGI_VerifySigLocalFriendCodeSeed(void);
/**
* @brief Verifies the RSA signature for the SecureInfo data already stored in memory.
*/
Result CFGI_VerifySigSecureInfo(void);
/**
* @brief Gets the system's serial number.
* @param serial Pointer to output the serial to. (This is normally 0xF)
*/
Result CFGI_SecureInfoGetSerialNumber(u8 *serial);
/**
* @brief Gets the 0x110-byte buffer containing the data for the LocalFriendCodeSeed.
* @param data Pointer to output the buffer. (The size must be at least 0x110-bytes)
*/
Result CFGI_GetLocalFriendCodeSeedData(u8 *data);
/**
* @brief Gets the 64-bit local friend code seed.
* @param seed Pointer to write the friend code seed to.
*/
Result CFGI_GetLocalFriendCodeSeed(u64* seed);
/**
* @brief Gets the 0x11-byte data following the SecureInfo signature.
* @param data Pointer to output the buffer. (The size must be at least 0x11-bytes)
*/
Result CFGI_GetSecureInfoData(u8 *data);
/**
* @brief Gets the 0x100-byte RSA-2048 SecureInfo signature.
* @param data Pointer to output the buffer. (The size must be at least 0x100-bytes)
*/
Result CFGI_GetSecureInfoSignature(u8 *data);
CFGI_VerifySigSecureInfo
Result CFGI_VerifySigSecureInfo(void)
Verifies the RSA signature for the SecureInfo data already stored in memory.
CFGU_GetSystemLanguage
Result CFGU_GetSystemLanguage(u8 *language)
Gets the system's language.
CFGI_VerifySigLocalFriendCodeSeed
Result CFGI_VerifySigLocalFriendCodeSeed(void)
Verifies the RSA signature for the LocalFriendCodeSeed data already stored in memory.
CFGI_FormatConfig
Result CFGI_FormatConfig(void)
Formats Config_Savegame.
CFGU_GetCountryCodeString
Result CFGU_GetCountryCodeString(u16 code, u16 *string)
Gets a string representing a country code.
CFGI_DeleteConfigSavefile
Result CFGI_DeleteConfigSavefile(void)
Deletes the "config" file stored in the NAND Config_Savegame.
CFGI_GetSecureInfoData
Result CFGI_GetSecureInfoData(u8 *data)
Gets the 0x11-byte data following the SecureInfo signature.
CFG_SetConfigInfoBlk8
Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, const void *inData)
Sets a config info block with flags = 8.
CFGU_GetModelNintendo2DS
Result CFGU_GetModelNintendo2DS(u8 *value)
Gets whether the system is a 2DS.
CFGU_GetCountryCodeID
Result CFGU_GetCountryCodeID(u16 string, u16 *code)
Gets a country code ID from its string.
CFGU_GenHashConsoleUnique
Result CFGU_GenHashConsoleUnique(u32 appIDSalt, u64 *hash)
Generates a console-unique hash.
CFGI_SecureInfoGetSerialNumber
Result CFGI_SecureInfoGetSerialNumber(u8 *serial)
Gets the system's serial number.
CFGU_GetConfigInfoBlk2
Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, void *outData)
Gets a config info block with flags = 2.
CFG_GetConfigInfoBlk8
Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, void *outData)
Gets a config info block with flags = 8.
CFGU_GetSystemModel
Result CFGU_GetSystemModel(u8 *model)
Gets the system's model.
CFG_UpdateConfigSavegame
Result CFG_UpdateConfigSavegame(void)
Writes the CFG buffer in memory to the savegame in NAND.
CFG_SystemModel
CFG_SystemModel
Definition: cfgu.h:40
CFG_MODEL_N3DS
@ CFG_MODEL_N3DS
New 3DS (KTR)
Definition: cfgu.h:43
CFG_MODEL_3DSXL
@ CFG_MODEL_3DSXL
Old 3DS XL (SPR)
Definition: cfgu.h:42
CFG_MODEL_N3DSXL
@ CFG_MODEL_N3DSXL
New 3DS XL (RED)
Definition: cfgu.h:45
CFG_MODEL_2DS
@ CFG_MODEL_2DS
Old 2DS (FTR)
Definition: cfgu.h:44
CFG_MODEL_3DS
@ CFG_MODEL_3DS
Old 3DS (CTR)
Definition: cfgu.h:41
CFG_MODEL_N2DSXL
@ CFG_MODEL_N2DSXL
New 2DS XL (JAN)
Definition: cfgu.h:46
CFGU_IsNFCSupported
Result CFGU_IsNFCSupported(bool *isSupported)
Checks if NFC (code name: fangate) is supported.
CFGI_RestoreLocalFriendCodeSeed
Result CFGI_RestoreLocalFriendCodeSeed(void)
Deletes the NAND LocalFriendCodeSeed file, then recreates it using the LocalFriendCodeSeed data store...
CFGU_GetRegionCanadaUSA
Result CFGU_GetRegionCanadaUSA(u8 *value)
Gets whether the system's region is Canada or USA.
CFGI_GetLocalFriendCodeSeed
Result CFGI_GetLocalFriendCodeSeed(u64 *seed)
Gets the 64-bit local friend code seed.
cfguInit
Result cfguInit(void)
Initializes CFGU.
CFGI_GetLocalFriendCodeSeedData
Result CFGI_GetLocalFriendCodeSeedData(u8 *data)
Gets the 0x110-byte buffer containing the data for the LocalFriendCodeSeed.
CFG_Language
CFG_Language
Configuration language values.
Definition: cfgu.h:22
CFG_LANGUAGE_NL
@ CFG_LANGUAGE_NL
Dutch.
Definition: cfgu.h:32
CFG_LANGUAGE_TW
@ CFG_LANGUAGE_TW
Traditional Chinese.
Definition: cfgu.h:35
CFG_LANGUAGE_DE
@ CFG_LANGUAGE_DE
German.
Definition: cfgu.h:27
CFG_LANGUAGE_KO
@ CFG_LANGUAGE_KO
Korean.
Definition: cfgu.h:31
CFG_LANGUAGE_IT
@ CFG_LANGUAGE_IT
Italian.
Definition: cfgu.h:28
CFG_LANGUAGE_EN
@ CFG_LANGUAGE_EN
English.
Definition: cfgu.h:25
CFG_LANGUAGE_ZH
@ CFG_LANGUAGE_ZH
Simplified Chinese.
Definition: cfgu.h:30
CFG_LANGUAGE_FR
@ CFG_LANGUAGE_FR
French.
Definition: cfgu.h:26
CFG_LANGUAGE_ES
@ CFG_LANGUAGE_ES
Spanish.
Definition: cfgu.h:29
CFG_LANGUAGE_RU
@ CFG_LANGUAGE_RU
Russian.
Definition: cfgu.h:34
CFG_LANGUAGE_PT
@ CFG_LANGUAGE_PT
Portugese.
Definition: cfgu.h:33
CFG_LANGUAGE_JP
@ CFG_LANGUAGE_JP
Japanese.
Definition: cfgu.h:24
CFG_LANGUAGE_DEFAULT
@ CFG_LANGUAGE_DEFAULT
Use system language in errorInit.
Definition: cfgu.h:23
CFG_Region
CFG_Region
Configuration region values.
Definition: cfgu.h:10
CFG_REGION_AUS
@ CFG_REGION_AUS
Australia.
Definition: cfgu.h:14
CFG_REGION_EUR
@ CFG_REGION_EUR
Europe.
Definition: cfgu.h:13
CFG_REGION_USA
@ CFG_REGION_USA
USA.
Definition: cfgu.h:12
CFG_REGION_TWN
@ CFG_REGION_TWN
Taiwan.
Definition: cfgu.h:17
CFG_REGION_JPN
@ CFG_REGION_JPN
Japan.
Definition: cfgu.h:11
CFG_REGION_KOR
@ CFG_REGION_KOR
Korea.
Definition: cfgu.h:16
CFG_REGION_CHN
@ CFG_REGION_CHN
China.
Definition: cfgu.h:15
CFGI_ClearParentalControls
Result CFGI_ClearParentalControls(void)
Clears parental controls.
CFGU_SecureInfoGetRegion
Result CFGU_SecureInfoGetRegion(u8 *region)
Gets the system's region from secure info.
CFG_SetConfigInfoBlk4
Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, const void *inData)
Sets a config info block with flags = 4.
CFGI_RestoreSecureInfo
Result CFGI_RestoreSecureInfo(void)
Deletes the NAND SecureInfo file, then recreates it using the SecureInfo data stored in memory.
CFGI_GetSecureInfoSignature
Result CFGI_GetSecureInfoSignature(u8 *data)
Gets the 0x100-byte RSA-2048 SecureInfo signature.
cfguExit
void cfguExit(void)
Exits CFGU.
CFG_GetConfigInfoBlk4
Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, void *outData)
Gets a config info block with flags = 4.
types.h
Various system types.
u64
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
u8
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
Result
s32 Result
Function result.
Definition: types.h:42
u16
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23