mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
TWLパーティションのセーブデータを書き込むように
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
This commit is contained in:
parent
0a2855fa1b
commit
32036eb784
@ -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<std::string>& 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<std::string>& 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:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -31,6 +31,7 @@ nn::Result SetupFileList();
|
||||
void FinalizeImportThread();
|
||||
bool IsImportFinished();
|
||||
void ImportTwlSoundData();
|
||||
void ImportTwlSaveData();
|
||||
void ImportTwlPhotoData();
|
||||
nn::Result ImportData();
|
||||
void CreateWriteFinishedFile();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user