@@ -577,11 +577,26 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector<u8>& code) const
577
577
const auto mods_path =
578
578
fmt::format (" {}mods/{:016X}/" , FileUtil::GetUserPath (FileUtil::UserPath::LoadDir),
579
579
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{{
581
595
{mods_path + " exefs/code.ips" , Patch::ApplyIpsPatch},
582
596
{mods_path + " exefs/code.bps" , Patch::ApplyBpsPatch},
583
597
{mods_path + " code.ips" , Patch::ApplyIpsPatch},
584
598
{mods_path + " code.bps" , Patch::ApplyBpsPatch},
599
+ {luma_ips_location, Patch::ApplyIpsPatch},
585
600
{filepath + " .exefsdir/code.ips" , Patch::ApplyIpsPatch},
586
601
{filepath + " .exefsdir/code.bps" , Patch::ApplyBpsPatch},
587
602
}};
0 commit comments