Download TWL titles from NUS and list them in AM. (#7162)

* Download TWL titles from NUS and list them in AM.

* Remove duplicate entries.

* Move TODO comment
This commit is contained in:
PabloMK7 2023-11-14 10:33:58 +01:00 committed by GitHub
parent 88cc6acb4d
commit 63d1830429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View file

@ -646,6 +646,8 @@ std::string GetTitleContentPath(Service::FS::MediaType media_type, u64 tid, std:
} }
std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) { std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) {
// TODO(PabloMK7) TWL titles should be in TWL Nand. Assuming CTR Nand for now.
u32 high = static_cast<u32>(tid >> 32); u32 high = static_cast<u32>(tid >> 32);
u32 low = static_cast<u32>(tid & 0xFFFFFFFF); u32 low = static_cast<u32>(tid & 0xFFFFFFFF);
@ -698,10 +700,20 @@ void Module::ScanForTitles(Service::FS::MediaType media_type) {
if (tid_string.length() == TITLE_ID_VALID_LENGTH) { if (tid_string.length() == TITLE_ID_VALID_LENGTH) {
const u64 tid = std::stoull(tid_string, nullptr, 16); const u64 tid = std::stoull(tid_string, nullptr, 16);
FileSys::NCCHContainer container(GetTitleContentPath(media_type, tid)); if (tid & TWL_TITLE_ID_FLAG) {
if (container.Load() == Loader::ResultStatus::Success) // TODO(PabloMK7) Move to TWL Nand, for now only check that
// the contents exists in CTR Nand as this is a SRL file
// instead of NCCH.
if (FileUtil::Exists(GetTitleContentPath(media_type, tid))) {
am_title_list[static_cast<u32>(media_type)].push_back(tid); am_title_list[static_cast<u32>(media_type)].push_back(tid);
} }
} else {
FileSys::NCCHContainer container(GetTitleContentPath(media_type, tid));
if (container.Load() == Loader::ResultStatus::Success) {
am_title_list[static_cast<u32>(media_type)].push_back(tid);
}
}
}
} }
} }
} }

View file

@ -68,6 +68,8 @@ enum class InstallStatus : u32 {
// Title ID valid length // Title ID valid length
constexpr std::size_t TITLE_ID_VALID_LENGTH = 16; constexpr std::size_t TITLE_ID_VALID_LENGTH = 16;
constexpr u64 TWL_TITLE_ID_FLAG = 0x0000800000000000ULL;
// Progress callback for InstallCIA, receives bytes written and total bytes // Progress callback for InstallCIA, receives bytes written and total bytes
using ProgressCallback = void(std::size_t, std::size_t); using ProgressCallback = void(std::size_t, std::size_t);

View file

@ -21,7 +21,7 @@ struct SystemTitleCategory {
std::vector<SystemTitle> titles; std::vector<SystemTitle> titles;
}; };
static constexpr u32 NUM_SYSTEM_TITLE_CATEGORIES = 7; static constexpr u32 NUM_SYSTEM_TITLE_CATEGORIES = 9;
static constexpr u64 home_menu_title_id_high = 0x00040030; static constexpr u64 home_menu_title_id_high = 0x00040030;
static constexpr SystemTitle home_menu_title = { static constexpr SystemTitle home_menu_title = {
@ -1130,6 +1130,36 @@ static const std::array<SystemTitleCategory, NUM_SYSTEM_TITLE_CATEGORIES>
0x20000202, 0x20000202, 0x20000202}, 0x20000202, 0x20000202, 0x20000202},
}, },
}}, }},
{.name = "TWL System Applications",
.title_id_high = 0x00048005,
.titles =
{
{
.name = "DS Internet",
.title_id_lows = {0x42383841, 0x42383841, 0x42383841, 0x42383841,
0x42383841, 0x42383841, 0x42383841},
},
{
.name = "DS Download Play",
.title_id_lows = {0x484E4441, 0x484E4441, 0x484E4441, 0x484E4441,
0x484E4443, 0x484E444B, 0x484E4441},
},
}},
{.name = "TWL System Data Archives",
.title_id_high = 0x0004800F,
.titles =
{
{
.name = "DS Card Whitelist",
.title_id_lows = {0x484E4841, 0x484E4841, 0x484E4841, 0x484E4841,
0x484E4841, 0x484E4841, 0x484E4841},
},
{
.name = "DS Version Data",
.title_id_lows = {0x484E4C41, 0x484E4C41, 0x484E4C41, 0x484E4C41,
0x484E4C41, 0x484E4C41, 0x484E4C41},
},
}},
}}; }};
std::vector<u64> GetSystemTitleIds(SystemTitleSet set, u32 region) { std::vector<u64> GetSystemTitleIds(SystemTitleSet set, u32 region) {