diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp index b060d0e..62b0d87 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp @@ -135,7 +135,6 @@ typedef enum RestoreState RESTORE_IN_PROGRESS, // 書き込み中 POST_RESTORE, // 書き込み後の処理 RESTORE_DONE, // 書き込み完了 - RESTORE_TEST, // 書き込み後のチェック REBOOTING, // 再起動を行う ERASE, // 削除処理を行う RESTORE_CAL, // cfgの一部をcal値で上書きする @@ -778,14 +777,15 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector(serial)); + ::std::string serialStr(reinterpret_cast (serial)); operationMessage.push_back(::std::string("Serial Number in SD : ") + serialStr); } else @@ -852,7 +852,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector 99) { - s_RestoreState = RESTORE_TEST; + s_RestoreState = POST_RESTORE; } else { @@ -1260,8 +1260,8 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector #include #include -#include #include #include // cfg:norの初期化に必要 #include @@ -623,43 +622,6 @@ bool InitializeFileSystem() return true; } -nn::Result GetNewIvs(void* oldBuf, size_t oldBufSize, void* newBuf, size_t newBufSize, size_t* newIvsSize) -{ - if (oldBufSize < nn::fs::CTR::SIZE_INTEGRITY_VERIFICATION_SEED - || newBufSize < nn::fs::CTR::SIZE_INTEGRITY_VERIFICATION_SEED - || oldBuf == NULL || newBuf == NULL - ) - { - return nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON, - nn::Result::DESCRIPTION_OUT_OF_MEMORY); - } - - nn::Result result; - result = common::SdMountManager::Mount(); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - common::SdReaderWriter sdReader; - size_t readSize; - result = sdReader.ReadBufWithCmac(common::IVS_PATHNAME, oldBuf, oldBufSize, &readSize); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - *newIvsSize = readSize; - - // AES復号化する - nn::crypto::Initialize(); - nn::crypto::SwAesCtrContext swAesCtrContest; - - swAesCtrContest.Initialize(common::iv, common::key, sizeof(common::key)); - result = swAesCtrContest.Decrypt(newBuf, oldBuf, readSize); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - nn::crypto::Finalize(); - - result = common::SdMountManager::Unmount(); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - return nn::ResultSuccess(); -} - nn::Result ImportIvs() { nn::Result result = nn::ResultSuccess(); @@ -674,7 +636,7 @@ nn::Result ImportIvs() size_t readSize; result = sdReader.ReadBufWithCmac(common::IVS_PATHNAME, enc, bufSize, &readSize); - if (result.IsSuccess()) + if(result.IsSuccess()) { // SDから読み出し成功 result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); @@ -770,7 +732,6 @@ void ImportThreadFunc() NN_LOG("Import Thread Finalize\n"); } - namespace { @@ -1895,72 +1856,6 @@ bool IsImportSucceeded() return s_IsImportSucceeded; } - -nn::Result GetNewSaveDirRoot(std::wstring& sysSaveRoot) -{ - nn::Result result; - - const size_t BUF_SIZE = 1024; - common::HeapManager oldBuf(BUF_SIZE); - common::HeapManager newBuf(BUF_SIZE); - size_t ivsSize; - - result = GetNewIvs(oldBuf.GetAddr(), BUF_SIZE, newBuf.GetAddr(), BUF_SIZE, &ivsSize); - COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result); - - std::string root; - common::Util::GetSaveDataDirectoryRoot(root, newBuf.GetAddr(), ivsSize); - - wchar_t rootName[256]; - std::mbstowcs(rootName, root.c_str(), root.size() + 1); - sysSaveRoot = rootName; - - return nn::ResultSuccess(); -} - -void TestCtrDataThreadFunc() -{ - nn::Result result; - s_IsImportSucceeded = true; - - // 新IVSディレクトリを取得 - std::wstring sysSaveRoot; - result = GetNewSaveDirRoot(sysSaveRoot); - COMMON_LOGGER_RETURN_VOID_SET_BOOL_IF_FAILED(result, s_IsImportSucceeded); - - result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); - COMMON_LOGGER_RETURN_VOID_SET_BOOL_IF_FAILED(result, s_IsImportSucceeded); - - u32 fileNum = 0; - s64 fileSize = 0; - result = common::CalculateFileNum( - ::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + sysSaveRoot + std::wstring(L"/"), fileNum, - fileSize); - COMMON_LOGGER_RETURN_VOID_SET_BOOL_IF_FAILED(result, s_IsImportSucceeded); - - common::InitializeTransferProgress(fileSize); - - size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE); - common::HeapManager buf(bufSize, AES_BLOCK_SIZE); - - if(!common::TestReadDirectory((std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + sysSaveRoot + std::wstring(L"/")).c_str(), buf.GetAddr(), bufSize - )) - { - s_IsImportSucceeded = false; - return; - } - - result = nn::fs::Unmount(common::NAND_ARCHIVE_NAME); - COMMON_LOGGER_RETURN_VOID_SET_BOOL_IF_FAILED(result, s_IsImportSucceeded); - -} - -void TestCtrData() -{ - COMMON_LOGGER("Test NAND Data Start...\n"); - s_ImportThread.Start(TestCtrDataThreadFunc, s_ImportThreadStack); -} - nn::Result ImportData() { static nn::Result result = nn::ResultSuccess(); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h index a875a7c..e2c49b1 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h @@ -160,9 +160,6 @@ bool ImportIvsData(); // 書き込みが成功したかどうか bool IsImportSucceeded(); -// 新たにスレッドを立て、CTR-NAND領域をテストする -void TestCtrData(); - } #endif /* IMPORTER_H_ */ diff --git a/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp b/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp index ba419f3..16bea31 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp +++ b/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp @@ -767,88 +767,4 @@ bool AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t * return true; } - -bool TestReadDirectory(const wchar_t* path, void* buf, const size_t bufSize) -{ - nn::fs::Directory dir; - nn::fs::DirectoryEntry entry; - s32 numread = 0; - std::wostringstream targetStream; - - NN_LOG("Read Directory %ls\n", path); - nn::Result result = dir.TryInitialize(path); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result); - - while (1) - { - result = dir.TryRead(&numread, &entry, 1); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result); - - if(numread == 0) - { - break; - } - - if (std::wcscmp(entry.entryName, L".") == 0 || std::wcscmp(entry.entryName, L"..") == 0) - { - continue; - } - - targetStream.str(L""); - targetStream.clear(std::stringstream::goodbit); - targetStream << path << entry.entryName; - - // ディレクトリの場合 - if (entry.attributes.isDirectory) - { - targetStream << L"/"; - - // 再帰処理 - if (!TestReadDirectory(targetStream.str().c_str(), buf, bufSize)) - { - return false; - } - } - // ファイルの場合 - else - { - // ファイル作成 - nn::fs::FileInputStream file; - s64 filesize; - s32 readsize; - - NN_LOG("Read File %ls\n", targetStream.str().c_str()); - - // 読み込み対象ファイル開く - result = file.TryInitialize(targetStream.str().c_str()); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result); - - // 読み込み対象ファイルのサイズ取得 - result = file.TryGetSize(&filesize); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result); - - // ファイル全体を読みきるまでループ - while (1) - { - result = file.TryRead(&readsize, buf, bufSize); - COMMON_LOGGER_RETURN_FALSE_IF_FAILED(result); - - if (readsize == 0) - { - break; - } - else - { - s_FinishedFileSize += readsize; - s_Progress = s_FinishedFileSize * 100 / s_TotalFileSize; - NN_LOG( - "finish = %lld, total = %lld, progress = %lld\n", s_FinishedFileSize, s_TotalFileSize, s_Progress); - } - } - } - } - - return true; -} - } diff --git a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h index 7a6e4c0..e55f3bf 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h +++ b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h @@ -57,9 +57,6 @@ void InitializeTransferProgress(u64 totalSize); // 内部のバッファを使用するためスレッドアンセーフ const char* GetCharStr(const wchar_t* path); -// pathで指定したディレクトリ以下を再帰的に読み込んでエラーが発生しないかテストする -bool TestReadDirectory(const wchar_t* path, void* buf, const size_t bufSize); - } #endif /* FILETRANSFER_H_ */