mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
MMENの8thNUP不具合を解消のためMMENのシステムセーブデータを修正するように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@823 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
391dc6e222
commit
9a3cfd3e9c
@ -20,6 +20,7 @@
|
||||
#include "CommonLogger.h"
|
||||
#include "Checker.h"
|
||||
#include "FileTransfer.h"
|
||||
#include "MenuSavedataModifier.h"
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
@ -32,6 +33,7 @@ namespace
|
||||
typedef enum BackupState
|
||||
{
|
||||
STARTUP, // 初期値
|
||||
MODIFY_MENU_SAVEDATA, // MMENセーブデータの修正
|
||||
CHECK_SAVEDATA, // セーブデータの確認
|
||||
EXPORT_TWL_NAND, // TWLセーブデータ領域の吸出し中
|
||||
EXPORT_TWL_SOUND, // TWLサウンド領域の吸出し中
|
||||
@ -183,12 +185,24 @@ void ControlState(common::HardwareStateManager& manager, common::OperationMessag
|
||||
{
|
||||
s_BackupMode = BACKUP_MODE_DELETE_IF_FAILED;
|
||||
}
|
||||
s_BackupState = CHECK_SAVEDATA;
|
||||
s_BackupState = MODIFY_MENU_SAVEDATA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MODIFY_MENU_SAVEDATA:
|
||||
{
|
||||
MenuSavedataModifier modifier;
|
||||
common::VerDef version;
|
||||
manager.GetVersionData(&version);
|
||||
|
||||
nn::Result result = modifier.Modify(nn::cfg::GetRegion(), version.cup);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
s_BackupState = CHECK_SAVEDATA;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHECK_SAVEDATA:
|
||||
{
|
||||
static bool init = true;
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: MenuSavedataModifier.cpp
|
||||
|
||||
Copyright (C)2014 Nintendo Co., Ltd. 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/fs/fs_ApiSysSaveData.h>
|
||||
#include <nn/drivers/aes/CTR/ARM946ES/driverAes_Types.h>
|
||||
|
||||
#include "MenuSavedataModifier.h"
|
||||
#include "LauncherSaveData.h"
|
||||
#include "HeapManager.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
|
||||
namespace ConsoleBackup{
|
||||
|
||||
MenuSavedataModifier::MenuSavedataModifier()
|
||||
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
MenuSavedataModifier::~MenuSavedataModifier()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
// MMENのコードを移植
|
||||
void MenuSavedataModifier::set_initialize_data_802_(LauncherSavedataRaw* mpRaw)
|
||||
{
|
||||
// トップのカーソル位置をクリア
|
||||
mpRaw->mFcsIconIdx = 0; // フォーカスしていたアイコン(初回起動ではゲームカードにあっている)
|
||||
mpRaw->mHeadIconIdx = 0; // 画面左上のアイコン
|
||||
|
||||
// フォルダ内のカーソル位置のクリア
|
||||
for( int i = 0; i < LauncherSavedataRaw::scmFolderMax; i++ )
|
||||
{
|
||||
mpRaw->mFolderFcsIconIdx[ i ] = 0; // フォルダごとのフォーカスしていたアイコン(デフォルト左上)
|
||||
mpRaw->mFolderHeadIconIdx[ i ] = 0; // フォルダごとの画面左上のアイコン(デフォルト左上)
|
||||
}
|
||||
}
|
||||
|
||||
nn::Result MenuSavedataModifier::Modify(nn::cfg::CfgRegionCode region, nn::pl::CTR::CardUpdateVersion cup)
|
||||
{
|
||||
if(!m_Version.IsModificationRequired(cup.majorVersion, cup.minorVersion))
|
||||
{
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
u64 id = GetId(region);
|
||||
|
||||
const char* const SYSTEM_SAVEDATA_ARCHIVE_NAME = "ssave:";
|
||||
const char* const MENU_SAVE_FILE_NAME = "ssave:/Launcher.dat";
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
nn::fs::MountSystemSaveData(SYSTEM_SAVEDATA_ARCHIVE_NAME, id));
|
||||
|
||||
nn::fs::FileStream file;
|
||||
NN_UTIL_RETURN_IF_FAILED_1(
|
||||
file.TryInitialize(MENU_SAVE_FILE_NAME, nn::fs::OPEN_MODE_READ | nn::fs::OPEN_MODE_WRITE),
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
|
||||
s64 fileSize = file.GetSize();
|
||||
common::HeapManager heap(fileSize, AES_BLOCK_SIZE);
|
||||
void* buf = heap.GetAddr();
|
||||
if (buf != NULL)
|
||||
{
|
||||
s32 readSize;
|
||||
NN_UTIL_RETURN_IF_FAILED_1(file.TryRead(&readSize, buf, fileSize),
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
}
|
||||
else
|
||||
{
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME);
|
||||
return nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
|
||||
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
// カーソル位置を初期化
|
||||
set_initialize_data_802_(reinterpret_cast<LauncherSavedataRaw*>(buf));
|
||||
|
||||
// 先頭に移動して書き込み
|
||||
NN_UTIL_RETURN_IF_FAILED_1(file.TrySeek(0, nn::fs::POSITION_BASE_BEGIN),
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
s32 writeSize;
|
||||
NN_UTIL_RETURN_IF_FAILED_1(file.TryWrite(&writeSize, buf, fileSize, true),
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
|
||||
// コミットする
|
||||
NN_UTIL_RETURN_IF_FAILED_1(nn::fs::CommitSystemSaveData(SYSTEM_SAVEDATA_ARCHIVE_NAME),
|
||||
nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
|
||||
COMMON_LOGGER_WARN("Modified Menu Savedata\n");
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(nn::fs::Unmount(SYSTEM_SAVEDATA_ARCHIVE_NAME));
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
u64 MenuSavedataModifier::GetId(nn::cfg::CfgRegionCode region)
|
||||
{
|
||||
using namespace nn::cfg;
|
||||
|
||||
if(region == CFG_REGION_JAPAN)
|
||||
{
|
||||
return PROGRAM_ID_JP;
|
||||
}
|
||||
else if(region == CFG_REGION_AMERICA)
|
||||
{
|
||||
return PROGRAM_ID_US;
|
||||
}
|
||||
else if(region == CFG_REGION_AUSTRALIA || region == CFG_REGION_EUROPE)
|
||||
{
|
||||
return PROGRAM_ID_EU;
|
||||
}
|
||||
else
|
||||
{
|
||||
return PROGRAM_ID_JP;
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ConsoleBackup */
|
||||
@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: MenuSavedataModifier.h
|
||||
|
||||
Copyright (C)2014 Nintendo Co., Ltd. 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$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef SOURCES_CONSOLEBACKUP_MENUSAVEDATAMODIFIER_H_
|
||||
#define SOURCES_CONSOLEBACKUP_MENUSAVEDATAMODIFIER_H_
|
||||
|
||||
#include <nn/Result.h>
|
||||
#include <nn/cfg.h>
|
||||
#include <nn/pl/CTR/pl_Version.h>
|
||||
#include "MenuSavedataVersion.h"
|
||||
#include "LauncherSaveData.h"
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
class MenuSavedataModifier
|
||||
{
|
||||
public:
|
||||
MenuSavedataModifier();
|
||||
virtual ~MenuSavedataModifier();
|
||||
|
||||
nn::Result Modify(nn::cfg::CfgRegionCode region, nn::pl::CTR::CardUpdateVersion cup);
|
||||
|
||||
private:
|
||||
MenuSavedataVersion m_Version;
|
||||
u64 GetId(nn::cfg::CfgRegionCode region);
|
||||
void set_initialize_data_802_(LauncherSavedataRaw* mpRaw);
|
||||
|
||||
};
|
||||
|
||||
} /* namespace ConsoleBackup */
|
||||
|
||||
#endif /* SOURCES_CONSOLEBACKUP_MENUSAVEDATAMODIFIER_H_ */
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: MenuSavedataVersion.cpp
|
||||
|
||||
Copyright (C)2014 Nintendo Co., Ltd. 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 "MenuSavedataVersion.h"
|
||||
|
||||
const u8 CUP_MAJOR_3 = 4;
|
||||
const u8 CUP_MAJOR_7 = 8;
|
||||
const u8 CUP_MAJOR_8 = 9;
|
||||
const u8 CUP_MINOR_8_1 = 1;
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
MenuSavedataVersion::MenuSavedataVersion()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
MenuSavedataVersion::~MenuSavedataVersion()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
bool MenuSavedataVersion::IsModificationRequired(u8 cupMajor, u8 cupMinor)
|
||||
{
|
||||
if(cupMajor < CUP_MAJOR_3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(CUP_MAJOR_3<= cupMajor && cupMajor <= CUP_MAJOR_7)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(cupMajor == CUP_MAJOR_8)
|
||||
{
|
||||
if(cupMinor <= CUP_MINOR_8_1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(cupMinor > CUP_MINOR_8_1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(cupMajor > CUP_MAJOR_8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace ConsoleBackup */
|
||||
@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: MenuSavedataVersion.h
|
||||
|
||||
Copyright (C)2014 Nintendo Co., Ltd. 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$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef SOURCES_CONSOLEBACKUP_MENUSAVEDATAVERSION_H_
|
||||
#define SOURCES_CONSOLEBACKUP_MENUSAVEDATAVERSION_H_
|
||||
|
||||
#if defined(__ARMCC_VERSION)
|
||||
#include <nn.h>
|
||||
#include <nn/cfg.h>
|
||||
#else
|
||||
#include "test_common.h"
|
||||
#endif
|
||||
#include <nn/cfg/CTR/cfg_RegionCode.h>
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
class MenuSavedataVersion
|
||||
{
|
||||
public:
|
||||
MenuSavedataVersion();
|
||||
virtual ~MenuSavedataVersion();
|
||||
|
||||
bool IsModificationRequired(u8 cupMajor, u8 cupMinor);
|
||||
|
||||
};
|
||||
|
||||
} /* namespace ConsoleBackup */
|
||||
|
||||
#endif /* SOURCES_CONSOLEBACKUP_MENUSAVEDATAVERSION_H_ */
|
||||
@ -28,6 +28,8 @@ SOURCES[] =
|
||||
Exporter.cpp
|
||||
Checker.cpp
|
||||
SavedataChecker.cpp
|
||||
MenuSavedataModifier.cpp
|
||||
MenuSavedataVersion.cpp
|
||||
../common/Util.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
|
||||
@ -85,7 +85,7 @@ const SystemSaveDataCouple SYSTEM_SAVEDATA_COUPLE_LIST[] =
|
||||
{"ARGAMES_NCL_US", 0x0002021e },
|
||||
{"ARGAMES_NCL_EU", 0x0002022e },
|
||||
|
||||
{"MENU_JP", 0x00020081 },
|
||||
{"MENU_JP", 0x00020082 },
|
||||
{"MENU_US", 0x0002008f },
|
||||
{"MENU_EU", 0x00020098 },
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
INCLUDES[] +=
|
||||
./
|
||||
../common
|
||||
../../../ConsoleBackup
|
||||
$(HORIZON_ROOT)/include
|
||||
|
||||
TARGET = testMenuSavedataVersion
|
||||
TEST_TARGET = MenuSavedataVersion
|
||||
|
||||
SRC_FILES[] =
|
||||
testMenuSavedataVersion
|
||||
MenuSavedataVersion
|
||||
|
||||
# テスト独自のスタブを使用する場合に定義する
|
||||
#CXXFLAGS += -DPCTEST_USE_STUB
|
||||
|
||||
# テストディレクトリ外にあるので独自ルールでビルド
|
||||
$(TEST_TARGET)$(EXT_OBJ): ../../../ConsoleBackup/$(TEST_TARGET).cpp
|
||||
$(CXX) $(CXXFLAGS) $(PREFIXED_INCLUDES) -c $<
|
||||
|
||||
.DEFAULT: $(TEST_TARGET)$(EXT_OBJ) $(TARGET)$(EXE)
|
||||
|
||||
include $(COMMON_BUILD)
|
||||
@ -0,0 +1,40 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "MenuSavedataVersion.h"
|
||||
|
||||
using namespace nn::cfg::CTR;
|
||||
|
||||
|
||||
TEST(testbelow3rdNUP, ALL)
|
||||
{
|
||||
ConsoleBackup::MenuSavedataVersion version;
|
||||
|
||||
ASSERT_FALSE(version.IsModificationRequired(3, 0));
|
||||
}
|
||||
|
||||
TEST(test3rdNUPto8thNUP, ALL)
|
||||
{
|
||||
ConsoleBackup::MenuSavedataVersion version;
|
||||
|
||||
ASSERT_TRUE(version.IsModificationRequired(4, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(5, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(6, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(7, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(8, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(9, 0));
|
||||
ASSERT_TRUE(version.IsModificationRequired(9, 1));
|
||||
}
|
||||
|
||||
TEST(test8_0_2thNUP, ALL)
|
||||
{
|
||||
ConsoleBackup::MenuSavedataVersion version;
|
||||
|
||||
ASSERT_FALSE(version.IsModificationRequired(9, 2));
|
||||
}
|
||||
|
||||
TEST(testFuture, ALL)
|
||||
{
|
||||
ConsoleBackup::MenuSavedataVersion version;
|
||||
|
||||
ASSERT_FALSE(version.IsModificationRequired(10, 0));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user