Fix ncch loader building wrong update title ID (#930)

This commit is contained in:
PabloMK7 2025-04-15 16:27:32 +02:00 committed by GitHub
parent 81ce14e0db
commit 72eb16f933
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View file

@ -2104,7 +2104,7 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list; std::vector<u64> title_id_list;
Result res{0}; Result res{0};
std::vector<u8> out; std::vector<TitleInfo> out;
Kernel::MappedBuffer* title_id_list_buffer; Kernel::MappedBuffer* title_id_list_buffer;
Kernel::MappedBuffer* title_info_out; Kernel::MappedBuffer* title_info_out;
}; };
@ -2144,7 +2144,7 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) {
return 0; return 0;
} }
async_data->out.resize(title_infos->second); async_data->out.resize(title_infos->second / sizeof(TitleInfo));
memcpy(async_data->out.data(), title_infos->first, title_infos->second); memcpy(async_data->out.data(), title_infos->first, title_infos->second);
return 0; return 0;
}, },
@ -2156,7 +2156,7 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(*async_data->title_info_out); rb.PushMappedBuffer(*async_data->title_info_out);
} else { } else {
async_data->title_info_out->Write(async_data->out.data(), 0, async_data->title_info_out->Write(async_data->out.data(), 0,
async_data->out.size()); async_data->out.size() * sizeof(TitleInfo));
IPC::RequestBuilder rb(ctx, 1, 4); IPC::RequestBuilder rb(ctx, 1, 4);
rb.Push(async_data->res); rb.Push(async_data->res);

View file

@ -32,7 +32,7 @@
namespace Loader { namespace Loader {
using namespace Common::Literals; using namespace Common::Literals;
static const u64 UPDATE_MASK = 0x0000000e00000000; static constexpr u64 UPDATE_TID_HIGH = 0x0004000e00000000;
FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) { FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
u32 magic; u32 magic;
@ -283,8 +283,9 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
LOG_INFO(Loader, "Program ID: {}", program_id); LOG_INFO(Loader, "Program ID: {}", program_id);
update_ncch.OpenFile(Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, u64 update_tid = (ncch_program_id & 0xFFFFFFFFULL) | UPDATE_TID_HIGH;
ncch_program_id | UPDATE_MASK)); update_ncch.OpenFile(
Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_tid));
result = update_ncch.Load(); result = update_ncch.Load();
if (result == ResultStatus::Success) { if (result == ResultStatus::Success) {
overlay_ncch = &update_ncch; overlay_ncch = &update_ncch;
@ -371,8 +372,9 @@ ResultStatus AppLoader_NCCH::DumpRomFS(const std::string& target_path) {
ResultStatus AppLoader_NCCH::DumpUpdateRomFS(const std::string& target_path) { ResultStatus AppLoader_NCCH::DumpUpdateRomFS(const std::string& target_path) {
u64 program_id; u64 program_id;
ReadProgramId(program_id); ReadProgramId(program_id);
u64 update_tid = (program_id & 0xFFFFFFFFULL) | UPDATE_TID_HIGH;
update_ncch.OpenFile( update_ncch.OpenFile(
Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, program_id | UPDATE_MASK)); Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_tid));
return update_ncch.DumpRomFS(target_path); return update_ncch.DumpRomFS(target_path);
} }