mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
クラス名変更 HardwareInfo -> Util
IVS取得モードのシーケンス実装 git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@218 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
53e4f388aa
commit
d94579f71f
@ -53,7 +53,7 @@
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "common_Types.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "HardwareInfo.h"
|
||||
#include "Util.h"
|
||||
#include "ResFont.h"
|
||||
|
||||
// svnリビジョン埋め込み用
|
||||
@ -267,8 +267,7 @@ extern "C" void nnMain(void)
|
||||
}
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
common::HardwareInfo hwInfo;
|
||||
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
common::Util::AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
|
||||
// デバイスIDの取得
|
||||
result = nn::ps::CTR::GetDeviceId(&s_DeviceId);
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
#include "Aes_define.h"
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
@ -56,8 +57,6 @@ common::SdReaderWriter s_SdWriter;
|
||||
common::NtrNorData s_NtrNorData;
|
||||
common::CfgCountryLanguage s_CountryLanguage;
|
||||
|
||||
::std::string s_SysSaveRoot;
|
||||
|
||||
const size_t EXPORT_THREAD_STACK_SIZE = 0x4000;
|
||||
nn::os::Thread s_ExportThread;
|
||||
nn::os::StackBuffer<EXPORT_THREAD_STACK_SIZE> s_ExportThreadStack;
|
||||
@ -318,51 +317,6 @@ void WriteIvs()
|
||||
}
|
||||
}
|
||||
|
||||
// IVSからセーブデータディレクトリ名を生成する
|
||||
void GetSaveDataDirectoryRoot()
|
||||
{
|
||||
nn::Result result;
|
||||
using namespace nn::dbg;
|
||||
|
||||
const size_t SEED_SIZE = 16;
|
||||
bit8 hash[nn::crypto::Sha256Context::HASH_SIZE];
|
||||
const size_t SYS_SAVE_ROOT_LENGTH = 16;
|
||||
char rootHash[SYS_SAVE_ROOT_LENGTH];
|
||||
char rootStr[SYS_SAVE_ROOT_LENGTH * 2 + 1];
|
||||
|
||||
void* addr;
|
||||
size_t size;
|
||||
GetIvs(&addr, &size);
|
||||
|
||||
// 最後の16バイトのハッシュを使う
|
||||
nn::crypto::CalculateSha256(hash, &reinterpret_cast<bit8*> (addr)[size - SEED_SIZE], SEED_SIZE);
|
||||
|
||||
for (u8 i = 0; i < SEED_SIZE / 4; i++)
|
||||
{
|
||||
for (u8 j = 0; j < SEED_SIZE / 4; j++)
|
||||
{
|
||||
rootHash[i * 4 + j] = hash[i * 4 + 3 - j];
|
||||
}
|
||||
}
|
||||
|
||||
// 得られたハッシュから文字列を生成
|
||||
for (s32 k = 0; k < SEED_SIZE; k++)
|
||||
{
|
||||
for (s32 i = 6; i < 8; ++i)
|
||||
{
|
||||
bit32 n = (rootHash[k] >> ((7 - i) * 4)) & 0xf;
|
||||
NN_TASSERT_(n < 16);
|
||||
rootStr[i - 6 + k * 2] = static_cast<char> (n < 10 ? '0' + n : 'a' + (n - 10));
|
||||
}
|
||||
}
|
||||
rootStr[SYS_SAVE_ROOT_LENGTH * 2] = '\0';
|
||||
|
||||
// セーブデータディレクトリ名を保存する
|
||||
s_SysSaveRoot = ::std::string(rootStr);
|
||||
|
||||
NN_LOG("%s\n", s_SysSaveRoot.c_str());
|
||||
}
|
||||
|
||||
void CreateTwlDirectory(enum common::TWL_PATH_INDEX path)
|
||||
{
|
||||
NN_ASSERT(path < common::TWL_PATHNAME_MAX);
|
||||
@ -799,7 +753,7 @@ void ExportThreadFunc()
|
||||
NN_LOG("Export Thread Finalize\n");
|
||||
}
|
||||
|
||||
nn::Result WriteSaveData()
|
||||
nn::Result WriteSaveData(::std::string& sysSaveRoot)
|
||||
{
|
||||
// NANDからSDカードに書き出し
|
||||
nn::Result result;
|
||||
@ -818,7 +772,7 @@ nn::Result WriteSaveData()
|
||||
// 進捗表示用
|
||||
common::InitializeTransferProgress(fileSize);
|
||||
|
||||
::std::mbstowcs(s_RootName, s_SysSaveRoot.c_str(), s_SysSaveRoot.size() + 1);
|
||||
::std::mbstowcs(s_RootName, sysSaveRoot.c_str(), sysSaveRoot.size() + 1);
|
||||
|
||||
NN_LOG("%ls\n", (::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str());
|
||||
|
||||
@ -903,8 +857,12 @@ void ExportData()
|
||||
// 完全性検証SEEDをSDカードに書き込む
|
||||
WriteIvs();
|
||||
|
||||
::std::string systemSaveRoot;
|
||||
void* ivs;
|
||||
size_t size;
|
||||
GetIvs(&ivs, &size);
|
||||
// IVSからセーブデータディレクトリ名を計算
|
||||
GetSaveDataDirectoryRoot();
|
||||
common::Util::GetSaveDataDirectoryRoot(systemSaveRoot, ivs, size);
|
||||
|
||||
// プレイ履歴をSDに書き出す
|
||||
//WritePlayHistory();
|
||||
@ -916,7 +874,7 @@ void ExportData()
|
||||
WriteVersionData();
|
||||
|
||||
// NANDのセーブデータをSDに書き出す
|
||||
WriteSaveData();
|
||||
WriteSaveData(systemSaveRoot);
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ SOURCES[] =
|
||||
ConsoleBackup.cpp
|
||||
Controller.cpp
|
||||
Exporter.cpp
|
||||
../common/HardwareInfo.cpp
|
||||
../common/Util.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
#include "SDMountManager.h"
|
||||
#include "HeapManager.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "HardwareInfo.h"
|
||||
#include "Util.h"
|
||||
#include "ResFont.h"
|
||||
|
||||
// svnリビジョン埋め込み用
|
||||
@ -228,6 +228,7 @@ extern "C" void nnMain(void)
|
||||
// RenderSystemを作ってからログが出せる
|
||||
common::Logger::InitializeEjectThread();
|
||||
common::Logger::SetEjectHandler(OnSdEjected);
|
||||
common::Logger::SetInsertHandler(OnSdEjected);
|
||||
COMMON_LOGGER("\n");
|
||||
COMMON_LOGGER("CTR Console Restore start\n");
|
||||
|
||||
@ -274,8 +275,7 @@ extern "C" void nnMain(void)
|
||||
std::memset(s_SerialNo, '\0',
|
||||
nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN);
|
||||
result = nn::cfg::CTR::system::GetSerialNo(s_SerialNo);
|
||||
common::HardwareInfo hwInfo;
|
||||
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
common::Util::AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
s_CanReadSerialNumber = true;
|
||||
@ -399,6 +399,12 @@ extern "C" void nnMain(void)
|
||||
titleColor.g = 0.35f;
|
||||
titleColor.b = 0.f;
|
||||
}
|
||||
else if(GetRestoreMode() == RESTORE_MODE_GET_IVS)
|
||||
{
|
||||
titleColor.r = 1.0f;
|
||||
titleColor.g = 0.2f;
|
||||
titleColor.b = 0.2f;
|
||||
}
|
||||
|
||||
// 上画面表示
|
||||
common::DrawSystemState("CTR Console Restore",
|
||||
@ -420,14 +426,23 @@ extern "C" void nnMain(void)
|
||||
s_SerialNo
|
||||
);
|
||||
|
||||
if (GetRestoreMode() == RESTORE_MODE_NUP_ONLY)
|
||||
if (GetRestoreMode() != RESTORE_MODE_RESTORE)
|
||||
{
|
||||
const u8 spaceSize = 10;
|
||||
const u8 lineBottom = 23;
|
||||
const u32 screenWidth = 400;
|
||||
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
s_RenderSystem.DrawText(0, lineBottom * spaceSize, "NUP-Only Mode");
|
||||
|
||||
if (GetRestoreMode() == RESTORE_MODE_NUP_ONLY)
|
||||
{
|
||||
s_RenderSystem.DrawText(0, lineBottom * spaceSize, "NUP-Only Mode");
|
||||
}
|
||||
else if (GetRestoreMode() == RESTORE_MODE_GET_IVS)
|
||||
{
|
||||
s_RenderSystem.DrawText(0, lineBottom * spaceSize, "GET-IVS Mode");
|
||||
}
|
||||
|
||||
s_RenderSystem.SetColor(titleColor.r, titleColor.g, titleColor.b);
|
||||
s_RenderSystem.FillRectangle(0, lineBottom * spaceSize, screenWidth, spaceSize);
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
|
||||
@ -43,9 +43,11 @@ namespace
|
||||
// インターネット設定を読んだかどうか
|
||||
bool s_ReadSettingDone = false;
|
||||
// インターネット設定を読んだ結果
|
||||
bool s_ReadSettingSuccess = false;
|
||||
bool s_ReadSettingIsSuccess = false;
|
||||
// NUP専用モードかどうか
|
||||
bool s_NupOnlyMode = false;
|
||||
// IVS取得専用モードかどうか
|
||||
bool s_GetIvsOnlyMode = false;
|
||||
|
||||
// APSettingの書式が無い警告サウンドを鳴らしたかどうか
|
||||
bool s_ExistAPSettingAnnotation = false;
|
||||
@ -106,6 +108,9 @@ typedef enum RestoreState
|
||||
NUP_ONLY_WAIT_NEXT, // NUP_ONLYモードでキー入力待ち
|
||||
DOWNLOAD_IVS, // インフラからIVSを取得する
|
||||
DOWNLOAD_IVS_DONE, // インフラからIVSを取得完了
|
||||
CHECK_IVS, // IVSとSDカードのセーブデータディレクトリの一致を確認
|
||||
CHECK_SD_DIRECTORY, // SDカードのIVS依存ディレクトリを探す
|
||||
CHECK_SD_DIRECTORY_DONE, // SDカードのIVS依存ディレクトリチェック完了
|
||||
DELETE_ACCOUNT, // ショップアカウントを削除する
|
||||
DELETE_ACCOUNT_DONE, // ショップアカウント削除完了
|
||||
SYNC_TICKET, // eTicketを同期する
|
||||
@ -217,7 +222,11 @@ void CheckNupExecuted(::std::vector<std::string>& message, bool& goNextStep)
|
||||
{
|
||||
if (common::ExistsUpdateCheckedFile())
|
||||
{
|
||||
if (s_NupOnlyMode)
|
||||
if(s_GetIvsOnlyMode)
|
||||
{
|
||||
CheckDownloadIvs(message, goNextStep);
|
||||
}
|
||||
else if (s_NupOnlyMode)
|
||||
{
|
||||
s_RestoreState = NUP_ONLY_WAIT_SD_EJECT;
|
||||
|
||||
@ -263,7 +272,14 @@ void CheckDownloadIvs(::std::vector<std::string>& message, bool& goNextStep)
|
||||
// IVS取得確認ファイルがあるか?
|
||||
if (common::ExistsDownloadIvsCheckedFile())
|
||||
{
|
||||
CheckWriteFinished(message, goNextStep);
|
||||
if(s_GetIvsOnlyMode)
|
||||
{
|
||||
s_RestoreState = CHECK_IVS;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckWriteFinished(message, goNextStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -431,11 +447,27 @@ void CheckRegioinSd(::std::vector<std::string>& message, bool& goNextStep)
|
||||
}
|
||||
}
|
||||
|
||||
void ShopOperationSuccess(ShopOperation op, const char* logMessage, RestoreState nextState)
|
||||
{
|
||||
COMMON_LOGGER("%s", logMessage);
|
||||
if (op == SHOP_OPERATION_UNREGISTER)
|
||||
{
|
||||
CreateDeleteAccountFinishedFile();
|
||||
}
|
||||
else if (op == SHOP_OPERATION_GET_IVS)
|
||||
{
|
||||
CreateDownloadIvsFinishedFile();
|
||||
}
|
||||
|
||||
s_RestoreState = nextState;
|
||||
|
||||
}
|
||||
|
||||
void ShopOperationSingleTemplate(
|
||||
std::vector<std::string>& message,
|
||||
ShopOperation op,
|
||||
const char* aliveMessage,
|
||||
const char* logMesasge,
|
||||
const char* logMessage,
|
||||
const char* retryLogMessage,
|
||||
RestoreState nextState
|
||||
)
|
||||
@ -480,11 +512,13 @@ void ShopOperationSingleTemplate(
|
||||
|
||||
if (GetShopOperationSingleResult().IsSuccess())
|
||||
{
|
||||
COMMON_LOGGER("%s", logMesasge);
|
||||
// アカウント削除完了ファイルを作成
|
||||
CreateDeleteAccountFinishedFile();
|
||||
|
||||
s_RestoreState = nextState;
|
||||
ShopOperationSuccess(op, logMessage, nextState);
|
||||
}
|
||||
// IVSがアップロードされていない場合もあるため
|
||||
// IVSを取得できない状況も成功として扱う
|
||||
else if(op == SHOP_OPERATION_GET_IVS && GetShopOperationSingleResult() == nn::nim::ResultCannotGetIvs())
|
||||
{
|
||||
ShopOperationSuccess(op, logMessage, nextState);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -596,15 +630,28 @@ bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
||||
if (!s_ReadSettingDone)
|
||||
{
|
||||
s_ReadSettingDone = true;
|
||||
s_ReadSettingSuccess = ReadSetting(&s_NupOnlyMode);
|
||||
s_ReadSettingIsSuccess = ReadSetting(&s_NupOnlyMode, &s_GetIvsOnlyMode);
|
||||
}
|
||||
|
||||
if(s_NupOnlyMode)
|
||||
if(s_NupOnlyMode && s_GetIvsOnlyMode)
|
||||
{
|
||||
s_RestoreMode = RESTORE_MODE_NUP_ONLY;
|
||||
COMMON_LOGGER("Both NUP_ONLY and GET_IVS settings are described!!");
|
||||
s_ReadSettingIsSuccess = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_NupOnlyMode)
|
||||
{
|
||||
s_RestoreMode = RESTORE_MODE_NUP_ONLY;
|
||||
}
|
||||
|
||||
if (s_GetIvsOnlyMode)
|
||||
{
|
||||
s_RestoreMode = RESTORE_MODE_GET_IVS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s_ReadSettingSuccess)
|
||||
if (!s_ReadSettingIsSuccess)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Invalid Accsess_Point_Setting format!"));
|
||||
if(!s_APSettingAnnotation)
|
||||
@ -612,10 +659,9 @@ bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
||||
s_APSettingAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return s_ReadSettingSuccess;
|
||||
return s_ReadSettingIsSuccess;
|
||||
}
|
||||
|
||||
void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* str)
|
||||
@ -839,6 +885,46 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep)
|
||||
}
|
||||
break;
|
||||
|
||||
case CHECK_IVS:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Insert User's SD Card"));
|
||||
}
|
||||
break;
|
||||
|
||||
case CHECK_SD_DIRECTORY:
|
||||
{
|
||||
if (nn::fs::IsSdmcInserted())
|
||||
{
|
||||
// ユーザのSDカードにはAP設定ファイルは無いはず
|
||||
if (ExistsAPSetting())
|
||||
{
|
||||
s_RestoreState = CHECK_IVS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ExistsIvsDirectory())
|
||||
{
|
||||
s_RestoreState = CHECK_SD_DIRECTORY_DONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CHECK_SD_DIRECTORY_DONE:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
DeleteAllCheckFiles();
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
operationMessage.push_back(::std::string("Check User's SD Card Done."));
|
||||
operationMessage.push_back(::std::string("Pull Out SD Card"));
|
||||
}
|
||||
break;
|
||||
|
||||
case DELETE_ACCOUNT:
|
||||
{
|
||||
@ -1054,7 +1140,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep)
|
||||
}
|
||||
break;
|
||||
|
||||
// NUPすることでIVSが送信される
|
||||
// 本体更新が発生しない状況でNUPすることでIVSが送信される
|
||||
// UPLOAD_IN_PROGRESSでのNUP実行後、サーバが更新されないという前提なので注意
|
||||
case UPLOAD_IVS:
|
||||
{
|
||||
@ -1257,7 +1343,7 @@ bool IsRestoreFailed()
|
||||
|
||||
void OnSdEjected()
|
||||
{
|
||||
if(s_RestoreState == WAIT_SD_EJECT || s_RestoreState == ALL_DONE)
|
||||
if (s_RestoreState == WAIT_SD_EJECT || s_RestoreState == ALL_DONE || s_RestoreState == CHECK_SD_DIRECTORY_DONE)
|
||||
{
|
||||
s_RestoreState = ALL_DONE;
|
||||
}
|
||||
@ -1266,13 +1352,23 @@ void OnSdEjected()
|
||||
s_RestoreState = NUP_ONLY_WAIT_NEXT;
|
||||
}
|
||||
// FAILのときは一旦電源を切らないと動かないようにしておく
|
||||
else if(s_RestoreState != FAIL)
|
||||
// IVSチェック時はユーザのSDカードを挿入してもらうため
|
||||
else if(s_RestoreState != FAIL &&
|
||||
s_RestoreState != CHECK_IVS)
|
||||
{
|
||||
InitializeState();
|
||||
ClearFileReadResult();
|
||||
}
|
||||
}
|
||||
|
||||
void OnSdInserted()
|
||||
{
|
||||
if(s_RestoreState == CHECK_IVS)
|
||||
{
|
||||
s_RestoreState = CHECK_SD_DIRECTORY;
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeState()
|
||||
{
|
||||
s_RestoreState = STARTUP;
|
||||
@ -1288,7 +1384,7 @@ void InitializeState()
|
||||
|
||||
s_ExistAPSettingAnnotation = false;
|
||||
s_ReadSettingDone = false;
|
||||
s_ReadSettingSuccess = false;
|
||||
s_ReadSettingIsSuccess = false;
|
||||
s_APSettingAnnotation = false;
|
||||
s_SerialNumberAnnotation = false;
|
||||
s_PlayedFailSound = false;
|
||||
|
||||
@ -26,7 +26,8 @@ namespace ConsoleRestore
|
||||
typedef enum RestoreMode
|
||||
{
|
||||
RESTORE_MODE_RESTORE,
|
||||
RESTORE_MODE_NUP_ONLY
|
||||
RESTORE_MODE_NUP_ONLY,
|
||||
RESTORE_MODE_GET_IVS
|
||||
} RestoreMode;
|
||||
|
||||
const u32 RETRY_MAX = 3;
|
||||
@ -38,6 +39,7 @@ bool IsRestoreFailed();
|
||||
u32 GetProgress();
|
||||
|
||||
void OnSdEjected();
|
||||
void OnSdInserted();
|
||||
void InitializeState();
|
||||
RestoreMode GetRestoreMode();
|
||||
|
||||
|
||||
@ -820,9 +820,10 @@ nn::Result ReadVersionData()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AlreadyExecutedNup()
|
||||
bool ExistsIvsDirectory()
|
||||
{
|
||||
return s_SDVersionData.nup.majorVersion != 0;
|
||||
// TODO: Nintendo 3DS ディレクトリを検索する
|
||||
return true;
|
||||
}
|
||||
|
||||
void Cleanup()
|
||||
@ -956,7 +957,7 @@ bool UpdateNetworkSetting(nn::ac::NetworkSetting& networkSetting)
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool ReadSetting(bool* nupOnly)
|
||||
bool ReadSetting(bool* nupOnly, bool* getIvs)
|
||||
{
|
||||
nn::Result result;
|
||||
bool retval = true;
|
||||
@ -1258,10 +1259,11 @@ bool ReadSetting(bool* nupOnly)
|
||||
}
|
||||
|
||||
{
|
||||
const wchar_t* const NUP_ONLY_STR = L"NUP_ONLY";
|
||||
NN_NULL_ASSERT(nupOnly);
|
||||
if (configfileLoader.ReadAsChar(L"NUP_ONLY") != NULL)
|
||||
if (configfileLoader.ReadAsChar(NUP_ONLY_STR) != NULL)
|
||||
{
|
||||
s32 num = configfileLoader.ReadAsInteger(L"NUP_ONLY");
|
||||
s32 num = configfileLoader.ReadAsInteger(NUP_ONLY_STR);
|
||||
if (num == 1)
|
||||
{
|
||||
*nupOnly = true;
|
||||
@ -1270,6 +1272,20 @@ bool ReadSetting(bool* nupOnly)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const wchar_t* const GET_IVS_STR = L"GET_IVS";
|
||||
NN_NULL_ASSERT(getIvs);
|
||||
if (configfileLoader.ReadAsChar(GET_IVS_STR) != NULL)
|
||||
{
|
||||
s32 num = configfileLoader.ReadAsInteger(GET_IVS_STR);
|
||||
if (num == 1)
|
||||
{
|
||||
*getIvs = true;
|
||||
COMMON_LOGGER("GET IVS Mode.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configfileLoader.Finalize();
|
||||
|
||||
// 書き込み完了しなければfalse
|
||||
|
||||
@ -65,7 +65,7 @@ struct TimeZone
|
||||
NN_PADDING3;
|
||||
};
|
||||
|
||||
bool ReadSetting(bool* nupOnly);
|
||||
bool ReadSetting(bool* nupOnly, bool* getIvs);
|
||||
char* GetNtpServerName();
|
||||
TimeZone GetTimeZone();
|
||||
|
||||
@ -93,8 +93,9 @@ nn::Result InitializeHardwareDependentSetting();
|
||||
|
||||
// SDカード上のバージョン情報を読みます
|
||||
nn::Result ReadVersionData();
|
||||
// 移行元本体がNUP済みかどうか
|
||||
bool AlreadyExecutedNup();
|
||||
|
||||
// SDカードのNintendo 3DS以下ににIVSと一致するディレクトリがあるかどうか
|
||||
bool ExistsIvsDirectory();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ SOURCES[] =
|
||||
Ntpclient.cpp
|
||||
TitleDownloader.cpp
|
||||
Shop.cpp
|
||||
../common/HardwareInfo.cpp
|
||||
../common/Util.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HardwareInfo.cpp
|
||||
|
||||
Copyright 2009 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "HardwareInfo.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
HardwareInfo::HardwareInfo()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
HardwareInfo::~HardwareInfo()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
// NULL終端されたシリアルナンバーを受け取る
|
||||
// NULL終端された場所にチェックデジットを付加して新たにNULL終端する
|
||||
void HardwareInfo::AddCheckDigit(char* serial)
|
||||
{
|
||||
size_t len = std::strlen(serial);
|
||||
|
||||
u8 digit = 0;
|
||||
bool odd = true;
|
||||
for(u8 i = len - 1; i > 0 && std::isdigit(serial[i]); i--)
|
||||
{
|
||||
if(odd)
|
||||
{
|
||||
digit += (serial[i] - '0') * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
digit += (serial[i] - '0');
|
||||
}
|
||||
odd = !odd;
|
||||
}
|
||||
|
||||
if(digit % 10 != 0)
|
||||
{
|
||||
serial[len] = 10 - (digit % 10) + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
serial[len] = '0';
|
||||
}
|
||||
|
||||
serial[len + 1] = '\0';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
111
trunk/ConsoleDataMigration/sources/common/Util.cpp
Normal file
111
trunk/ConsoleDataMigration/sources/common/Util.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Util.cpp
|
||||
|
||||
Copyright 2009 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "Util.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
Util::Util()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
Util::~Util()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
// NULL終端されたシリアルナンバーを受け取る
|
||||
// NULL終端された場所にチェックデジットを付加して新たにNULL終端する
|
||||
void Util::AddCheckDigit(char* serial)
|
||||
{
|
||||
size_t len = std::strlen(serial);
|
||||
|
||||
u8 digit = 0;
|
||||
bool odd = true;
|
||||
for(u8 i = len - 1; i > 0 && std::isdigit(serial[i]); i--)
|
||||
{
|
||||
if(odd)
|
||||
{
|
||||
digit += (serial[i] - '0') * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
digit += (serial[i] - '0');
|
||||
}
|
||||
odd = !odd;
|
||||
}
|
||||
|
||||
if(digit % 10 != 0)
|
||||
{
|
||||
serial[len] = 10 - (digit % 10) + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
serial[len] = '0';
|
||||
}
|
||||
|
||||
serial[len + 1] = '\0';
|
||||
}
|
||||
|
||||
// IVSからセーブデータディレクトリ名を生成する
|
||||
void Util::GetSaveDataDirectoryRoot(::std::string& sysSaveRoot, void* ivs, size_t size)
|
||||
{
|
||||
nn::Result result;
|
||||
using namespace nn::dbg;
|
||||
|
||||
const size_t SEED_SIZE = 16;
|
||||
bit8 hash[nn::crypto::Sha256Context::HASH_SIZE];
|
||||
const size_t SYS_SAVE_ROOT_LENGTH = 16;
|
||||
char rootHash[SYS_SAVE_ROOT_LENGTH];
|
||||
char rootStr[SYS_SAVE_ROOT_LENGTH * 2 + 1];
|
||||
|
||||
// 最後の16バイトのハッシュを使う
|
||||
nn::crypto::CalculateSha256(hash, &reinterpret_cast<bit8*> (ivs)[size - SEED_SIZE], SEED_SIZE);
|
||||
|
||||
for (u8 i = 0; i < SEED_SIZE / 4; i++)
|
||||
{
|
||||
for (u8 j = 0; j < SEED_SIZE / 4; j++)
|
||||
{
|
||||
rootHash[i * 4 + j] = hash[i * 4 + 3 - j];
|
||||
}
|
||||
}
|
||||
|
||||
// 得られたハッシュから文字列を生成
|
||||
for (s32 k = 0; k < SEED_SIZE; k++)
|
||||
{
|
||||
for (s32 i = 6; i < 8; ++i)
|
||||
{
|
||||
bit32 n = (rootHash[k] >> ((7 - i) * 4)) & 0xf;
|
||||
NN_TASSERT_(n < 16);
|
||||
rootStr[i - 6 + k * 2] = static_cast<char> (n < 10 ? '0' + n : 'a' + (n - 10));
|
||||
}
|
||||
}
|
||||
rootStr[SYS_SAVE_ROOT_LENGTH * 2] = '\0';
|
||||
|
||||
// セーブデータディレクトリ名を保存する
|
||||
sysSaveRoot = ::std::string(rootStr);
|
||||
|
||||
NN_LOG("%s\n", sysSaveRoot.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HardwareInfo.h
|
||||
File: Util.h
|
||||
|
||||
Copyright 2009 Nintendo. All rights reserved.
|
||||
|
||||
@ -13,21 +13,24 @@
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef HARDWAREINFO_H_
|
||||
#define HARDWAREINFO_H_
|
||||
#ifndef UTIL_H_
|
||||
#define UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
class HardwareInfo
|
||||
class Util
|
||||
{
|
||||
public:
|
||||
HardwareInfo();
|
||||
virtual ~HardwareInfo();
|
||||
Util();
|
||||
virtual ~Util();
|
||||
|
||||
void AddCheckDigit(char* serial);
|
||||
static void AddCheckDigit(char* serial);
|
||||
static void GetSaveDataDirectoryRoot(::std::string& sysSaveRoot, void* ivs, size_t size);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* HARDWAREINFO_H_ */
|
||||
#endif /* UTIL_H_ */
|
||||
@ -25,7 +25,7 @@ INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \
|
||||
|
||||
SOURCES[] =
|
||||
main.cpp
|
||||
../../common/HardwareInfo.cpp
|
||||
../../common/Util.cpp
|
||||
../../common/FileTransfer.cpp
|
||||
../../common/FileChecker.cpp
|
||||
../../common/SdReaderWriter.cpp
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "common_Types.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "HardwareInfo.h"
|
||||
#include "Util.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
namespace
|
||||
|
||||
Loading…
Reference in New Issue
Block a user