diff --git a/libctru/include/3ds/services/cfgu.h b/libctru/include/3ds/services/cfgu.h index f75cfba..926e005 100644 --- a/libctru/include/3ds/services/cfgu.h +++ b/libctru/include/3ds/services/cfgu.h @@ -60,7 +60,7 @@ Result CFGU_GetRegionCanadaUSA(u8* value); /** * @brief Gets the system's model. - * @param model Pointer to output the model to. (0 = O3DS, 1 = O3DSXL, 2 = N3DS, 3 = 2DS, 4 = N3DSXL) + * @param model Pointer to output the model to. (0 = O3DS, 1 = O3DSXL, 2 = N3DS, 3 = 2DS, 4 = N3DSXL, 5 = N2DSXL) */ Result CFGU_GetSystemModel(u8* model); @@ -128,10 +128,45 @@ Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8* inData); /** * @brief Writes the CFG buffer in memory to the savegame in NAND. */ -Result CFG_UpdateConfigNANDSavegame(void); +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); diff --git a/libctru/source/services/cfgu.c b/libctru/source/services/cfgu.c index 0a657c8..48ea174 100644 --- a/libctru/source/services/cfgu.c +++ b/libctru/source/services/cfgu.c @@ -215,7 +215,7 @@ Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8* inData) return (Result)cmdbuf[1]; } -Result CFG_UpdateConfigNANDSavegame(void) +Result CFG_UpdateConfigSavegame(void) { Result ret = 0; u32 *cmdbuf = getThreadCommandBuffer(); @@ -231,3 +231,87 @@ Result CFGU_GetSystemLanguage(u8* language) { return CFGU_GetConfigInfoBlk2(1, 0xA0002, language); } + +Result CFGI_RestoreLocalFriendCodeSeed(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x80D, 0, 0); // 0x80D0000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_RestoreSecureInfo(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x812,0,0); // 0x8120000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_DeleteConfigSavefile(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x805,0,0); // 0x8050000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_FormatConfig(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x806,0,0); // 0x8060000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_ClearParentalControls(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x40F,0,0); // 0x40F0000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_VerifySigLocalFriendCodeSeed(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x80E,0,0); // 0x80E0000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_VerifySigSecureInfo(void) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x813,0,0); // 0x8130000 + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +}