CMAC検証エラー時にFAILするように

Thread::IsAliveの前にThread::IsValidをチェックするように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@138 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-03-14 12:14:49 +00:00
parent 4dc123cbf9
commit ad0301f4b0
7 changed files with 228 additions and 134 deletions

View File

@ -558,7 +558,7 @@ u32 GetProgress()
bool IsExportFinished()
{
return !s_ExportThread.IsAlive();
return s_ExportThread.IsValid() && !s_ExportThread.IsAlive();
}
}

View File

@ -20,6 +20,7 @@
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
#include <nn/ptm/CTR/ptm_ApiSystem.h>
#include <nn/pl/CTR/pl_PlayHistoryApiSysmenu.h>
#include <nn/cfg/CTR/cfg_ApiSys.h>
#include "Controller.h"
#include "FileChecker.h"
@ -90,6 +91,8 @@ bool s_PlayedSdPullOutCursor = false;
bool s_ExistsVersionDataAnnotation = false;
// バージョンデータを読んだかどうか
bool s_ReadVersionDone = false;
// バージョンデータを読んだ結果
nn::Result s_ReadVersionResult = nn::ResultSuccess();
// SDに書き込みできない警告サウンドを鳴らしたかどうか
bool s_SdWriteProetctAnnotation = false;
@ -147,7 +150,7 @@ bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
return s_ReadSettingSuccess;
}
bool CheckAndReadVersionData(::std::vector<std::string>& operationMessage)
nn::Result CheckAndReadVersionData(::std::vector<std::string>& operationMessage)
{
using namespace common;
@ -159,17 +162,18 @@ bool CheckAndReadVersionData(::std::vector<std::string>& operationMessage)
common::PlaySound(common::SOUND_ANNOTATION);
}
operationMessage.push_back(::std::string("Version Data does not exist!"));
return false;
return nn::Result(nn::Result::LEVEL_PERMANENT, nn::Result::SUMMARY_NOT_FOUND, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_NOT_FOUND);
}
// バージョン情報ファイルを読み込む
if (!s_ReadVersionDone)
{
s_ReadVersionDone = true;
ReadVersionData();
s_ReadVersionResult = ReadVersionData();
}
return s_ReadSettingSuccess;
return s_ReadVersionResult;
}
void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* str)
@ -195,14 +199,20 @@ void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* s
i += 4;
}
void ExecSyncMcuRtc()
nn::Result ExecSyncMcuRtc()
{
nn::Result result = nn::ResultSuccess();
if(!common::ExistsRtcSyncFinishedFile())
{
ImportMcuRtc();
// 時計を無効化する
CreateRtcSyncFinishedFile();
result = ImportMcuRtc();
if(result.IsSuccess())
{
// RTCを同期完了ファイルを作る
CreateRtcSyncFinishedFile();
}
}
return result;
}
// Zero NUP限定コード
@ -221,6 +231,7 @@ bool NeedsNup()
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore)
{
using namespace common;
nn::Result result;
// 状態遷移Controller
switch (s_RestoreState)
@ -248,7 +259,14 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
break;
}
CheckAndReadVersionData(operationMessage);
result = CheckAndReadVersionData(operationMessage);
if(result.IsFailure())
{
// バージョン情報の取得に失敗
error = true;
s_RestoreState = FAIL;
}
validApSetting = CheckAndReadAPSetting(operationMessage);
if (!validApSetting)
{
@ -287,8 +305,18 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
}
else
{
::std::string serial(reinterpret_cast<char*> (ReadSerialNumber()));
operationMessage.push_back(::std::string("Serial Number in SD : ") + serial);
u8 serial[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
result = ReadSerialNumber(serial);
if(result.IsSuccess())
{
::std::string serialStr(reinterpret_cast<char*> (serial));
operationMessage.push_back(::std::string("Serial Number in SD : ") + serialStr);
}
else
{
error = true;
s_RestoreState = FAIL;
}
}
@ -296,7 +324,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
if (ExistsRegionData())
{
// リージョンデータは一致しているか?
if (!EqualsRegionDataandRegion())
if (EqualsRegionDataandRegion().IsFailure())
{
COMMON_LOGGER("Current Region and Region in SD differ!!\n");
error = true;
@ -416,11 +444,16 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
// Zero NUP限定
// RTC同期を行う
// NUPされない場合があるのでここで同期
ExecSyncMcuRtc();
s_RestoreState = RESTORE_TWL_SOUND;
result = ExecSyncMcuRtc();
if(result <= nn::fs::ResultVerificationFailed())
{
s_RestoreState = FAIL;
}
else
{
s_RestoreState = RESTORE_TWL_SOUND;
}
}
}
}
break;
@ -460,9 +493,15 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
// アップデートを行う
if(!s_ExecuteFgNup)
{
ImportCountryLanguageData();
StartFGNetworkUpdate();
s_ExecuteFgNup = true;
if(ImportCountryLanguageData().IsSuccess())
{
StartFGNetworkUpdate();
s_ExecuteFgNup = true;
}
else
{
s_RestoreState = FAIL;
}
}
// 動いていることを表示
@ -588,7 +627,10 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
}
// データを読み込む
ImportData();
if(ImportData().IsFailure())
{
s_RestoreState = FAIL;
}
// 処理が完了した
if (continueRestore && IsImportFinished())
@ -616,8 +658,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
if (init)
{
// ErrDispから引用
// 権限をもらえば成功するはず
nn::Result result = nn::ns::CTR::InitializeForShell();
result = nn::ns::CTR::InitializeForShell();
if (result.IsSuccess())
{
COMMON_LOGGER("System Reboot.\n");
@ -866,6 +907,7 @@ void InitializeState()
s_NupOnlyMode = false;
s_ReadVersionDone = false;
s_SdWriteProetctAnnotation = false;
s_ReadVersionResult = nn::ResultSuccess();
}
u32 GetProgress()

View File

@ -79,7 +79,7 @@ bool CreateEmptyFile(const wchar_t* path);
// SDからNANDにセーブデータをコピーする
void ImportSaveData();
// SDからNORにNORデータをコピーする
void ImportNorData();
nn::Result ImportNorData();
// SDカードに保存してあるバージョン情報
common::VerDef s_SDVersionData;
@ -198,13 +198,14 @@ bool CreateEmptyFile(const wchar_t* path)
}
u8* ReadSerialNumber()
nn::Result ReadSerialNumber(u8* serial)
{
nn::Result result;
static nn::Result result = nn::ResultSuccess();
if(s_ReadSerialNumber)
{
return s_SerialNo;
std::memcpy(serial, s_SerialNo, sizeof(s_SerialNo));
return result;
}
COMMON_LOGGER("Read Serial Number in SD.\n");
@ -219,21 +220,26 @@ u8* ReadSerialNumber()
if(result.IsSuccess())
{
std::memcpy(s_SerialNo, buf, sizeof(s_SerialNo));
s_ReadSerialNumber = true;
std::memcpy(serial, s_SerialNo, sizeof(s_SerialNo));
s_ReadSerialNumber = true;
}
common::HeapManager::GetHeap()->Free(buf);
}
return s_SerialNo;
else
{
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
return result;
}
bool EqualsDeviceIdFileandDeviceId()
nn::Result EqualsDeviceIdFileandDeviceId()
{
nn::Result result;
static bool retval = false;
static nn::Result result = nn::ResultSuccess();
if(s_CheckedEqualsDeviceIdFileandDeviceId)
{
return retval;
return result;
}
COMMON_LOGGER("Check Device Id\n");
@ -245,24 +251,29 @@ bool EqualsDeviceIdFileandDeviceId()
s_CheckedEqualsDeviceIdFileandDeviceId = true;
if(result.IsSuccess())
{
retval = (GetDeviceId() == sdDeviceId);
return retval;
if(GetDeviceId() == sdDeviceId)
{
result = nn::ResultSuccess();
return result;
}
result = nn::Result(nn::Result::LEVEL_STATUS, nn::Result::SUMMARY_INVALID_RESULT_VALUE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_INVALID_RESULT_VALUE);
return result;
}
else
{
retval = false;
return retval;
return result;
}
}
bool EqualsRegionDataandRegion()
nn::Result EqualsRegionDataandRegion()
{
nn::Result result;
static bool retval = false;
static nn::Result result = nn::ResultSuccess();
if(s_CheckedEqualsRegionDataandRegion)
{
return retval;
return result;
}
COMMON_LOGGER("Check Region\n");
@ -281,24 +292,26 @@ bool EqualsRegionDataandRegion()
if (result.IsSuccess())
{
std::memcpy(&sdRegion, buf, sizeof(sdRegion));
s_CheckedEqualsRegionDataandRegion = true;
if(result.IsSuccess())
{
retval = (region == sdRegion);
}
else
{
retval = false;
}
}
else
{
retval = false;
s_CheckedEqualsRegionDataandRegion = true;
if(region == sdRegion)
{
result = nn::ResultSuccess();
}
else
{
result = nn::Result(nn::Result::LEVEL_STATUS, nn::Result::SUMMARY_INVALID_RESULT_VALUE,
nn::Result::MODULE_COMMON, nn::Result::DESCRIPTION_INVALID_RESULT_VALUE);
}
}
common::HeapManager::GetHeap()->Free(buf);
}
else
{
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
return retval;
return result;
}
void SetCountry(nn::cfg::CTR::CfgCountryCode countryCode)
@ -339,9 +352,9 @@ void SetLanguage(nn::cfg::CTR::CfgLanguageCode languageCode)
nn::cfg::nor::CTR::Finalize();
}
void ImportCountryLanguageData()
nn::Result ImportCountryLanguageData()
{
nn::Result result;
nn::Result result = nn::ResultSuccess();
if (common::ExistsCountryLanguageFile())
{
@ -360,11 +373,9 @@ void ImportCountryLanguageData()
SetLanguage(reinterpret_cast<common::CfgCountryLanguage*> (buf)->language);
}
else
{
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
common::HeapManager::GetHeap()->Free(buf);
NN_UTIL_RETURN_IF_FAILED(result);
}
}
else
@ -419,6 +430,8 @@ void ImportCountryLanguageData()
}
}
return result;
}
inline u8 DecimalToBcd(u8 param)
@ -429,10 +442,10 @@ inline u8 DecimalToBcd(u8 param)
return (theTen << 4 | theOne);
}
void ImportMcuRtc()
nn::Result ImportMcuRtc()
{
COMMON_LOGGER("Import RTC Data.\n");
nn::Result result;
nn::Result result = nn::ResultSuccess();
nn::Handle handle = GetMcuHandle();
if(handle.IsValid())
@ -469,16 +482,25 @@ void ImportMcuRtc()
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
common::HeapManager::GetHeap()->Free(buf);
NN_UTIL_RETURN_IF_FAILED(result);
}
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
}
}
else
{
result = nn::Result(nn::Result::LEVEL_PERMANENT, nn::Result::SUMMARY_INVALID_STATE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_INVALID_HANDLE);
}
return result;
}
void InitializeFileSystem()
@ -558,9 +580,9 @@ void InitializeFileSystem()
nn::fs::InitializeCtrFileSystem();
}
void ImportIvs()
nn::Result ImportIvs()
{
nn::Result result;
nn::Result result = nn::ResultSuccess();
nn::fs::FileOutputStream fos;
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize() / 2;
@ -606,17 +628,27 @@ void ImportIvs()
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
}
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
}
else
{
return result;
}
common::HeapManager::GetHeap()->Free(enc);
}
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
return result;
}
void ImportThreadFunc()
@ -678,11 +710,11 @@ void ImportSaveData()
}
void ImportNorData()
nn::Result ImportNorData()
{
COMMON_LOGGER("Import NOR Data.\n");
nn::Result result;
nn::Result result = nn::ResultSuccess();
nn::cfg::nor::CTR::Initialize();
@ -714,24 +746,28 @@ void ImportNorData()
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
common::HeapManager::GetHeap()->Free(buf);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
NN_UTIL_RETURN_IF_FAILED(result);
}
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
return result;
}
}
void ReadVersionData()
nn::Result ReadVersionData()
{
nn::Result result;
nn::Result result = nn::ResultSuccess();
std::memset(&s_SDVersionData, 0, sizeof(common::VerDef));
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
@ -755,14 +791,19 @@ void ReadVersionData()
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
common::HeapManager::GetHeap()->Free(buf);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
NN_UTIL_RETURN_IF_FAILED(result);
}
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
return result;
}
bool AlreadyExecutedNup()
@ -811,7 +852,7 @@ void FinalizeImportThread()
bool IsImportFinished()
{
return !s_ImportThread.IsAlive();
return s_ImportThread.IsValid() && !s_ImportThread.IsAlive();
}
void CreateWriteFinishedFile()
@ -1386,12 +1427,11 @@ void ExportCalData()
common::SdMountManager::Unmount();
}
bool ImportCalData(common::CfgCalData *data)
nn::Result ImportCalData(common::CfgCalData *data)
{
using namespace nn::cfg::CTR::detail;
nn::Result result;
bool retval = false;
nn::Result result = nn::ResultSuccess();
COMMON_LOGGER("Import CalData\n");
@ -1409,61 +1449,63 @@ bool ImportCalData(common::CfgCalData *data)
{
// SDから読み出し成功
std::memcpy(data, buf, readSize);
retval = true;
}
else
{
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
}
common::HeapManager::GetHeap()->Free(buf);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
NN_UTIL_RETURN_IF_FAILED(result);
}
else
{
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
}
common::SdMountManager::Unmount();
return retval;
return result;
}
void InitializeHardwareDependentSetting()
nn::Result InitializeHardwareDependentSetting()
{
using namespace nn::cfg::CTR::detail;
nn::Result result = nn::ResultSuccess();
common::CfgCalData cfgCalData;
if (ImportCalData(&cfgCalData))
{
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_TOUCHPANEL),
&cfgCalData.touchPanelCfgData, sizeof(TouchPanelCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = ImportCalData(&cfgCalData);
NN_UTIL_RETURN_IF_FAILED(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_LCD, NN_CFG_LCD_CAL_FLICKER),
&cfgCalData.lcdFlickerCfgData, sizeof(LcdFlickerCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_TOUCHPANEL),
&cfgCalData.touchPanelCfgData, sizeof(TouchPanelCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_FCRAM, NN_CFG_FCRAM_CAL_DELAY),
&cfgCalData.fcramCfgData, sizeof(FcramCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_LCD, NN_CFG_LCD_CAL_FLICKER),
&cfgCalData.lcdFlickerCfgData, sizeof(LcdFlickerCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_RTC, NN_CFG_RTC_CAL_COMPENSATION),
&cfgCalData.rtcCfgData, sizeof(RtcCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_FCRAM, NN_CFG_FCRAM_CAL_DELAY), &cfgCalData.fcramCfgData,
sizeof(FcramCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_GYROSCOPE),
&cfgCalData.gyroscopeCfgData, sizeof(GyroscopeCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_RTC, NN_CFG_RTC_CAL_COMPENSATION),
&cfgCalData.rtcCfgData, sizeof(RtcCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_ACCELEROMETER),
&cfgCalData.accelCfgData, sizeof(AccelCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_GYROSCOPE),
&cfgCalData.gyroscopeCfgData, sizeof(GyroscopeCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_CODEC, NN_CFG_CODEC_CAL), &cfgCalData.codecCfgData,
sizeof(CodecCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_HID, NN_CFG_HID_CAL_ACCELEROMETER),
&cfgCalData.accelCfgData, sizeof(AccelCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_MCU, NN_CFG_MCU_SLIDE_VOLUME), &cfgCalData.mcuSlideVolumeRangeCfgData,
sizeof(McuSlideVolumeRangeCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_CODEC, NN_CFG_CODEC_CAL), &cfgCalData.codecCfgData,
sizeof(CodecCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
NN_LOG("Set cfgCalData\n");
}
result = nn::cfg::CTR::init::SetConfig(GET_CFG_KEY(NN_CFG_MCU, NN_CFG_MCU_SLIDE_VOLUME),
&cfgCalData.mcuSlideVolumeRangeCfgData, sizeof(McuSlideVolumeRangeCfgData));
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
NN_LOG("Set cfgCalData\n");
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
@ -1472,21 +1514,28 @@ void InitializeHardwareDependentSetting()
nn::cfg::CTR::init::ResetAnalogStickCalibration();
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
return result;
}
void ImportData()
nn::Result ImportData()
{
static nn::Result result = nn::ResultSuccess();
static bool init = true;
if(init)
{
init = false;
// NANDのごみを削除する
Cleanup();
// SDカードのIVSファイルを書き込む
ImportIvs();
result = ImportIvs();
NN_UTIL_RETURN_IF_FAILED(result);
// NORデータを書き込む
ImportNorData();
result = ImportNorData();
NN_UTIL_RETURN_IF_FAILED(result);
// 固体固有calLデータをSDカードに出力する
// 本体初期化後はcal値が設定されている
@ -1494,10 +1543,9 @@ void ImportData()
// SDカードのセーブデータをNANDに書き込む
ImportSaveData();
init = false;
}
return result;
}
}

