diff --git a/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp b/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp index c5e0c21a..d1cd4da2 100644 --- a/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp +++ b/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp @@ -33,7 +33,7 @@ namespace ams::dmnt::cheat { MemoryRegionExtents heap_extents; MemoryRegionExtents alias_extents; MemoryRegionExtents aslr_extents; - u8 main_nso_build_id[0x20]; + u8 main_nso_module_id[0x20]; }; static_assert(util::is_pod::value && sizeof(CheatProcessMetadata) == 0x70, "CheatProcessMetadata definition!"); diff --git a/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/libstratosphere/include/stratosphere/ldr/ldr_types.hpp index 6bcf05cf..6a7bf6e8 100644 --- a/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ b/libstratosphere/include/stratosphere/ldr/ldr_types.hpp @@ -73,8 +73,12 @@ namespace ams::ldr { } static_assert(sizeof(PinId) == sizeof(u64) && util::is_pod::value, "PinId definition!"); - /* Import ModuleInfo from libnx. */ - using ModuleInfo = ::LoaderModuleInfo; + struct ModuleInfo { + u8 module_id[0x20]; + u64 address; + u64 size; + }; + static_assert(sizeof(ModuleInfo) == 0x30); /* NSO types. */ struct NsoHeader { @@ -123,7 +127,7 @@ namespace ams::ldr { }; SegmentInfo segments[Segment_Count]; }; - u8 build_id[sizeof(ModuleInfo::build_id)]; + u8 module_id[sizeof(ModuleInfo::module_id)]; union { u32 compressed_sizes[Segment_Count]; struct { diff --git a/libstratosphere/include/stratosphere/ro/impl/ro_debug_monitor_interface.hpp b/libstratosphere/include/stratosphere/ro/impl/ro_debug_monitor_interface.hpp index 0e151cb5..b4c99061 100644 --- a/libstratosphere/include/stratosphere/ro/impl/ro_debug_monitor_interface.hpp +++ b/libstratosphere/include/stratosphere/ro/impl/ro_debug_monitor_interface.hpp @@ -17,9 +17,10 @@ #pragma once #include #include +#include #include #define AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessModuleInfo, (sf::Out out_count, const sf::OutArray &out_infos, os::ProcessId process_id), (out_count, out_infos, process_id)) + AMS_SF_METHOD_INFO(C, H, 0, Result, GetProcessModuleInfo, (sf::Out out_count, const sf::OutArray &out_infos, os::ProcessId process_id), (out_count, out_infos, process_id)) AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IDebugMonitorInterface, AMS_RO_I_DEBUG_MONITOR_INTERFACE_INTERFACE_INFO) diff --git a/libstratosphere/include/stratosphere/ro/ro_types.hpp b/libstratosphere/include/stratosphere/ro/ro_types.hpp index 060625b8..fb716b02 100644 --- a/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ b/libstratosphere/include/stratosphere/ro/ro_types.hpp @@ -27,10 +27,11 @@ namespace ams::ro { NrrKind_Count, }; + static constexpr size_t ModuleIdSize = 0x20; struct ModuleId { - u8 build_id[0x20]; + u8 data[ModuleIdSize]; }; - static_assert(sizeof(ModuleId) == sizeof(LoaderModuleInfo::build_id), "ModuleId definition!"); + static_assert(sizeof(ModuleId) == ModuleIdSize); struct NrrCertification { static constexpr size_t RsaKeySize = 0x100; diff --git a/libstratosphere/include/stratosphere/util/util_singleton_traits.hpp b/libstratosphere/include/stratosphere/util/util_singleton_traits.hpp index 45e470a4..052b6077 100644 --- a/libstratosphere/include/stratosphere/util/util_singleton_traits.hpp +++ b/libstratosphere/include/stratosphere/util/util_singleton_traits.hpp @@ -43,3 +43,16 @@ \ return ::ams::util::GetReference(s_singleton_storage); \ } + +#define AMS_CONSTINIT_SINGLETON_TRAITS(_CLASSNAME_) \ + private: \ + NON_COPYABLE(_CLASSNAME_); \ + NON_MOVEABLE(_CLASSNAME_); \ + private: \ + constexpr _CLASSNAME_ () = default; \ + public: \ + static _CLASSNAME_ &GetInstance() { \ + /* Declare singleton instance variables. */ \ + static constinit _CLASSNAME_ s_singleton_instance; \ + return s_singleton_instance; \ + } \ No newline at end of file diff --git a/libstratosphere/source/patcher/patcher_api.cpp b/libstratosphere/source/patcher/patcher_api.cpp index 1898046b..3157d496 100644 --- a/libstratosphere/source/patcher/patcher_api.cpp +++ b/libstratosphere/source/patcher/patcher_api.cpp @@ -56,8 +56,8 @@ namespace ams::patcher { /* Read module id from name. */ std::memset(out_module_id, 0, sizeof(*out_module_id)); for (unsigned int name_ofs = 0, id_ofs = 0; name_ofs < name_len - extension_len && id_ofs < sizeof(*out_module_id); id_ofs++) { - out_module_id->build_id[id_ofs] |= ConvertHexNybble(name[name_ofs++]) << 4; - out_module_id->build_id[id_ofs] |= ConvertHexNybble(name[name_ofs++]); + out_module_id->data[id_ofs] |= ConvertHexNybble(name[name_ofs++]) << 4; + out_module_id->data[id_ofs] |= ConvertHexNybble(name[name_ofs++]); } return true; @@ -76,7 +76,7 @@ namespace ams::patcher { bool IsIpsFileForModule(const char *name, const ro::ModuleId *module_id) { const size_t name_len = std::strlen(name); - /* The path must be correct size for a build id (with trailing zeroes optionally trimmed) + ".ips". */ + /* The path must be correct size for a module id (with trailing zeroes optionally trimmed) + ".ips". */ if (!(IpsFileExtensionLength < name_len && name_len <= ModuleIpsPatchLength)) { return false; } diff --git a/libstratosphere/source/scs/scs_shell.cpp b/libstratosphere/source/scs/scs_shell.cpp index 01881496..e645ab11 100644 --- a/libstratosphere/source/scs/scs_shell.cpp +++ b/libstratosphere/source/scs/scs_shell.cpp @@ -330,7 +330,7 @@ namespace ams::scs { Result PrepareToLaunchProgram(ncm::ProgramId program_id, const void *args, size_t args_size) { /* Set the arguments. */ R_TRY_CATCH(ldr::SetProgramArgument(program_id, args, args_size)) { - R_CATCH(ldr::ResultTooManyArguments) { + R_CATCH(ldr::ResultArgumentCountOverflow) { /* There are too many arguments already registered. Flush the arguments queue. */ R_TRY(ldr::FlushArguments()); diff --git a/libvapours/include/vapours/results/loader_results.hpp b/libvapours/include/vapours/results/loader_results.hpp index d10a98ec..691acbd4 100644 --- a/libvapours/include/vapours/results/loader_results.hpp +++ b/libvapours/include/vapours/results/loader_results.hpp @@ -21,29 +21,30 @@ namespace ams::ldr { R_DEFINE_NAMESPACE_RESULT_MODULE(9); - R_DEFINE_ERROR_RESULT(TooLongArgument, 1); - R_DEFINE_ERROR_RESULT(TooManyArguments, 2); - R_DEFINE_ERROR_RESULT(TooLargeMeta, 3); - R_DEFINE_ERROR_RESULT(InvalidMeta, 4); - R_DEFINE_ERROR_RESULT(InvalidNso, 5); - R_DEFINE_ERROR_RESULT(InvalidPath, 6); - R_DEFINE_ERROR_RESULT(TooManyProcesses, 7); - R_DEFINE_ERROR_RESULT(NotPinned, 8); - R_DEFINE_ERROR_RESULT(InvalidProgramId, 9); + 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(InsufficientAddressSpace, 51); - R_DEFINE_ERROR_RESULT(InvalidNro, 52); - R_DEFINE_ERROR_RESULT(InvalidNrr, 53); - R_DEFINE_ERROR_RESULT(InvalidSignature, 54); - R_DEFINE_ERROR_RESULT(InsufficientNroRegistrations, 55); - R_DEFINE_ERROR_RESULT(InsufficientNrrRegistrations, 56); + R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 51); + R_DEFINE_ERROR_RESULT(InvalidNroImage, 52); + R_DEFINE_ERROR_RESULT(InvalidNrrImage, 53); + R_DEFINE_ERROR_RESULT(NotAuthorized, 54); + R_DEFINE_ERROR_RESULT(MaxModule, 55); + R_DEFINE_ERROR_RESULT(MaxRegistration, 56); R_DEFINE_ERROR_RESULT(NroAlreadyLoaded, 57); R_DEFINE_ERROR_RESULT(InvalidAddress, 81); R_DEFINE_ERROR_RESULT(InvalidSize, 82); + R_DEFINE_ERROR_RESULT(InvalidCurrentMemory, 83); R_DEFINE_ERROR_RESULT(NotLoaded, 84); R_DEFINE_ERROR_RESULT(NotRegistered, 85); R_DEFINE_ERROR_RESULT(InvalidSession, 86);