From d219a48f09817cd0df07eaebf0791e9c9e7b6400 Mon Sep 17 00:00:00 2001 From: N2614 Date: Thu, 24 Feb 2011 04:54:47 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B8=E3=81=8D=E8=BE=BC=E3=81=BF=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=83=AA=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=81=8C?= =?UTF-8?q?=E8=AA=AD=E3=81=BF=E5=8F=96=E3=82=8C=E3=81=AA=E3=81=84=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=80=81=E3=83=AA=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E4=B8=80=E8=87=B4=E3=81=97=E3=81=AA=E3=81=84=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=AFFail=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=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@87 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../ConsoleBackup/Exporter.cpp | 13 +++++++ .../ConsoleRestore/Controller.cpp | 20 +++++++++++ .../ConsoleRestore/Importer.cpp | 36 +++++++++++++++++++ .../ConsoleRestore/Importer.h | 1 + .../common/FileChecker.cpp | 5 +++ .../ConsoleDataMigration/common/FileChecker.h | 5 ++- trunk/ConsoleDataMigration/common/FileName.h | 1 + 7 files changed, 80 insertions(+), 1 deletion(-) diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp b/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp index 234d034..9979eed 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp +++ b/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp @@ -147,6 +147,16 @@ void DeleteTrash(std::wstring currentDirectory) common::SdMountManager::Unmount(); } +void WriteRegionData() +{ + COMMON_LOGGER("Export Region Data.\n"); + + nn::cfg::CTR::CfgRegionCode region; + region = nn::cfg::CTR::GetRegion(); + + s_SdWriter.WriteBuf(common::REGION_DATA_PATHNAME, ®ion, sizeof(nn::cfg::CTR::CfgRegionCode)); +} + void WriteCountryLanguageData() { COMMON_LOGGER("Export Country and Language Data.\n"); @@ -501,6 +511,9 @@ void ExportData() if (init) { + // リージョンデータをSDに書き込む + WriteRegionData(); + // 国データと言語データをSDに書き込む WriteCountryLanguageData(); diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp index 5479d5f..a120bfd 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp @@ -290,6 +290,26 @@ void ControlState(::std::vector& operationMessage, bool& nextStep, COMMON_LOGGER("Can't Write SD Card!!\n"); } } + + // SDカードにリージョンデータがあるか? + if(ExistsRegionData()) + { + // リージョンデータは一致しているか? + if(!EqualsRegionDataandRegion()) + { + COMMON_LOGGER("Current Region and Region in SD differ!!\n"); + error = true; + s_RestoreState = FAIL; + } + } + else + { + // 移行不能なのでFAIL + COMMON_LOGGER("Can't Read Region in SD Card!!\n"); + error = true; + s_RestoreState = FAIL; + } + } else { diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp index 54d6fe7..11b4898 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp @@ -67,6 +67,7 @@ const size_t NTP_SERVER_NAME_LENGTH = 256; char s_NtpServerName[NTP_SERVER_NAME_LENGTH]; bool s_CheckedEqualsIVSFileandIVS = false; +bool s_CheckedEqualsRegionDataandRegion = false; bool s_ReadSerialNumber = false; // シリアルナンバー @@ -219,6 +220,7 @@ u8* ReadSerialNumber() s_ReadSerialNumber = true; return s_SerialNo; } + bool EqualsIVSFileandIVS() { nn::Result result; @@ -286,6 +288,39 @@ bool EqualsIVSFileandIVS() return retval; } +bool EqualsRegionDataandRegion() +{ + nn::Result result; + static bool retval = false; + + if(s_CheckedEqualsRegionDataandRegion) + { + return retval; + } + + COMMON_LOGGER("Check Region\n"); + + nn::cfg::CTR::CfgRegionCode region; + region = nn::cfg::CTR::GetRegion(); + + nn::cfg::CTR::CfgRegionCode sdRegion; + common::SdReaderWriter sdReader; + size_t dummy; + + result = sdReader.ReadBuf(common::REGION_DATA_PATHNAME, &sdRegion, sizeof(sdRegion), &dummy); + s_CheckedEqualsRegionDataandRegion = true; + if(result.IsSuccess()) + { + retval = (region == sdRegion); + return retval; + } + else + { + retval = false; + return retval; + } +} + void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode) { using namespace nn::cfg::CTR; @@ -1310,6 +1345,7 @@ void ImportTwlSoundData() void ClearFileReadResult() { s_CheckedEqualsIVSFileandIVS = false; + s_CheckedEqualsRegionDataandRegion = false; s_ReadSerialNumber = false; } diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h index 7a82222..03f46d1 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.h @@ -24,6 +24,7 @@ namespace ConsoleRestore { bool EqualsIVSFileandIVS(); +bool EqualsRegionDataandRegion(); u8* ReadSerialNumber(); void FinalizeImportThread(); diff --git a/trunk/ConsoleDataMigration/common/FileChecker.cpp b/trunk/ConsoleDataMigration/common/FileChecker.cpp index 61b2e0e..c7e1f97 100644 --- a/trunk/ConsoleDataMigration/common/FileChecker.cpp +++ b/trunk/ConsoleDataMigration/common/FileChecker.cpp @@ -117,6 +117,11 @@ bool ExistsVersionData() return ExistsFile(EXISTS_VERSION_DATA); } +bool ExistsRegionData() +{ + return ExistsFile(EXISTS_REGION_DATA); +} + void InitializeFileCheck() { for(u32 i = 0; i < EXISTS_MAX; i++) diff --git a/trunk/ConsoleDataMigration/common/FileChecker.h b/trunk/ConsoleDataMigration/common/FileChecker.h index 7d593fb..fc1ac42 100644 --- a/trunk/ConsoleDataMigration/common/FileChecker.h +++ b/trunk/ConsoleDataMigration/common/FileChecker.h @@ -33,6 +33,7 @@ typedef enum FILE_EXISTS_CHECK EXISTS_COUNTRY_LANGUAGE, EXISTS_TRY_RESTORE_SAME_CONSOLE, EXISTS_VERSION_DATA, + EXISTS_REGION_DATA, EXISTS_MAX } FileExistsCheck; @@ -47,7 +48,8 @@ const wchar_t* const FILENAME_TABLE[EXISTS_MAX] = common::RTC_SYNC_CHECK_PATHNAME, common::COUNTRY_SETTING_PATHNAME, common::TRY_RESTORE_SAME_CONSOLE_PATHNAME, - common::VERSION_DATA_PATHNAME + common::VERSION_DATA_PATHNAME, + common::REGION_DATA_PATHNAME }; bool CheckFileExists(const wchar_t* path); @@ -61,6 +63,7 @@ bool ExistsRtcSyncFinishedFile(); bool ExistsCountryLanguageFile(); bool ExistsTryRestoreSameConsoleFile(); bool ExistsVersionData(); +bool ExistsRegionData(); void InitializeFileCheck(); diff --git a/trunk/ConsoleDataMigration/common/FileName.h b/trunk/ConsoleDataMigration/common/FileName.h index 84cb1b0..531efee 100644 --- a/trunk/ConsoleDataMigration/common/FileName.h +++ b/trunk/ConsoleDataMigration/common/FileName.h @@ -54,6 +54,7 @@ const wchar_t* const PLAYHISTORY_PATHNAME = L"sdmc:/CTR_Console_Repair/playhisto const wchar_t* const PLAYHISTORY_COUNT_PATHNAME = L"sdmc:/CTR_Console_Repair/playhistoryCount.bin"; const wchar_t* const TOUCH_PANEL_CALIBRATION_PATHNAME = L"sdmc:/CTR_Console_Repair/tpCalibration.bin"; const wchar_t* const VERSION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/version.bin"; +const wchar_t* const REGION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/Region.bin"; enum TWL_PATH_INDEX {