Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit b1e5485

Browse files
authored
Allow loading IPS files from Luma3DS folders. (#87)
1 parent de65b15 commit b1e5485

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/core/file_sys/ncch_container.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,26 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector<u8>& code) const
577577
const auto mods_path =
578578
fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir),
579579
GetModId(ncch_header.program_id));
580-
const std::array<PatchLocation, 6> patch_paths{{
580+
581+
constexpr u32 system_module_tid_high = 0x00040130;
582+
583+
std::string luma_ips_location;
584+
if ((static_cast<u32>(ncch_header.program_id >> 32) & system_module_tid_high) ==
585+
system_module_tid_high) {
586+
luma_ips_location =
587+
fmt::format("{}luma/sysmodules/{:016X}.ips",
588+
FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), ncch_header.program_id);
589+
} else {
590+
luma_ips_location =
591+
fmt::format("{}luma/titles/{:016X}/code.ips",
592+
FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), ncch_header.program_id);
593+
}
594+
const std::array<PatchLocation, 7> patch_paths{{
581595
{mods_path + "exefs/code.ips", Patch::ApplyIpsPatch},
582596
{mods_path + "exefs/code.bps", Patch::ApplyBpsPatch},
583597
{mods_path + "code.ips", Patch::ApplyIpsPatch},
584598
{mods_path + "code.bps", Patch::ApplyBpsPatch},
599+
{luma_ips_location, Patch::ApplyIpsPatch},
585600
{filepath + ".exefsdir/code.ips", Patch::ApplyIpsPatch},
586601
{filepath + ".exefsdir/code.bps", Patch::ApplyBpsPatch},
587602
}};

0 commit comments

Comments
 (0)