mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
書き込み時にリージョンが読み取れないとき、リージョンが一致しないときはFailするように
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
This commit is contained in:
parent
cb82c8d23e
commit
d219a48f09
@ -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();
|
||||
|
||||
|
||||
@ -290,6 +290,26 @@ void ControlState(::std::vector<std::string>& 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
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ namespace ConsoleRestore
|
||||
{
|
||||
|
||||
bool EqualsIVSFileandIVS();
|
||||
bool EqualsRegionDataandRegion();
|
||||
u8* ReadSerialNumber();
|
||||
|
||||
void FinalizeImportThread();
|
||||
|
||||
@ -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++)
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user