diff --git a/build/libraries_sysmenu/namut/ARM9/src/namut.c b/build/libraries_sysmenu/namut/ARM9/src/namut.c index b75acbba..a8f094be 100644 --- a/build/libraries_sysmenu/namut/ARM9/src/namut.c +++ b/build/libraries_sysmenu/namut/ARM9/src/namut.c @@ -22,8 +22,10 @@ #include #include #include +#include #include #include +#include /*---------------------------------------------------------------------------* 定数定義 @@ -60,32 +62,16 @@ static const char* sDeleteNonProtecedDirectoryList[] = }; // 擬似フォーマット実行時に -// 指定ファイルは0xffでFillされます。 +// 指定ファイルはランダムデータでFillされます。 static const char* sFillFileList[] = { "nand:/shared1/TWLCFG0.dat", "nand:/shared1/TWLCFG1.dat" }; -static const u8 sClearData[CLEAR_DATA_SIZE] = -{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; + +static u8 sClearData[CLEAR_DATA_SIZE] ATTRIBUTE_ALIGN(32); +static u32 sNCFGAddr; /*---------------------------------------------------------------------------* 内部変数定義 @@ -106,6 +92,7 @@ static BOOL NAMUTi_DeleteNandDirectory(const char *path); static BOOL NAMUTi_MountAndFormatOtherTitleSaveData(u64 titleID, const char *arcname); static void NAMUTi_DrawNandTree(s32 depth, const char *path); static BOOL NAMUTi_FillFile(const char* path); +static void NAMUTi_ClearWiFiSettings( void ); static void PrintDirectory(s32 depth, const char* path); static void PrintFile(s32 depth, const char* path); @@ -159,6 +146,9 @@ BOOL NAMUT_Format(void) } } + // WiFi設定データをクリアします + NAMUTi_ClearWiFiSettings(); + return ret; } @@ -549,10 +539,14 @@ static BOOL NAMUTi_FillFile(const char* path) // ファイルオープン if (FS_OpenFileEx(&file, path, (FS_FILEMODE_RWL))) { - // ファイルを0xFFでクリア + // ファイルをランダムデータでクリア u32 filesize = FS_GetFileLength(&file); for (; filesize > CLEAR_DATA_SIZE; filesize -= CLEAR_DATA_SIZE) { + if( AES_Rand(sClearData, CLEAR_DATA_SIZE) != AES_RESULT_SUCCESS ) + { + return FALSE; + } FS_WriteFile(&file, sClearData, CLEAR_DATA_SIZE); } FS_WriteFile(&file, sClearData, (s32)filesize); @@ -696,6 +690,41 @@ static void NAMUTi_DrawNandTree(s32 depth, const char *path) FS_CloseDirectory(&dir); } + +/*---------------------------------------------------------------------------* + Name: NAMUTi_ClearWiFiSettings + + Description: NVRAMのWiFi設定データをクリアする。 + + Arguments: None. + + Returns: None. + *---------------------------------------------------------------------------*/ +static void NAMUTi_ClearWiFiSettings( void ) +{ +#define NCFG_ADDR 0x20 +#define NTR_WIFI_DATA_SIZE 0x400 +#define TWL_WIFI_DATA_SIZE 0x600 + int len = ( NTR_WIFI_DATA_SIZE + TWL_WIFI_DATA_SIZE ); + + if (!NVRAMi_IsInitialized()) { + NVRAMi_Init(); + } + DC_FlushRange( &sNCFGAddr, 2 ); + sNCFGAddr = 0; + NVRAMi_Read( NCFG_ADDR, 2, (u8 *)&sNCFGAddr); + sNCFGAddr = (u32)( ( sNCFGAddr << 3 ) - len ); + + MI_CpuFillFast( sClearData, 0xffffffff, CLEAR_DATA_SIZE); + DC_FlushRange( sClearData, CLEAR_DATA_SIZE ); + while( len > 0 ) { + NVRAMi_Write( sNCFGAddr, CLEAR_DATA_SIZE , sClearData ); + sNCFGAddr += CLEAR_DATA_SIZE; + len -= CLEAR_DATA_SIZE; + } +} + + /*---------------------------------------------------------------------------* Name: PrintDirectory diff --git a/include/sysmenu/sysmenu_lib/common/sysmenu_api.h b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h index b7be6e5f..31d972e6 100644 --- a/include/sysmenu/sysmenu_lib/common/sysmenu_api.h +++ b/include/sysmenu/sysmenu_lib/common/sysmenu_api.h @@ -131,7 +131,7 @@ extern void SYSM_GoSleepMode( void ); // ペアレンタルコントロール問い合わせ u32 SYSM_CalcPCTLInquiryCode( void ); // 問い合わせコード(10進8桁)算出 -u32 SYSM_CalcPCTLMasterKey( void ); // マスターキー  (10進5桁)算出 +u32 SYSM_CalcPCTLMasterKey( void ); // マスターキー  (10進5桁)算出(※内部でRTC_GetDateを使用します。) #endif