View File

@ -23,15 +23,15 @@
namespace ConsoleRestore
{
bool EqualsDeviceIdFileandDeviceId();
bool EqualsRegionDataandRegion();
u8* ReadSerialNumber();
nn::Result EqualsDeviceIdFileandDeviceId();
nn::Result EqualsRegionDataandRegion();
nn::Result ReadSerialNumber(u8* serial);
void FinalizeImportThread();
bool IsImportFinished();
void ImportTwlSoundData();
void ImportTwlPhotoData();
void ImportData();
nn::Result ImportData();
void CreateWriteFinishedFile();
void CreateUpdateFinishedFile();
void CreateConsoleInitializedFile();
@ -71,8 +71,8 @@ struct CheckedNetworkSetting
};
CheckedNetworkSetting* GetTempNetworkSetting();
void ImportCountryLanguageData();
void ImportMcuRtc();
nn::Result ImportCountryLanguageData();
nn::Result ImportMcuRtc();
// TWL写真領域を初期化してから本体初期化を行う
void InitializeFileSystem();
@ -83,10 +83,10 @@ void ClearFileReadResult();
void ImportPlayHistory();
// cfgのハードウェア固有領域をcal値で初期化します
void InitializeHardwareDependentSetting();
nn::Result InitializeHardwareDependentSetting();
// SDカード上のバージョン情報を読みます
void ReadVersionData();
nn::Result ReadVersionData();
// 移行元本体がNUP済みかどうか
bool AlreadyExecutedNup();

