diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index ad8b32629c..2ebd31f2e6 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -577,11 +577,26 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector& code) const const auto mods_path = fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), GetModId(ncch_header.program_id)); - const std::array patch_paths{{ + + constexpr u32 system_module_tid_high = 0x00040130; + + std::string luma_ips_location; + if ((static_cast(ncch_header.program_id >> 32) & system_module_tid_high) == + system_module_tid_high) { + luma_ips_location = + fmt::format("{}luma/sysmodules/{:016X}.ips", + FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), ncch_header.program_id); + } else { + luma_ips_location = + fmt::format("{}luma/titles/{:016X}/code.ips", + FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), ncch_header.program_id); + } + const std::array patch_paths{{ {mods_path + "exefs/code.ips", Patch::ApplyIpsPatch}, {mods_path + "exefs/code.bps", Patch::ApplyBpsPatch}, {mods_path + "code.ips", Patch::ApplyIpsPatch}, {mods_path + "code.bps", Patch::ApplyBpsPatch}, + {luma_ips_location, Patch::ApplyIpsPatch}, {filepath + ".exefsdir/code.ips", Patch::ApplyIpsPatch}, {filepath + ".exefsdir/code.bps", Patch::ApplyBpsPatch}, }};