From 0f0a440c550c8af9727cf6203d679b966fb3973e Mon Sep 17 00:00:00 2001 From: N2205 Date: Tue, 24 May 2011 06:03:28 +0000 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@268 385bec56-5757-e545-9c3a-d8741f4650f1 --- trunk/KENJEraser/main.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/trunk/KENJEraser/main.cpp b/trunk/KENJEraser/main.cpp index ac8f7e2..e49b980 100644 --- a/trunk/KENJEraser/main.cpp +++ b/trunk/KENJEraser/main.cpp @@ -45,6 +45,7 @@ namespace { const char* const NAND_TWL_ARCHIVE_NAME = "twln:"; const char* const NAND_TWL_KENJ_DIR_PATHNAME = "twln:/title/00030004/4b454e4a"; const char* const NAND_TWL_KENJ_SAVE_DATA_PATHNAME = "twln:/title/00030004/4b454e4a/data/Public.sav"; + const nn::ProgramId NAND_TWL_KENJ_PROGRAM_ID = 0x000480044b454e4aULL; // 乱数生成クラス // 線形合同法を用いて乱数を生成する。 @@ -133,14 +134,12 @@ namespace { // セーブデータファイルのサイズを読む result = file.TryGetSize( &file_size ); - NN_LOG("save data size : %d\n", file_size); if( result.IsFailure() ) { file.Finalize(); return result; } - nn::fnd::TimeSpan ts; nn::fnd::DateTime tm; nn::os::Tick tick; Random rand; @@ -152,11 +151,10 @@ namespace { NN_TPANIC_IF_NULL_( buf ); // 乱数のシードを設定 - // [TODO]シードをちゃんと決める - seed = (u64)(ts.GetMilliSeconds() ^ tick.GetSystemCurrent()); - // NN_LOG("Time Span MilliSec : %x\n", ts.GetMilliSeconds()); - // NN_LOG("Get System Current Tick : %x\n", tick.GetSystemCurrent()); - NN_LOG("seed : %d\n", seed); + nn::fnd::DateTimeParameters param = tm.GetNow().GetParameters(); + seed = tm.DateToDays( param.year, param.month, param.day ); + seed = (u64)(seed * 86400 + param.hour * 3600 + param.minute * 60 + param.second); + seed = (u64)(seed ^ tick.GetSystemCurrent()); rand.SetSeed( seed ); // バッファを乱数で埋める @@ -165,17 +163,9 @@ namespace { { p[loopSizeFile] = (u8)rand.Get32(0xff); } - + // 書き込み - result = file.TryWrite( &sizeResult, buf, file_size); - if( file_size != sizeResult ) - { - NN_LOG("Write Failed...\n"); - NN_LOG("File Size : %d\n", file_size); - NN_LOG("Write Size : %d\n", sizeResult); - } - - NN_LOG("Save Data Fill Success!\n"); + result = file.TryWrite(&sizeResult, buf, file_size); file.Finalize(); @@ -211,9 +201,14 @@ namespace { // ほぼ日健康手帳のセーブデータを乱数で埋める result = FillRandamDataToKENJSaveData(); + if( result.IsFailure() ) + { + nn::fs::Unmount( "twln:" ); + return result; + } // ほぼ日健康手帳を消す - result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, 0x000480044b454e4aULL); + result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, NAND_TWL_KENJ_PROGRAM_ID); UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result); }