View File

@ -232,7 +232,7 @@ void FinishFGNetworkUpdate()
bool IsNetworkUpdateFinished()
{
return !s_UpdaterThread.IsAlive();
return s_UpdaterThread.IsValid() && !s_UpdaterThread.IsAlive();
}
u32 GetUpdateProgress()

View File

@ -78,9 +78,9 @@ void PlayHistoryManager::Export()
SdMountManager::Unmount();
}
void PlayHistoryManager::GetPlayHistoryNums(size_t* nums)
nn::Result PlayHistoryManager::GetPlayHistoryNums(size_t* nums)
{
nn::Result result;
nn::Result result = nn::ResultSuccess();
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
@ -95,13 +95,15 @@ void PlayHistoryManager::GetPlayHistoryNums(size_t* nums)
*nums = *reinterpret_cast<size_t*> (buf);
}
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
HeapManager::GetHeap()->Free(buf);
}
HeapManager::GetHeap()->Free(buf);
return result;
}
void PlayHistoryManager::Import()
nn::Result PlayHistoryManager::Import()
{
nn::Result result;
nn::Result result = nn::ResultSuccess();
SdMountManager::Mount();
SdReaderWriter sd;
@ -161,10 +163,12 @@ void PlayHistoryManager::Import()
else
{
NN_LOG("Failed Allocate Heap!! %s, %d", __FILE__, __LINE__);
return;
return result;
}
SdMountManager::Unmount();
return result;
}
void PlayHistoryManager::Dump()

View File

@ -30,13 +30,13 @@ public:
void Export();
//! @brief SDカードからプレイ履歴に書き込みます
void Import();
nn::Result Import();
//! @brief デバッグ用。プレイ履歴をデバッグ出力します。
void Dump();
private:
void GetPlayHistoryNums(size_t* nums);
nn::Result GetPlayHistoryNums(size_t* nums);
};