mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
TWLタイトルのリストを出力するように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@205 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
0d5491fe3d
commit
fb5e0ebbc3
@ -34,6 +34,7 @@
|
||||
#include <nn/fs/fs_ApiSharedExtSaveData.h>
|
||||
#include <nn/nim.h>
|
||||
#include <nn/ndm.h>
|
||||
#include <nn/am.h>
|
||||
|
||||
#include "demo.h"
|
||||
|
||||
@ -187,6 +188,9 @@ extern "C" void nnMain(void)
|
||||
|
||||
nn::mcu::CTR::HwCheck mcu(s_McuSession);
|
||||
|
||||
// amの初期化
|
||||
nn::am::InitializeForSystemMenu();
|
||||
|
||||
// ヒープの確保
|
||||
common::HeapManager::GetHeap()->Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ namespace
|
||||
typedef enum BackupState
|
||||
{
|
||||
STARTUP, // 初期値
|
||||
EXPORT_TWL_LIST, // TWLアプリのリストを書き出し中
|
||||
EXPORT_TWL_NAND, // TWLセーブデータ領域の吸出し中
|
||||
EXPORT_TWL_SOUND, // TWLサウンド領域の吸出し中
|
||||
EXPORT_TWL_PHOTO, // TWL写真領域の吸出し中
|
||||
@ -146,6 +147,28 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
|
||||
if (nextStep && !error)
|
||||
{
|
||||
COMMON_LOGGER("Start Export Data\n");
|
||||
|
||||
s_BackupState = EXPORT_TWL_LIST;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// TWLセーブデータ領域の吸出し中
|
||||
case EXPORT_TWL_LIST:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
// データを書き込む
|
||||
ExportTwlTitleList();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 処理が完了した
|
||||
if (IsExportFinished())
|
||||
{
|
||||
FinalizeExportThread();
|
||||
s_BackupState = EXPORT_TWL_NAND;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <nn/nstd.h>
|
||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/cfg/CTR/cfg_Api.h>
|
||||
@ -30,6 +31,7 @@
|
||||
#include <nn/crypto/crypto_Sha256.h>
|
||||
#include <nn/crypto/crypto_SwAesCmac.h>
|
||||
#include <nn/mcu.h>
|
||||
#include <nn/am.h>
|
||||
|
||||
#include "Exporter.h"
|
||||
#include "CommonLogger.h"
|
||||
@ -154,6 +156,67 @@ void DeleteTrash(std::wstring currentDirectory)
|
||||
common::SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void WriteTwlTitleData()
|
||||
{
|
||||
COMMON_LOGGER("Export TwlTitle Data.\n");
|
||||
|
||||
const u32 AM_TICKET_MAX = 8192;
|
||||
|
||||
s32 personalizedTicketNum;
|
||||
nn::am::TicketInfo *ticketInfoBuffer =
|
||||
reinterpret_cast<nn::am::TicketInfo*> (common::HeapManager::GetHeap()->Allocate(
|
||||
sizeof(nn::am::TicketInfo) * AM_TICKET_MAX));
|
||||
if(ticketInfoBuffer == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nn::Result result=nn::am::GetPersonalizedTicketInfoList(&personalizedTicketNum, ticketInfoBuffer, AM_TICKET_MAX); // 全部
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
if(result.IsFailure())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
u32 twlTiteNum = 0;
|
||||
for (u32 i = 0; i < personalizedTicketNum; i++)
|
||||
{
|
||||
if (nn::CTR::IsTwlApp(ticketInfoBuffer[i].titleId))
|
||||
{
|
||||
twlTiteNum++;
|
||||
}
|
||||
}
|
||||
|
||||
if (twlTiteNum > 0)
|
||||
{
|
||||
const size_t BYTES_PER_LINE = sizeof(nn::ProgramID) * 2 + sizeof('\n');
|
||||
char* titleListBuf = reinterpret_cast<char*> (common::HeapManager::GetHeap()->Allocate(
|
||||
BYTES_PER_LINE * twlTiteNum + sizeof('0')));
|
||||
if (titleListBuf != NULL)
|
||||
{
|
||||
for (u32 i = 0; i < personalizedTicketNum; i++)
|
||||
{
|
||||
if (nn::CTR::IsTwlApp(ticketInfoBuffer[i].titleId))
|
||||
{
|
||||
nn::nstd::TSNPrintf(titleListBuf + i * BYTES_PER_LINE,
|
||||
BYTES_PER_LINE * twlTiteNum + sizeof('0') - i * BYTES_PER_LINE, "%016llx\n",
|
||||
ticketInfoBuffer[i].titleId);
|
||||
NN_LOG("%016llx\n", ticketInfoBuffer[i].titleId);
|
||||
}
|
||||
}
|
||||
|
||||
result = s_SdWriter.WriteBufWithCmac(common::TWL_TITLELIST_PATHNAME, titleListBuf,
|
||||
BYTES_PER_LINE * twlTiteNum);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
common::HeapManager::GetHeap()->Free(titleListBuf);
|
||||
}
|
||||
}
|
||||
|
||||
common::HeapManager::GetHeap()->Free(ticketInfoBuffer);
|
||||
}
|
||||
|
||||
|
||||
void WriteRegionData()
|
||||
{
|
||||
COMMON_LOGGER("Export Region Data.\n");
|
||||
@ -639,11 +702,16 @@ void InitializeFileListContext()
|
||||
s_FileListContext.Initialize();
|
||||
}
|
||||
|
||||
void ExportTwlSaveData()
|
||||
void ExportTwlTitleList()
|
||||
{
|
||||
// 不要なデータを削除する
|
||||
DeleteTrash((std::wstring(common::LOG_ROOT_DIRECTORY_PATH) + std::wstring(L"/")).c_str());
|
||||
|
||||
s_ExportThread.Start(WriteTwlTitleData, s_ExportThreadStack);
|
||||
}
|
||||
|
||||
void ExportTwlSaveData()
|
||||
{
|
||||
s_ExportThread.Start(WriteTwlSaveData, s_ExportThreadStack);
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ namespace ConsoleBackup
|
||||
{
|
||||
|
||||
void InitializeFileListContext();
|
||||
void ExportTwlTitleList();
|
||||
void ExportTwlSaveData();
|
||||
void ExportTwlPhotoData();
|
||||
void ExportTwlSoundData();
|
||||
|
||||
@ -72,6 +72,7 @@ LIBS += libnn_cfg \
|
||||
libnn_nwm \
|
||||
libnn_friends \
|
||||
libnn_nim \
|
||||
libnn_am \
|
||||
|
||||
INSTALL_SDK_TOOL = true
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ const wchar_t* const VERSION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/version.
|
||||
const wchar_t* const REGION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/Region.bin";
|
||||
const wchar_t* const DEVICE_ID_PATHNAME = L"sdmc:/CTR_Console_Repair/deviceId.bin";
|
||||
const wchar_t* const FILE_LIST_PATHNAME = L"sdmc:/CTR_Console_Repair/FileList.txt";
|
||||
const wchar_t* const TWL_TITLELIST_PATHNAME = L"sdmc:/CTR_Console_Repair/TwlTitleList.txt";
|
||||
|
||||
enum TWL_PATH_INDEX
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user