mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-20 01:45:07 -04:00
mitm/cfg: pass around override status for decision-making
This commit is contained in:
parent
37e065fa2d
commit
421324b498
59 changed files with 425 additions and 265 deletions
|
@ -23,46 +23,60 @@
|
|||
|
||||
namespace ams::ldr {
|
||||
|
||||
namespace {
|
||||
|
||||
Result GetProgramInfoImpl(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
|
||||
/* Zero output. */
|
||||
std::memset(out, 0, sizeof(*out));
|
||||
cfg::OverrideStatus status = {};
|
||||
|
||||
R_TRY(ldr::GetProgramInfo(out, &status, loc));
|
||||
|
||||
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) {
|
||||
char path[FS_MAX_PATH];
|
||||
const ncm::ProgramLocation new_loc = ncm::ProgramLocation::Make(out->program_id, static_cast<ncm::StorageId>(loc.storage_id));
|
||||
|
||||
R_TRY(ResolveContentPath(path, loc));
|
||||
R_TRY(RedirectContentPath(path, new_loc));
|
||||
|
||||
const auto arg_info = args::Get(loc.program_id);
|
||||
if (arg_info != nullptr) {
|
||||
R_TRY(args::Set(new_loc.program_id, arg_info->args, arg_info->args_size));
|
||||
}
|
||||
}
|
||||
|
||||
if (out_status != nullptr) {
|
||||
*out_status = status;
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Official commands. */
|
||||
Result LoaderService::CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h) {
|
||||
os::ManagedHandle reslimit_holder(reslimit_h.GetValue());
|
||||
ncm::ProgramLocation loc;
|
||||
cfg::OverrideStatus override_status;
|
||||
char path[FS_MAX_PATH];
|
||||
|
||||
/* Get location. */
|
||||
R_TRY(ldr::ro::GetProgramLocation(&loc, id));
|
||||
/* Get location and override status. */
|
||||
R_TRY(ldr::ro::GetProgramLocationAndStatus(&loc, &override_status, id));
|
||||
|
||||
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None)) {
|
||||
R_TRY(ResolveContentPath(path, loc));
|
||||
}
|
||||
|
||||
return ldr::CreateProcess(proc_h.GetHandlePointer(), id, loc, path, flags, reslimit_holder.Get());
|
||||
return ldr::CreateProcess(proc_h.GetHandlePointer(), id, loc, override_status, path, flags, reslimit_holder.Get());
|
||||
}
|
||||
|
||||
Result LoaderService::GetProgramInfo(sf::Out<ProgramInfo> out, const ncm::ProgramLocation &loc) {
|
||||
/* Zero output. */
|
||||
std::memset(out.GetPointer(), 0, sizeof(*out.GetPointer()));
|
||||
|
||||
R_TRY(ldr::GetProgramInfo(out.GetPointer(), loc));
|
||||
|
||||
if (loc.storage_id != static_cast<u8>(ncm::StorageId::None) && loc.program_id != out->program_id) {
|
||||
char path[FS_MAX_PATH];
|
||||
const ncm::ProgramLocation new_loc = ncm::ProgramLocation::Make(out->program_id, static_cast<ncm::StorageId>(loc.storage_id));
|
||||
|
||||
R_TRY(ResolveContentPath(path, loc));
|
||||
R_TRY(RedirectContentPath(path, new_loc));
|
||||
|
||||
const auto arg_info = args::Get(loc.program_id);
|
||||
if (arg_info != nullptr) {
|
||||
R_TRY(args::Set(new_loc.program_id, arg_info->args, arg_info->args_size));
|
||||
}
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
return GetProgramInfoImpl(out.GetPointer(), nullptr, loc);
|
||||
}
|
||||
|
||||
Result LoaderService::PinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc) {
|
||||
return ldr::ro::PinProgram(out_id.GetPointer(), loc);
|
||||
return ldr::ro::PinProgram(out_id.GetPointer(), loc, cfg::OverrideStatus{});
|
||||
}
|
||||
|
||||
Result LoaderService::UnpinProgram(PinId id) {
|
||||
|
@ -95,4 +109,12 @@ namespace ams::ldr {
|
|||
out.SetValue(ldr::HasLaunchedProgram(program_id));
|
||||
}
|
||||
|
||||
Result LoaderService::AtmosphereGetProgramInfo(sf::Out<ProgramInfo> out_program_info, sf::Out<cfg::OverrideStatus> out_status, const ncm::ProgramLocation &loc) {
|
||||
return GetProgramInfoImpl(out_program_info.GetPointer(), out_status.GetPointer(), loc);
|
||||
}
|
||||
|
||||
Result LoaderService::AtmospherePinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status) {
|
||||
return ldr::ro::PinProgram(out_id.GetPointer(), loc, override_status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue