移行元本体の国コード、言語コードを反映するように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@5 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-01-31 07:37:52 +00:00
parent b8ffcb4006
commit 6c279d66be
6 changed files with 103 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include <cstdlib>
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
#include <nn/cfg/CTR/cfg_Api.h>
#include <nn/cfg/CTR/cfg_ApiNor.h> // cfg:norの初期化に必要
#include <nn/cfg/CTR/cfg_NtrSettings.h>
#include <nn/ps/CTR/ps_API.h>
@ -45,6 +46,7 @@ namespace
common::SdReaderWriter s_SdWriter;
common::NtrNorData s_NtrNorData;
common::CfgCountryLanguage s_CountryLanguage;
::std::string s_SysSaveRoot;
@ -151,6 +153,23 @@ void DeleteTrash()
common::SdMountManager::Unmount();
}
void WriteCountryLanguageData()
{
COMMON_LOGGER("Export Country and Language Data.\n");
nn::Result result;
nn::cfg::nor::CTR::Initialize();
// 国設定
s_CountryLanguage.country = nn::cfg::CTR::GetCountry();
// 言語設定
s_CountryLanguage.language = nn::cfg::CTR::GetLanguage();
s_SdWriter.WriteBuf(common::COUNTRY_SETTING_PATHNAME, &s_CountryLanguage, sizeof(s_CountryLanguage));
}
void WriteNorData()
{
COMMON_LOGGER("Export NOR Data.\n");
@ -358,6 +377,9 @@ void ExportData()
// 不要なデータを削除する
DeleteTrash();
// 国データと言語データをSDに書き込む
WriteCountryLanguageData();
// NORデータをSDカードに書き込む
WriteNorData();

View File

@ -317,6 +317,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
// アップデートを行う
if(!s_ExecuteFgNup)
{
ImportCountryLanguageData();
StartFGNetworkUpdate();
s_ExecuteFgNup = true;
}

View File

@ -16,10 +16,14 @@
#include <nn.h>
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
#include <nn/cfg/CTR/cfg_ApiInit.h>
#include <nn/cfg/CTR/cfg_ApiNor.h> // cfg:norの初期化に必要
#include <nn/cfg/CTR/cfg_Api.h>
#include <nn/am/am_ApiSystemMenu.h>
#include <nn/cfg/CTR/cfg_NtrSettings.h>
#include <nn/cfg/CTR/cfg_ApiSys.h>
#include <nn/cfg/CTR/detail/cfg_DataStructures.h>
#include <nn/cfg/CTR/detail/cfg_Keys.h>
#include <nn/drivers/aes/CTR/ARM946ES/driverAes_Types.h>
#include <nn/crypto/crypto_SwAesCtrContext.h>
#include <nn/ac/CTR/private/ac_NetworkSetting.h>
@ -367,6 +371,71 @@ bool ExistsConsoleInitializedFile()
return ExistsFile(EXISTS_CONSOLE_INTIALIZED);
}
void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
{
using namespace nn::cfg::CTR;
using namespace nn::cfg::CTR::detail;
SimpleAddressIdCfgData simpleAddressId;
TwlCountryCodeCfgData countryData;
nn::cfg::CTR::system::Initialize();
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::GetConfig(&simpleAddressId, sizeof(SimpleAddressIdCfgData), GET_CFG_KEY(NN_CFG_SIMPLE_ADDRESS, NN_CFG_SIMPLE_ADDRESS_ID)));
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::GetConfig(&countryData, sizeof(TwlCountryCodeCfgData), GET_CFG_KEY(NN_CFG_TWL, NN_CFG_TWL_COUNTRY_CODE)));
nn::cfg::CTR::system::Finalize();
simpleAddressId.id = (countryCode << CFG_SIMPLE_ADDRESS_ID_COUNTRY_SHIFT) | (1
<< CFG_SIMPLE_ADDRESS_ID_REGION_SHIFT);
countryData.country = countryCode;
nn::cfg::CTR::system::Initialize();
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::SetConfig(GET_CFG_KEY(NN_CFG_SIMPLE_ADDRESS, NN_CFG_SIMPLE_ADDRESS_ID), &simpleAddressId, sizeof(SimpleAddressIdCfgData)));
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::system::SetConfig(GET_CFG_KEY(NN_CFG_TWL, NN_CFG_TWL_COUNTRY_CODE), &countryData, sizeof(TwlCountryCodeCfgData)));
nn::cfg::CTR::system::FlushConfig();
nn::cfg::CTR::system::Finalize();
}
void SetLanguage(nn::cfg::CTR::CfgLanguageCode languageCode)
{
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::init::SetConfig(
GET_CFG_KEY(nn::cfg::CTR::detail::NN_CFG_USER_INFO,
nn::cfg::CTR::detail::NN_CFG_USER_INFO_LANGUAGE),
&languageCode,
sizeof(nn::cfg::CTR::detail::LanguageCfgData)));
NN_UTIL_PANIC_IF_FAILED(nn::cfg::CTR::init::FlushConfig());
nn::cfg::nor::CTR::Initialize();
NN_UTIL_PANIC_IF_FAILED(nn::cfg::nor::CTR::SetLanguage(static_cast<nn::cfg::CTR::CfgLanguageCode>(languageCode)));
nn::cfg::nor::CTR::Finalize();
}
void ImportCountryLanguageData()
{
nn::Result result;
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
if (buf != NULL)
{
common::SdReaderWriter sdReader;
size_t readSize;
result = sdReader.ReadBuf(common::COUNTRY_SETTING_PATHNAME, buf, bufSize, &readSize);
if(result.IsSuccess())
{
// SDから読み出し成功
SetCountry(reinterpret_cast<common::CfgCountryLanguage*>(buf)->country);
SetLanguage(reinterpret_cast<common::CfgCountryLanguage*>(buf)->language);
}
else
{
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
common::HeapManager::GetHeap()->Free(buf);
}
}
void ImportIvs()
{
nn::Result result;

View File

@ -86,6 +86,7 @@ struct CheckedNetworkSetting
};
CheckedNetworkSetting* GetTempNetworkSetting();
void ImportCountryLanguageData();
}

View File

@ -23,6 +23,7 @@ const char* const NAND_ARCHIVE_NAME = "nand:";
const char* const SD_ARCHIVE_NAME = "sdmc:";
const wchar_t* const SD_SAVEDATA_ROOT_NAME = L"CTR_ConsoleBackup/";
const wchar_t* const COUNTRY_SETTING_PATHNAME = L"sdmc:/CountrySetting.bin";
const wchar_t* const AP_SETTING_FILENAME = L"APSetting.txt";
const wchar_t* const AP_SETTING_PATHNAME = L"sdmc:/APSetting.txt";
const wchar_t* const NOR_PATHNAME = L"sdmc:/NtrNorSetting.bin";

View File

@ -17,6 +17,8 @@
#define COMMON_TYPES_H_
#include <nn/cfg/CTR/cfg_NtrSettings.h>
#include <nn/cfg/CTR/cfg_CountryCode.h>
#include <nn/cfg/CTR/cfg_LanguageCode.h>
namespace common
{
@ -33,6 +35,13 @@ struct NtrNorData
u8 NtrWiFiSetting[NTR_WIFI_SETTING_SIZE];
};
struct CfgCountryLanguage
{
enum nn::cfg::CTR::CfgCountryCode country;
enum nn::cfg::CTR::CfgLanguageCode language;
NN_PADDING1;
};
}