From 32036eb784ca02890caa67aedfb365182757c4f1 Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 15 Apr 2011 06:22:44 +0000 Subject: [PATCH] =?UTF-8?q?TWL=E3=83=91=E3=83=BC=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E3=82=BB=E3=83=BC=E3=83=96?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E6=9B=B8=E3=81=8D=E8=BE=BC?= =?UTF-8?q?=E3=82=80=E3=82=88=E3=81=86=E3=81=AB?= 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@203 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleRestore/Controller.cpp | 23 ++++++++- .../ConsoleRestore/Importer.cpp | 48 ++++++++++++++++++- .../ConsoleRestore/Importer.h | 1 + .../common/FileTransfer.cpp | 5 +- 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp index ad8f6ae..5321a5f 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp @@ -48,6 +48,7 @@ typedef enum RestoreState NUP_ONLY_WAIT_SD_EJECT, // NUP_ONLYモードでSDカード抜き待ち NUP_ONLY_WAIT_NEXT, // NUP_ONLYモードでキー入力待ち RESTORE_READ_FILELIST, // ファイル一覧の読み込み + RESTORE_TWL_NAND, // TWL NANDの書き込み中 RESTORE_TWL_SOUND, // TWLサウンドの書き込み中 RESTORE_TWL_PHOTO, // TWL写真の書き込み中 RESTORE_IN_PROGRESS, // 書き込み中 @@ -610,7 +611,7 @@ void ControlState(::std::vector& operationMessage, bool& nextStep, if(result.IsSuccess()) { - s_RestoreState = RESTORE_TWL_SOUND; + s_RestoreState = RESTORE_TWL_NAND; } else { @@ -619,6 +620,26 @@ void ControlState(::std::vector& operationMessage, bool& nextStep, } break; + // TWL NAND領域の書き込み中 + case RESTORE_TWL_NAND: + { + static bool init = true; + if (init) + { + // データを書き込む + ImportTwlSaveData(); + init = false; + } + + // 処理が完了した + if (IsImportFinished()) + { + FinalizeImportThread(); + s_RestoreState = RESTORE_TWL_SOUND; + } + } + break; + // TWLサウンド領域の書き込み中 case RESTORE_TWL_SOUND: diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp index 7ddfc16..d74a19d 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp @@ -74,6 +74,7 @@ bool s_ReadSerialNumber = false; struct SdFileSize { s64 totalFileSize; + s64 twlFileSize; s64 twlSoundFileSize; s64 twlPhotoFileSize; s64 ctrFileSize; @@ -1329,6 +1330,37 @@ void ImportTwlData(enum common::TWL_PATH_INDEX path, s64 fileSize) } +void ImportTwlTitleSaveData(s64 fileSize) +{ + nn::Result result; + + result = nn::fs::MountSpecialArchive(common::NAND_TWL_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_TWL_NAND); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + + result = common::SdMountManager::Mount(); + + size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize(); + NN_LOG("AllocatableSize = %d\n", bufSize); + + // ファイルサイズ設定 + common::InitializeTransferProgress(fileSize); + + void* buf = common::HeapManager::GetHeap()->Allocate(bufSize, AES_BLOCK_SIZE); + if (buf != NULL) + { + common::CopyDirectory( + &s_FileLists, + (::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(common::SD_SAVEDATA_TWL_ROOT_NAME)).c_str(), + (std::wstring(common::NAND_TWL_DATA_ROOT_PATHNAME_WITHOUT_SLASH) + ::std::wstring(L"/")).c_str(), + buf, bufSize, false, NULL, NULL); + + common::HeapManager::GetHeap()->Free(buf); + } + + common::SdMountManager::Unmount(); + nn::fs::Unmount(common::NAND_TWL_ARCHIVE_NAME); +} + void ImportTwlPhotoDataFunc() { COMMON_LOGGER("Import Twl Photo Data.\n"); @@ -1341,6 +1373,12 @@ void ImportTwlSoundDataFunc() ImportTwlData(common::TWL_SOUND, s_SdFileSize.twlSoundFileSize); } +void ImportTwlSaveDataFunc() +{ + COMMON_LOGGER("Import Twl Save Data.\n"); + ImportTwlTitleSaveData(s_SdFileSize.twlFileSize); +} + void ImportTwlPhotoData() { s_ImportThread.Start(ImportTwlPhotoDataFunc, s_ImportThreadStack); @@ -1351,6 +1389,11 @@ void ImportTwlSoundData() s_ImportThread.Start(ImportTwlSoundDataFunc, s_ImportThreadStack); } +void ImportTwlSaveData() +{ + s_ImportThread.Start(ImportTwlSaveDataFunc, s_ImportThreadStack); +} + void ClearFileReadResult() { @@ -1599,7 +1642,10 @@ nn::Result ReadFileList(SdFileSize* sdFiles, common::ImportDataList* fileList) { sdFiles->twlSoundFileSize += size; } - + else if(std::wcsstr(wcToken, common::SD_SAVEDATA_TWL_ROOT_NAME) != NULL) + { + sdFiles->twlFileSize += size; + } } } else diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h index 855130e..bf55266 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h @@ -31,6 +31,7 @@ nn::Result SetupFileList(); void FinalizeImportThread(); bool IsImportFinished(); void ImportTwlSoundData(); +void ImportTwlSaveData(); void ImportTwlPhotoData(); nn::Result ImportData(); void CreateWriteFinishedFile(); diff --git a/trunk/ConsoleDataMigration/common/FileTransfer.cpp b/trunk/ConsoleDataMigration/common/FileTransfer.cpp index 363bc7b..c67d566 100644 --- a/trunk/ConsoleDataMigration/common/FileTransfer.cpp +++ b/trunk/ConsoleDataMigration/common/FileTransfer.cpp @@ -157,7 +157,7 @@ bool ExportTwlSaveFile(const wchar_t* from_path, const wchar_t* to_path, void* b nn::Result result; - bool ret_value = false; + bool ret_value = true; // ファイル作成 nn::fs::FileInputStream from_file; nn::fs::FileStream to_file; @@ -800,6 +800,7 @@ bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file if (!VerifyMac(from_file, to_file, sdFileSize, nandFileSize, truePath, buf, bufSize)) { // 検証に失敗したので削除する + s_FinishedFileSize -= nandFileSize; COMMON_LOGGER("**********Verification Failed %s, Delete**********\n", GetCharStr(sdPath)); result = nn::fs::TryDeleteFile(tmpPath); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); @@ -813,6 +814,8 @@ bool ConfirmFile(nn::fs::FileInputStream* from_file, nn::fs::FileStream* to_file COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); if (result.IsFailure()) { + COMMON_LOGGER_RESULT_IF_FAILED(result); + s_FinishedFileSize -= nandFileSize; ret_value = false; } }