diff --git a/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp b/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp index 651b25bf..39c0bc3d 100644 --- a/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp +++ b/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp @@ -19,14 +19,14 @@ #include #include -#define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle &&reslimit_h), (proc_h, id, flags, std::move(reslimit_h))) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out out_program_info, const ncm::ProgramLocation &loc), (out_program_info, loc)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabledProgramVerification, (bool enabled), (enabled), hos::Version_10_0_0) \ - AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out out, ncm::ProgramId program_id), (out, program_id)) \ - AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetProgramInfo, (sf::Out out_program_info, sf::Out out_status, const ncm::ProgramLocation &loc), (out_program_info, out_status, loc)) \ - AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmospherePinProgram, (sf::Out out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status), (out_id, loc, override_status)) +#define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle &&reslimit_h, const ldr::ProgramAttributes &attrs), (proc_h, id, flags, std::move(reslimit_h), attrs)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out out_program_info, const ncm::ProgramLocation &loc, const ldr::ProgramAttributes &attrs), (out_program_info, loc, attrs)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabledProgramVerification, (bool enabled), (enabled), hos::Version_10_0_0) \ + AMS_SF_METHOD_INFO(C, H, 65000, void, AtmosphereHasLaunchedBootProgram, (sf::Out out, ncm::ProgramId program_id), (out, program_id)) \ + AMS_SF_METHOD_INFO(C, H, 65001, Result, AtmosphereGetProgramInfo, (sf::Out out_program_info, sf::Out out_status, const ncm::ProgramLocation &loc, const ldr::ProgramAttributes &attrs), (out_program_info, out_status, loc, attrs)) \ + AMS_SF_METHOD_INFO(C, H, 65002, Result, AtmospherePinProgram, (sf::Out out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status), (out_id, loc, override_status)) AMS_SF_DEFINE_INTERFACE(ams::ldr::impl, IProcessManagerInterface, AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO, 0x01518B8E) diff --git a/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp b/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp index dd5d34b9..310c6fa5 100644 --- a/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp +++ b/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp @@ -20,15 +20,15 @@ namespace ams::ldr::pm { /* Process Manager API. */ - Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle reslimit); - Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc); + Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle reslimit, ldr::ProgramAttributes attrs); + Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc, ldr::ProgramAttributes attrs); Result PinProgram(PinId *out, const ncm::ProgramLocation &loc); Result UnpinProgram(PinId pin_id); Result SetEnabledProgramVerification(bool enabled); Result HasLaunchedBootProgram(bool *out, ncm::ProgramId program_id); /* Atmosphere extension API. */ - Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc); + Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, ldr::ProgramAttributes attrs); Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status); } diff --git a/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/libstratosphere/include/stratosphere/ldr/ldr_types.hpp index 52465704..5cc2fbb8 100644 --- a/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ b/libstratosphere/include/stratosphere/ldr/ldr_types.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace ams::ldr { @@ -265,4 +266,10 @@ namespace ams::ldr { }; static_assert(sizeof(Npdm) == 0x80 && util::is_pod::value, "Npdm definition!"); + struct ProgramAttributes { + ncm::ContentMetaPlatform platform; + fs::ContentAttributes content_attributes; + }; + static_assert(sizeof(ProgramAttributes) == 2 && util::is_pod::value, "ProgramAttributes definition!"); + } diff --git a/libstratosphere/source/ldr/ldr_ams.os.horizon.c b/libstratosphere/source/ldr/ldr_ams.os.horizon.c index 7d0b4f90..3a0dca19 100644 --- a/libstratosphere/source/ldr/ldr_ams.os.horizon.c +++ b/libstratosphere/source/ldr/ldr_ams.os.horizon.c @@ -32,8 +32,14 @@ Result ldrPmAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id) { return _ldrAtmosphereHasLaunchedBootProgram(ldrPmGetServiceSession(), out, program_id); } -Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out_program_info, CfgOverrideStatus *out_status, const NcmProgramLocation *loc) { - return serviceDispatchInOut(ldrPmGetServiceSession(), 65001, *loc, *out_status, +Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out_program_info, CfgOverrideStatus *out_status, const NcmProgramLocation *loc, const LoaderProgramAttributes *attr) { + const struct { + LoaderProgramAttributes attr; + u16 pad1; + u32 pad2; + NcmProgramLocation loc; + } in = { *attr, 0, 0, *loc }; + return serviceDispatchInOut(ldrPmGetServiceSession(), 65001, in, *out_status, .buffer_attrs = { SfBufferAttr_Out | SfBufferAttr_HipcPointer | SfBufferAttr_FixedSize }, .buffers = { { out_program_info, sizeof(*out_program_info) } }, ); diff --git a/libstratosphere/source/ldr/ldr_ams.os.horizon.h b/libstratosphere/source/ldr/ldr_ams.os.horizon.h index 30a5e416..b5280711 100644 --- a/libstratosphere/source/ldr/ldr_ams.os.horizon.h +++ b/libstratosphere/source/ldr/ldr_ams.os.horizon.h @@ -19,7 +19,7 @@ typedef struct { Result ldrPmAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id); Result ldrDmntAtmosphereHasLaunchedBootProgram(bool *out, u64 program_id); -Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out, CfgOverrideStatus *out_status, const NcmProgramLocation *loc); +Result ldrPmAtmosphereGetProgramInfo(LoaderProgramInfo *out, CfgOverrideStatus *out_status, const NcmProgramLocation *loc, const LoaderProgramAttributes *attr); Result ldrPmAtmospherePinProgram(u64 *out, const NcmProgramLocation *loc, const CfgOverrideStatus *status); #ifdef __cplusplus diff --git a/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp b/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp index 2e00417d..f461f9f7 100644 --- a/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp +++ b/libstratosphere/source/ldr/ldr_pm_api.os.horizon.cpp @@ -19,13 +19,14 @@ namespace ams::ldr::pm { /* Information API. */ - Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, Handle reslimit) { - R_RETURN(ldrPmCreateProcess(pin_id.value, flags, reslimit, out)); + Result CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, Handle reslimit, ldr::ProgramAttributes attrs) { + static_assert(sizeof(attrs) == sizeof(::LoaderProgramAttributes)); + R_RETURN(ldrPmCreateProcess(pin_id.value, flags, reslimit, reinterpret_cast(std::addressof(attrs)), out)); } - Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc) { + Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc, ldr::ProgramAttributes attrs) { static_assert(sizeof(*out) == sizeof(LoaderProgramInfo)); - R_RETURN(ldrPmGetProgramInfo(reinterpret_cast(std::addressof(loc)), reinterpret_cast(out))); + R_RETURN(ldrPmGetProgramInfo(reinterpret_cast(std::addressof(loc)), reinterpret_cast(std::addressof(attrs)), reinterpret_cast(out))); } Result PinProgram(PinId *out, const ncm::ProgramLocation &loc) { @@ -41,10 +42,10 @@ namespace ams::ldr::pm { R_RETURN(ldrPmAtmosphereHasLaunchedBootProgram(out, static_cast(program_id))); } - Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { + Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, ldr::ProgramAttributes attrs) { static_assert(sizeof(*out_status) == sizeof(CfgOverrideStatus), "CfgOverrideStatus definition!"); static_assert(sizeof(*out) == sizeof(LoaderProgramInfo)); - R_RETURN(ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(std::addressof(loc)))); + R_RETURN(ldrPmAtmosphereGetProgramInfo(reinterpret_cast(out), reinterpret_cast(out_status), reinterpret_cast(std::addressof(loc)), reinterpret_cast(std::addressof(attrs)))); } Result SetEnabledProgramVerification(bool enabled) { diff --git a/libvapours/include/vapours/results/loader_results.hpp b/libvapours/include/vapours/results/loader_results.hpp index d9cfa62b..25e3debe 100644 --- a/libvapours/include/vapours/results/loader_results.hpp +++ b/libvapours/include/vapours/results/loader_results.hpp @@ -21,20 +21,20 @@ R_DEFINE_NAMESPACE_RESULT_MODULE(ams::ldr, 9); namespace ams::ldr { - R_DEFINE_ERROR_RESULT(ArgumentOverflow, 1); - R_DEFINE_ERROR_RESULT(ArgumentCountOverflow, 2); - R_DEFINE_ERROR_RESULT(MetaOverflow, 3); - R_DEFINE_ERROR_RESULT(InvalidMeta, 4); - R_DEFINE_ERROR_RESULT(InvalidNso, 5); - R_DEFINE_ERROR_RESULT(InvalidPath, 6); - R_DEFINE_ERROR_RESULT(MaxProcess, 7); - R_DEFINE_ERROR_RESULT(NotPinned, 8); - R_DEFINE_ERROR_RESULT(InvalidProgramId, 9); - R_DEFINE_ERROR_RESULT(InvalidVersion, 10); - R_DEFINE_ERROR_RESULT(InvalidAcidSignature, 11); - R_DEFINE_ERROR_RESULT(InvalidNcaSignature, 12); + R_DEFINE_ERROR_RESULT(ArgumentOverflow, 1); + R_DEFINE_ERROR_RESULT(ArgumentCountOverflow, 2); + R_DEFINE_ERROR_RESULT(MetaOverflow, 3); + R_DEFINE_ERROR_RESULT(InvalidMeta, 4); + R_DEFINE_ERROR_RESULT(InvalidNso, 5); + R_DEFINE_ERROR_RESULT(InvalidPath, 6); + R_DEFINE_ERROR_RESULT(MaxProcess, 7); + R_DEFINE_ERROR_RESULT(NotPinned, 8); + R_DEFINE_ERROR_RESULT(InvalidProgramId, 9); + R_DEFINE_ERROR_RESULT(InvalidVersion, 10); + R_DEFINE_ERROR_RESULT(InvalidAcidSignature, 11); + R_DEFINE_ERROR_RESULT(InvalidNcaSignature, 12); - R_DEFINE_ERROR_RESULT(InvalidPlatformId, 14); + R_DEFINE_ERROR_RESULT(InvalidProgramAttributes, 14); R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 51); R_DEFINE_ERROR_RESULT(InvalidNroImage, 52);